def to_mininet_topology(self): topo = mininet.topo.Topo() for h in self.hosts: mn_host = topo.addHost(h.hostname) for s in self.switches + self.routers: mn_switch = topo.addSwitch(s.name) for src, src_iface, dst, dst_iface in self.links: if src_iface is not None: intfName1 = src.name + "-" + src_iface else: intfName1 = None if dst_iface is not None: intfName2 = dst.name + "-" + dst_iface else: intfName2 = None topo.addLink(src.name, dst.name, intfName1=intfName1, intfName2=intfName2) return topo
def create_network(controller_ip, controller_port): """Create topology and mininet network.""" topo = mininet.topo.Topo() topo.addSwitch('s1') topo.addHost('h1') topo.addHost('h2') topo.addLink('h1', 's1') topo.addLink('h2', 's1') switch=mininet.util.customConstructor( {'ovsk':OVSKernelSwitch}, 'ovsk,protocols=OpenFlow13') controller=mininet.util.customConstructor( {'remote': RemoteController}, 'remote,ip=%s,port=%s' % (controller_ip,controller_port)) net = mininet.net.Mininet(topo=topo, switch=switch, controller=controller) return net
def to_mininet_topology(self): topo = mininet.topo.Topo() for h in self.hosts: mn_host = topo.addHost(h.hostname) for s in self.switches + self.routers: mn_switch = topo.addSwitch(s.name) for src, src_iface, dst, dst_iface in self.links: if src_iface is not None: intfName1 = src.name + "-" + src_iface else: intfName1 = None if dst_iface is not None: intfName2 = dst.name + "-" + dst_iface else: intfName2 = None topo.addLink(src.name, dst.name, intfName1=intfName1, intfName2=intfName2) return topo