network_service

Methods to work with FABRIC network services.

class fabrictestbed_extensions.fablib.network_service.NetworkService(slice: Slice = None, fim_network_service: FimNetworkService = None)

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

__str__()

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

static calculate_l2_nstype(interfaces: List[Interface] = None) ServiceType

Not inteded for API use

Determines the L2 network service type based on the number of interfaces inputted.

Parameters:

interfaces (list[Interface]) – a list of interfaces

Raises:

Exception – if no network service type is not appropriate for the number of interfaces

Returns:

the network service type

Return type:

ServiceType

get_available_ips(count: int = 256) List[IPv4Address]

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 – number of addresse to include

Returns:

gateway IP

Return type:

List[IPv4Address]

get_error_message() str

Gets the error messages

Returns:

network service types

Return type:

String

static get_fim_l2network_service_types() List[str]

Not inteded for API use

static get_fim_l3network_service_types() List[str]

Not inteded for API use

get_fim_network_service() NetworkService

Not recommended for most users.

Gets the FABRIC network service this instance represents.

Returns:

the FIM network service

Return type:

FIMNetworkService

static get_fim_network_service_types() List[str]

Not inteded for API use

static get_fim_special_service_types() List[str]

Not intended for API use

get_gateway() IPv4Address

Gets the assigend gateway for a FABnetv L3 IPv6 or IPv4 network

Returns:

gateway IP

Return type:

IPv4Address or IPv6Network

get_interface(name: str = None) Interface or None

Gets a particular interface on this network service.

Parameters:

name (str) – the name of the interface to search for

Returns:

the particular interface

Return type:

Interface

get_interfaces() List[Interface]

Gets the interfaces on this network service.

Returns:

the interfaces on this network service

Return type:

List[Interfaces]

static get_l2network_service(slice: Slice = None, name: str = None)

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: Slice = None) list

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: Slice = None, name: str = None)

Not inteded for API use.

static get_l3network_services(slice: Slice = None) list

Not intended for API use.

get_layer() str

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

Returns:

L2 or L3

Return type:

String

get_name() str

Gets the name of this network service.

Returns:

the name of this network service

Return type:

String

static get_network_service(slice: Slice = None, name: str = None)

Not inteded for API use.

static get_network_services(slice: Slice = None) list

Not inteded for API use.

get_public_ips() List[IPv4Address]

Get list of public IPs assigned to the FabNetv*Ext service :return: List of Public IPs :rtype: List[IPv4Address] or List[IPv6Address] or None

get_reservation_id() str

Gets the reservation id of the network

Returns:

reservation ID

Return type:

String

get_reservation_state() str

Gets the reservation state of the network

Returns:

reservation state

Return type:

String

get_slice() Slice

Gets the fablib slice this network service is built on.

Returns:

the slice this network is on

Return type:

Slice

get_subnet() IPv4Network

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

Returns:

gateway IP

Return type:

IPv4Network or IPv6Network

get_type()

Gets the type of the network services

Returns:

network service types

Return type:

String

has_interface(interface: Interface) bool

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

static new_l2network(slice: Slice = None, name: str = None, interfaces: List[Interface] = [], type: str = None, user_data: dict = {})

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 – the type of network service to build (optional)

Tyep type:

str

Returns:

the new L2 network service

Return type:

NetworkService

static new_l3network(slice: Slice = None, name: str = None, interfaces: List[Interface] = [], type: str = None, user_data={})

Not inteded for API use. See slice.add_l3network

static new_network_service(slice: Slice = None, name: str = None, nstype: ServiceType = None, interfaces: List[Interface] = [], user_data: dict = {})

Not intended for API use. See slice.add_l2network

Creates a new FABRIC network service and returns the fablib instance.

Parameters:
  • slice (Slice) – the fabric slice to build the network service with

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

  • nstype (ServiceType) – the type of network service to create

  • interfaces – a list of interfaces to

Returns:

the new fablib network service

Return type:

NetworkService

static new_portmirror_service(slice: Slice = None, name: str = None, mirror_interface_name: str = None, receive_interface: Interface or None = None, mirror_direction: str = 'both') NetworkService

Instantiate a new PortMirror service.

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

show(fields=None, output=None, quiet=False, colors=False, pretty_names=True)

Show a table containing the current network attributes.

There are several output options: “text”, “pandas”, and “json” that determine the format of the output that is returned and (optionally) displayed/printed.

output: ‘text’: string formatted with tabular

‘pandas’: pandas dataframe ‘json’: string in json format

fields: json output will include all available fields.

Example: fields=[‘Name’,’State’]

Parameters:
  • output (str) – output format

  • fields (List[str]) – list of fields to show

  • quiet (bool) – True to specify printing/display

  • colors (bool) – True to specify state colors for pandas output

Returns:

table in format specified by output parameter

Return type:

Object

toDict(skip=[])

Returns the network attributes as a dictionary

Returns:

network attributes as dictionary

Return type:

dict

toJson()

Returns the network attributes as a json string

Returns:

network attributes as json string

Return type:

str

static validate_nstype(type, interfaces)

Not intended for API use

Verifies the network service type against the number of interfaces.

Parameters:
  • type (ServiceType) – the network service type to check

  • interfaces (list[Interface]) – the list of interfaces to check

Raises:

Exception – if the network service type is invalid based on the number of interfaces

Returns:

true if the network service type is valid based on the number of interfaces

Return type:

bool