Add IP with python custom script #610
Replies: 1 comment
-
Since this has nothing to do with In any case, I don't think you need to use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone
I am trying to create a custom script to automatically detect specific devices and assign them to an IP address but I'm running in some errors.
This is my sample code:
` from ipam.models import IPAddress
import ipaddress
def checkAndSaveLoop(self, loopIps):
ip = "10.120.23.193/26"
ip = ipaddress.IPv4Network(ip)
newLoopIp = IPAddress(
address=ip,
status=IPAddressStatusChoices.STATUS_ACTIVE,
)
newLoopIp.clean()
newLoopIp.save()
`
I have tried several options:
Exception: AttributeError: 'str' object has no attribute 'prefixlen'
Exception: AttributeError: 'str' object has no attribute 'prefixlen'
Exception: AttributeError: 'IPv4Network' object has no attribute '_value'
Exception: ValueError: ip has host bits set
Does anyone have experience of how to create an IP for a custom script?
Netbox v3.6.4
Beta Was this translation helpful? Give feedback.
All reactions