Skip to content

Commit

Permalink
Github checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kthare10 committed May 29, 2024
1 parent 6488b7f commit 9d03fce
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 87 deletions.
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
72 changes: 52 additions & 20 deletions fabrictestbed_extensions/fablib/fablib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,12 @@ def list_sites(
"""
return self.get_resources(
update=update, force_refresh=force_refresh, start=start, end=end, avoid=avoid, includes=includes
update=update,
force_refresh=force_refresh,
start=start,
end=end,
avoid=avoid,
includes=includes,
).list_sites(
output=output,
fields=fields,
Expand Down Expand Up @@ -1364,11 +1369,13 @@ def get_facility_ports(self, update: bool = True) -> FacilityPorts:
return self.facility_ports

def get_resources(
self, update: bool = True, force_refresh: bool = False,
start: datetime = None,
end: datetime = None,
avoid: List[str] = None,
includes: List[str] = None
self,
update: bool = True,
force_refresh: bool = False,
start: datetime = None,
end: datetime = None,
avoid: List[str] = None,
includes: List[str] = None,
) -> Resources:
"""
Get a reference to the resources object. The resources object
Expand Down Expand Up @@ -1396,8 +1403,14 @@ def get_resources(
:rtype: Resources
"""
if not self.resources:
self.get_available_resources(update=update, force_refresh=force_refresh,
start=start, end=end, avoid=avoid, includes=includes)
self.get_available_resources(
update=update,
force_refresh=force_refresh,
start=start,
end=end,
avoid=avoid,
includes=includes,
)

return self.resources

Expand Down Expand Up @@ -1602,11 +1615,13 @@ def get_site_advertisement(self, site: str) -> FimNode:
return topology.sites[site]

def get_available_resources(
self, update: bool = False, force_refresh: bool = False,
self,
update: bool = False,
force_refresh: bool = False,
start: datetime = None,
end: datetime = None,
avoid: List[str] = None,
includes: List[str] = None
includes: List[str] = None,
) -> Resources:
"""
Get the available resources.
Expand Down Expand Up @@ -1638,11 +1653,22 @@ def get_available_resources(
from fabrictestbed_extensions.fablib.resources import Resources

if self.resources is None:
self.resources = Resources(self, force_refresh=force_refresh,
start=start, end=end, avoid=avoid, includes=includes)
self.resources = Resources(
self,
force_refresh=force_refresh,
start=start,
end=end,
avoid=avoid,
includes=includes,
)
elif update:
self.resources.update(force_refresh=force_refresh,
start=start, end=end, avoid=avoid, includes=includes)
self.resources.update(
force_refresh=force_refresh,
start=start,
end=end,
avoid=avoid,
includes=includes,
)

return self.resources

Expand Down Expand Up @@ -2268,7 +2294,10 @@ def __can_allocate_node_in_worker(
:rtype: Tuple[bool, str]
"""
if worker is None or site is None:
return True, f"Ignoring validation: Worker: {worker}, Site: {site} not available."
return (
True,
f"Ignoring validation: Worker: {worker}, Site: {site} not available.",
)

msg = f"Node can be allocated on the host: {worker.name}."

Expand Down Expand Up @@ -2359,8 +2388,13 @@ def validate_node(self, node: Node, allocated: dict = None) -> Tuple[bool, str]:
site = self.get_resources().get_topology_site(site_name=node.get_site())

if not site:
logging.warning(f"Ignoring validation: Site: {node.get_site()} not available in resources.")
return True, f"Ignoring validation: Site: {node.get_site()} not available in resources."
logging.warning(
f"Ignoring validation: Site: {node.get_site()} not available in resources."
)
return (
True,
f"Ignoring validation: Site: {node.get_site()} not available in resources.",
)

site_maint_info = site.maintenance_info.get(site.name)
if site_maint_info and str(site_maint_info.state) != "Active":
Expand All @@ -2369,9 +2403,7 @@ def validate_node(self, node: Node, allocated: dict = None) -> Tuple[bool, str]:
return False, msg
workers = self.get_resources().get_nodes(site=site)
if not workers:
msg = (
f"Node cannot be validated, host information not available for {site}."
)
msg = f"Node cannot be validated, host information not available for {site}."
logging.error(msg)
return False, msg

Expand Down
8 changes: 5 additions & 3 deletions fabrictestbed_extensions/fablib/facility_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,17 @@ def new_facility_port(
site: str = None,
vlan: Union[List, str] = None,
bandwidth: int = 10,
labels: Labels = None, peer_labels: Labels = None, capacities: Capacities = None
labels: Labels = None,
peer_labels: Labels = None,
capacities: Capacities = None,
):
if capacities is None:
if not bandwidth:
bandwidth = 10
capacities = Capacities(bw=bandwidth)

interfaces = None

if vlan:
index = 1
interfaces = []
Expand All @@ -172,7 +174,7 @@ def new_facility_port(
capacities=capacities,
labels=labels,
peer_labels=peer_labels,
interfaces=interfaces
interfaces=interfaces,
)
return FacilityPort(slice, fim_facility_port)

Expand Down
14 changes: 7 additions & 7 deletions fabrictestbed_extensions/fablib/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def __init__(self, fablib_manager):
self.fablib_manager = fablib_manager

def list_metrics(
self,
output=None,
fields=None,
quiet=False,
filter_function=None,
pretty_names=True
self,
output=None,
fields=None,
quiet=False,
filter_function=None,
pretty_names=True,
):
table = []
metric_dict = self.metrics_to_dict()
Expand Down Expand Up @@ -81,4 +81,4 @@ def metrics_to_dict(self):
if not latlon:
d.pop("location")

return d
return d
21 changes: 16 additions & 5 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, Capacities
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,7 +336,7 @@ def new_l3network(
interfaces: List[Interface] = [],
type: str = None,
user_data={},
technology: str = None
technology: str = None,
):
"""
Not inteded for API use. See slice.add_l3network
Expand Down Expand Up @@ -444,7 +444,7 @@ def new_network_service(
nstype: ServiceType = None,
interfaces: List[Interface] = [],
user_data: dict = {},
technology: str = None
technology: str = None,
):
"""
Not intended for API use. See slice.add_l2network
Expand Down Expand Up @@ -1282,7 +1282,13 @@ def config(self):
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):
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
Expand All @@ -1300,4 +1306,9 @@ def peer(self, other: NetworkService, labels: Labels, peer_labels: Labels, capac
"""
# Peer Cloud L3VPN with FABRIC L3VPN
self.get_fim().peer(other.get_fim(), labels=labels, peer_labels=peer_labels, capacities=capacities)
self.get_fim().peer(
other.get_fim(),
labels=labels,
peer_labels=peer_labels,
capacities=capacities,
)
6 changes: 5 additions & 1 deletion fabrictestbed_extensions/fablib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ class Node:
default_image = "default_rocky_8"

def __init__(
self, slice: Slice, node: FimNode, validate: bool = False, raise_exception: bool = False
self,
slice: Slice,
node: FimNode,
validate: bool = False,
raise_exception: bool = False,
):
"""
Node constructor, usually invoked by ``Slice.add_node()``.
Expand Down
Loading

0 comments on commit 9d03fce

Please sign in to comment.