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

Sda.adds_border_device virtualNetwork array not accepted as value #64

Closed
2 tasks done
nextnoob opened this issue Aug 9, 2022 · 4 comments
Closed
2 tasks done
Labels
bug Something isn't working in-progress Team is working to solve issue.

Comments

@nextnoob
Copy link

nextnoob commented Aug 9, 2022

Prerequisites

  • Have you tested the operation in the API directly?

Yes →

Example Payload:

[
    {
        "deviceManagementIpAddress": "172.22.4.2",
        "siteNameHierarchy": "Global/SH-2",
        "deviceRole": [
            "Border_Node", 
            "Control_Plane_Node",
            "Edge_Node"
        ],
        "externalDomainRoutingProtocolName": "BGP",
        "externalConnectivityIpPoolName": "L3-Handoff",
        "internalAutonomouSystemNumber": "65101",
        "borderPriority": "10",
        "borderSessionType": "ANYWHERE",
        "connectedToInternet": "True",
        "borderWithExternalConnectivity": "True",
        "externalConnectivitySettings": [
            {
                "interfaceName": "GigabitEthernet1/0/24",
                "interfaceDescription": "Automated Value",
                "externalAutonomouSystemNumber": "65100",
                "l3Handoff": [
                    {
                        "virtualNetwork": 
                            {
                                "virtualNetworkName": "INFRA_VN",
                                "vlanId": "3200" 
                            }                       
                    },
                    {
                        "virtualNetwork": 
                            {
                                "virtualNetworkName": "BECHTLAB",
                                "vlanId": "3201" 
                            }                           
                    }                      
                ]
            }
        ]
    }
]
  • Do you have the latest SDK version?
pip show dnacentersdk
Name: dnacentersdk
Version: 2.5.2
Summary: Cisco DNA Center Platform SDK
Home-page: https://dnacentersdk.readthedocs.io/en/latest/
Author: Jose Bogarin Solano
Author-email: jbogarin@altus.cr
License: MIT
Location: c:\users\username\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages
Requires: fastjsonschema, future, requests, requests-toolbelt
Required-by: 

Describe the bug

Class: classSda
Function: adds_border_device(headers=None, payload=None, active_validation=True, **request_parameters)

The scheme under Developer DNAC Docs wants arrays for the key virtualNetworkand as values. Unfortunately, in reality arrays are not accepted by the DNA Center here.

Payload:

[
    {
        "deviceManagementIpAddress": "172.22.4.2",
        "siteNameHierarchy": "Global/SH-2",
        "deviceRole": [
            "Border_Node", 
            "Control_Plane_Node",
            "Edge_Node"
        ],
        "externalDomainRoutingProtocolName": "BGP",
        "externalConnectivityIpPoolName": "L3-Handoff",
        "internalAutonomouSystemNumber": "65101",
        "borderPriority": "10",
        "borderSessionType": "ANYWHERE",
        "connectedToInternet": "True",
        "borderWithExternalConnectivity": "True",
        "externalConnectivitySettings": [
            {
                "interfaceName": "GigabitEthernet1/0/24",
                "interfaceDescription": "Automated Value",
                "externalAutonomouSystemNumber": "65100",
                "l3Handoff": [
                    {
                        "virtualNetwork": [
                            {
                                "virtualNetworkName": "INFRA_VN",
                                "vlanId": "3200" 
                            } 
                        ]                          
                    },  
                    {
                        "virtualNetwork": [
                            {
                                "virtualNetworkName": "BECHTLAB",
                                "vlanId": "3201" 
                            } 
                        ]                          
                    }             
                ]
            }
        ]
    }
]

Error message:

PS E:\Users\username\ios-xe-nc-trial> python3 .\add_border_node.py
Traceback (most recent call last):
  File "E:\Users\username\ios-xe-nc-trial\add_border_node.py", line 78, in <module>
    dnac.sda.adds_border_device(payload = payload)
  File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\dnacentersdk\api\v2_3_3_0\sda.py", line 370, in adds_border_device
    json_data = self._session.post(endpoint_full_url, params=_params,
  File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\dnacentersdk\restsession.py", line 619, in post
    response = self.request('POST', url, erc, 0, params=params,
  File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\dnacentersdk\restsession.py", line 471, in request
    check_response_code(response, erc)
  File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\dnacentersdk\utils.py", line 209, in check_response_code
    raise ApiError(response)
dnacentersdk.exceptions.ApiError: [400] Bad Request - The request was invalid or cannot be otherwise served.

image

Expected behavior
The API should accept arrays according to the schema, but it does not.

Screenshots
image
image

Environment (please complete the following information):

  • Cisco DNA Center Version and patch: Version 2.3.3.4
  • Python version: Python 3.10.6
  • SDK version: 2.5.2
  • OS Version: Python:3 Windows 10, 21H2

Additional context

Thanks for maintaining the very good SDK 😊

@nextnoob nextnoob changed the title Sda_adds_border_device virtualNetwork array not accepted as value Sda.adds_border_device virtualNetwork array not accepted as value Aug 9, 2022
@fmunozmiranda fmunozmiranda added bug Something isn't working in-progress Team is working to solve issue. labels Aug 9, 2022
fmunozmiranda pushed a commit that referenced this issue Aug 9, 2022
@fmunozmiranda
Copy link
Collaborator

Hey @nextnoob , there´s a new version of dnacentersdk (2.5.3) with solved problem, try it and let us know if it works for you.

@nextnoob
Copy link
Author

nextnoob commented Aug 9, 2022

Hey @fmunozmiranda ,

unfortunately the validation does not work yet.

Error Message:

Reason: data[0].externalConnectivitySettings[0].l3Handoff[0].virtualNetwork must be object

Detail:

PS E:\Users\username\ios-xe-nc-trial> python3 .\add_border_node.py      
Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\dnacentersdk\models\validators\v2_3_3_0\jsd_b6f2d8e46cdd5f05bb06f52cd1b26fb2.py", line 142, in validate
    self._validator(request)
  File "<string>", line 124, in validate
fastjsonschema.exceptions.JsonSchemaValueException: data[0].externalConnectivitySettings[0].l3Handoff[0].virtualNetwork must be object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\Users\username\ios-xe-nc-trial\add_border_node.py", line 78, in <module>
    dnac.sda.adds_border_device(payload = payload)
  File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\dnacentersdk\api\v2_3_3_0\sda.py", line 355, in adds_border_device
  File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\dnacentersdk\models\validators\v2_3_3_0\jsd_b6f2d8e46cdd5f05bb06f52cd1b26fb2.py", line 144, in validate
    raise MalformedRequest(
dnacentersdk.exceptions.MalformedRequest: [{'deviceManagementIpAddress': '172.22.4.2', 'siteNameHierarchy': 'Global/SH-2', 'deviceRole': ['Border_Node', 'Control_Plane_Node', 'Edge_Node'], 'externalDomainRoutingProtocolName': 'BGP', 'externalConnectivityIpPoolName': 'L3-Handoff', 'internalAutonomouSystemNumber': '65101', 'borderPriority': '10', 'borderSessionType': 'ANYWHERE', 'connectedToInternet': 'True', 'borderWithExternalConnectivity': 'True', 'externalConnectivitySettings': [{'interfaceName': 'GigabitEthernet1/0/24', 'interfaceDescription': 'Automated Value', 'externalAutonomouSystemNumber': '65100', 'l3Handoff': [{'virtualNetwork': [{'virtualNetworkName': 'INFRA_VN', 'vlanId': '3200'}]}, {'virtualNetwork': [{'virtualNetworkName': 'BECHTLAB', 'vlanId': '3201'}]}]}]}] is invalid. Reason: data[0].externalConnectivitySettings[0].l3Handoff[0].virtualNetwork must be object

@fmunozmiranda
Copy link
Collaborator

fmunozmiranda commented Aug 9, 2022

@nextnoob, I see may be something wrong with the object creation. Malformed request details this structure:

"l3Handoff": [
                    {
                        "virtualNetwork": [
                            {
                                "virtualNetworkName": "INFRA_VN",
                                "vlanId": "3200"
                            }
                        ]
                    },
                    {
                        "virtualNetwork": [
                            {
                                "virtualNetworkName": "BECHTLAB",
                                "vlanId": "3201"
                            }
                        ]
                    }
                ]
                

A valid request, should be like this:

"l3Handoff": [
                   {
                       "virtualNetwork": 
                           {
                               "virtualNetworkName": "INFRA_VN",
                               "vlanId": "3200"
                           }
                       
                   },
                   {
                       "virtualNetwork": 
                           {
                               "virtualNetworkName": "BECHTLAB",
                               "vlanId": "3201"
                           }
                       
                   }
               ]

@nextnoob
Copy link
Author

Oh, my mistake. I still had the "old" syntax from the DNAC API documentation.

Thank you for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in-progress Team is working to solve issue.
Projects
None yet
Development

No branches or pull requests

2 participants