Replies: 3 comments
-
The IP has to be assigned to an interface that is _on_ the device before you can make it the primary_ip4, and assignment happens on the IPAddress record with the relation type 'dcim.interfaces' and the id number of the interface.
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: mrzepa ***@***.***>
Sent: Thursday, February 24, 2022 2:08 PM
To: netbox-community/netbox ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [netbox-community/netbox] Adding device via RestAPI errors (Discussion #8746)
Greetings,
I'm trying to add a new device to netbox via the RestAPI with the primary IP address set, I do a lookup in Netbox to get the ID of the IP address I am trying to add, then the parameters I am providing is the primary_ip4=2689, however when I try and create the device, I get an error:
{"primary_ip4":["The specified IP address (172.16.15.31/32) is not assigned to this device."]}
Of course it is not assigned to that device, I am only creating the device now.
It appears to be a catch 22, in order to assign the IP to the device, the device needs to be created, but creating the device with the IP requires the IP to be assigned to the device.
—
Reply to this email directly, view it on GitHub<#8746>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM7WHSGWVCXS4HHXK73U42F5JANCNFSM5PILV7YQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Mark,
Just to clarify, the steps should be:
1) Add device
2) Add interface to device
3) Lookup device ID and Interface ID
4) Update IP address with device ID and Interface ID
5) Lookup IP address ID
6) Update device attribute primary_ip4 with IP address ID
I can handle this. I wish there was a way to document in swagger “parameters that can be used for creation” vs “parameters that can only be updated after creation”.
… On Feb 24, 2022, at 3:26 PM, Mark Tinberg ***@***.***> wrote:
The IP has to be assigned to an interface that is _on_ the device before you can make it the primary_ip4, and assignment happens on the IPAddress record with the relation type 'dcim.interfaces' and the id number of the interface.
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
________________________________
From: mrzepa ***@***.***>
Sent: Thursday, February 24, 2022 2:08 PM
To: netbox-community/netbox ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [netbox-community/netbox] Adding device via RestAPI errors (Discussion #8746)
Greetings,
I'm trying to add a new device to netbox via the RestAPI with the primary IP address set, I do a lookup in Netbox to get the ID of the IP address I am trying to add, then the parameters I am providing is the primary_ip4=2689, however when I try and create the device, I get an error:
{"primary_ip4":["The specified IP address (172.16.15.31/32) is not assigned to this device."]}
Of course it is not assigned to that device, I am only creating the device now.
It appears to be a catch 22, in order to assign the IP to the device, the device needs to be created, but creating the device with the IP requires the IP to be assigned to the device.
—
Reply to this email directly, view it on GitHub<#8746>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM7WHSGWVCXS4HHXK73U42F5JANCNFSM5PILV7YQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
—
Reply to this email directly, view it on GitHub <#8746 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ANBXP6AQTAC3BCE72DSNEQTU42H6PANCNFSM5PILV7YQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
That's largely correct although I'd add that the return result for adding or modifying a record over REST is a copy of the new record, so yuou will already have the new device id in step one and the interface id in step two so you don't need another lookup (step 3), and when you search for the correct IP record you will the update it by id so it'll be one PATCH to the /ipam/ip-address/<id>/ endpoint and then one to the /dcim/devices/<id>/ enpoint, if I am getting that right. In fact in step 2 you may not need to add the interface at all if it is one that is created by the Device Type template, and already exists.
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
________________________________
From: mrzepa ***@***.***>
Sent: Thursday, February 24, 2022 3:04 PM
To: netbox-community/netbox ***@***.***>
Cc: Mark Tinberg ***@***.***>; Comment ***@***.***>
Subject: Re: [netbox-community/netbox] Adding device via RestAPI errors (Discussion #8746)
Mark,
Just to clarify, the steps should be:
1) Add device
2) Add interface to device
3) Lookup device ID and Interface ID
4) Update IP address with device ID and Interface ID
5) Lookup IP address ID
6) Update device attribute primary_ip4 with IP address ID
I can handle this. I wish there was a way to document in swagger “parameters that can be used for creation” vs “parameters that can only be updated after creation”.
On Feb 24, 2022, at 3:26 PM, Mark Tinberg ***@***.***> wrote:
The IP has to be assigned to an interface that is _on_ the device before you can make it the primary_ip4, and assignment happens on the IPAddress record with the relation type 'dcim.interfaces' and the id number of the interface.
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
________________________________
From: mrzepa ***@***.***>
Sent: Thursday, February 24, 2022 2:08 PM
To: netbox-community/netbox ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [netbox-community/netbox] Adding device via RestAPI errors (Discussion #8746)
Greetings,
I'm trying to add a new device to netbox via the RestAPI with the primary IP address set, I do a lookup in Netbox to get the ID of the IP address I am trying to add, then the parameters I am providing is the primary_ip4=2689, however when I try and create the device, I get an error:
{"primary_ip4":["The specified IP address (172.16.15.31/32) is not assigned to this device."]}
Of course it is not assigned to that device, I am only creating the device now.
It appears to be a catch 22, in order to assign the IP to the device, the device needs to be created, but creating the device with the IP requires the IP to be assigned to the device.
—
Reply to this email directly, view it on GitHub<#8746>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM7WHSGWVCXS4HHXK73U42F5JANCNFSM5PILV7YQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
—
Reply to this email directly, view it on GitHub <#8746 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ANBXP6AQTAC3BCE72DSNEQTU42H6PANCNFSM5PILV7YQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.
—
Reply to this email directly, view it on GitHub<#8746 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM3Z3HII2ZCOQGRWSU3U42MMLANCNFSM5PILV7YQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mrzepa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings,
I'm trying to add a new device to netbox via the RestAPI with the primary IP address set, I do a lookup in Netbox to get the ID of the IP address I am trying to add, then the parameters I am providing is the primary_ip4=2689, however when I try and create the device, I get an error:
{"primary_ip4":["The specified IP address (172.16.15.31/32) is not assigned to this device."]}
Of course it is not assigned to that device, I am only creating the device now.
It appears to be a catch 22, in order to assign the IP to the device, the device needs to be created, but creating the device with the IP requires the IP to be assigned to the device.
Beta Was this translation helpful? Give feedback.
All reactions