Skip to content

IPAM

pynautobot.models.ipam

Overrides for models in the IPAM app.

Classes, attributes and methods only need to be defined here if they need to override the default behavior.

pynautobot.models.ipam.IpAddresses

Bases: Record

IP Address Object.

__str__()

Return the string representation of the IpAddresses object.

pynautobot.models.ipam.Prefixes

Bases: Record

Prefix Object.

available_ips: DetailEndpoint property

Represents the available-ips detail endpoint.

Returns a DetailEndpoint object that is the interface for viewing and creating IP addresses inside a prefix.

Returns:

Name Type Description
DetailEndpoint DetailEndpoint

The detail endpoint interface for available IPs.

Examples:

List available IPs:

>>> prefix = nb.ipam.prefixes.get(prefix="10.0.192.0/18")
>>> prefix.available_ips.list()
[
    <pynautobot.models.ipam.IpAddresses ('10.0.192.1/18') at 0x103cb59d0>,
    <pynautobot.models.ipam.IpAddresses ('10.0.192.2/18') at 0x103cefb90>,
    ...
]

To create a single IP:

>>> prefix = nb.ipam.prefixes.get(prefix="10.0.192.0/18")
>>> ip_address = prefix.available_ips.create({"status": "Active"})
>>> ip_address
<pynautobot.models.ipam.IpAddresses ('10.0.192.1/18') at 0x7f7b595e6160>

To create multiple IPs:

>>> prefix = nb.ipam.prefixes.get(prefix="10.0.192.0/18")
>>> ip_addresses = prefix.available_ips.create([{"status": "Active"} for i in range(2)])
>>> len(create)
2

available_prefixes: DetailEndpoint property

Represents the available-prefixes detail endpoint.

Returns a DetailEndpoint object that is the interface for viewing and creating prefixes inside a parent prefix.

Very similar to :py:meth:~pynautobot.ipam.Prefixes.available_ips, except that the dict (or list of dicts) passed to .create() needs to have a prefix_length key/value specified.

Returns:

Name Type Description
DetailEndpoint DetailEndpoint

The detail endpoint interface for available prefixes.

Examples:

List available prefixes:

>>> prefix = nb.ipam.prefixes.get(prefix="10.0.0.0/16")
>>> prefix.available_prefixes.list()
[<pynautobot.models.ipam.Prefixes ('10.1.0.0/16') at 0x7f7b595f0b80>]

Creating a single child prefix:

>>> new_prefix = prefix.available_prefixes.create({
    'prefix_length': 24,
    'status': 'Active',
    'type': 'network',
})
>>> new_prefix
<pynautobot.models.ipam.Prefixes ('10.0.0.0/24') at 0x7f7b595e6c70>

__str__()

Return the string representation of the Prefixes object.