Infoblox adapter¶
The infoblox module provisions IPv4 networks and fixed addresses through Infoblox WAPI. It can allocate subnets, create network objects, and reserve individual IP addresses while keeping allocations stable across recompiles.
How to use it¶
Define a provider with your WAPI URL, credentials, and SSL verification settings. Then use the provided entities plus plugins (and matching allocators for LSM services) to allocate networks and fixed addresses.
Prerequisites¶
Infoblox WAPI URL (for example
https://infoblox.example.com/wapi/v2.13.1)Credentials with rights to read/write network objects
Network view to operate in (defaults to
default)Permission to create/update extensible attributes: the module keeps a stable allocation key in the
InmantaAllocationIdextensible attribute so repeated runs reuse the same subnet or IP. You can pre-create this attribute, but the module creates it on first use if it is missing.
Allocating a subnet¶
import infoblox
provider = infoblox::Provider(
name="ib",
wapi_url="https://infoblox.example.com/wapi/v2.13.1",
username=std::get_env("INFOBLOX_USERNAME"),
password=std::get_env("INFOBLOX_PASSWORD"),
wapi_version="2.13.1",
verify_ssl=true,
)
parent = "10.0.0.0/16"
child = infoblox::Subnet(
provider=provider,
network_view="default",
cidr=infoblox::allocate_ipv4_subnet(
provider=provider,
parent_network=parent,
prefix_length=24,
id="my-service:subnet" # id must be unique per allocation
),
)
Allocating an IP address¶
import infoblox
provider = infoblox::Provider(
name="ib",
wapi_url="https://infoblox.example.com/wapi/v2.13.1",
username=std::get_env("INFOBLOX_USERNAME"),
password=std::get_env("INFOBLOX_PASSWORD"),
wapi_version="2.13.1",
verify_ssl=true,
)
parent = "10.0.0.0/24"
reservation = infoblox::FixedAddress(
provider=provider,
network_view="default",
ipv4addr=infoblox::allocate_ipv4_address(
provider=provider,
parent_network=parent,
id="my-service:ip" # must be unique per allocation
),
match_client="RESERVED",
)
Always supply a stable, unique
idper allocation; leaving it empty makes the plugin refuse the allocation.Allocator variants (for example
allocate_ipv4_addressandallocate_ipv4_subnet) are available to integrate with LSM services; the example above calls the plugin directly.
Managing a DHCP range¶
import infoblox
provider = infoblox::Provider(
name="ib",
wapi_url="https://infoblox.example.com/wapi/v2.13.1",
username=std::get_env("INFOBLOX_USERNAME"),
password=std::get_env("INFOBLOX_PASSWORD"),
wapi_version="2.13.1",
verify_ssl=true,
)
network = infoblox::Network(
provider=provider,
cidr="10.0.0.0/24",
network_view="default",
)
dhcp_range = infoblox::DhcpRange(
provider=provider,
network=network,
range_index="my-service:dhcp-range",
start_addr="10.0.0.10",
end_addr="10.0.0.100",
comment="DHCP range for my service",
extattrs={"Owner": "platform-team"},
)
Use a stable, unique range_index per DHCP range. The module stores it in the InmantaDhcpRangeId extensible attribute so it can keep tracking the same Infoblox range when start_addr or end_addr changes.
Managing a DHCPv6 range¶
import infoblox
provider = infoblox::Provider(
name="ib",
wapi_url="https://infoblox.example.com/wapi/v2.13.1",
username=std::get_env("INFOBLOX_USERNAME"),
password=std::get_env("INFOBLOX_PASSWORD"),
wapi_version="2.13.1",
verify_ssl=true,
)
network = infoblox::Ipv6Network(
provider=provider,
cidr="2001:db8:10::/48",
network_view="default",
)
dhcpv6_range = infoblox::Ipv6DhcpRange(
provider=provider,
network=network,
range_index="my-service:dhcpv6-range",
start_addr="2001:db8:10::30:1",
end_addr="2001:db8:10::30:20",
comment="DHCPv6 range for my service",
extattrs={"Owner": "platform-team"},
)
Use a stable, unique range_index per DHCPv6 range. The module stores it in the InmantaDhcpRangeId extensible attribute so it can keep tracking the same Infoblox range when start_addr or end_addr changes.
Running tests¶
python3 -m venv .venv && source .venv/bin/activate
pip install -e . -c requirements.txt -r requirements.dev.txt
pytest tests