/srv/deployment/netbox/deploy-cache/revs/5251cf14234a945a529f72863af30797baeed8fd/src/netbox/netbox/settings.py:192: UserWarning: The 'webhooks' REDIS configuration section has been renamed to 'tasks'. Please update your configuration as support for the old name will be removed in a future release.
"The 'webhooks' REDIS configuration section has been renamed to 'tasks'. Please update your configuration as "
### NetBox interactive shell (netbox1001)
### Python 3.7.3 | Django 3.0.6 | NetBox 2.8.4
### lsmodels() will show available models. Use help(<model>) for more info.
>>> import uuid
>>>
>>> import netaddr
>>>
>>>
>>> def reserve_ips(prefix, request_id, user):
... # The first IP is excluded by get_first_available_ip() for non-pool prefixes
... to_reserve = [f'{p}/{prefix.prefix.prefixlen}' for p in netaddr.IPSet(prefix.prefix)][:6]
... while True:
... next_ip = prefix.get_first_available_ip()
... if next_ip not in to_reserve:
... print(f'Prefix {prefix} has all first 5 IPs assigned or reserved')
... break
... print(f'Reserving IP {next_ip} in prefix {prefix}')
... address = IPAddress(address=next_ip, status='reserved', tenant=prefix.tenant, description='reserved for infra')