diff --git a/docs/source/index.rst b/docs/source/index.rst index 0ce3259e..45400a28 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -11,6 +11,8 @@ Welcome to fabrictestbed-extensions's documentation! :caption: Contents: +This is the tesxt to introduce you to FABlib! + Indices and tables ================== diff --git a/fabrictestbed_extensions/fablib/network_service.py b/fabrictestbed_extensions/fablib/network_service.py index d352ba1b..15da8f19 100644 --- a/fabrictestbed_extensions/fablib/network_service.py +++ b/fabrictestbed_extensions/fablib/network_service.py @@ -106,11 +106,12 @@ def calculate_l2_nstype(interfaces=None): rtn_nstype = None if len(sites) == 1: rtn_nstype = NetworkService.network_service_map['L2Bridge'] - elif basic_nic_count == 0 and len(sites) == 2 and len(interfaces) == 2: - #TODO: remove this when STS works on all links. - rtn_nstype = NetworkService.network_service_map['L2PTP'] - elif len(sites) == 2 and basic_nic_count == 2 and len(interfaces) == 2: - rtn_nstype = NetworkService.network_service_map['L2STS'] + #elif basic_nic_count == 0 and len(sites) == 2 and len(interfaces) == 2: + # #TODO: remove this when STS works on all links. + # rtn_nstype = NetworkService.network_service_map['L2PTP'] + elif len(sites) == 2: + if len(interfaces) >= 2: + rtn_nstype = NetworkService.network_service_map['L2STS'] else: raise Exception(f"Invalid Network Service: Networks are limited to 2 unique sites. Site requested: {sites}") @@ -131,9 +132,12 @@ def validate_nstype(type, interfaces): """ sites = set([]) nics = set([]) + nodes = set([]) for interface in interfaces: sites.add(interface.get_site()) nics.add(interface.get_model()) + nodes.add(interface.get_node()) + # models: 'NIC_Basic', 'NIC_ConnectX_6', 'NIC_ConnectX_5' if type == NetworkService.network_service_map['L2Bridge']: @@ -147,10 +151,25 @@ def validate_nstype(type, interfaces): raise Exception(f"Network type {type} does not support interfaces of type 'NIC_Basic'") elif type == NetworkService.network_service_map['L2STS']: - if not len(sites) == 2: - raise Exception(f"Network type {type} must include interfaces from exactly two sites. {len(sites)} sites requested: {sites}") + exception_list = [] + if len(sites) != 2: + exception_list.append(f"Network type {type} must include interfaces from exactly two sites. {len(sites)} sites requested: {sites}") + if len(interfaces) > 2: + hosts = set([]) + for interface in interfaces: + node = interface.get_node() + if interface.get_model() == 'NIC_Basic': + if node.get_host() == None: + exception_list.append(f"Network type {type} does not support multiple NIC_Basic interfaces on VMs residing on the same host. Please see Node.set_host(host_nane) to explicitily bind a nodes to a specific host. Node {node.get_name()} is unbound.") + elif node.get_host() in hosts: + exception_list.append(f"Network type {type} does not support multiple NIC_Basic interfaces on VMs residing on the same host. Please see Node.set_host(host_nane) to explicitily bind a nodes to a specific host. Multiple nodes bound to {node.get_host()}.") + else: + hosts.add(node.get_host()) + + if len(exception_list) > 0: + raise Exception(f"{exception_list}") else: - raise Exception(f"Invalid l2 network type: {type}. Please choose from {NetworkService.get_fim_l2network_service_types()} or None for automatic selection") + raise Exception(f"Unknown network type {type}") return True diff --git a/fabrictestbed_extensions/fablib/node.py b/fabrictestbed_extensions/fablib/node.py index dd19ccac..f0e975a0 100644 --- a/fabrictestbed_extensions/fablib/node.py +++ b/fabrictestbed_extensions/fablib/node.py @@ -241,6 +241,9 @@ def set_host(self, host_name=None): labels.instance_parent = host_name self.get_fim_node().set_properties(labels=labels) + #set an attribute used to get host before Submit + self.host = host_name + def get_slice(self): """ Gets the fablib slice associated with this node. @@ -330,6 +333,11 @@ def get_host(self): :rtype: str """ try: + try: + #If we set the host but have not yet submitted + return self.host + except: + pass return self.get_fim_node().get_property(pname='label_allocations').instance_parent except: return None diff --git a/fabrictestbed_extensions/fablib/slice.py b/fabrictestbed_extensions/fablib/slice.py index f3778ff1..bbe74216 100644 --- a/fabrictestbed_extensions/fablib/slice.py +++ b/fabrictestbed_extensions/fablib/slice.py @@ -537,7 +537,7 @@ def get_components(self): return_components.append(component) except Exception as e: - print("get_components: exception") + print(f"get_components: exception {e}") #traceback.print_exc() pass return return_components @@ -556,7 +556,7 @@ def get_network_services(self): return_networks.append(NetworkService(slice = self, fim_network_service = net)) except Exception as e: - print("get_network_services: exception") + print(f"get_network_services: exception {e}") #traceback.print_exc() pass return return_networks @@ -578,7 +578,7 @@ def get_nodes(self): for node_name, node in self.get_fim_topology().nodes.items(): return_nodes.append(Node.get_node(self, node)) except Exception as e: - print("get_nodes: exception") + print(f"get_nodes: exception {e}") #traceback.print_exc() pass return return_nodes