NetworkManager

class SoftLayer.managers.NetworkManager(client)[source]

Manage SoftLayer network objects: VLANs, subnets and IPs

See product information here: https://www.ibm.com/cloud/network

Parameters:

client (SoftLayer.API.BaseClient) – the client instance

__init__(client)[source]

Methods

__init__(client)

add_global_ip([version, test_order])

Adds a global IP address to the account.

add_securitygroup_rule(group_id[, ...])

Add a rule to a security group

add_securitygroup_rules(group_id, rules)

Add rules to a security group

add_subnet(subnet_type[, quantity, ...])

Orders a new subnet

assign_global_ip(global_ip_id, target)

Assigns a global IP address to a specified target.

attach_securitygroup_component(group_id, ...)

Attaches a network component to a security group.

attach_securitygroup_components(group_id, ...)

Attaches network components to a security group.

cancel_global_ip(global_ip_id)

Cancels the specified global IP address.

cancel_item(identifier, cancel_immediately, ...)

Cancel a billing item immediately, deleting all its data.

cancel_subnet(subnet_id)

Cancels the specified subnet.

clear_route(identifier)

Calls SoftLayer_Network_Subnet::clearRoute()

create_securitygroup([name, description])

Creates a security group.

delete_securitygroup(group_id)

Deletes the specified security group.

detach_securitygroup_component(group_id, ...)

Detaches a network component from a security group.

detach_securitygroup_components(group_id, ...)

Detaches network components from a security group.

edit(instance_id[, name, note, tags])

Edit a vlan.

edit_note_subnet(subnet_id, note)

Edit the note for this subnet.

edit_securitygroup(group_id[, name, description])

Edit security group details.

edit_securitygroup_rule(group_id, rule_id[, ...])

Edit a security group rule.

get_cancel_failure_reasons(identifier)

get the reasons why we cannot cancel the VLAN.

get_closed_pods()

Calls SoftLayer_Network_Pod::getAllObjects()

get_datacenter([_filter, datacenter])

Calls SoftLayer_Location::getDatacenters()

get_datacenter_by_keyname([keyname])

Calls SoftLayer_Location::getDatacenters()

get_event_logs_by_request_id(request_id)

Gets all event logs by the given request id

get_ip_by_address(ip_address)

get the ip address object

get_list_datacenter()

Calls SoftLayer_Location::getDatacenters()

get_nas_credentials(identifier, **kwargs)

Returns a list of IDs of VLANs which match the given VLAN name.

get_pods([datacenter, mask])

Calls SoftLayer_Network_Pod::getAllObjects()

get_routers(identifier)

Calls SoftLayer_Location::getRouters()

get_securitygroup(group_id, **kwargs)

Returns the information about the given security group.

get_subnet(subnet_id, **kwargs)

Returns information about a single subnet.

get_subnet_item_price(item, subnet_type, version)

Get the subnet specific item price id.

get_vlan(vlan_id[, mask])

Returns information about a single VLAN.

ip_lookup(ip_address)

Looks up an IP address and returns network information about it.

list_global_ips([version, identifier])

Returns a list of all global IP address records on the account.

list_securitygroup_rules(group_id)

List security group rules associated with a security group.

list_securitygroups(**kwargs)

List security groups.

list_subnets([identifier, datacenter, ...])

Display a list of all subnets on the account.

list_vlans([datacenter, vlan_number, name, ...])

Display a list of all VLANs on the account.

remove_securitygroup_rule(group_id, rule_id)

Remove a rule from a security group.

remove_securitygroup_rules(group_id, rules)

Remove rules from a security group.

resolve_global_ip_ids(identifier)

Resolve global ip ids.

resolve_subnet_ids(identifier)

Resolve subnet ids.

resolve_vlan_ids(identifier)

Resolve VLAN ids.

route(subnet_id, type_serv, target)

Assigns a subnet to a specified target.

search_for_vlan(vlan)

Returns a list of matching VLAN objects.

set_subnet_ipddress_note(identifier, note)

Set the ip address note of the subnet

set_tags(tags, vlan_id)

Sets tags on a vlan with a retry decorator

set_tags_subnet(subnet_id, tags)

Tag a subnet by passing in one or more tags separated by a comma.

summary_by_datacenter()

Summary of the networks on the account, grouped by data center.

unassign_global_ip(global_ip_id)

Unassigns a global IP address from a target.

add_global_ip(version=4, test_order=False)[source]

Adds a global IP address to the account.

Parameters:
  • version (int) – Specifies whether this is IPv4 or IPv6

  • test_order (bool) – If true, this will only verify the order.

add_securitygroup_rule(group_id, remote_ip=None, remote_group=None, direction=None, ethertype=None, port_max=None, port_min=None, protocol=None)[source]

Add a rule to a security group

Parameters:
  • group_id (int) – The ID of the security group to add this rule to

  • remote_ip (str) – The remote IP or CIDR to enforce the rule on

  • remote_group (int) – The remote security group ID to enforce the rule on

  • direction (str) – The direction to enforce (egress or ingress)

  • ethertype (str) – The ethertype to enforce (IPv4 or IPv6)

  • port_max (int) – The upper port bound to enforce (icmp code if the protocol is icmp)

  • port_min (int) – The lower port bound to enforce (icmp type if the protocol is icmp)

  • protocol (str) – The protocol to enforce (icmp, udp, tcp)

add_securitygroup_rules(group_id, rules)[source]

Add rules to a security group

Parameters:
  • group_id (int) – The ID of the security group to add the rules to

  • rules (list) – The list of rule dictionaries to add

add_subnet(subnet_type, quantity=None, endpoint_id=None, version=4, test_order=False)[source]

Orders a new subnet

Parameters:
  • subnet_type (str) – Type of subnet to add: private, public, global,static

  • quantity (int) – Number of IPs in the subnet

  • endpoint_id (int) – id for the subnet to be placed into

  • version (int) – 4 for IPv4, 6 for IPv6

  • test_order (bool) – If true, this will only verify the order.

assign_global_ip(global_ip_id, target)[source]

Assigns a global IP address to a specified target.

Parameters:
  • global_ip_id (int) – The ID of the global IP being assigned

  • target (string) – The IP address to assign

attach_securitygroup_component(group_id, component_id)[source]

Attaches a network component to a security group.

Parameters:
  • group_id (int) – The ID of the security group

  • component_id (int) – The ID of the network component to attach

attach_securitygroup_components(group_id, component_ids)[source]

Attaches network components to a security group.

Parameters:
  • group_id (int) – The ID of the security group

  • component_ids (list) – The IDs of the network components to attach

cancel_global_ip(global_ip_id)[source]

Cancels the specified global IP address.

Parameters:

id (int) – The ID of the global IP to be cancelled.

cancel_item(identifier, cancel_immediately, reason_cancel, customer_note)[source]

Cancel a billing item immediately, deleting all its data.

Parameters:
  • identifier (integer) – the instance ID to cancel

  • reason_cancel (string) – reason cancel

cancel_subnet(subnet_id)[source]

Cancels the specified subnet.

Parameters:

subnet_id (int) – The ID of the subnet to be cancelled.

clear_route(identifier)[source]

Calls SoftLayer_Network_Subnet::clearRoute()

returns true or false.

create_securitygroup(name=None, description=None)[source]

Creates a security group.

Parameters:
  • name (string) – The name of the security group

  • description (string) – The description of the security group

delete_securitygroup(group_id)[source]

Deletes the specified security group.

Parameters:

group_id (int) – The ID of the security group

detach_securitygroup_component(group_id, component_id)[source]

Detaches a network component from a security group.

Parameters:
  • group_id (int) – The ID of the security group

  • component_id (int) – The ID of the component to detach

detach_securitygroup_components(group_id, component_ids)[source]

Detaches network components from a security group.

Parameters:
  • group_id (int) – The ID of the security group

  • component_ids (list) – The IDs of the network components to detach

edit(instance_id, name=None, note=None, tags=None)[source]

Edit a vlan.

Parameters:
  • instance_id (integer) – the instance ID to edit.

  • name (string) – valid name.

  • note (string) – note about this particular vlan.

  • tags (string) – tags to set on the vlan as a comma separated list. Use the empty string to remove all tags.

Returns:

bool – True or an Exception

edit_note_subnet(subnet_id, note)[source]

Edit the note for this subnet.

Parameters:
  • subnet_id (int) – The ID of the subnet.

  • note (string) – The note.

edit_securitygroup(group_id, name=None, description=None)[source]

Edit security group details.

Parameters:
  • group_id (int) – The ID of the security group

  • name (string) – The name of the security group

  • description (string) – The description of the security group

edit_securitygroup_rule(group_id, rule_id, remote_ip=None, remote_group=None, direction=None, ethertype=None, port_max=None, port_min=None, protocol=None)[source]

Edit a security group rule.

Parameters:
  • group_id (int) – The ID of the security group the rule belongs to

  • rule_id (int) – The ID of the rule to edit

  • remote_ip (str) – The remote IP or CIDR to enforce the rule on

  • remote_group (int) – The remote security group ID to enforce the rule on

  • direction (str) – The direction to enforce (egress or ingress)

  • ethertype (str) – The ethertype to enforce (IPv4 or IPv6)

  • port_max (str) – The upper port bound to enforce

  • port_min (str) – The lower port bound to enforce

  • protocol (str) – The protocol to enforce (icmp, udp, tcp)

get_cancel_failure_reasons(identifier)[source]

get the reasons why we cannot cancel the VLAN.

Parameters:

identifier (integer) – the instance ID

get_closed_pods()[source]

Calls SoftLayer_Network_Pod::getAllObjects()

returns list of all closing network pods.

get_datacenter(_filter=None, datacenter=None)[source]

Calls SoftLayer_Location::getDatacenters()

returns datacenter list.

get_datacenter_by_keyname(keyname=None)[source]

Calls SoftLayer_Location::getDatacenters()

returns datacenter list.

get_event_logs_by_request_id(request_id)[source]

Gets all event logs by the given request id

Parameters:

request_id (string) – The request id we want to filter on

get_ip_by_address(ip_address)[source]

get the ip address object

Parameters:

ip_address (string) – the ip address to edit.

get_list_datacenter()[source]

Calls SoftLayer_Location::getDatacenters()

returns all datacenter locations.

get_nas_credentials(identifier, **kwargs)[source]

Returns a list of IDs of VLANs which match the given VLAN name.

Parameters:

instance_id (integer) – the instance ID

Returns:

A dictionary containing a large amount of information about the specified instance.

get_pods(datacenter=None, mask=None)[source]

Calls SoftLayer_Network_Pod::getAllObjects()

returns list of all network pods and their routers.

get_routers(identifier)[source]

Calls SoftLayer_Location::getRouters()

returns all routers locations.

get_securitygroup(group_id, **kwargs)[source]

Returns the information about the given security group.

Parameters:

id (string) – The ID for the security group

Returns:

A diction of information about the security group

get_subnet(subnet_id, **kwargs)[source]

Returns information about a single subnet.

Parameters:

id (string) – Either the ID for the subnet or its network identifier

Returns:

A dictionary of information about the subnet

static get_subnet_item_price(item, subnet_type, version)[source]

Get the subnet specific item price id.

Parameters:
  • version – 4 for IPv4, 6 for IPv6.

  • subnet_type – Type of subnet to add: private, public, global,static.

  • item – Subnet item.

get_vlan(vlan_id, mask=None)[source]

Returns information about a single VLAN.

Parameters:
  • vlan_id (int) – The unique identifier for the VLAN

  • mask (string) – mask for request

Returns:

A dictionary containing a large amount of information about the specified VLAN.

ip_lookup(ip_address)[source]

Looks up an IP address and returns network information about it.

Parameters:

ip_address (string) – An IP address. Can be IPv4 or IPv6

Returns:

A dictionary of information about the IP

list_global_ips(version=None, identifier=None, **kwargs)[source]

Returns a list of all global IP address records on the account.

Parameters:
  • version (int) – Only returns IPs of this version (4 or 6)

  • identifier (string) – If specified, the list will only contain the global ips matching this network identifier.

list_securitygroup_rules(group_id)[source]

List security group rules associated with a security group.

Parameters:

group_id (int) – The security group to list rules for

list_securitygroups(**kwargs)[source]

List security groups.

list_subnets(identifier=None, datacenter=None, version=0, subnet_type=None, network_space=None, **kwargs)[source]

Display a list of all subnets on the account.

This provides a quick overview of all subnets including information about data center residence and the number of devices attached.

Parameters:
  • identifier (string) – If specified, the list will only contain the subnet matching this network identifier.

  • datacenter (string) – If specified, the list will only contain subnets in the specified data center.

  • version (int) – Only returns subnets of this version (4 or 6).

  • subnet_type (string) – If specified, it will only returns subnets of this type.

  • network_space (string) – If specified, it will only returns subnets with the given address space label.

  • **kwargs (dict) – response-level options (mask, limit, etc.)

list_vlans(datacenter=None, vlan_number=None, name=None, limit=100, mask=None, _filter=None)[source]

Display a list of all VLANs on the account.

This provides a quick overview of all VLANs including information about data center residence and the number of devices attached.

Parameters:
  • datacenter (string) – If specified, the list will only contain VLANs in the specified data center.

  • vlan_number (int) – If specified, the list will only contain the VLAN matching this VLAN number.

  • name (int) – If specified, the list will only contain the VLAN matching this VLAN name.

  • **kwargs (dict) – response-level options (mask, limit, etc.)

remove_securitygroup_rule(group_id, rule_id)[source]

Remove a rule from a security group.

Parameters:
  • group_id (int) – The ID of the security group

  • rule_id (int) – The ID of the rule to remove

remove_securitygroup_rules(group_id, rules)[source]

Remove rules from a security group.

Parameters:
  • group_id (int) – The ID of the security group

  • rules (list) – The list of IDs to remove

resolve_global_ip_ids(identifier)[source]

Resolve global ip ids.

resolve_subnet_ids(identifier)[source]

Resolve subnet ids.

resolve_vlan_ids(identifier)[source]

Resolve VLAN ids.

route(subnet_id, type_serv, target)[source]

Assigns a subnet to a specified target.

https://sldn.softlayer.com/reference/services/SoftLayer_Network_Subnet/route/ :param int subnet_id: The ID of the SoftLayer_Network_Subnet_IpAddress being routed :param string type_serv: The type service to assign :param string target: The instance to assign

search_for_vlan(vlan)[source]

Returns a list of matching VLAN objects.

Parameters:

vlan (string) – Could be either vlan name, number, id, or fully qualified name

Return list:

List of SoftLayer_Network_Vlan objects

set_subnet_ipddress_note(identifier, note)[source]

Set the ip address note of the subnet

Parameters:

identifier (integer) – the ip address ID to edit. :param json note: the note to edit.

set_tags(tags, vlan_id)[source]

Sets tags on a vlan with a retry decorator

Just calls vlan.setTags, but if it fails from an APIError will retry.

set_tags_subnet(subnet_id, tags)[source]

Tag a subnet by passing in one or more tags separated by a comma.

Parameters:
  • subnet_id (int) – The ID of the subnet.

  • tags (string) – Comma separated list of tags.

summary_by_datacenter()[source]

Summary of the networks on the account, grouped by data center.

The resultant dictionary is primarily useful for statistical purposes. It contains count information rather than raw data. If you want raw information, see the list_vlans() method instead.

Returns:

A dictionary keyed by data center with the data containing a set of counts for subnets, hardware, virtual servers, and other objects residing within that data center.

unassign_global_ip(global_ip_id)[source]

Unassigns a global IP address from a target.

Parameters:

id (int) – The ID of the global IP being unassigned