def create_topo_config(self, network_graph): """Return topo object and a simple stack config generated from network_graph""" host_links = {} host_vlans = {} dp_options = {} host_n = 0 for dp_i in network_graph.nodes(): for _ in range(self.NUM_HOSTS): for v_i in range(self.NUM_VLANS): host_links[host_n] = [dp_i] host_vlans[host_n] = v_i host_n += 1 dp_options[dp_i] = {'hardware': 'GenericTFM'} if dp_i == 0: dp_options[dp_i]['stack'] = {'priority': 1} switch_links = list( network_graph.edges()) * self.SWITCH_TO_SWITCH_LINKS link_vlans = {link: None for link in switch_links} topo = FaucetFakeOFTopoGenerator('ovstype', 'portsock', 'testname', host_links, host_vlans, switch_links, link_vlans, start_port=self.START_PORT, port_order=self.PORT_ORDER, get_serialno=self.get_serialno) config = topo.get_config(self.NUM_VLANS, dp_options=dp_options) return topo, config
def create_config(network_graph, stack=True): """Return topo object and a simple stack config generated from network_graph""" host_links = {} host_vlans = {} dp_options = {} host_n = 0 for dp_i in network_graph.nodes(): for _ in range(num_hosts): for v_i in range(num_vlans): host_links[host_n] = [dp_i] host_vlans[host_n] = v_i host_n += 1 dp_options[dp_i] = {'hardware': 'GenericTFM'} if dp_i == 0 and stack: dp_options[dp_i]['stack'] = {'priority': 1} switch_links = list(network_graph.edges()) * 2 if stack: link_vlans = {link: None for link in switch_links} else: link_vlans = {link: list(range(num_vlans)) for link in switch_links} topo = FaucetFakeOFTopoGenerator( 'ovstype', 'portsock', 'testname', len(network_graph.nodes()), False, host_links, host_vlans, switch_links, link_vlans, start_port=1, port_order=[0, 1, 2, 3], get_serialno=get_serialno) config = topo.get_config(num_vlans, dp_options=dp_options) return config
def create_topo_config(self, network_graph): """Return topo object and a simple stack config generated from network_graph""" host_links = {} host_vlans = {} dp_options = {} host_n = 0 for dp_i in network_graph.nodes(): for _ in range(self.NUM_HOSTS): a_vlans = random.randint(0, self.NUM_VLANS - 1) b_vlans = random.randint(0, self.NUM_VLANS - 1) min_vlans = min(a_vlans, b_vlans) max_vlans = max(a_vlans, b_vlans) is_tagged = random.choice([True, False]) if is_tagged: if min_vlans != max_vlans: vlans = list(range(min_vlans, max_vlans)) else: vlans = [min_vlans] host_links[host_n] = [dp_i] host_vlans[host_n] = vlans host_n += 1 else: for v_i in range(min_vlans, max_vlans): host_links[host_n] = [dp_i] host_vlans[host_n] = v_i host_n += 1 dp_options[dp_i] = {'hardware': 'GenericTFM'} if dp_i == 0: dp_options[dp_i]['stack'] = {'priority': 1} switch_links = list( network_graph.edges()) * self.SWITCH_TO_SWITCH_LINKS link_vlans = {link: None for link in switch_links} topo = FaucetFakeOFTopoGenerator('ovstype', 'portsock', 'testname', self.NUM_DPS, False, host_links, host_vlans, switch_links, link_vlans, start_port=self.START_PORT, port_order=self.PORT_ORDER, get_serialno=self.get_serialno) config = topo.get_config(self.NUM_VLANS, dp_options=dp_options) return topo, config