cisco-en-programmability / dnacentersdk

Cisco DNA Center Python SDK
https://dnacentersdk.readthedocs.io/en/latest/
MIT License
70 stars 33 forks source link

network_settings.create_network() issue #34

Closed maconrad closed 3 years ago

maconrad commented 3 years ago

Hi All JSON Schema Validation is incorrect for all DNS related stuff in this request.

Original Request / dnacentersdk.exceptions.MalformedRequest: {'settings': {'dnsServer': {'primaryIpAddress': '10.5.5.5', 'secondaryIpAddress': '10.6.6.6'}, 'dhcpServer': ['10.1.1.1', '10.2.2.2'], 'ntpServer': ['10.3.3.3', '10.4.4.4']}

If you put in the value of the acutal enum the validation passes and the request "works", or at least gets sent off to the DNAC. But of course fail because of wrong arguments. {'dnsServer': {'primaryIpAddress': 'valid range : 1.0.0.0 - 223.255.255.255', 'secondaryIpAddress': 'valid range : 1.0.0.0 - 223.255.255.255'}, 'dhcpServer': ['10.1.1.1', '10.2.2.2'], 'ntpServer': ['10.3.3.3', '10.4.4.4'], 'timezone': 'Europe/Berlin (CEST)'}

same with the domain name: Reason: data.settings.dnsServer.domainName must be one of ['can only contain alphanumeric characters or hyphen']

if you put in that value ( can only....) it passes validation and get sent to dnac {'dnsServer': {'domainName': 'can only contain alphanumeric characters or hyphen', 'primaryIpAddress': 'valid range : 1.0.0.0 - 223.255.255.255', 'secondaryIpAddress': 'valid range : 1.0.0.0 - 223.255.255.255'}, 'dhcpServer': ['10.1.1.1', '10.2.2.2'], 'ntpServer': ['10.3.3.3', '10.4.4.4'], 'timezone': 'Europe/Berlin (CEST)'}

maconrad commented 3 years ago

I'm pretty sure it is because of the ENUM in the json schema.

"primaryIpAddress": { "enum": [ "valid range : 1.0.0.0 - 223.255.255.255" ], "type": "string" }, "secondaryIpAddress": { "enum": [ "valid range : 1.0.0.0 - 223.255.255.255" ],

whereas json schema supports built-in ipv4 format:

https://json-schema.org/understanding-json-schema/reference/string.html#ip-addresses

maconrad commented 3 years ago

same will probably be true for network_aaa and clientAndEndpoint_aaa as they are also using enums...

wastorga commented 3 years ago

Hi @maconrad.

Thank you for reporting the issue. We are working on updating the library to the latest Cisco DNA Center software version.

We will remove the enum in the JSON schemas files that do not have actual values and are instead descriptions.

Furthermore, we will consider adding the format: ipv4 to those cases.

For the time being, you can call the function with the active_validation=False.

wastorga commented 3 years ago

New published version (2.2.5) has the changes JSON schema changes described above.