diff --git a/examples/demos/stitching-chameleon-cloudlab-via-fabric/config.fab b/examples/demos/stitching-chameleon-cloudlab-via-fabric/config.fab new file mode 100644 index 00000000..58171e73 --- /dev/null +++ b/examples/demos/stitching-chameleon-cloudlab-via-fabric/config.fab @@ -0,0 +1,51 @@ +provider: + - cloudlab: + - cloudlab_provider: + credential_file: ~/.fabfed/fabfed_credentials.yml + profile: cloudlab + - fabric: + - fabric_provider: + credential_file: ~/.fabfed/fabfed_credentials.yml + profile: fabric + - chi: + - chi_provider: + credential_file: ~/.fabfed/fabfed_credentials.yml + profile: chi + +config: + - layer3: + - my_layer: + subnet: 192.168.1.0/24 + gateway: 192.168.1.1 + ip_start: 192.168.1.2 + ip_end: 192.168.1.254 +resource: + - network: + - cnet: + provider: '{{cloudlab.cloudlab_provider }}' + layer3: "{{ layer3.my_layer }}" + - fabric_network: + provider: '{{ fabric.fabric_provider }}' + layer3: "{{ layer3.my_layer }}" + stitch_with: + - network: '{{ network.chi_network }}' + stitch_option: + site: TACC + - network: '{{ network.cnet }}' + stitch_option: + site: UTAH + - chi_network: + provider: '{{ chi.chi_provider }}' + name: stitch_net + layer3: "{{ layer3.my_layer }}" + - node: + - cloudlab_node: + provider: '{{ cloudlab.cloudlab_provider }}' + network: "{{ network.cnet }}" + count: 1 + - chi_node: + provider: '{{ chi.chi_provider }}' + image: CC-Ubuntu20.04 + network: '{{ network.chi_network }}' + flavor: m1.medium + count: 1 diff --git a/fabfed/controller/helper.py b/fabfed/controller/helper.py index 0441d367..97e80175 100644 --- a/fabfed/controller/helper.py +++ b/fabfed/controller/helper.py @@ -66,14 +66,15 @@ def partition_layer3_config(*, networks: list): dhcp_start = dhcp_end + 1 -def find_peer_network(*, network): +def find_peer_networks(*, network): dependencies = network.dependencies + peer_networks = [] for ed in dependencies: if ed.key == Constants.RES_STITCH_INTERFACE: - return ed.resource + peer_networks.append(ed.resource) - return None + return peer_networks def find_nodes_related_to_network(*, network, resources): @@ -99,29 +100,33 @@ def find_node_clusters(*, resources): for net in networks: if net.label not in visited_networks: - peer = find_peer_network(network=net) + peers = find_peer_networks(network=net) - if peer: + if peers: + cluster = [] visited_networks.append(net.label) nodes = find_nodes_related_to_network(network=net, resources=resources) - visited_networks.append(peer.label) - nodes.extend(find_nodes_related_to_network(network=peer, resources=resources)) visited_nodes.extend([n.label for n in nodes]) + cluster.extend(nodes) - if nodes: - clusters.append(nodes) + for peer in peers: + visited_networks.append(peer.label) + nodes = find_nodes_related_to_network(network=peer, resources=resources) + visited_nodes.extend([n.label for n in nodes]) + + if nodes: + cluster.extend(nodes) + + if cluster: + clusters.append(cluster) for net in networks: if net.label not in visited_networks: - peer = find_peer_network(network=net) + nodes = find_nodes_related_to_network(network=net, resources=resources) - if not peer: - visited_networks.append(net.label) - nodes = find_nodes_related_to_network(network=net, resources=resources) + if nodes: visited_nodes.extend([n.label for n in nodes]) - - if nodes: - clusters.append(nodes) + clusters.append(nodes) nodes = [r for r in resources if r.is_node] diff --git a/fabfed/provider/fabric/fabric_network.py b/fabfed/provider/fabric/fabric_network.py index dc73a5c7..2e263bb2 100644 --- a/fabfed/provider/fabric/fabric_network.py +++ b/fabfed/provider/fabric/fabric_network.py @@ -113,7 +113,7 @@ def __init__(self, label, provider: FabricProvider, slice_object: Slice, name, r logger.info(f'Network {self.net_name} found interface {interface}') self.vlan = interface.get('vlan') - if self.stitch_port: + if isinstance(self.stitch_port, dict): self.device = self.stitch_port.get(Constants.STITCH_PORT_DEVICE_NAME) self.site = self.stitch_port.get(Constants.STITCH_PORT_SITE)