infoblox_client package

Submodules

infoblox_client.connector module

class infoblox_client.connector.Connector(options)[source]

Bases: object

Connector stands for interacting with Infoblox NIOS

Defines methods for getting, creating, updating and removing objects from an Infoblox server instance.

DEFAULT_HEADER = {'Content-type': 'application/json'}
DEFAULT_OPTIONS = {'http_pool_maxsize': 10, 'wapi_version': '1.4', 'http_request_timeout': 10, 'silent_ssl_warnings': False, 'ssl_verify': False, 'http_pool_connections': 10, 'max_results': None, 'max_retries': 3, 'log_api_calls_as_info': False}
call_func(*args, **kwargs)[source]
create_object(*args, **kwargs)[source]

Create an Infoblox object of type ‘obj_type’

Args:
obj_type (str): Infoblox object type,
e.g. ‘network’, ‘range’, etc.

payload (dict): Payload with data to send return_fields (list): List of fields to be returned

Returns:
The object reference of the newly create object
Raises:
InfobloxException
delete_object(*args, **kwargs)[source]

Remove an Infoblox object

Args:
ref (str): Object reference
Returns:
The object reference of the removed object
Raises:
InfobloxException
get_object(*args, **kwargs)[source]

Retrieve a list of Infoblox objects of type ‘obj_type’

Some get requests like ‘ipv4address’ should be always proxied to GM on Hellfire If request is cloud and proxy is not forced yet, then plan to do 2 request: - the first one is not proxied to GM - the second is proxied to GM

Args:
obj_type (str): Infoblox object type, e.g. ‘network’,
‘range’, etc.

payload (dict): Payload with data to send return_fields (list): List of fields to be returned extattrs (list): List of Extensible Attributes force_proxy (bool): Set _proxy_search flag

to process requests on GM
max_results (int): Maximum number of objects to be returned.
If set to a negative number the appliance will return an error when the number of returned objects would exceed the setting. The default is -1000. If this is set to a positive number, the results will be truncated when necessary.
Returns:
A list of the Infoblox objects requested
Raises:
InfobloxObjectNotFound
static is_cloud_wapi(wapi_version)[source]
update_object(*args, **kwargs)[source]

Update an Infoblox object

Args:
ref (str): Infoblox object reference payload (dict): Payload with data to send
Returns:
The object reference of the updated object
Raises:
InfobloxException
infoblox_client.connector.reraise_neutron_exception(func)[source]

infoblox_client.exceptions module

exception infoblox_client.exceptions.BaseExc(**kwargs)[source]

Bases: exceptions.Exception

Base Exception

To correctly use this class, inherit from it and define a ‘message’ property. That message will get printf’d with the keyword arguments provided to the constructor.

message = 'An unknown exception occurred.'
exception infoblox_client.exceptions.HostRecordNotPresent(**kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxObjectParsingError

message = "Cannot parse Host Record object from dict because 'ipv4addrs'/'ipv6addrs' is absent."
exception infoblox_client.exceptions.InfobloxBadWAPICredential(response, **kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxException

message = 'Infoblox IPAM is misconfigured: infoblox_username and infoblox_password are incorrect.'
exception infoblox_client.exceptions.InfobloxCannotAllocateIp(**kwargs)[source]

Bases: infoblox_client.exceptions.BaseExc

message = 'Cannot allocate IP %(ip_data)s'
exception infoblox_client.exceptions.InfobloxCannotCreateObject(response, **kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxException

message = "Cannot create '%(obj_type)s' object(s): %(content)s [code %(code)s]"
exception infoblox_client.exceptions.InfobloxCannotDeleteObject(response, **kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxException

message = 'Cannot delete object with ref %(ref)s: %(content)s [code %(code)s]'
exception infoblox_client.exceptions.InfobloxCannotUpdateObject(response, **kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxException

message = 'Cannot update object with ref %(ref)s: %(content)s [code %(code)s]'
exception infoblox_client.exceptions.InfobloxConfigException(**kwargs)[source]

Bases: infoblox_client.exceptions.BaseExc

Generic Infoblox Config Exception.

message = 'Config error: %(msg)s'
exception infoblox_client.exceptions.InfobloxConnectionError(**kwargs)[source]

Bases: infoblox_client.exceptions.BaseExc

message = 'Infoblox HTTP request failed with: %(reason)s'
exception infoblox_client.exceptions.InfobloxDidNotReturnCreatedIPBack(**kwargs)[source]

Bases: infoblox_client.exceptions.BaseExc

message = 'Infoblox did not return created IP back'
exception infoblox_client.exceptions.InfobloxException(response, **kwargs)[source]

Bases: infoblox_client.exceptions.BaseExc

Generic Infoblox Exception.

exception infoblox_client.exceptions.InfobloxFuncException(response, **kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxException

message = "Error occurred during function's '%(func_name)s' call: ref %(ref)s: %(content)s [code %(code)s]"
exception infoblox_client.exceptions.InfobloxHostRecordIpAddrNotCreated(**kwargs)[source]

Bases: infoblox_client.exceptions.BaseExc

message = 'Infoblox host record ipv4addr/ipv6addr has not been created for IP %(ip)s, mac %(mac)s'
exception infoblox_client.exceptions.InfobloxInvalidIp(**kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxObjectParsingError

message = 'Bad IP address: %(ip)s'
exception infoblox_client.exceptions.InfobloxMemberAlreadyAssigned(response, **kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxCannotCreateObject

exception infoblox_client.exceptions.InfobloxNetworkNotAvailable(**kwargs)[source]

Bases: infoblox_client.exceptions.BaseExc

message = 'No network view %(network_view)s for %(cidr)s'
exception infoblox_client.exceptions.InfobloxObjectParsingError(**kwargs)[source]

Bases: infoblox_client.exceptions.BaseExc

message = 'Infoblox object cannot be parsed from dict: %(data)s'
exception infoblox_client.exceptions.InfobloxSearchError(response, **kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxException

message = "Cannot search '%(obj_type)s' object(s): %(content)s [code %(code)s]"
exception infoblox_client.exceptions.InfobloxTimeoutError(response, **kwargs)[source]

Bases: infoblox_client.exceptions.InfobloxException

message = 'Connection to NIOS timed out'

infoblox_client.feature module

class infoblox_client.feature.Feature(version, feature_versions=None)[source]

Bases: object

Class representing available NIOS features

Based on the following:
  • Infoblox WAPI Version
  • Known features and corresponding WAPI version requirement

the Feature class represents available NIOS features as attributes.

class infoblox_client.feature.WapiVersionUtil(version)[source]

Bases: object

Provide utility functions for manipulating WAPI version

Provide methods that manipulate and get information from WAPI version string.

is_version_supported(req_ver)[source]
major_version[source]
minor_version[source]
patch_version[source]
version_parts[source]

infoblox_client.object_manager module

class infoblox_client.object_manager.InfobloxObjectManager(connector)[source]

Bases: object

add_ip_to_host_record_from_range(host_record, network_view, mac, first_ip, last_ip, use_dhcp=True)[source]
add_ip_to_record(host_record, ip, mac, use_dhcp=True)[source]
bind_name_with_host_record(dns_view, ip, name, extattrs, network_view=None)[source]
bind_name_with_record_a(dns_view, ip, name, bind_list, extattrs)[source]
create_dns_view(network_view, dns_view)[source]
create_dns_zone(dns_view, dns_zone, grid_primary=None, grid_secondaries=None, zone_format=None, ns_group=None, prefix=None, extattrs=None)[source]
create_ea_definition(ea_def, reraise=False)[source]
create_fixed_address_for_given_ip(network_view, mac, ip, extattrs)[source]
create_fixed_address_from_cidr(netview, mac, cidr, extattrs)[source]
create_fixed_address_from_range(network_view, mac, first_ip, last_ip, extattrs)[source]
create_host_record_for_given_ip(dns_view, zone_auth, hostname, mac, ip, extattrs, use_dhcp, use_dns=True)[source]
create_host_record_from_range(dns_view, network_view_name, zone_auth, hostname, mac, first_ip, last_ip, extattrs, use_dhcp, use_dns=True)[source]
create_ip_range(network_view, start_ip, end_ip, network, disable, range_extattrs)[source]

Creates IPRange or fails if already exists.

create_network(net_view_name, cidr, nameservers=None, members=None, gateway_ip=None, dhcp_trel_ip=None, network_extattrs=None)[source]

Create NIOS Network and prepare DHCP options.

Some DHCP options are valid for IPv4 only, so just skip processing them for IPv6 case.

Parameters:
  • net_view_name – network view name
  • cidr – network to allocate, example ‘172.23.23.0/24’
  • nameservers – list of name servers hosts/ip
  • members – list of objects.AnyMember objects that are expected to serve dhcp for created network
  • gateway_ip – gateway ip for the network (valid for IPv4 only)
  • dhcp_trel_ip – ip address of dhcp relay (valid for IPv4 only)
  • network_extattrs – extensible attributes for network (instance of objects.EA)
Returns:

created network (instance of objects.Network)

create_network_from_template(network_view, cidr, template, extattrs)[source]
create_network_view(network_view, extattrs)[source]
create_required_ea_definitions(required_ea_defs, reraise=False)[source]
delete_all_associated_objects(network_view, ip, delete_list)[source]
delete_dns_view(dns_view)[source]
delete_dns_zone(dns_view, dns_zone_fqdn)[source]
delete_fixed_address(network_view, ip_address)[source]
delete_host_record(dns_view, ip_address, network_view=None)[source]
delete_ip_from_host_record(host_record, ip)[source]
delete_ip_range(network_view, start_ip, end_ip)[source]
delete_network(network_view, cidr)[source]
delete_network_view(network_view)[source]
delete_object_by_ref(ref)[source]
delete_objects_associated_with_a_record(name, view, delete_list)[source]

Deletes records associated with record:a or record:aaaa.

find_hostname(dns_view, hostname, ip, network_view=None)[source]
get_all_ea_definitions()[source]
get_host_record(dns_view, ip, network_view=None)[source]
get_member(member)[source]
get_network(network_view, cidr)[source]
has_dns_zones(dns_view)[source]
has_networks(network_view_name)[source]
network_exists(network_view, cidr)[source]

Deprecated, use get_network() instead.

restart_all_services(member)[source]
unbind_name_from_record_a(dns_view, ip, name, unbind_list)[source]
update_dns_record_eas(dns_view, ip, extattrs)[source]
update_dns_zone_attrs(dns_view, dns_zone_fqdn, extattrs)[source]
update_fixed_address_eas(network_view, ip, extattrs)[source]
update_host_record_eas(dns_view, ip, extattrs)[source]
update_network_options(ib_network, extattrs=None)[source]

infoblox_client.objects module

class infoblox_client.objects.AAAARecord(connector, **kwargs)[source]

Bases: infoblox_client.objects.ARecordBase

class infoblox_client.objects.ARecord(connector, **kwargs)[source]

Bases: infoblox_client.objects.ARecordBase

class infoblox_client.objects.ARecordBase(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

classmethod get_v4_class()[source]
classmethod get_v6_class()[source]
class infoblox_client.objects.AnyMember(**kwargs)[source]

Bases: infoblox_client.objects.SubObjects

ip[source]
class infoblox_client.objects.BaseObject(**kwargs)[source]

Bases: object

Base class that provides minimal new object model interface

This class add next features to objects: - initialize public instance variables with None for fields

defined in ‘_fields’ and ‘_shadow_fields’
  • accept fields from ‘_fields’ and ‘_shadow_fields’ as a parameter on init
  • dynamically remap one fields into another using _remap dict,
mapping is in effect on all stages (on init, getter and setter)
  • provides nice object representation that contains class
and not None object fields (useful in python interpretter)
classmethod from_dict(ip_dict)[source]
ref[source]
to_dict()[source]
class infoblox_client.objects.DNSView(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

class infoblox_client.objects.DNSZone(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

class infoblox_client.objects.DhcpOption(**kwargs)[source]

Bases: infoblox_client.objects.SubObjects

class infoblox_client.objects.EA(ea_dict=None)[source]

Bases: object

Extensible Attributes

This class represents extensible attributes (EA). Converts EAs into format suitable for NIOS (to_dict) and builds EA class from NIOS reply (from_dict).

ea_dict[source]

Returns dict with EAs in {ea_name: ea_value} format.

classmethod from_dict(eas_from_nios)[source]

Converts extensible attributes from the NIOS reply.

get(name, default=None)[source]

Return value of requested EA.

set(name, value)[source]

Set value of requested EA.

to_dict()[source]

Converts extensible attributes into the format suitable for NIOS.

class infoblox_client.objects.EADefinition(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

Extensible Attribute Definition

class infoblox_client.objects.FixedAddress(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

classmethod get_v4_class()[source]
classmethod get_v6_class()[source]
ip[source]
class infoblox_client.objects.FixedAddressV4(connector, **kwargs)[source]

Bases: infoblox_client.objects.FixedAddress

class infoblox_client.objects.FixedAddressV6(connector, **kwargs)[source]

Bases: infoblox_client.objects.FixedAddress

FixedAddress for IPv6

mac[source]
class infoblox_client.objects.HostRecord(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

Base class for HostRecords

HostRecord uses ipvXaddr for search and ipvXaddrs for object creation. ipvXaddr and ipvXaddrs are quite different: ipvXaddr is single ip as a string ipvXaddrs is list of dicts with ipvXaddr, mac, configure_for_dhcp and host keys. In ‘ipvXaddr’ ‘X’ stands for 4 or 6 depending on ip version of the class.

To find HostRecord use next syntax: hr = HostRecord.search(connector, ip=‘192.168.1.25’, view=’some-view’)

To create host record create IP object first: ip = IP(ip=‘192.168.1.25’, mac=’aa:ab;ce:12:23:34’) hr = HostRecord.create(connector, ip=ip, view=’some-view’)

classmethod get_v4_class()[source]
classmethod get_v6_class()[source]
class infoblox_client.objects.HostRecordV4(connector, **kwargs)[source]

Bases: infoblox_client.objects.HostRecord

HostRecord for IPv4

ipv4addrs[source]
class infoblox_client.objects.HostRecordV6(connector, **kwargs)[source]

Bases: infoblox_client.objects.HostRecord

HostRecord for IPv6

ipv6addrs[source]
class infoblox_client.objects.IP(**kwargs)[source]

Bases: infoblox_client.objects.SubObjects

classmethod create(ip=None, mac=None, **kwargs)[source]
hostname[source]
ip[source]
ip_version = None
zone_auth[source]
class infoblox_client.objects.IPAddress(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

classmethod get_v4_class()[source]
classmethod get_v6_class()[source]
class infoblox_client.objects.IPAllocation(address, next_available_ip)[source]

Bases: object

classmethod next_available_ip_from_cidr(net_view_name, cidr)[source]
classmethod next_available_ip_from_range(net_view_name, first_ip, last_ip)[source]
class infoblox_client.objects.IPRange(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

classmethod get_v4_class()[source]
classmethod get_v6_class()[source]
class infoblox_client.objects.IPRangeV4(connector, **kwargs)[source]

Bases: infoblox_client.objects.IPRange

class infoblox_client.objects.IPRangeV6(connector, **kwargs)[source]

Bases: infoblox_client.objects.IPRange

class infoblox_client.objects.IPv4(**kwargs)[source]

Bases: infoblox_client.objects.IP

ip_version = 4
class infoblox_client.objects.IPv4Address(connector, **kwargs)[source]

Bases: infoblox_client.objects.IPAddress

class infoblox_client.objects.IPv6(**kwargs)[source]

Bases: infoblox_client.objects.IP

ip_version = 6
class infoblox_client.objects.IPv6Address(connector, **kwargs)[source]

Bases: infoblox_client.objects.IPAddress

class infoblox_client.objects.InfobloxObject(connector, **kwargs)[source]

Bases: infoblox_client.objects.BaseObject

Base class for all Infoblox related objects

_fields - fields that represents NIOS object (WAPI fields) and
are sent to NIOS on object creation

_search_fields - fields that can be used to find object on NIOS side _updateable_search_fields - fields that can be used to find object on

NIOS side, but also can be changed, so has to be sent on update.
_shadow_fields - fields that object usually has but they should not
be sent to NIOS. These fields can be received from NIOS. Examples: [_ref, is_default]
_return_fields - fields requested to be returned from NIOS side
if object is found/created

_infoblox_type - string representing wapi type of described object _remap - dict that maps user faced names into internal

representation (_fields)
_custom_field_processing - dict that define rules (lambda) for building
objects from data returned by NIOS side. Expected to be redefined in child class as needed, _custom_field_processing has priority over _global_field_processing, so can redefine for child class global rules defined in _global_field_processing.
_global_field_processing - almost the same as _custom_field_processing,
but defines rules for building field on global level. Fields defined in this dict will be processed in the same way in all child classes. Is not expected to be redefined in child classes.
_ip_version - ip version of the object, used to mark version
specific classes. Value other than None indicates that no versioned class lookup needed.
classmethod create(connector, check_if_exists=True, update_if_exists=False, **kwargs)[source]
delete()[source]
fetch(only_ref=False)[source]

Fetch object from NIOS by _ref or searchfields

Update existent object with fields returned from NIOS Return True on successful object fetch

field_to_dict(field)[source]

Read field value and converts to dict if possible

classmethod from_dict(connector, ip_dict)[source]

Build dict fields as SubObjects if needed.

Checks if lambda for building object from dict exists. _global_field_processing and _custom_field_processing rules are checked.

classmethod get_class_from_args(kwargs)[source]
classmethod get_v4_class()[source]
classmethod get_v6_class()[source]
infoblox_type[source]
ip_version[source]
return_fields[source]
classmethod search(connector, **kwargs)[source]
classmethod search_all(connector, **kwargs)[source]
to_dict(search_fields=None)[source]

Builds dict without None object fields

update()[source]
update_from_dict(ip_dict, only_ref=False)[source]
static value_to_dict(value)[source]
class infoblox_client.objects.Member(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

class infoblox_client.objects.Network(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

classmethod get_v4_class()[source]
classmethod get_v6_class()[source]
class infoblox_client.objects.NetworkV4(connector, **kwargs)[source]

Bases: infoblox_client.objects.Network

class infoblox_client.objects.NetworkV6(connector, **kwargs)[source]

Bases: infoblox_client.objects.Network

class infoblox_client.objects.NetworkView(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

class infoblox_client.objects.PtrRecord(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

classmethod get_v4_class()[source]
classmethod get_v6_class()[source]
class infoblox_client.objects.PtrRecordV4(connector, **kwargs)[source]

Bases: infoblox_client.objects.PtrRecord

class infoblox_client.objects.PtrRecordV6(connector, **kwargs)[source]

Bases: infoblox_client.objects.PtrRecord

class infoblox_client.objects.SubObjects(**kwargs)[source]

Bases: infoblox_client.objects.BaseObject

Base class for objects that do not require all InfobloxObject power

classmethod from_dict(ip_dict)[source]
to_dict()[source]
class infoblox_client.objects.Tenant(connector, **kwargs)[source]

Bases: infoblox_client.objects.InfobloxObject

infoblox_client.utils module

infoblox_client.utils.determine_ip_version(ip_in)[source]
infoblox_client.utils.generate_duid(mac)[source]

DUID is consisted of 10 hex numbers.

0x00 + 3 random hex + mac with 6 hex

infoblox_client.utils.is_valid_ip(ip)[source]
infoblox_client.utils.safe_json_load(data)[source]
infoblox_client.utils.try_value_to_bool(value, strict_mode=True)[source]

Tries to convert value into boolean.

strict_mode is True: - Only string representation of str(True) and str(False)

are converted into booleans;
  • Otherwise unchanged incoming value is returned;

strict_mode is False: - Anything that looks like True or False is converted into booleans. Values accepted as True: - ‘true’, ‘on’, ‘yes’ (case independent) Values accepted as False: - ‘false’, ‘off’, ‘no’ (case independent) - all other values are returned unchanged

Module contents