Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Al2s support #327

Merged
merged 8 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# Unreleased

### Fixed
- AL2S Support (Issue [#325](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/325))
- Deny infeasible slices (Issue [#326](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/326))
- Add display of switch port name to network service table listing (Issue [#152](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/152))
- Error *may* be inaccurate or wrong when I issue an invalid configuration. (Issue [#304](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/304))
- Add Facility Port to allow adding multiple interfaces (Issue [#289](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/289))
Expand Down
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 @@ -336,6 +336,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 @@ -365,6 +366,7 @@ def new_l3network(
nstype=nstype,
interfaces=interfaces,
user_data=user_data,
technology=technology,
)

@staticmethod
Expand Down Expand Up @@ -442,6 +444,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 @@ -456,6 +459,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 @@ -467,7 +473,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 @@ -1275,3 +1281,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
Loading