Assigning Primary IPv4 address to a device via script #7931
-
I am trying to bulk import IP addresses into IPAM via csv and assigning the required IP address to a devices interface also making the IP address the primary ipv4 IP address. The script I created below successfully imports the IP Address and assigns the IP address to a devices interface, although I cannot get the IP address to set as the Primary IPv4 address on the device.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
You cannot generally use the _for auto generated keys to assign. What you want instead is... Interface.device.primary_ip4 = address or interface.device.primary_ip6 = address and then interface.device.save() |
Beta Was this translation helpful? Give feedback.
-
There is a custom script here which may have some useful clues in it: It creates a VM, an interface, an IP address (or two: v4 and v6), and sets the VM's primary address(es). |
Beta Was this translation helpful? Give feedback.
You cannot generally use the _for auto generated keys to assign.
What you want instead is...
Interface.device.primary_ip4 = address or interface.device.primary_ip6 = address and then interface.device.save()