cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 8

IPAM API to update subnet data?

Jump to solution

Hi

I am new to Solarwinds IPAM and its API, and in the descriptions, it says that the API can do CRUD operations with subnets.  When I looked at it, it references the subnet and parent data as SubnetID and ParentID.  How do find out what the SubnetID for a subnet is?  Also, how do I find the ParentID for the group?  My main goal currently is to be able to move subnets into groups based on their location data.  I can script it myself to put it into the group I want, so I don't need the script to figure that logic out.  As long as I can script it so that I can move a subnet into a group I am happy   Can someone help guide me in the right direction in accomplishing this?  Thank you.

0 Kudos
1 Solution

Hi tuyen,

you could use the update operation IPAM 4.7 API · solarwinds/OrionSDK Wiki · GitHub

Set-SwisObject $swis -Uri 'swis://localhost/Orion/IPAM.Subnet/SubnetId=100,ParentId=2' -Properties @{ParentId='9999'}

This is just a basic example. The first ParentId-Field in the string will select the target subnet (together with subnetid). With the -Properties you change the Field ParentId to 9999.

I can't test it myself right now, but that should get you in the right direction. You could also use customproperties for subnets and groups, to add your own unique identifier you can work with.

But be aware, that missconfigured/wrong api-calls against the DB could lead to inconsistent data, so please have a backup available or try this in a test enviroment. 🙂

Regards

Rene

View solution in original post

5 Replies
Level 11

Hi tuyen,

i created a report a few days ago based on a SQL query which contains most of the IDs you need, maybe it will help you. Query is not cleaned up, hope it is helpful anyway. Just create a new query in the database manager on your mainpoller.

SELECT  g1.GroupID, g1.ParentID, g1.Address, g1.AddressMask, g1.CIDR, g1.FriendlyName, g1.VLAN, n1.IPAddress, n1.DnsBackward, n1.SubnetID, ga.AncestorGroupId, ga.Distance, g2.FriendlyName as "Primary Folder", g3.FriendlyName as "Parent Folder" FROM IPAM_Group g1

JOIN IPAM_GROUPAncestors ga ON ga.GroupID = g1.GroupID

JOIN IPAM_Group g2 ON  g2.GroupID = ga.AncestorGroupId

JOIN IPAM_Group g3 ON  g1.ParentID = g3.GroupID

JOIN IPAM_GroupReportView v1 ON g1.GroupID = v1.GroupID

JOIN IPAM_Node n1 ON n1.SubnetID = v1.SubnetID

Where n1.DnsBackward IS NOT NULL AND n1.Status = 1 AND ga.AncestorGroupId IN

(Select GroupId FROM IPAM_Group Where ParentId = 0) AND g1.CIDR < 30 AND g1.CIDR > 0 ORDER BY ga.AncestorGroupId, g1.ParentId, g1.Address;

Regards

Rene

Hi

Thanks for the report.  I did figure out the ParentID already which we can easily get the SQL query from the SWQL Studio.  Using the query, I have can get a list of the subnets and their descriptions, and have the SubnetID and ParentID.  My main issue is how can we use the API to modify the ParentID of the subnet? 

0 Kudos

Hi tuyen,

you could use the update operation IPAM 4.7 API · solarwinds/OrionSDK Wiki · GitHub

Set-SwisObject $swis -Uri 'swis://localhost/Orion/IPAM.Subnet/SubnetId=100,ParentId=2' -Properties @{ParentId='9999'}

This is just a basic example. The first ParentId-Field in the string will select the target subnet (together with subnetid). With the -Properties you change the Field ParentId to 9999.

I can't test it myself right now, but that should get you in the right direction. You could also use customproperties for subnets and groups, to add your own unique identifier you can work with.

But be aware, that missconfigured/wrong api-calls against the DB could lead to inconsistent data, so please have a backup available or try this in a test enviroment. 🙂

Regards

Rene

View solution in original post

Hi,

Yes, thanks.  I figured out that the way I referenced the -Uri was not correct because it is case sensitive as well as the -Properties setting of ParentId is case sensitive as well -- and this was the reason why I had been having issues before.

I did run it and it made the change, but the parent group did not reflect immediately in the web console though, but through SWQL Studio, I could see that the ParentId did change.  I tried rebooting the server, and after the reboot, the subnet did move into the new group correctly.  Do you know why this is the case?  What needed to be restarted for the IPAM to reread from the database to see that it changed?

0 Kudos

Hi tuyen,

tuyen  schrieb:

I did run it and it made the change, but the parent group did not reflect immediately in the web console though, but through SWQL Studio, I could see that the ParentId did change.  I tried rebooting the server, and after the reboot, the subnet did move into the new group correctly.  Do you know why this is the case?  What needed to be restarted for the IPAM to reread from the database to see that it changed?

To be honest i dont know why it doesn't reflect the changes immediately. Maybe it could be something with the subnet scan intervall or a browser related issue. Maybe deleting the browsers cache could help, but thats just a suggestion.

Regards

Rene

0 Kudos