Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Reports is not successful (cisco.dnac.reports) #57

Closed
2 tasks done
beye91 opened this issue Mar 30, 2022 · 6 comments
Closed
2 tasks done

Creating Reports is not successful (cisco.dnac.reports) #57

beye91 opened this issue Mar 30, 2022 · 6 comments

Comments

@beye91
Copy link

beye91 commented Mar 30, 2022

Prerequisites

  • Have you tested the operation in the API directly?
  • Do you have the latest Ansible collection version?

Describe the bug
Ansible play:

    - name: Create
      cisco.dnac.reports:
        dnac_host: "{{dnac_host}}"
        dnac_username: "{{dnac_username}}"
        dnac_password: "{{dnac_password}}"
        dnac_verify: "{{dnac_verify}}"
        dnac_port: "{{dnac_port}}"
        dnac_debug: "{{dnac_debug}}"
        state: present
        deliveries:
        -
        name: "AP-ANSIBLE"
        schedule: {"type": "SCHEDULE_NOW","dateTime":1648380084211}
        tags: 
        - 
        view:
          fieldGroups:
          - fieldGroupDisplayName: "AP Detail By AP"
            fieldGroupName: "apDetailByAP"
            fields:
            - displayName: "AP MAC Address"
              name: "macAddress"
            - displayName: "Up Time"
              name: "upTime"
          filters:
          - displayName: "Location"
            name: "Location"
            type: "MULTI_SELECT_TREE"
            value: {"value": "sample-global-site-id", "displayValue": "Global"}
          - displayName: "Time Range"
            name: "TimeRange"
            type: "TIME_RANGE"
            value: {"timeRangeOption":"LAST_3_HOURS","startDateTime":0,"endDateTime":0}
          format:
            formatType: "CSV"
            name: "CSV"
          name: AP
        viewGroupId: "c8bfe5c9-4941-4251-8bf5-0fb643e90816"
        viewGroupVersion: "2.0.0"
      register: result

Error:
{'tags': [None], 'deliveries': [None], 'name': 'AP-ANSIBLE', 'schedule': {'type': 'SCHEDULE_NOW', 'dateTime': 1648380084211}, 'view': {'fieldGroups': [{'fieldGroupDisplayName': 'AP Detail By AP', 'fieldGroupName': 'apDetailByAP', 'fields': [{'displayName': 'AP MAC Address', 'name': 'macAddress'}, {'displayName': 'Up Time', 'name': 'upTime'}]}], 'filters': [{'displayName': 'Location', 'name': 'Location', 'type': 'MULTI_SELECT_TREE', 'value': {'value': 'sample-global-site-id', 'displayValue': 'Global'}}, {'displayName': 'Time Range', 'name': 'TimeRange', 'type': 'TIME_RANGE', 'value': {'timeRangeOption': 'LAST_3_HOURS', 'startDateTime': 0, 'endDateTime': 0}}], 'format': {'formatType': 'CSV', 'name': 'CSV'}, 'name': 'AP'}, 'viewGroupId': 'c8bfe5c9-4941-4251-8bf5-0fb643e90816', 'viewGroupVersion': '2.0.0'}

How the data should look like:

{
   "tags":[
       
   ],
   "deliveries":[
       
   ],
   "name":"AP-ANSIBLE",
   "schedule":{
      "type":"SCHEDULE_NOW",
      "dateTime":1648380084211
   },
   "view":{
      "fieldGroups":[
         {
            "fieldGroupDisplayName":"AP Detail By AP",
            "fieldGroupName":"apDetailByAP",
            "fields":[
               {
                  "displayName":"AP MAC Address",
                  "name":"macAddress"
               },
               {
                  "displayName":"Up Time",
                  "name":"upTime"
               }
            ]
         }
      ],
      "filters":[
         {
            "displayName":"Location",
            "name":"Location",
            "type":"MULTI_SELECT_TREE",
            "value":[
                {
               "value":"sample-global-site-id",
               "displayValue":"Global"
            }
        ]
         },
         {
            "displayName":"Time Range",
            "name":"TimeRange",
            "type":"TIME_RANGE",
            "value":{
               "timeRangeOption":"LAST_3_HOURS",
               "startDateTime":0,
               "endDateTime":0
            }
         }
      ],
      "format":{
         "formatType":"CSV",
         "name":"CSV"
      },
      "name":"AP"
   },
   "viewGroupId":"c8bfe5c9-4941-4251-8bf5-0fb643e90816",
   "viewGroupVersion":"2.0.0"
}

Environment (please complete the following information):
Package Version


ansible 5.5.0
ansible-core 2.12.3
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.0.12
cryptography 36.0.2
dnacentersdk 2.4.7
fastjsonschema 2.15.3
future 0.18.2
idna 3.3
Jinja2 3.0.3
MarkupSafe 2.1.1
packaging 21.3
pip 21.3.1
pycparser 2.21
pyparsing 3.0.7
PyYAML 6.0
requests 2.27.1
requests-toolbelt 0.9.1
resolvelib 0.5.4
setuptools 60.5.0
urllib3 1.26.9

@fmunozmiranda
Copy link
Collaborator

Hey @beye91 , we are working on it.

@fmunozmiranda
Copy link
Collaborator

@beye91 , a question, in this request are there any other attributes that should go as empty arrays besides tags and deliveries?

@beye91
Copy link
Author

beye91 commented Mar 30, 2022

Hey @fmunozmiranda , yes the brackets for value in filters:

        "value":[ <
            {
           "value":"sample-global-site-id",
           "displayValue":"Global"
        }
    ] <

@fmunozmiranda
Copy link
Collaborator

fmunozmiranda commented Mar 31, 2022

Hey @beye91 , dnacenter-ansible 6.3.0 has been published, try the request with this version again and let us know if is working for you.


IMPORTANT

Set the validate_response_schema flag to false, this is because the behavior of filters.values (sometimes dictionary, sometimes array) can cause validation problems, here is a playbook that worked for me.


- hosts: dnac_servers
  vars_files:
    - credentials.yml
  gather_facts: no
  tasks:
  - name: Create
    cisco.dnac.reports:
      dnac_host: "{{dnac_host}}"
      dnac_username: "{{dnac_username}}"
      dnac_password: "{{dnac_password}}"
      dnac_verify: "{{dnac_verify}}"
      dnac_port: "{{dnac_port}}"
      dnac_debug: "{{dnac_debug}}"
      validate_response_schema: false
      state: present
      tags: []
      deliveries: []
      name: AP-ANSIBLE
      schedule:
        type: SCHEDULE_NOW
        dateTime: 1648380084211
      view:
        fieldGroups:
        - fieldGroupDisplayName: AP Detail By AP
          fieldGroupName: apDetailByAP
          fields:
          - displayName: AP MAC Address
            name: macAddress
          - displayName: Up Time
            name: upTime
        filters:
        - displayName: Location
          name: Location
          type: MULTI_SELECT_TREE
          value:
          - value: sample-global-site-id
            displayValue: Global
        - displayName: Time Range
          name: TimeRange
          type: TIME_RANGE
          value:
            timeRangeOption: LAST_3_HOURS
            startDateTime: 0
            endDateTime: 0
        format:
          formatType: CSV
          name: CSV
        name: AP
      viewGroupId: c8bfe5c9-4941-4251-8bf5-0fb643e90816
      viewGroupVersion: 2.0.0

    register: result

  - name: Show result
    ansible.builtin.debug:
      msg: "{{ result }}"

@beye91
Copy link
Author

beye91 commented Apr 1, 2022

Hey @fmunozmiranda the module is working now. Thanks!

@fmunozmiranda
Copy link
Collaborator

With pleasure @beye91, I proceed to close the issue.

ajithandrewj pushed a commit to ajithandrewj/dnacenter-ansible that referenced this issue Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants