I am trying to update the description field in IPAM with python and am getting a 'The given key was not present in the dictionary' error. I have browsed other solutions, but can't see a big difference in my code and other 'working' code. I know I am close by looking at the first dictionary I am printing based on the uri, but when I go to actually change it, it gives the error.
Here is what I have:
from orionsdk import SwisClient from getpass import getpass npm_server = 'solarwinds.omitted.org' username = 'omitted' password = getpass('password: ') swis = SwisClient(npm_server, username, password) uri = "swis://solarwinds.omitted.ORG/Orion/IPAM.IPNode/IpNodeId=22098015" def update_solarwinds(uri): result = swis.update(uri, Description='test.omitted.org') print(result) if __name__ == "__main__": print(swis.read(uri)) update_solarwinds(uri)
and this is the result:
{'IpNodeId': 22098015, 'SubnetId': 3595, 'IPOrdinal': 206, 'IPAddress': '1.2.3.4', 'IPAddressN': 'ce6d8b0c-0000-0000-0000-000000000000', 'IPMapped': None, 'IPMappedN': None, 'Alias': '', 'MAC': '', 'DnsBackward': '', 'DhcpClientName': '', 'SysName': '', 'Description': '', 'Contact': '', 'Location': '', 'SysObjectID': None, 'Vendor': '', 'VendorIcon': None, 'MachineType': '', 'Comments': 'omitted comment', 'ResponseTime': None, 'LastBoot': None, 'LastSync': '2020-11-02T11:04:00.023', 'LastCredential': None, 'Status': 1, 'AllocPolicy': 1, 'SkipScan': True, 'LeaseExpires': None, 'DnsBy': 1, 'MacBy': 1, 'StatusBy': 0, 'SystemDataBy': 0, 'DisplayName': '1.2.3.4', 'InstanceType': 'IPAM.IPNode', 'Uri': 'swis://solarwinds.omitted.ORG/Orion/IPAM.IPNode/IpNodeId=22098015', 'InstanceSiteId': 0} C:\Users\omitted\Documents\Github\Python Scrips\venv\lib\site-packages\urllib3\connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'solarwinds.omitted.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings warnings.warn( Traceback (most recent call last): File "C:\Users\omitted\Documents\Github\Python Scrips\test.py", line 18, in <module> update_solarwinds(uri) File "C:\Users\omitted\Documents\Github\Python Scrips\test.py", line 13, in update_solarwinds result = swis.update(uri, Description='test.omitted.org') File "C:\Users\omitted\Documents\Github\Python Scrips\venv\lib\site-packages\orionsdk\swisclient.py", line 42, in update self._req("POST", uri, properties) File "C:\Users\omitted\Documents\Github\Python Scrips\venv\lib\site-packages\orionsdk\swisclient.py", line 63, in _req resp.raise_for_status() File "C:\Users\omitted\Documents\Github\Python Scrips\venv\lib\site-packages\requests\models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: The given key was not present in the dictionary. for url: https://solarwinds.omitted.org:17778/SolarWinds/InformationService/v3/Json/swis://solarwinds.omitted.ORG/Orion/IPAM.IPNode/IpNodeId=22098015
Thanks!