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:
- 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
- generate_template_context(skip=None)[source]¶
Build a Jinja2 template context dict for this 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:
- 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()orset_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:
- 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:
- Raises:
Exception – if the network is not found
- Returns:
the particular network service
- Return type:
- 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:
- 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:
- 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:
- Returns:
a particular network service
- Return type:
- 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:
- 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_slice()[source]¶
Gets the fablib slice this network service is built on.
- Returns:
the slice this network is on
- Return type:
- 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()orset_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.
- 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:
- Tyep type:
str
- Returns:
the new L2 network service
- Return type:
- 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_directioncan be"rx","tx"or"both"(non-case-sensitive)- Return type:
- 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
- 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_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.
- class fabrictestbed_extensions.fablib.network_service.NetworkService(slice=None, fim_network_service=None, name=None)[source]
Note
Not inteded for API use.
- Parameters:
- __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
- 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:
- 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()orset_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:
- 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:
- Raises:
Exception – if the network is not found
- Returns:
the particular network service
- Return type:
- 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:
- 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:
- 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:
- Returns:
a particular network service
- Return type:
- 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:
- 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_slice()[source]
Gets the fablib slice this network service is built on.
- Returns:
the slice this network is on
- Return type:
- 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()orset_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.
- init_fablib_data()[source]
Initialize fablib data.
- is_instantiated()[source]
Return
Trueif 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:
- Tyep type:
str
- Returns:
the new L2 network service
- Return type:
- 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_directioncan be"rx","tx"or"both"(non-case-sensitive)- Return type:
- 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
- set_allocated_ip(addr=None)[source]
Add
addrto 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.
- 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