Hi All
I've noticed a bug when running my python script that updates IP custom fields. I am checking if the guys have updated our platform as this didn't happen before.
I've had to test and demo this a few times so I usually clear down the IP's in a subnet or two and then re-run the script to update those subnets.
I attempted to do do the same again today but for some reason the custom fields did not update. The status updated, and if I update the comments field, that gets updated but the custom fields remain blank.
If I delete the IP entirely, or update an IP that has never been used before - it works OK.
The only thing that could relate is that I added way too many IP's and went above our license limit, I've since removed all of those orphaned IP's so that we are under the limit now. Doesn't explain why only the Custom fields are not updating.
version: 2020.2.5
Any ideas?
def update_node_Info(ip_address, host, description, status):
nodeinfo = connect_to_solarwinds.swis.query("\
SELECT TOP 1 IpNodeId, SubnetId, IPOrdinal, IPAddress, Alias, Description, Comments, Status, Uri FROM IPAM.IPNode \
WHERE IPAddress=@IP", IP = ip_address)
node_uri = ""
if host == "": host = "-"
if description == "": description = "-"
#If node is found then record node details
if len(nodeinfo['results']) == 1:
node_id = nodeinfo['results'][0]['IpNodeId']
node_uri = nodeinfo['results'][0]['Uri']
node_status = nodeinfo['results'][0]['Status']
#print("\nNode ID: " + str(node_id))
#print("Node URI: " + str(node_uri))
#print("Node Status: " + str(node_status))
#print(nodeinfo)
if node_uri: # If a node has been found attempt update
try:
update_main_repsonse = connect_to_solarwinds.swis.update(node_uri, Status=status, Comments="A-Comment-Test")
node_status_msg = "Status updated OK"
except:
node_status_msg = "Status update failed"
try:
update_custom_repsonse = connect_to_solarwinds.swis.update(node_uri + "/CustomProperties", Imported_Host=host, Imported_Desc = description)
node_customfields_msg = "Custom fields updated OK"
except:
node_customfields_msg = "Custom fields update failed"
update_message = str(ip_address + ": " + node_status_msg + " - " + str(node_customfields_msg))
else:
update_message = update_message = str(ip_address + ": " + "not found in IPAM")
return update_message