network_service

Methods to work with FABRIC network services.

class fabrictestbed_extensions.fablib.network_service.NetworkService(slice=None, fim_network_service=None, name=None)[source]

Note

Not inteded for API use.

Parameters:
  • slice (Slice) – the fablib slice to set as instance state

  • fim_network_service (FimNetworkService) – the FIM network service to set as instance state

  • name (str) – the name of the network service

add_interface(interface)[source]

Add an Interface to the network service.

allocate_ip(addr=None)[source]

Allocate an IP for the network service.

config()[source]

Sets up the meta data for the Network Service

  • For layer3 services, Subnet, gateway and allocated IPs are updated/maintained fablib_data saved in UserData blob in the FIM model

  • For layer2 services, no action is taken

delete()[source]

Delete the network service.

free_ip(addr)[source]

Remove an IP from the list of allocated IPs.

generate_template_context(skip=None)[source]

Build a Jinja2 template context dict for this network service.

get_allocated_ips()[source]

Get the list of IP addesses allocated for the network service.

get_available_ips(count=256)[source]

Gets the IPs available for a FABnet L3 network

Note: large IPv6 address spaces take considerable time to build this list. By default this will return the first 256 addresses. If you needed more addresses, set the count parameter.

Parameters:

count (int) – number of addresse to include

Returns:

gateway IP

Return type:

List[IPv4Address]

get_bandwidth()[source]

Get the bandwidth of the network service (L2PTP only).

Returns:

Bandwidth in Gbps

Return type:

int

get_fim()[source]

Gets the FABRIC information model (FIM) object.

Return type:

NetworkService

static get_fim_network_service_types()[source]

Not intended for API use. Returns a list of all FIM network service types.

Returns:

List of all FIM network service types.

Return type:

List[str]

get_gateway()[source]

Gets the assigned gateway for a FABnetv L3 IPv6 or IPv4 network.

Results are cached for performance. Cache is invalidated when set_gateway() or set_instantiated() is called.

Returns:

gateway IP

Return type:

IPv4Address or IPv6Network

get_interface(name=None, refresh=False, raise_exception=None)[source]

Gets a particular interface on this network service.

Parameters:
  • name (str) – the name of the interface to search for

  • refresh (bool) – force refresh from FIM

  • raise_exception (bool) – if True, raise ResourceNotFoundError when the interface is not found; if False, return None. When None (default), falls back to the global FablibManager.raise_on_not_found setting.

Returns:

the particular interface or None

Return type:

Optional[Interface]

Raises:

ResourceNotFoundError – if the interface is not found and raising is enabled

get_interfaces(refresh=False)[source]

Gets the interfaces on this network service.

Results are cached. Use refresh=True to force reload.

Parameters:

refresh (bool) – force refresh from FIM

Returns:

the interfaces on this network service

Return type:

List[Interfaces]

static get_l2network_service(slice=None, name=None)[source]

Not inteded for API use.

Gets a particular network service on a fablib slice.

Parameters:
  • slice (Slice) – the fablib slice from which to get the network service

  • name (str) – the name of the network service to get

Raises:

Exception – if the network is not found

Returns:

the particular network service

Return type:

NetworkService

static get_l2network_services(slice=None)[source]

Not inteded for API use.

Gets a list of L2 network services on a fablib slice.

Parameters:

slice (Slice) – the fablib slice from which to get the network services

Returns:

a list of network services on slice

Return type:

list[NetworkService]

static get_l3network_service(slice=None, name=None)[source]

Gets a particular L3 network service from this slice.

Parameters:
  • slice (Slice) – the fabric slice to build this network on

  • name (String) – Name network

Returns:

network services on this slice

Return type:

list[NetworkService]

static get_l3network_services(slice=None)[source]

Gets all L3 networks services in this slice

Returns:

List of all network services in this slice

Return type:

List[NetworkService]

get_layer()[source]

Gets the layer of the network services (L2 or L3).

Results are cached for performance.

Returns:

L2 or L3

Return type:

String

static get_network_service(slice=None, name=None)[source]

Gest a particular network service from this slice.

Parameters:
  • slice (Slice) – the fablib slice from which to get the network services

  • name (str) – the name of the network service to search for

Returns:

a particular network service

Return type:

NetworkService

static get_network_services(slice=None, output='list')[source]

Gets all network services (L2 and L3) in this slice

Returns:

Dict of all network services in this slice

Return type:

dict[str, NetworkService]

static get_pretty_name_dict()[source]

Return mappings from non-pretty names to pretty names.

Pretty names are used when rendering table headers.

get_public_ips()[source]

Get list of public IPs assigned to the FabNetv*Ext service

Returns:

List of Public IPs

Return type:

List[IPv4Address] or List[IPv6Address] or None

get_site()[source]

Gets site name on network service.

Return type:

Optional[str]

get_slice()[source]

Gets the fablib slice this network service is built on.

Returns:

the slice this network is on

Return type:

Slice

get_sliver()[source]

Gets the sliver.

Return type:

SliverDTO

get_subnet()[source]

Gets the assigned subnet for a FABnet L3 IPv6 or IPv4 network.

Results are cached for performance. Cache is invalidated when set_subnet() or set_instantiated() is called.

Returns:

subnet

Return type:

IPv4Network or IPv6Network

get_type()[source]

Gets the type of the network services.

Results are cached for performance.

Returns:

network service types

Return type:

String

has_interface(interface)[source]

Determines whether this network service has a particular interface.

Parameters:

interface (Interface) – the fablib interface to search for

Returns:

whether this network service has interface

Return type:

bool

init_fablib_data()[source]

Initialize fablib data.

is_instantiated()[source]

Return True if network service has been instantiated.

make_ip_publicly_routable(ipv6=None, ipv4=None)[source]

Mark a list of IPs as publicly routable.

static new_l2network(slice=None, name=None, interfaces=[], type=None, user_data={})[source]

Not inteded for API use. See slice.add_l2network

Creates a new L2 network service.

Parameters:
  • slice (Slice) – the fablib slice to build this network on

  • name (str) – the name of the new network

  • interfaces (list[Interface]) – a list of interfaces to build the network service on

  • type (str) – the type of network service to build (optional)

Tyep type:

str

Returns:

the new L2 network service

Return type:

NetworkService

static new_l3network(slice=None, name=None, interfaces=[], type=None, user_data={}, technology=None, subnet=None, site=None)[source]

Not inteded for API use. See slice.add_l3network

static new_portmirror_service(slice=None, name=None, mirror_interface_name=None, mirror_interface_vlan=None, receive_interface=None, mirror_direction='both')[source]

Instantiate a new PortMirror service.

mirror_direction can be "rx", "tx" or "both" (non-case-sensitive)

Return type:

NetworkService

peer(other, labels, peer_labels, capacities)[source]

Peer a network service; used for AL2S peering between FABRIC Networks and Cloud Networks Peer this network service to another. A few constraints are enforced like services being of the same type. Both services will have ServicePort interfaces facing each other over a link. It typically requires labels and capacities to put on the interface facing the other service

Parameters:
  • other (NetworkService) – network service to be peered

  • labels (Labels) – labels

  • peer_labels (Labels) – peer labels

  • capacities (Capacities) – capacities

remove_interface(interface)[source]

Remove an Interface from the network service.

set_allocated_ip(addr=None)[source]

Add addr to the list of allocated IPs.

set_allocated_ips(allocated_ips)[source]

Set a list of IPs to be “allocated IPs”.

set_bandwidth(bw)[source]

Set the bandwidth for an L2PTP Network Service.

This sets the bandwidth uniformly for the service and both connected interfaces.

Parameters:

bw (int) – Bandwidth in Gbps

set_gateway(gateway)[source]

Add gateway info to the network service.

set_instantiated(instantiated=True)[source]

Set instantiated flag in the fablib_data saved in UserData blob in the FIM model.

Parameters:

instantiated (bool) – flag indicating if the service has been instantiated or not

set_l2_route_hops(hops)[source]

Define the sequence of sites or hops to be used for a layer 2 connection.

Maps site names to corresponding layer 2 loopback IPs used in Explicit Route Options (ERO) in the Network Service configuration.

Parameters:

hops (List[str]) – A list of site names to be used as hops.

set_subnet(subnet)[source]

Add subnet info to the network service.

toDict(skip=None)[source]

Returns the network attributes as a dictionary.

Results are cached. Cache is invalidated when _invalidate_cache() is called.

Parameters:

skip (List[str]) – list of keys to skip

Returns:

network attributes as dictionary

Return type:

dict

update(fim_network_service=None)[source]

Update the network service with new FIM data.

Parameters:

fim_network_service (FimNetworkService) – The new FIM network service data

class fabrictestbed_extensions.fablib.network_service.NetworkService(slice=None, fim_network_service=None, name=None)[source]

Note

Not inteded for API use.

Parameters:
  • slice (Slice) – the fablib slice to set as instance state

  • fim_network_service (FimNetworkService) – the FIM network service to set as instance state

  • name (str) – the name of the network service

__str__()[source]

Creates a tabulated string describing the properties of the network service.

Intended for printing network service information.

Returns:

Tabulated string of network service information

Return type:

String

add_interface(interface)[source]

Add an Interface to the network service.

allocate_ip(addr=None)[source]

Allocate an IP for the network service.

config()[source]

Sets up the meta data for the Network Service

  • For layer3 services, Subnet, gateway and allocated IPs are updated/maintained fablib_data saved in UserData blob in the FIM model

  • For layer2 services, no action is taken

delete()[source]

Delete the network service.

free_ip(addr)[source]

Remove an IP from the list of allocated IPs.

generate_template_context(skip=None)[source]

Build a Jinja2 template context dict for this network service.

get_allocated_ips()[source]

Get the list of IP addesses allocated for the network service.

get_available_ips(count=256)[source]

Gets the IPs available for a FABnet L3 network

Note: large IPv6 address spaces take considerable time to build this list. By default this will return the first 256 addresses. If you needed more addresses, set the count parameter.

Parameters:

count (int) – number of addresse to include

Returns:

gateway IP

Return type:

List[IPv4Address]

get_bandwidth()[source]

Get the bandwidth of the network service (L2PTP only).

Returns:

Bandwidth in Gbps

Return type:

int

get_fim()[source]

Gets the FABRIC information model (FIM) object.

Return type:

NetworkService

static get_fim_network_service_types()[source]

Not intended for API use. Returns a list of all FIM network service types.

Returns:

List of all FIM network service types.

Return type:

List[str]

get_gateway()[source]

Gets the assigned gateway for a FABnetv L3 IPv6 or IPv4 network.

Results are cached for performance. Cache is invalidated when set_gateway() or set_instantiated() is called.

Returns:

gateway IP

Return type:

IPv4Address or IPv6Network

get_interface(name=None, refresh=False, raise_exception=None)[source]

Gets a particular interface on this network service.

Parameters:
  • name (str) – the name of the interface to search for

  • refresh (bool) – force refresh from FIM

  • raise_exception (bool) – if True, raise ResourceNotFoundError when the interface is not found; if False, return None. When None (default), falls back to the global FablibManager.raise_on_not_found setting.

Returns:

the particular interface or None

Return type:

Optional[Interface]

Raises:

ResourceNotFoundError – if the interface is not found and raising is enabled

get_interfaces(refresh=False)[source]

Gets the interfaces on this network service.

Results are cached. Use refresh=True to force reload.

Parameters:

refresh (bool) – force refresh from FIM

Returns:

the interfaces on this network service

Return type:

List[Interfaces]

static get_l2network_service(slice=None, name=None)[source]

Not inteded for API use.

Gets a particular network service on a fablib slice.

Parameters:
  • slice (Slice) – the fablib slice from which to get the network service

  • name (str) – the name of the network service to get

Raises:

Exception – if the network is not found

Returns:

the particular network service

Return type:

NetworkService

static get_l2network_services(slice=None)[source]

Not inteded for API use.

Gets a list of L2 network services on a fablib slice.

Parameters:

slice (Slice) – the fablib slice from which to get the network services

Returns:

a list of network services on slice

Return type:

list[NetworkService]

static get_l3network_service(slice=None, name=None)[source]

Gets a particular L3 network service from this slice.

Parameters:
  • slice (Slice) – the fabric slice to build this network on

  • name (String) – Name network

Returns:

network services on this slice

Return type:

list[NetworkService]

static get_l3network_services(slice=None)[source]

Gets all L3 networks services in this slice

Returns:

List of all network services in this slice

Return type:

List[NetworkService]

get_layer()[source]

Gets the layer of the network services (L2 or L3).

Results are cached for performance.

Returns:

L2 or L3

Return type:

String

static get_network_service(slice=None, name=None)[source]

Gest a particular network service from this slice.

Parameters:
  • slice (Slice) – the fablib slice from which to get the network services

  • name (str) – the name of the network service to search for

Returns:

a particular network service

Return type:

NetworkService

static get_network_services(slice=None, output='list')[source]

Gets all network services (L2 and L3) in this slice

Returns:

Dict of all network services in this slice

Return type:

dict[str, NetworkService]

static get_pretty_name_dict()[source]

Return mappings from non-pretty names to pretty names.

Pretty names are used when rendering table headers.

get_public_ips()[source]

Get list of public IPs assigned to the FabNetv*Ext service

Returns:

List of Public IPs

Return type:

List[IPv4Address] or List[IPv6Address] or None

get_site()[source]

Gets site name on network service.

Return type:

Optional[str]

get_slice()[source]

Gets the fablib slice this network service is built on.

Returns:

the slice this network is on

Return type:

Slice

get_sliver()[source]

Gets the sliver.

Return type:

SliverDTO

get_subnet()[source]

Gets the assigned subnet for a FABnet L3 IPv6 or IPv4 network.

Results are cached for performance. Cache is invalidated when set_subnet() or set_instantiated() is called.

Returns:

subnet

Return type:

IPv4Network or IPv6Network

get_type()[source]

Gets the type of the network services.

Results are cached for performance.

Returns:

network service types

Return type:

String

has_interface(interface)[source]

Determines whether this network service has a particular interface.

Parameters:

interface (Interface) – the fablib interface to search for

Returns:

whether this network service has interface

Return type:

bool

init_fablib_data()[source]

Initialize fablib data.

is_instantiated()[source]

Return True if network service has been instantiated.

make_ip_publicly_routable(ipv6=None, ipv4=None)[source]

Mark a list of IPs as publicly routable.

static new_l2network(slice=None, name=None, interfaces=[], type=None, user_data={})[source]

Not inteded for API use. See slice.add_l2network

Creates a new L2 network service.

Parameters:
  • slice (Slice) – the fablib slice to build this network on

  • name (str) – the name of the new network

  • interfaces (list[Interface]) – a list of interfaces to build the network service on

  • type (str) – the type of network service to build (optional)

Tyep type:

str

Returns:

the new L2 network service

Return type:

NetworkService

static new_l3network(slice=None, name=None, interfaces=[], type=None, user_data={}, technology=None, subnet=None, site=None)[source]

Not inteded for API use. See slice.add_l3network

static new_portmirror_service(slice=None, name=None, mirror_interface_name=None, mirror_interface_vlan=None, receive_interface=None, mirror_direction='both')[source]

Instantiate a new PortMirror service.

mirror_direction can be "rx", "tx" or "both" (non-case-sensitive)

Return type:

NetworkService

peer(other, labels, peer_labels, capacities)[source]

Peer a network service; used for AL2S peering between FABRIC Networks and Cloud Networks Peer this network service to another. A few constraints are enforced like services being of the same type. Both services will have ServicePort interfaces facing each other over a link. It typically requires labels and capacities to put on the interface facing the other service

Parameters:
  • other (NetworkService) – network service to be peered

  • labels (Labels) – labels

  • peer_labels (Labels) – peer labels

  • capacities (Capacities) – capacities

remove_interface(interface)[source]

Remove an Interface from the network service.

set_allocated_ip(addr=None)[source]

Add addr to the list of allocated IPs.

set_allocated_ips(allocated_ips)[source]

Set a list of IPs to be “allocated IPs”.

set_bandwidth(bw)[source]

Set the bandwidth for an L2PTP Network Service.

This sets the bandwidth uniformly for the service and both connected interfaces.

Parameters:

bw (int) – Bandwidth in Gbps

set_gateway(gateway)[source]

Add gateway info to the network service.

set_instantiated(instantiated=True)[source]

Set instantiated flag in the fablib_data saved in UserData blob in the FIM model.

Parameters:

instantiated (bool) – flag indicating if the service has been instantiated or not

set_l2_route_hops(hops)[source]

Define the sequence of sites or hops to be used for a layer 2 connection.

Maps site names to corresponding layer 2 loopback IPs used in Explicit Route Options (ERO) in the Network Service configuration.

Parameters:

hops (List[str]) – A list of site names to be used as hops.

set_subnet(subnet)[source]

Add subnet info to the network service.

toDict(skip=None)[source]

Returns the network attributes as a dictionary.

Results are cached. Cache is invalidated when _invalidate_cache() is called.

Parameters:

skip (List[str]) – list of keys to skip

Returns:

network attributes as dictionary

Return type:

dict

update(fim_network_service=None)[source]

Update the network service with new FIM data.

Parameters:

fim_network_service (FimNetworkService) – The new FIM network service data