Skip to content

Commit

Permalink
test sts for hairpin avoidance
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-ruth committed Mar 26, 2022
1 parent d2f4350 commit 9b6ba01
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docs/source/index.rst
Expand Up @@ -11,6 +11,8 @@ Welcome to fabrictestbed-extensions's documentation!
:caption: Contents:


This is the tesxt to introduce you to FABlib!


Indices and tables
==================
Expand Down
35 changes: 27 additions & 8 deletions fabrictestbed_extensions/fablib/network_service.py
Expand Up @@ -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}")

Expand All @@ -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']:
Expand All @@ -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

Expand Down
8 changes: 8 additions & 0 deletions fabrictestbed_extensions/fablib/node.py
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions fabrictestbed_extensions/fablib/slice.py
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9b6ba01

Please sign in to comment.