This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Python Orion SDK swis.update broken after IPAM 4.6.0 upgrade

Before upgrade, the Python Orion SDK swis.update was working fine. After upgrade, the Python Orion SDK swis.update broke with the error HTTP error 400: "The given key was not present in the dictionary”

Full technical details

Before upgrade: IPAM 4.5.2, SAM  6.4.0, VMAN 8.0.0, NPM 12.1, 

After upgrade:  IPAM 4.6.0, SAM 6.5.0, VMAN 8.1.0, NPM 12.2

The Python code

    swis = orionsdk.SwisClient(solarwinds_url, solarwinds_user, solarwinds_pass)

    ipFree = swis.query(

        "SELECT TOP 1 I.uri, I.DisplayName FROM IPAM.IPNode I WHERE Status=2 " +

        " AND I.DNSBackward is NULL " +

        " AND I.Subnet.DisplayName = '" + solarwinds_network + "'")

    ipAddr=ipFree['results'][0]['DisplayName']

    ipUri=ipFree['results'][0]['uri']

    swis.update(ipUri , Status=1, DNSBackward=customer_hostname)

Did a HTTP request and reponse capture

  1. Find the next free IP (This works)
    URL: https://solarwinds.url.com:17778
    POST /SolarWinds/InformationService/v3/Json/Query
    Request: {"query": "SELECT TOP 1 I.uri, I.DisplayName FROM IPAM.IPNode I WHERE Status=2  AND I.DNSBackward is NULL  AND I.Subnet.DisplayName = \'Mgt Services\'", "parameters": {}}
    Response: [{u'DisplayName': u'10.10.14.26', u'uri': u'swis://HE1-SWAPP-01.headquarters.healthedge.com/Orion/IPAM.IPNode/IpNodeId=9316'}]
  2. Change IP Node status to Used (This does not work)
    URL: https://solarwinds.url.com:17778

POST /SolarWinds/InformationService/v3/Json/swis://HE1-SWAPP-01.headquarters.healthedge.com/Orion/IPAM.IPNode/IpNodeId=9316
Request: {"Status": 1, "DNSBackward": "mynewdomain.url.com"}
Response: 'HTTP/1.1 400 Bad Request  "The given key was not present in the dictionary”

There is an open Solarwinds ticket for this issue 35188

Message was edited by: Jirawat Uttayaya

  • According to IPAM 4.6 API · solarwinds/OrionSDK Wiki · GitHub, the valid values for the Status property of IPAM.IPNode are "Used", "Available", "Reserved", "Transient", and "Blocked". It's weird that when you query it you get a number but when you set it you have to use the name of the status, but that's what the docs say.

  • I did not work.

    I Tried "Used", "used", "USED"

    We are using the OrionSDK Python and not the OrionSDK powercli

    I will provide more technical details of our debugging next message

  • 1. Used does not work

    URL: https://solarwinds.url.com

    POST /SolarWinds/InformationService/v3/Json/swis://HE1-SWAPP-01.headquarters.healthedge.com/Orion/IPAM.IPNode/IpNodeId=9316

    {"Status": "Used", "DNSBackward": "he1-ansb-02.url.com"}'

    reply: 'HTTP/1.1 400 Bad Request\r\n'

    header: Content-Length: 1386

    header: Content-Type: application/json

    header: Server: Microsoft-HTTPAPI/2.0

    header: Date: Fri, 12 Jan 2018 20:53:27 GMT

    400 Client Error: The given key was not present in the dictionary.

    2. USED does not work

    URL: https://solarwinds.url.com

    POST /SolarWinds/InformationService/v3/Json/swis://HE1-SWAPP-01.headquarters.healthedge.com/Orion/IPAM.IPNode/IpNodeId=9316

    {"Status": "USED", "DNSBackward": "he1-ansb-02.url.com"}'

    reply: 'HTTP/1.1 400 Bad Request\r\n'

    header: Content-Length: 1386

    header: Content-Type: application/json

    header: Server: Microsoft-HTTPAPI/2.0

    header: Date: Fri, 12 Jan 2018 20:53:27 GMT

    400 Client Error: The given key was not present in the dictionary.

    3. used does not work

    URL: https://solarwinds.url.com

    POST /SolarWinds/InformationService/v3/Json/swis://HE1-SWAPP-01.headquarters.healthedge.com/Orion/IPAM.IPNode/IpNodeId=9316

    {"Status": "used", "DNSBackward": "he1-ansb-02.url.com"}'

    reply: 'HTTP/1.1 400 Bad Request\r\n'

    header: Content-Length: 1386

    header: Content-Type: application/json

    header: Server: Microsoft-HTTPAPI/2.0

    header: Date: Fri, 12 Jan 2018 20:53:27 GMT

    400 Client Error: The given key was not present in the dictionary.

  • message "The given key was not present in the dictionary" means that some property, you have entered does not exists. in you case Status is valid property, but DNSBackward is not valid. Once you connect with SWQL studio, you can see list of all available fields in an entity. You need to remove DNSBackward from parameters of your query.

  • If DNSBackward is an invalid attribute, what is the correct IPAM.IPNode attribute to set the hostname of the IP?

    Looking at the IPAM.IPNode documentation, ( IPAM 4.6 API · solarwinds/OrionSDK Wiki · GitHub ) , in the CRUD operations for IPAM.IPNode section, DnsBackward is listed as the attribute for hostname . Happy to use another attribute, I just need to know what that attribute is.

  • Hi thanks for the reply... unforunately I am a bit confused my apologies...

    We do seem to have a 'DnsBackward' entity in IPAM.IPnode... (I've redacted the field values below but they are there).... additionally the query we use to make sure the hostname has not already been taken references DnsBackward and DOES NOT error out

    "SELECT TOP 1 I.Status, I.DisplayName, I.DNSBackward FROM IPAM.IPNode I WHERE Status=1 " +

    " AND I.DNSBackward='" + customer_hostname +

    "' AND I.Subnet.DisplayName = '" + solarwinds_network + "'"

    here's a screenshot of our SWQL Studio below (DnsBackward fields I've painted over but they are there and populated....

    pastedImage_1.png

  • Just found workaround, create one request which sets Status to Used and second which updates DnsBackward.

  • Thank-you Sir !

    That worked like a charm.

    Quick question if you don't mind... it seems where the change occurred was in the REST API itself (no longer supporting updating multiple fields at once ?)

    Is this considered a bug, and if so would a fix be forthcoming.

    Reason being updating status and BackwardDNS is to us an atomic operation, we would rather they be handled as a single unit-of-work... not a huge deal just wondering your thoughts.

    Thanks again...

    cheers,

    sean

  • Yes, this is a bug. It even has a number now! IPAM-1359

  • I get this error when I try to update the status only.  Any suggestions? 

    Code (Server name changed):

    Uri = swis://xxxxxxxxxx.aaa.com/Orion/IPAM.IPNode/IpNodeId=5006

    swis.update(Uri, Status='Used')

    Exception has occurred: requests.exceptions.HTTPError

    400 Client Error: The given key was not present in the dictionary. for url: https://xxxxxxxxxx.aaa.com:17778/SolarWinds/InformationService/v3/Json/swis://xxxxxxxxxx.aaa.com/Orion/IPAM.IPNode/IpNodeId=5006

      File "C:\File_Path...", line 47, in <module> swis.update(Uri, Status='Used')

    I know the Uri is right as I copied it out of the SQWL Studio table.