Skip to content

Commit

Permalink
black, isort, changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
kthare10 committed Jun 5, 2024
1 parent 1b8fec2 commit 6be6af9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# Unreleased

### Fixed
- ERO Support (Issue [#338](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/338))
- List hosts (Issue [#331](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/331))
- 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))
Expand Down
37 changes: 25 additions & 12 deletions fabrictestbed_extensions/fablib/network_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def get_fim_network_service_types() -> List[str]:
)

@staticmethod
def __calculate_l2_nstype(interfaces: List[Interface] = None, ero_enabled: bool = False) -> ServiceType:
def __calculate_l2_nstype(
interfaces: List[Interface] = None, ero_enabled: bool = False
) -> ServiceType:
"""
Not inteded for API use
Expand Down Expand Up @@ -170,9 +172,9 @@ def __calculate_l2_nstype(interfaces: List[Interface] = None, ero_enabled: bool
# L2PTP limitation for Facility Ports:
# basically the layer-2 point-to-point server template applied is not popping
# vlan tags over the MPLS tunnel between two facility ports.
if (((includes_facility_port and facility_port_interfaces < 2) or ero_enabled)
and not basic_nic_count
):
if (
(includes_facility_port and facility_port_interfaces < 2) or ero_enabled
) and not basic_nic_count:
# For now WAN FacilityPorts require L2PTP
rtn_nstype = NetworkService.network_service_map["L2PTP"]
elif len(interfaces) >= 2:
Expand Down Expand Up @@ -431,7 +433,9 @@ def new_l2network(
NetworkService.__validate_nstype(nstype, interfaces)

# Set default VLANs for P2P networks that did not pass in VLANs
if nstype == ServiceType.L2PTP and len(interfaces): # or nstype == ServiceType.L2STS:
if nstype == ServiceType.L2PTP and len(
interfaces
): # or nstype == ServiceType.L2STS:
vlan1 = interfaces[0].get_vlan()
vlan2 = interfaces[1].get_vlan()

Expand Down Expand Up @@ -1136,7 +1140,9 @@ def add_interface(self, interface: Interface):
curr_nstype = self.get_type()
if self.get_layer() == NSLayer.L2:
ero_enabled = True if self.get_fim().ero else False
new_nstype = NetworkService.__calculate_l2_nstype(interfaces=new_interfaces, ero_enabled=ero_enabled)
new_nstype = NetworkService.__calculate_l2_nstype(
interfaces=new_interfaces, ero_enabled=ero_enabled
)
if curr_nstype != new_nstype:
self.__replace_network_service(new_nstype)
else:
Expand Down Expand Up @@ -1179,7 +1185,9 @@ def remove_interface(self, interface: Interface):
curr_nstype = self.get_type()
if self.get_layer() == NSLayer.L2:
ero_enabled = True if self.get_fim().ero else False
new_nstype = NetworkService.__calculate_l2_nstype(interfaces=interfaces, ero_enabled=ero_enabled)
new_nstype = NetworkService.__calculate_l2_nstype(
interfaces=interfaces, ero_enabled=ero_enabled
)
if curr_nstype != new_nstype:
self.__replace_network_service(new_nstype)

Expand Down Expand Up @@ -1383,17 +1391,22 @@ def set_l2_route_hops(self, hops: List[str]):

interfaces = self.get_interfaces()

if len(interfaces) != 2 or self.get_type() not in [ServiceType.L2STS, ServiceType.L2PTP]:
raise Exception("Network path can only be specified for a Point to Point Layer2 connection!")
if len(interfaces) != 2 or self.get_type() not in [
ServiceType.L2STS,
ServiceType.L2PTP,
]:
raise Exception(
"Network path can only be specified for a Point to Point Layer2 connection!"
)

ifs_sites = []
for ifs in interfaces:
ifs_sites.append(ifs.get_site())

resources = self.get_fablib_manager().get_resources()
resources.validate_requested_ero_path(source=ifs_sites[0],
end=ifs_sites[1],
hops=hops)
resources.validate_requested_ero_path(
source=ifs_sites[0], end=ifs_sites[1], hops=hops
)
p = Path()
p.set_symmetric(hops)
e = ERO()
Expand Down
10 changes: 6 additions & 4 deletions fabrictestbed_extensions/fablib/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,11 +836,13 @@ def validate_requested_ero_path(self, source: str, end: str, hops: List[str]):
if not source_site or not end_site:
raise Exception(f"Source {source} or End: {end} is not found!")

path = self.get_fim().graph_model.get_nodes_on_path_with_hops(node_a=source_site.node_id,
node_z=end_site.node_id,
hops=hop_sites_node_ids)
path = self.get_fim().graph_model.get_nodes_on_path_with_hops(
node_a=source_site.node_id, node_z=end_site.node_id, hops=hop_sites_node_ids
)
if not path or not len(path):
raise Exception(f"Requested path via {hops} between {source} and {end} is invalid!")
raise Exception(
f"Requested path via {hops} between {source} and {end} is invalid!"
)


class Links(Resources):
Expand Down
1 change: 1 addition & 0 deletions fabrictestbed_extensions/fablib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ def __load_hosts(self):
"""
try:
from fim.user import NodeType

for c_name, child in self.site.children.items():
if child.type == NodeType.Server:
self.hosts[child.name] = Host(
Expand Down

0 comments on commit 6be6af9

Please sign in to comment.