def build(self, ovs_type, ports_sock, test_name, dpids, n_tagged=0, tagged_vid=100, n_untagged=0, links_per_host=0, n_extended=0, e_cls=None, tmpdir=None, hw_dpid=None, host_namespace=None): if not host_namespace: host_namespace = {} for dpid in dpids: serialno = mininet_test_util.get_serialno( ports_sock, test_name) sid_prefix = self._get_sid_prefix(serialno) for host_n in range(n_tagged): self._add_tagged_host(sid_prefix, tagged_vid, host_n) for host_n in range(n_untagged): self._add_untagged_host(sid_prefix, host_n, host_namespace.get(host_n, True)) for host_n in range(n_extended): self._add_extended_host(sid_prefix, host_n, e_cls, tmpdir) switch_cls = FaucetSwitch if hw_dpid and hw_dpid == dpid: remap_dpid = str(int(dpid) + 1) output('bridging hardware switch DPID %s (%x) dataplane via OVS DPID %s (%x)' % ( dpid, int(dpid), remap_dpid, int(remap_dpid))) dpid = remap_dpid switch_cls = NoControllerFaucetSwitch switch = self._add_faucet_switch(sid_prefix, dpid, ovs_type, switch_cls) self._add_links(switch, self.hosts(), links_per_host)
def build(self, ovs_type, ports_sock, test_name, dpids, n_tagged=0, tagged_vid=100, n_untagged=0, links_per_host=0, n_extended=0, e_cls=None, tmpdir=None, hw_dpid=None, host_namespace=None, start_port=SWITCH_START_PORT): if not host_namespace: host_namespace = {} for dpid in dpids: serialno = mininet_test_util.get_serialno(ports_sock, test_name) sid_prefix = self._get_sid_prefix(serialno) for host_n in range(n_tagged): self._add_tagged_host(sid_prefix, tagged_vid, host_n) for host_n in range(n_untagged): self._add_untagged_host(sid_prefix, host_n, host_namespace.get(host_n, True)) for host_n in range(n_extended): self._add_extended_host(sid_prefix, host_n, e_cls, tmpdir) switch = self._add_faucet_switch(sid_prefix, dpid, hw_dpid, ovs_type) self._add_links(switch, self.hosts(), links_per_host, start_port)
def build(self, ovs_type, ports_sock, test_name, dpids, n_tagged=0, tagged_vid=100, n_untagged=0, links_per_host=0, n_extended=0, e_cls=None, tmpdir=None, hw_dpid=None, host_namespace=None): if not host_namespace: host_namespace = {} for dpid in dpids: serialno = mininet_test_util.get_serialno( ports_sock, test_name) sid_prefix = self._get_sid_prefix(serialno) for host_n in range(n_tagged): self._add_tagged_host(sid_prefix, tagged_vid, host_n) for host_n in range(n_untagged): self._add_untagged_host(sid_prefix, host_n, host_namespace.get(host_n, True)) for host_n in range(n_extended): self._add_extended_host(sid_prefix, host_n, e_cls, tmpdir) switch_cls = FaucetSwitch if hw_dpid and hw_dpid == dpid: remap_dpid = str(int(dpid) + 1) output('bridging hardware switch DPID %s (%x) dataplane via OVS DPID %s (%x)' % ( dpid, int(dpid), remap_dpid, int(remap_dpid))) dpid = remap_dpid switch_cls = NoControllerFaucetSwitch switch = self._add_faucet_switch(sid_prefix, dpid, ovs_type, switch_cls) self._add_links(switch, self.hosts(), links_per_host)
def build(self, ovs_type, ports_sock, test_name, dpids, n_tagged=0, tagged_vid=100, n_untagged=0, links_per_host=0, switch_to_switch_links=1, hw_dpid=None, stack_ring=False): """ Hosts |||| |||| +----+ +----+ +----+ ---+1 | |1234| | 1+--- Hosts ---+2 | | | | 2+--- Hosts ---+3 | | | | 3+--- ---+4 5+-------+5 6+-------+5 4+--- +----+ +----+ +----+ Faucet-1 Faucet-2 Faucet-3 | | | | | | +-------- controller -----+ * s switches (above S = 3; for S > 3, switches are added to the chain) * (n_tagged + n_untagged) hosts per switch * (n_tagged + n_untagged + 1) links on switches 0 and s-1, with final link being inter-switch * (n_tagged + n_untagged + 2) links on switches 0 < n < s-1, with final two links being inter-switch """ def addLinks(src, dst): # pylint: disable=invalid-name for _ in range(self.switch_to_switch_links): self.addLink(src, dst) first_switch = None last_switch = None self.switch_to_switch_links = switch_to_switch_links for dpid in dpids: serialno = mininet_test_util.get_serialno(ports_sock, test_name) sid_prefix = self._get_sid_prefix(serialno) hosts = [] for host_n in range(n_tagged): hosts.append( self._add_tagged_host(sid_prefix, tagged_vid, host_n)) for host_n in range(n_untagged): hosts.append(self._add_untagged_host(sid_prefix, host_n)) switch_cls = FaucetSwitch if hw_dpid and hw_dpid == dpid: remap_dpid = str(int(dpid) + 1) output( 'bridging hardware switch DPID %s (%x) dataplane via OVS DPID %s (%x)' % (dpid, int(dpid), remap_dpid, int(remap_dpid))) dpid = remap_dpid switch_cls = NoControllerFaucetSwitch switch = self._add_faucet_switch(sid_prefix, dpid, ovs_type, switch_cls) self._add_links(switch, hosts, links_per_host) if first_switch is None: first_switch = switch if last_switch is not None: # Add a switch-to-switch link with the previous switch, # if this isn't the first switch in the topology. addLinks(last_switch, switch) last_switch = switch if stack_ring: addLinks(first_switch, last_switch)
def build(self, ovs_type, ports_sock, test_name, dpids, n_tagged=0, tagged_vid=100, n_untagged=0, links_per_host=0, switch_to_switch_links=1, hw_dpid=None, stack_ring=False): """ Hosts |||| |||| +----+ +----+ +----+ ---+1 | |1234| | 1+--- Hosts ---+2 | | | | 2+--- Hosts ---+3 | | | | 3+--- ---+4 5+-------+5 6+-------+5 4+--- +----+ +----+ +----+ Faucet-1 Faucet-2 Faucet-3 | | | | | | +-------- controller -----+ * s switches (above S = 3; for S > 3, switches are added to the chain) * (n_tagged + n_untagged) hosts per switch * (n_tagged + n_untagged + 1) links on switches 0 and s-1, with final link being inter-switch * (n_tagged + n_untagged + 2) links on switches 0 < n < s-1, with final two links being inter-switch """ def addLinks(src, dst): # pylint: disable=invalid-name for _ in range(self.switch_to_switch_links): self.addLink(src, dst) first_switch = None last_switch = None self.switch_to_switch_links = switch_to_switch_links for dpid in dpids: serialno = mininet_test_util.get_serialno( ports_sock, test_name) sid_prefix = self._get_sid_prefix(serialno) hosts = [] for host_n in range(n_tagged): hosts.append(self._add_tagged_host(sid_prefix, tagged_vid, host_n)) for host_n in range(n_untagged): hosts.append(self._add_untagged_host(sid_prefix, host_n)) switch_cls = FaucetSwitch if hw_dpid and hw_dpid == dpid: remap_dpid = str(int(dpid) + 1) output('bridging hardware switch DPID %s (%x) dataplane via OVS DPID %s (%x)' % ( dpid, int(dpid), remap_dpid, int(remap_dpid))) dpid = remap_dpid switch_cls = NoControllerFaucetSwitch switch = self._add_faucet_switch(sid_prefix, dpid, ovs_type, switch_cls) self._add_links(switch, hosts, links_per_host) if first_switch is None: first_switch = switch if last_switch is not None: # Add a switch-to-switch link with the previous switch, # if this isn't the first switch in the topology. addLinks(last_switch, switch) last_switch = switch if stack_ring: addLinks(first_switch, last_switch)
def build(self, ovs_type, ports_sock, test_name, dpids, n_tagged=0, tagged_vid=100, n_untagged=0, links_per_host=0, switch_to_switch_links=1, hw_dpid=None, stack_ring=False, start_port=SWITCH_START_PORT): """ Hosts |||| |||| +----+ +----+ +----+ ---+1 | |1234| | 1+--- Hosts ---+2 | | | | 2+--- Hosts ---+3 | | | | 3+--- ---+4 5+-------+5 6+-------+5 4+--- +----+ +----+ +----+ Faucet-1 Faucet-2 Faucet-3 | | | | | | +-------- controller -----+ * s switches (above S = 3; for S > 3, switches are added to the chain) * (n_tagged + n_untagged) hosts per switch * (n_tagged + n_untagged + 1) links on switches 0 and s-1, with final link being inter-switch * (n_tagged + n_untagged + 2) links on switches 0 < n < s-1, with final two links being inter-switch """ def addLinks(src, dst, switch_ports): # pylint: disable=invalid-name for _ in range(self.switch_to_switch_links): self.addLink(src, dst, port1=switch_ports[src], port2=switch_ports[dst]) switch_ports[src] += 1 switch_ports[dst] += 1 first_switch = None last_switch = None self.switch_to_switch_links = switch_to_switch_links switch_ports = {} for dpid in dpids: serialno = mininet_test_util.get_serialno(ports_sock, test_name) sid_prefix = self._get_sid_prefix(serialno) hosts = [] for host_n in range(n_tagged): hosts.append( self._add_tagged_host(sid_prefix, tagged_vid, host_n)) for host_n in range(n_untagged): hosts.append(self._add_untagged_host(sid_prefix, host_n)) switch = self._add_faucet_switch(sid_prefix, dpid, hw_dpid, ovs_type) switch_ports[switch] = self._add_links(switch, hosts, links_per_host, start_port) if first_switch is None: first_switch = switch else: # Add a switch-to-switch link with the previous switch, # if this isn't the first switch in the topology. addLinks(last_switch, switch, switch_ports) last_switch = switch if stack_ring: addLinks(first_switch, last_switch, switch_ports)
def build(self, ovs_type, ports_sock, test_name, dpids, dp_links, host_links, host_vlans, vlan_vids, hw_dpid=None, switch_map=None, start_port=SWITCH_START_PORT, port_order=None, get_serialno=get_serialno): """ Creates the Faucet mininet switches & hosts Args: dp_links (dict): dp id key to list of dp id value host_links (dict): host id key to list of dp id value host_vlans (dict): host id key to vlans id value vlan_vids (dict): VLAN IDs for vlan index """ self.hw_dpid = hw_dpid self.hw_ports = sorted(switch_map) if switch_map else [] self.start_port = start_port self.switch_to_switch_links = 0 for dplinks in dp_links.values(): self.switch_to_switch_links += len(dplinks) self.host_to_switch_links = 0 for hostlinks in host_links.values(): self.host_to_switch_links += len(hostlinks) max_ports = self.host_to_switch_links + (2 * self.switch_to_switch_links) self.port_order = self.extend_port_order(port_order, max_ports) # Create hosts self.hosts_by_id = {} for host_id, vlans in host_vlans.items(): serialno = get_serialno(ports_sock, test_name) sid_prefix = self._get_sid_prefix(serialno) if isinstance(vlans, int): self.hosts_by_id[host_id] = self._add_untagged_host( sid_prefix, host_id) elif isinstance(vlans, tuple): self.hosts_by_id[host_id] = self._add_tagged_host( sid_prefix, [vlan_vids[v] for v in vlans], host_id) # Create switches & then host-switch links self.switch_peer_links = {} next_index = {} self.dpid_to_switch = {} for i, dpid in enumerate(dpids): serialno = get_serialno(ports_sock, test_name) sid_prefix = self._get_sid_prefix(serialno) switch = self._add_faucet_switch(sid_prefix, dpid, hw_dpid, ovs_type) self.dpid_to_switch[dpid] = switch next_index[switch] = 0 # Create host-switch links for host_id, hostlinks in host_links.items(): if i in hostlinks: n_links = hostlinks.count(i) for _ in range(n_links): host = self.hosts_by_id[host_id] next_index[switch] = self._add_host_to_switch_link( switch, dpid, host, next_index[switch]) # Create switch-switch links for src_index, dplinks in dp_links.items(): for dst_index in dplinks: src = self.dpid_to_switch[dpids[src_index]] dst = self.dpid_to_switch[dpids[dst_index]] self._add_switch_to_switch_link(src, dst, next_index)