Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…bed-extensions into rel1.7
  • Loading branch information
kthare10 committed May 30, 2024
2 parents 5f09fab + e7e51cf commit 545e494
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 104 deletions.
42 changes: 26 additions & 16 deletions fabrictestbed_extensions/fablib/facility_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,31 +141,41 @@ def new_facility_port(
slice: Slice = None,
name: str = None,
site: str = None,
vlan: Union[str, list] = None,
vlan: Union[List, str] = None,
bandwidth: int = 10,
labels: Labels = None,
peer_labels: Labels = None,
capacities: Capacities = None,
):
if isinstance(vlan, list):
interfaces = []
if capacities is None:
if not bandwidth:
bandwidth = 10
capacities = Capacities(bw=bandwidth)

interfaces = None

if vlan:
index = 1
interfaces = []
if isinstance(vlan, str):
vlan = [vlan]

for v in vlan:
iface_tuple = (
f"iface-{index}",
Labels(vlan=v),
Capacities(bw=bandwidth),
capacities,
)
interfaces.append(iface_tuple)
fim_facility_port = slice.get_fim_topology().add_facility(
name=name,
site=site,
interfaces=interfaces,
)
else:
fim_facility_port = slice.get_fim_topology().add_facility(
name=name,
site=site,
capacities=Capacities(bw=bandwidth),
labels=Labels(vlan=vlan),
)

fim_facility_port = slice.get_fim_topology().add_facility(
name=name,
site=site,
capacities=capacities,
labels=labels,
peer_labels=peer_labels,
interfaces=interfaces,
)
return FacilityPort(slice, fim_facility_port)

@staticmethod
Expand Down
84 changes: 0 additions & 84 deletions fabrictestbed_extensions/fablib/metrics.py

This file was deleted.

41 changes: 39 additions & 2 deletions fabrictestbed_extensions/fablib/network_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network

import jinja2
from fabrictestbed.slice_editor import Labels
from fabrictestbed.slice_editor import Capacities, Labels
from fabrictestbed.slice_editor import NetworkService as FimNetworkService
from fabrictestbed.slice_editor import ServiceType, UserData
from fim.slivers.network_service import NSLayer, ServiceType
Expand Down Expand Up @@ -340,6 +340,7 @@ def new_l3network(
interfaces: List[Interface] = [],
type: str = None,
user_data={},
technology: str = None,
):
"""
Not inteded for API use. See slice.add_l3network
Expand Down Expand Up @@ -369,6 +370,7 @@ def new_l3network(
nstype=nstype,
interfaces=interfaces,
user_data=user_data,
technology=technology,
)

@staticmethod
Expand Down Expand Up @@ -446,6 +448,7 @@ def new_network_service(
nstype: ServiceType = None,
interfaces: List[Interface] = [],
user_data: dict = {},
technology: str = None,
):
"""
Not intended for API use. See slice.add_l2network
Expand All @@ -460,6 +463,9 @@ def new_network_service(
:param nstype: the type of network service to create
:type nstype: ServiceType
:param interfaces: a list of interfaces to
:type interfaces: List
:param technology: Specify the technology used should be set to AL2S when using for AL2S peering; otherwise None
:type technology: str
:return: the new fablib network service
:rtype: NetworkService
"""
Expand All @@ -471,7 +477,7 @@ def new_network_service(
f"Create Network Service: Slice: {slice.get_name()}, Network Name: {name}, Type: {nstype}"
)
fim_network_service = slice.topology.add_network_service(
name=name, nstype=nstype, interfaces=fim_interfaces
name=name, nstype=nstype, interfaces=fim_interfaces, technology=technology
)

network_service = NetworkService(
Expand Down Expand Up @@ -1279,3 +1285,34 @@ def config(self):
if self.get_gateway() not in allocated_ips:
allocated_ips.append(self.get_gateway())
self.set_allocated_ip(self.get_gateway())

def peer(
self,
other: NetworkService,
labels: Labels,
peer_labels: Labels,
capacities: Capacities,
):
"""
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
:param other: network service to be peered
:type other: NetworkService
:param labels: labels
:type labels: Labels
:param peer_labels: peer labels
:type peer_labels: Labels
:param capacities: capacities
:type capacities: Capacities
"""
# Peer Cloud L3VPN with FABRIC L3VPN
self.get_fim().peer(
other.get_fim(),
labels=labels,
peer_labels=peer_labels,
capacities=capacities,
)
27 changes: 25 additions & 2 deletions fabrictestbed_extensions/fablib/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
from typing import TYPE_CHECKING, Tuple

import pandas as pd
from fim.user import Capacities, Labels
from fss_utils.sshkey import FABRICSSHKey
from IPython.core.display_functions import display

Expand Down Expand Up @@ -1001,6 +1002,7 @@ def add_l3network(
interfaces: List[Interface] = [],
type: str = "IPv4",
user_data: dict = {},
technology: str = None,
) -> NetworkService:
"""
Adds a new L3 network service to this slice.
Expand Down Expand Up @@ -1042,6 +1044,8 @@ def add_l3network(
:type type: String
:param user_data
:type user_data: dict
:param technology: Specify the technology used should be set to AL2S when using for AL2S peering; otherwise None
:type technology: str
:return: a new L3 network service
:rtype: NetworkService
Expand All @@ -1055,10 +1059,17 @@ def add_l3network(
interfaces=interfaces,
type=type,
user_data=user_data,
technology=technology,
)

def add_facility_port(
self, name: str = None, site: str = None, vlan: Union[str, list] = None
self,
name: str = None,
site: str = None,
vlan: Union[str, list] = None,
labels: Labels = None,
peer_labels: Labels = None,
capacities: Capacities = None,
) -> NetworkService:
"""
Adds a new L2 facility port to this slice
Expand All @@ -1069,11 +1080,23 @@ def add_facility_port(
:type site: String
:param vlan: vlan
:type vlan: String
:param labels: labels for the facility port such as VLAN, ip sub net
:type: labels: Labels
:param peer_labels: peer labels for the facility port such as VLAN, ip sub net, bgp key - used for AL2S Peering
:type: peer_labels: Labels
:param capacities: capacities for the facility port such as bandwidth
:type: capacities: Capacities
:return: a new L2 facility port
:rtype: NetworkService
"""
return FacilityPort.new_facility_port(
slice=self, name=name, site=site, vlan=vlan
slice=self,
name=name,
site=site,
vlan=vlan,
labels=labels,
peer_labels=peer_labels,
capacities=capacities,
)

def add_node(
Expand Down

0 comments on commit 545e494

Please sign in to comment.