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}¶
-
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
-
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.
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]¶
-
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_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)
-
infoblox_client.objects module¶
-
class
infoblox_client.objects.
AnyMember
(**kwargs)[source]¶ Bases:
infoblox_client.objects.SubObjects
-
ip
¶
-
-
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)-
ref
¶
-
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
¶ Returns dict with EAs in {ea_name: ea_value} format.
-
-
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
-
ip
¶
-
-
class
infoblox_client.objects.
FixedAddressV6
(connector, **kwargs)[source]¶ Bases:
infoblox_client.objects.FixedAddress
FixedAddress for IPv6
-
mac
¶
-
-
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’)
-
class
infoblox_client.objects.
HostRecordV4
(connector, **kwargs)[source]¶ Bases:
infoblox_client.objects.HostRecord
HostRecord for IPv4
-
ipv4addrs
¶
-
-
class
infoblox_client.objects.
HostRecordV6
(connector, **kwargs)[source]¶ Bases:
infoblox_client.objects.HostRecord
HostRecord for IPv6
-
ipv6addrs
¶
-
-
class
infoblox_client.objects.
IP
(**kwargs)[source]¶ Bases:
infoblox_client.objects.SubObjects
-
hostname
¶
-
ip
¶
-
ip_version
= None¶
-
zone_auth
¶
-
-
class
infoblox_client.objects.
IPv4
(**kwargs)[source]¶ Bases:
infoblox_client.objects.IP
-
ip_version
= 4¶
-
-
class
infoblox_client.objects.
IPv6
(**kwargs)[source]¶ Bases:
infoblox_client.objects.IP
-
ip_version
= 6¶
-
-
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.
-
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
-
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.
-
infoblox_type
¶
-
ip_version
¶
-
return_fields
¶
-
class
infoblox_client.objects.
SubObjects
(**kwargs)[source]¶ Bases:
infoblox_client.objects.BaseObject
Base class for objects that do not require all InfobloxObject power
infoblox_client.utils module¶
-
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.
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