IP4Network class - Platform - BlueCat Gateway - 24.1

Gateway Administration Guide

Locale
English
Product name
BlueCat Gateway
Version
24.1

class bluecat.ip4_network.IP4Network(api, api_entity)

Bases: bluecat.ip_object.IP4BlockNetwork bluecat.configuration.IP4SpaceConfigurationBlockNet bluecat.configuration.IP4SpaceConfigurationNet bluecat.deployment_option.DNSOptionActionsMixin bluecat.deployment_option.RawDeploymentOptionActionsMixin

Instantiate an IPv4 network.

Parameters Description
api

API instance used by the entity to communicate with BAM.

api_entity

The entity returned by the BAM API.

ALLOW_QUERY = 'allow-query'

add_dhcp4_range(start, end, properties='')

Adds IPv4 DHCP ranges.

Parameters Description
start

An IP address defining the lowest address or start of the range.

end

An IP address defining the highest address or end of the range

properties

Adds object properties, including the object name and user-defined fields.

Returns: The created IP4DHCPRange Entity object.

add_dhcp_deployment_role(server_interface, role_type, properties='')

Adds a DHCP deployment role to a specified object.

Parameters Description
server_interface

The object ID/server interface object to which the role is to be deployed.

role_type

The type of DHCP role to be added. Possible roles are: MASTER NONE

properties

A string containing options including: inherited - either true or false; indicates whether or not the deployment role was inherited. secondaryServerInterfaceId - the object ID of the secondary server interface for a DHCP failover.

Returns: The added DHCP deployment role object.

add_dns_deployment_option(dns_option, value, properties='')

Parameters Description
dns_option

The name of the DNS option being added.

value

The value being assigned to the option.

properties

Adds object properties, including comments and user-defined fields.

Returns: Instance of DNSOption added.

add_dns_deployment_role(server_interface, role_type, properties='')

Adds a DNS deployment role to a specified object.

Parameters Description
server_interface

The object ID/server interface object to which the role is to be added.

role_type

The type of DNS role to be added. The type must be one of: NONE MASTER MASTER_HIDDEN SLAVE SLAVE_STEALTH FORWARDER STUB RECURSION AD_MASTER

properties

Adds object properties, including the view associated with this DNS deployment role and user-defined fields.

Returns: Added DNS deployment role object.

add_raw_deployment_option(option_type, raw_data, properties='')

Parameters Description
option_type

the option types for Raw Deployment Options, the Three options are DNS_RAW, DHCP_RAW, DHCPV6_RAW.

raw_data

the raw option value for the deployment option.

properties

the properties of the raw option, if it is an DNSRawOption you need to set server in properties

Returns: Returns an instance of the type DNSOption that represents the DNS deployment option.

assign_ip4_address(address, mac_address, hostinfo, action, properties='')

Assign an IPv4 address (e.g. ‘192.168.0.1’).

Parameters Description
address

(e.g. ‘192.168.0.1’)

mac_address

(e.g. ‘“00-00-00-00-00-01’)

hostinfo

A string containing host information for the address in the following format: [hostname,viewId,reverseFlag,sameAsZoneFlag, ….]. Where:

  • hostname - The Fully Qualified Domain Name (FQDN) for the host record to be added

  • viewId - The object ID of the view under which this host should be created.

  • reverseFlag - The flag indicating if a reverse record should be created. The possible values are true or false.

  • sameAsZoneFlag - The flag indicating if record should be created as same as zone record. The possible values are true or false.

The comma-separated parameters may be repeated in the order shown above. The string must not end with a comma.

action

MAKE_STATIC / MAKE_RESERVED / MAKE_DHCP_RESERVED

properties

A string containing options.

Returns: Returns an APIEntity for the assigned IPv4 address object.

assign_next_available_ip4_address(mac_address, hostinfo, action, properties='')

Assigns next available IPv4 address.

Parameters Description
mac_address

(e.g. ‘00-00-00-00-00-01’)

hostinfo

A string containing host information for the address in the following format: [hostname,viewId,reverseFlag,sameAsZoneFlag, …]. Where:

  • hostname - The Fully Qualified Domain Name (FQDN) for the host record to be added

  • viewId - The object ID of the view under which this host should be created.

  • reverseFlag - The flag indicating if a reverse record should be created. The possible values are true or false.

  • sameAsZoneFlag - The flag indicating if record should be created as same as zone record. The possible
    • values are true or false.

The comma-separated parameters may be repeated in the order shown above. The string must not end with a comma.

action

MAKE_STATIC / MAKE_RESERVED / MAKE_DHCP_RESERVED

properties

A string containing options. Properties include:

  • excludeDHCPRange - Specifies whether IP addresses in DHCP ranges should be excluded from assignment. The value is either true or false, default value is false.

Returns: Returns an APIEntity for the assigned IPv4 address object.

assign_or_update_template(template_id, gateway_reapply_mode='', reserved_addresses_reapply_mode='', dhcp_ranges_reapply_mode='', ip_groups_reapply_mode='', options_reapply_mode='')

Assigns, updates, or removes IPv4 network templates. user can also specify the reapply mode for various properties of the template. if none is specified it will use ignore. The possible values for re-apply mode properties are:

  • ‘update’

  • ‘ignore’

  • ‘overwrite’

Parameters Description
template_id

The object ID of the DNS zone template or IPv4 network template. To remove a template, set this value to 0 (zero).

gateway_reapply_mode

set the reapply mode for gateway in the template.

reserved_addresses_reapply_mode

set the reapply mode for reserved addresses in the template.

dhcp_ranges_reapply_mode

set the reapply mode for dhcp ranges in the template.

ip_groups_reapply_mode

set the reapply mode for ip groups in the template.

options_reapply_mode

set the reapply mode for options in the template.

Example:

from bluecat.constants import TemplateValues

api = g.user.get_api()                              # get api object
ip4_network_id = 11111                              # ip4 network id
ip6_object = api.get_entity_by_id(ip4_network_id)
template_id = 12345                                 # the template id to be assigned

ip4_object.assign_or_update_template(template_id,
                                     gateway_reapply_mode=TemplateValues.UPDATE,
                                     reserved_addresses_reapply_mode=TemplateValues.IGNORE,
                                     dhcp_ranges_reapply_mode=TemplateValues.OVERWRITE,
                                     ip_groups_reapply_mode=TemplateValues.UPDATE,
                                     options_reapply_mode=TemplateValues.OVERWRITE)

get_deployment_options(option_types, server)

Get deployment Option for the entity.

Parameters Description
option_types

the Deployment option type you would like to search, Includes

  • DNSOption

  • DNSRawOption

  • DHCPRawOption

  • DHCPV6RawOption

  • DHCPV4ClientOption

  • DHCPV6ClientOption

  • DHCPServiceOption

  • DHCPV6ServiceOption

  • VendorClientOption

  • StartOfAuthority

server

the server which the deployment option is attached to, there are 3 options:

  • >0—returns only the options that are linked to the specified server ID.

  • <0—returns all options regardless of the server ID specified.

  • =0—returns only the options that are linked to all servers.

get_dhcp_deployment_role(server_interface)

Retrieves the DHCP deployment role assigned to a specified object.

Parameters Description
server_interface

The server interface to which the role is assigned.

Returns: Returns the DHCP deployment role assigned to the specified object.

get_dns_deployment_option(dns_option, server)

Parameters Description
dns_option

The name of the DNS option.

server

Specifies the server to which this option is assigned.

Returns: Returns an instance of the type DNSOption that represents the DNS deployment option.

get_dns_deployment_role(server_interface)

Retrieves a DNS deployment role from a specified object.

Parameters Description
server_interface

The object ID/server interface object to which the DNS deployment role is assigned.

get_entity_by_range(address1, address2)

Returns an IPv4 DHCP range object by calling it using its range.

Parameters Description
address1

An IP address defining the lowest address or start of the range.

address2

An IP address defining the highest address or end of the range.

Returns: An IP4DHCPRange Entity object.

get_first_addresses(n)

Get the first N addresses of the network as a list.

Parameters Description
n

how many addresses to return.

get_ip4_address(address)

Get an IPv4 address by IP (e.g. ‘192.168.0.1’).

Parameters Description
address

the IPv4 address string.

Returns: Returns the requested APIEntity of IPv4 Address object.

get_ip_range_by_ip(entity_type, address)

Warning:

This method has been deprecated, use get_ip_ranged_by_ip instead.

Use this method to find the Configuration, IPv4 Block, IPv6 Block, IPv4 Network, IPv6 Network, DHCP Range, or DHCPv6 range containing a specified address. You can specify the type of object to be returned, or you can leave the type of object empty to find the most direct container for the object.

Parameters Description
entity_type

The type of object containing the IPv4 or IPv6 address. Specify EntityType.IP4Block, EntityType.IP4Network, or EntityType.DHCP4Range to find the block, network, or range containing the IPv4 address. Specify EntityType.IP6Block, EntityType.IP6Network, or EntityType.DHCP6Range to find the block, network, or range containing the IPv6 address. Specify an empty string (“”) to return the most direct container for the IPv4 address or IPv6 address.

address

An IPv4 address or Ipv6 address.

Returns: Returns an APIEntity for the object containing the specified address. If EntityType.IP4Block, EntityType.IP6Block, EntityType.IP4Network, EntityType.IP6Network, EntityType.DHCP4Range, or EntityType.DHCP6Range is specified as the type parameter, returns an object of the specified type. If an empty string (“”) is specified as the type parameter, returns the most direct container for the IPv4 address or IPv6 address.

Raises:

PortalException – if no object matching the entity_type and address is found.

get_ip_ranged_by_ip(entity_type, address)

Use this method to find the Configuration, IPv4 Block, IPv6 Block, IPv4 Network, IPv6 Network, DHCP Range, or DHCPv6 range containing a specified address. You can specify the type of object to be returned, or you can leave the type of object empty to find the most direct container for the object.

Parameters Description
entity_type (str)

The type of object containing the IPv4 or IPv6 address. Specify EntityType.IP4Block, EntityType.IP4Network, or EntityType.DHCP4Range to find the block, network, or range containing the IPv4 address. Specify EntityType.IP6Block, EntityType.IP6Network, or EntityType.DHCP6Range to find the block, network, or range containing the IPv6 address. Specify an empty string (“”) to return the most direct container for the IPv4 address or IPv6 address.

address (str)

An IPv4 address or Ipv6 address.

Returns: Returns an APIEntity for the object containing the specified address. If EntityType.IP4Block, EntityType.IP6Block, EntityType.IP4Network, EntityType.IP6Network, EntityType.DHCP4Range, or EntityType.DHCP6Range is specified as the type parameter, returns an object of the specified type. If an empty string (“”) is specified as the type parameter, returns the most direct container for the IPv4 address or IPv6 address.

Raises:

PortalException – if no object matching the entity_type and address is found.

get_ksk(ksk_format)

Get Key Signing Key (KSK) associated to an ip4 block

Parameters Description
ksk_format

ksk return type, accepted formats are: TRUST_ANCHOR, DNS_KEY and DS_RECORD

Returns: List of KSKs in string format

Example:

from bluecat.constants import DNSSECKeyFormats

api = g.user.get_api()                              # get api object
ip4_network_id = 10223                              # ip4 network id
ip4_object = api.get_entity_by_id(ip4_network_id)

ksk_list = ip4_object.get_ksk(DNSSECKeyFormats.TRUST_ANCHOR)

get_next_available_ip4_address()

Gets next available IPv4 address in current configuration

Returns: Returns the next available IPv4 address in an existing network as a string.

get_next_ip4_address(exclude=None)

Get the next available IPv4 address (as a string) optionally excluding a given list of addresses.

Parameters Description
exclude (str, optional)

which addresses (as a list of strings) to exclude.

get_next_ip4_address_string(exclude=None)

Warning:

This method has been deprecated, use get_next_ip4_address instead.

Get the next available IPv4 address (as a string) optionally excluding a given list of addresses.

Parameters Description
exclude

which addresses (as a list of strings) to exclude.

move_ip_object(address, no_server_update=False)

Allows users to move the IP object to another address

Parameters Description
address

New address to be allocated

no_server_update

ONLY FOR IPV4 ADDRESSES, A boolean value. If set to True, instant dynamic host record changes will not occur on DNS/DHCP Servers when moving an IPv4 address object.

Example:

api = g.user.get_api()                  # get api object
ip4_id = 10234                          # ip4 block/ip4 network id
ip4_object = api.get_entity_by_id(ip4_id)
new_ip4_address = '10.0.0.1'            # new IP address to be allocated

ip4_object.move_ip_object(new_ip4_address)

split_ip4_network(number_of_parts=2, options='')

Splits an IPv4 network into the specified number of networks.

Parameters Description
number_of_parts

The number of the networks into which the network will be split. Valid values are 2 to the power of 2 up to 1024.

options

A string containing the following options:

  • assignDefaultGateway - a Boolean value. If set to true, a gateway will be created by using the default gateway value which is the first IP address in the network. If set to false, no gateway will be created. The default value is true.

  • overwriteConflicts - a Boolean value. If set to true, any conflicts within the split IPv4 network will be removed. The default value is false.

  • template - a network template ID. The default value is 0 which means no network template will be used. Specify a network template ID if you wish to apply one.

  • preserveGateway - a Boolean value. If set to true, the gateway in the original network will be preserved. The default value is true.

Returns: Returns an array of networks created after splitting the network.