当前位置: 首页>>代码示例>>Python>>正文


Python Mininet.configLinkStatus方法代码示例

本文整理汇总了Python中mininet.net.Mininet.configLinkStatus方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.configLinkStatus方法的具体用法?Python Mininet.configLinkStatus怎么用?Python Mininet.configLinkStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mininet.net.Mininet的用法示例。


在下文中一共展示了Mininet.configLinkStatus方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: emptyNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import configLinkStatus [as 别名]
def emptyNet():

    "Create an empty network and add nodes to it."

    #net = Mininet( controller=Controller )
    net = Mininet( controller=RemoteController )

    info( '*** Adding controller\n' )
    net.addController( 'c0' )

    info( '*** Adding hosts\n' )
    h1 = net.addHost( 'h1', ip='10.0.0.1' )
    h2 = net.addHost( 'h2', ip='10.0.0.2' )

    info( '*** Adding switch\n' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )
    s5 = net.addSwitch( 's5' )
    s6 = net.addSwitch( 's6' )

    info( '*** Creating links\n' )
    net.addLink( h1, s3 )
    net.addLink( s3, s4 )
    net.addLink( s3, s5 )
    net.addLink( s4, s6 )
    net.addLink( s5, s6 )
    net.addLink( h2, s6 )

    print "Stopping of " + 's5'
    net.configLinkStatus('s5', 's3', 'down')
    #net.configLinkStatus('s5', 's6', 'down')
    #net.hosts[0].cmd("ping -w 15 10.0.0.2")
    #net.pingAll()

    return net
开发者ID:stefanos1316,项目名称:BigData,代码行数:37,代码来源:test_net.py

示例2: IEEE30BusNetwork

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import configLinkStatus [as 别名]
def IEEE30BusNetwork():
    """Kickoff the network"""
    topo = IEEE30BusTopology()
    net = Mininet(topo=topo, host=Host, switch=OVSKernelSwitch, \
            controller=RemoteController, autoStaticArp=True, waitConnected=True)
    net.start()
    changed_sw = ['s5', 's8', 's13', 's18', 's20']

    if args.short:
        # test connectivity
        info('****** Quick test for connectivity between PMU and PDC ******\n')
        info('*** PING Test from PMU15 PMU23 and PMU25 ***\n')
        # PMUPingPDC(net, 'PMU15', 'PDC8', 1)
        # PMUPingPDC(net, 'PMU9', 'PDC5', 1)
        PMUPingAllPDC(net, 'PMU15', timeout=1)
        PMUPingAllPDC(net, 'PMU23', timeout=1)
        PMUPingAllPDC(net, 'PMU25', timeout=1)
    else:
        AllPMUPingAllPDC(net, 1)

    info('\n****** Show rules on critical switches ******\n')
    for sw in changed_sw:
        DumpRule(net, sw)

    # remove 2 pdcs by tear down link
    # info("\n****** Tear down link between PDC8 and Switch 8 ******\n")
    # info("****** Tear down link between PDC13 and Switch 13 ******\n")
    net.configLinkStatus('PDC8', 's8', 'down')
    net.configLinkStatus('PDC13', 's13', 'down')

    # old pdc should be unreachable
    info('\n****** PDC8 is isolated after being compromised ******\n')
    info('*** PING Test from PMU15 PMU23 ***\n')
    # PMUPingPDC(net, 'PMU15', 'PDC8', 1)
    PMUPingAllPDC(net, 'PMU15', 1)
    PMUPingAllPDC(net, 'PMU23', 1)
    info('\n****** PDC13 is isolated after being compromised ******\n')
    info('*** PING Test from PMU25 ***\n')
    PMUPingAllPDC(net, 'PMU25', 1)

    raw_input("\n****** Self-heal controller installed new rules to reconnect PMUs ******\n")
    # test newly installed rules
    info('*** Test rules installed to connect PMU15 to PDC5 ***\n')
    # PMUPingPDC(net, 'PMU15', 'PDC5', 1)
    PMUPingAllPDC(net, 'PMU15', timeout=1)
    info('*** Test rules installed to connect PMU23 to PDC5 ***\n')
    PMUPingAllPDC(net, 'PMU23', timeout=1)
    info('*** Test rules installed to connect PMU25 to PDC5 ***\n')
    PMUPingAllPDC(net, 'PMU25', timeout=1)

    info('\n****** Show rules on critical switches ******\n')
    for sw in changed_sw:
        DumpRule(net, sw)

    # if not args.short:
        # AllPMUPingAllPDC(net, 1)

    CLI(net)
    net.stop()
开发者ID:atirados,项目名称:PowerSystemDemo,代码行数:61,代码来源:bus_system.py

示例3: BeginSimulation

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import configLinkStatus [as 别名]
def BeginSimulation() :

    # We begin mininet initially
    net = Mininet( controller=Controller, switch=OVSSwitch)

    print "*** Creating (reference) controllers On 192.168.2.50/51 Change if necessary"
    c0 = RemoteController( 'c0', ip='192.168.56.21', port=6634 )  #This is parent controller (change tomcat 8081)
    c1 = RemoteController( 'c1', ip='192.168.56.21', port=6633 )
    c2 = RemoteController( 'c2', ip='192.168.56.1', port=6633 )

    print "*** Creating switches"
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )
    gs1 = net.addSwitch( 'gs1' )
    gs2 = net.addSwitch( 'gs2' )

    print "*** Creating hosts"
    print "*** Creating hosts"
    hosts1 = [ addHost1( net, n) for n in 1, 2, 3, 4 ]
    hosts2 = [ addHost2( net, n) for n in 5, 6, 7, 8 ]
    hosts3 = [ addHost3( net, n) for n in 9, 10, 11, 12 ]
    hosts4 = [ addHost4( net, n) for n in 13, 14, 15, 16 ]

    # These are the hsots that move to other side. We will bring the links up when we want to show the host movement
    s3_temp_host1 = net.addHost( 'h17', ip = '10.0.0.66', mac = '00:00:00:00:00:1') 
    s3_temp_host2 = net.addHost( 'h18', ip = '10.0.0.67', mac = '00:00:00:00:00:2') 

    print "*** Creating links"
    for h in hosts1:
        net.addLink( s1, h )
    for h in hosts2:
        net.addLink( s2, h )
    for h in hosts3:
        net.addLink( s3, h )
    for h in hosts4:
        net.addLink( s4, h )

    net.addLink( s1, s2 )
    net.addLink( s3, s4 )

    net.addLink( s2, s3 )

    net.addLink( gs1, gs2 )

    # Additional links to simlulate host movement (handover). Note that this link will be down initially
    net.addLink( s3, s3_temp_host1)
    net.addLink( s3, s3_temp_host2)

    print "*** Starting network"
    net.build()
    c0.start()
    c1.start()
    c2.start()
    s1.start( [ c1 ] )
    s2.start( [ c1 ] )
    s3.start( [ c2 ] )
    s4.start( [ c2 ] )
    gs1.start( [ c0 ] )
    gs2.start( [ c0 ] )

    # Remember that these two links will be down initially and needs to be manually pulled up whenever we need handover
    net.configLinkStatus('h17', 's3', 'down')
    net.configLinkStatus('h18', 's3', 'down')
    CLI(net)
开发者ID:avinsrid,项目名称:SDN-Project,代码行数:68,代码来源:controller.py

示例4: MininetManager

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import configLinkStatus [as 别名]
class MininetManager(object):

    def __init__(self):
        self.logger = logging.getLogger(__name__)
        self.net = None

    @Pyro4.expose
    def create_mininet(self, topo, tunnels=[],  switch=UserSwitch,
                       controller=None, STT=False):
        if(not self.net is None):
            self.logger.warn("running mininet instance detected!\
                              Shutting it down...")
            self.destroy_mininet()

        self.logger.info("Creating mininet instance")
        if controller:
            self.net = Mininet(topo=topo, intf=TCIntf, link=TCLink,
                               switch=switch, controller=controller)
        else:
            self.net = Mininet(topo=topo, intf=TCIntf, link=TCLink,
                               switch=switch)
        if STT:
            self.logger.info("Starting Mininet...")
            self.net.start()
        self.logger.info("Adding tunnels to mininet instance")
        for tunnel in tunnels:
            port = None
            cls = None
            if "port" in tunnel[2].keys():
                port = tunnel[2]["port"]
                del tunnel[2]["port"]
            if "cls" in tunnel[2].keys():
                cls = tunnel[2]["cls"]
                del tunnel[2]["cls"]
            self.addTunnel(tunnel[0], tunnel[1], port, cls, STT=STT, **tunnel[2])
        if not STT:
            self.logger.info("Starting Mininet...")
            self.net.start()
        self.logger.info("Startup complete.")
        self.x11popens = []
        return True

    @Pyro4.expose
    def destroy_mininet(self):
        """shut down mininet instance"""
        if self.net:
            for popen in self.x11popens:
                popen.terminate()
                popen.communicate()
                popen.wait()
            self.net.stop()
            self.logger.info("mininet instance terminated")
            self.net = None

    @Pyro4.expose
    def configLinkStatus(self, src, dst, status):
        self.net.configLinkStatus(src, dst, status)

    @Pyro4.expose
    def rpc(self, hostname, cmd, *params1, **params2):
        h = self.net.get(hostname)
        return getattr(h, cmd)(*params1, **params2)

    @Pyro4.expose
    def attr(self, hostname, name):
        h = self.net.get(hostname)
        return getattr(h, name)

    @Pyro4.expose
    def addHost(self, name, cls=None, **params):
        self.net.addHost(name, cls, **params)
        return name

    @Pyro4.expose
    def addSwitch(self, name, cls=None, **params):
        self.net.addSwitch(name, cls, **params)
        #TODO: This should not be done here
        self.net.get(name).start(self.net.controllers)
        return name

    @Pyro4.expose
    def addController(self, name="c0", controller=None, **params):
        self.net.addController(name, controller, **params)
        return name

    @Pyro4.expose
    def addTunnel(self, name, switch, port, intf, STT=False, **params):
        switch_i = self.net.get(switch)
        if not intf:
            intf = TCIntf
        if STT:
            subprocess.check_output(["ovs-vsctl","add-port", switch, name])
        else:
            intf(name, node=switch_i, port=port, link=None, **params)

    @Pyro4.expose
    def tunnelX11(self, node, display):
        node = self.net.get(node)
        (tunnel, popen) = mininet.term.tunnelX11(node, display)
        self.x11popens.append(popen)
#.........这里部分代码省略.........
开发者ID:schwabe,项目名称:MaxiNet,代码行数:103,代码来源:server.py

示例5: TestMininet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import configLinkStatus [as 别名]

#.........这里部分代码省略.........
        self.cmd(self.fuse_kafka, 'src/fuse_kafka.py stop')
        os.remove(self.kafka_config.name)
        self.data_directories_cleanup()
        self.impersonate()
        self.net.stop()
    def setUp(self):
        """ starts the topology, downloads kafka, does a data directory
        cleanup in case of previous run """
        self.launch = kafka_bin_directory + '{}-server-start.sh '
        self.stop = kafka_bin_directory + '{}-server-stop.sh '
        self.start_network()
        kafka_download()
        self.clients_initialize()
        self.data_directories_cleanup()
        self.components_start()
        # wait for fuse-kafka to be ready
        time.sleep(2)
    def check(self):
        self.assertTrue(os.path.exists(self.fuse_kafka_path),
            "you must build fuse kafka to run tests")
        os.stat("/tmp/fuse-kafka-test")
    def get_consumed_events(self, expected_number):
        from mininet.util import pmonitor
        events = []
        log = FuseKafkaLog()
        popens = {}
        popens[self.client] = self.consumer
        for host, line in pmonitor(popens):
            self.consumer.poll()
            events.append(log.load_fuse_kafka_event(line))
            if len(events) >= expected_number:
                break
        self.assertEqual(expected_number, len(events))
        return events
    def write_to_log(self, what = "test"):
        self.cmd(self.fuse_kafka, "echo -n {} > /tmp/fuse-kafka-test/xd 2>&1".format(what))
    def components_start(self):
        """ starts zookeepre, kafka, fuse_kafka, fuse_kafka consumer """
        self.zookeeper_start()
        self.kafka_start()
        self.fuse_kafka_start()
        self.consumer_start()
    def test_basic(self):
        """ runs the topology with a mininet shell """
        self.check()
        for message in ["hello", "world"]:
            self.write_to_log(message)
            events = self.get_consumed_events(1)
            self.assertEqual(message, events[0]["@message"])
        expected = ["foo", "bar"]
        for message in expected:
            self.write_to_log(message)
        actual = [event["@message"] for event in self.get_consumed_events(2)]
        self.assertEqual(sorted(expected), sorted(actual))
    def test_shutting_down_kafka(self):
        self.check()
        self.kafka_stop()
        self.write_to_log()
        self.kafka_start()
        self.get_consumed_events(1)
    def test_shutting_down_zookeeper(self):
        self.check()
        self.zookeeper_stop()
        self.write_to_log()
        self.zookeeper_start()
        self.get_consumed_events(1)
    def test_bringing_down_kafka(self):
        self.check()
        self.kafka_stop()
        self.write_to_log()
        self.kafka_start()
        self.get_consumed_events(1)
    def test_cutting_kafka(self):
        self.check()
        self.write_to_log()
        self.net.configLinkStatus(self.kafka.name, self.switch.name, "down") 
        self.assertRaises(ValueError, self.get_consumed_events, (1))
        self.net.configLinkStatus(self.kafka.name, self.switch.name, "up") 
        self.get_consumed_events(1)
    def test_cutting_zookeeper(self):
        self.check()
        self.write_to_log()
        self.net.configLinkStatus(self.zookeeper.name, self.switch.name, "down") 
        # zookeeper being brought down should not influence an already launched producer
        self.get_consumed_events(1)
    def test_cutting_kafka_periodically(self):
        self.check()
        ranges = {10: range(3), 1: range(4), 0: range(10)}
        for sleep_time in ranges:
            print("sleep time: " + str(sleep_time))
            for i in ranges[sleep_time]:
                print("loop # " + str(i))
                self.net.configLinkStatus(self.kafka.name, self.switch.name, "down") 
                time.sleep(sleep_time)
                self.assertRaises(ValueError, self.get_consumed_events, (1))
                self.net.configLinkStatus(self.kafka.name, self.switch.name, "up") 
                if sleep_time > 1:
                    time.sleep(7) # wait for kafka to be restarted
                self.write_to_log()
                self.get_consumed_events(1)
开发者ID:yazgoo,项目名称:fuse_kafka,代码行数:104,代码来源:build.py

示例6: ping_thread

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import configLinkStatus [as 别名]
import thread
import time

# ping forever function
def ping_thread (threadName, src, dst):
  while (1):
    time.sleep(1)
    print src.cmd('ping -c1 %s' % dst.IP())

# setup mininet network
net = Mininet()
c0 = net.addController('c0')
s0 = net.addSwitch('s0')
h0 = net.addHost('h0')
h1 = net.addHost('h1')
net.addLink(s0, h0) 
net.addLink(s0, h1)

# start network and test
net.start()

# do the actual test and run forever
thread.start_new_thread(ping_thread, ("pinging thread", h0, h1))

# wait 10 seconds before killing the network
time.sleep(10)
net.configLinkStatus("s0", "h1", "down")

# stop network
net.stop()
开发者ID:PerkinsRay,项目名称:pox,代码行数:32,代码来源:ping_and_drop.py

示例7: test

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import configLinkStatus [as 别名]

#.........这里部分代码省略.........
            #iperF2()
            #time.sleep(1)
            #print h2.cmd('jobs')
            #iperF4()
            #time.sleep(1)
            #print h4.cmd('jobs')

            #PAUSA DE X SEGUNDOS PARA ADICIONAR GRÁFICOS NO CACTI
            #sleep(10)

            #TRATAMENTO DE EXCEÇÕES E MENU DE MANIPULAÇÃO DA TOPOLOGIA

            try:
                info('Choose the action: \n\n')
                info('a: Link s2_FUNDAJ/s1-POP up\n')
                info('b: Link s2_FUNDAJ/s1_POP down\n')
                info('c: Link s2_FUNDAJ/s3_CPOR up\n')
                info('d: Link s2_FUNDAJ/s3_CPOR down\n')
                info('e: Start host3 - s3_CPOR \n')
                info('f: Start host22 - s2_FUNDAJ \n')
                info('g: Shutdown host22 (s2_FUNDAJ) down')
                info('h: Start host2  (s2_FUNDAJ) up\n')
                info('i: Shutdown host2 (s2_FUNDAJ) down\n')
                info('j: Start host33 - s3_CPOR \n')
                info('l: Shutdown host33 (s3_CPOR) down\n')
                info('m: Start host4 (s4_IFPE) up\n')
                info('n: Exit\n\n')
                inputKey = ''
                while inputKey != 'n':
                    inputKey = raw_input('Choose an option (just one letter): ')
                    if inputKey == 'a':
                        time.sleep(1)
                        info('\nlink s2_FUNDAJ / s1_POP UP\n')
                        net.configLinkStatus('s2_FUNDAJ','s1_POP','up')
                        time.sleep(1)
                        inputKey = ''
                    elif inputKey == 'b':
                        time.sleep(1)
                        info('\nlink s2_FUNDAJ / s1_POP DOWN\n')
                        net.configLinkStatus('s2_FUNDAJ','s1_POP','down')
                        time.sleep(1)
                        inputKey = ''
                    elif inputKey == 'c':
                        time.sleep(1)
                        info('\nlink s2_FUNDAJ / s3_CPOR UP\n')
                        net.configLinkStatus('s2_FUNDAJ','s3_CPOR','up')
                        time.sleep(1)
                        inputKey = ''
                    elif inputKey == 'd':
                        time.sleep(1)
                        info('\nlink s2_FUNDAJ \ s3_CPOR DOWN\n')
                        net.configLinkStatus('s2_FUNDAJ','s3_CPOR','down')
                        time.sleep(1)
                        inputKey = ''
                    elif inputKey == 'e':
                        time.sleep(1)
                        iperF3()
                        info('\njobs from h3\n')
                        print h3.cmd('jobs')
                        time.sleep(1)
                        inputKey=''
                    elif inputKey == 'f':
                        time.sleep(1)
                        iperF22()
                        time.sleep(1)
                        info('\n***Starting h22***\n')
开发者ID:josecarlosjr,项目名称:scripts,代码行数:70,代码来源:topo.py

示例8: MininetWrapper

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import configLinkStatus [as 别名]
class MininetWrapper(object):

    def __init__(self):
        self.mininet_client = None
        self.topology = []
        self.delay = None

    def set_delay(self, delay):
        delay = str(int(delay)) + 'ms'
        self.delay = delay

    def run_mininet(self, topology_string):
        """ Create and run multiple link network
        """
        self.topo_client = Topo()
        hosts = set()
        switches = set()

        relations = re.sub(r's', '', topology_string)
        relations = [i.split(':') for i in relations.split(',')
                     if 'h' not in i]
        relations = [[int(y) - 1 for y in x] for x in relations]
        builtin.log(relations, 'DEBUG')

        verticles_count = len(set(list(itertools.chain(*relations))))
        builtin.log(self.topology, 'DEBUG')

        for i in xrange(verticles_count):
            temp = []
            for j in xrange(verticles_count):
                temp.append(-1)
            self.topology.append(temp[:])

        builtin.log(self.topology, 'DEBUG')

        for i in relations:
            self.topology[i[0]][i[1]] = 1
            self.topology[i[1]][i[0]] = 1
        builtin.log(self.topology, 'DEBUG')

        for v1, v2 in [x.split(':') for x in str(topology_string).split(',')]:
            if 'h' in v1 and v1 not in hosts:
                self.topo_client.addHost(v1)
                hosts.add(v1)
            if 'h' in v2 and v2 not in hosts:
                self.topo_client.addHost(v2)
                hosts.add(v2)
            if 's' in v1 and v1 not in switches:
                self.topo_client.addSwitch(v1)
                switches.add(v1)
            if 's' in v2 and v2 not in switches:
                self.topo_client.addSwitch(v2)
                switches.add(v2)
            if self.delay:
                self.topo_client.addLink(v1, v2, delay=self.delay)
            else:
                self.topo_client.addLink(v1, v2)

        self.mininet_client = Mininet(switch=user_switch,
                                      controller=remote_controller,
                                      topo=self.topo_client, link=TCLink)
        self.mininet_client.start()
        builtin.log('Links info:')
        for link in self.topo_client.links(withKeys=True, withInfo=True):
            builtin.log(link)

        # self.mininet_client.waitConnected(timeout=20)
        sleep(20)

    def stop_mininet(self):
        if self.mininet_client is not None:
            self.mininet_client.stop()
        if self.topology:
            self.topology = []
        self.delay = None
        cleanup()
        sleep(20)

    def kill_link(self, host1, host2):
        host1, host2 = str(host1), str(host2)
        self.mininet_client.configLinkStatus(host1, host2, 'down')

        if 'h' not in host1 and 'h' not in host2:
            num_1 = int(host1[1:]) - 1
            num_2 = int(host2[1:]) - 1
            self.topology[num_1][num_2] = -1
            self.topology[num_2][num_1] = -1

        builtin.log(self.topology, 'DEBUG')
        builtin.log('Down link {0} - {1}'.format(host1, host2),
                    'DEBUG')

    def check_link(self, host1, host2):
        switch = self.mininet_client.getNodeByName(host1)
        connections = switch.connectionsTo(host2)
        if connections:
            return True
        else:
            return False

#.........这里部分代码省略.........
开发者ID:michaelsenin,项目名称:odl-test-framework,代码行数:103,代码来源:MininetWrapper.py

示例9: MininetCreator

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import configLinkStatus [as 别名]
class MininetCreator():
    def __init__(self):
        self.logger = logging.getLogger(__name__)
        pass

    def create_mininet(self, topo=None, tunnels=[],  switch=UserSwitch, controller=None):
        "Create a Mininet and test it with pingall"
        self.setLogLevel('debug')
        self.logger.info("Creating mininet instance")
        if not topo:
            topo=SingleSwitchTopo(k=2)
        if controller:
            self.net = Mininet(topo=topo, intf=TCIntf, link=TCLink, switch=switch, controller=controller)
        else:
            self.net = Mininet(topo=topo, intf=TCIntf, link=TCLink, switch=switch)
        self.logger.info("Adding tunnels to mininet instance")
        for tunnel in tunnels:
            port=None
            cls=None
            if "port" in tunnel[2].keys():
                port = tunnel[2]["port"]
                del tunnel[2]["port"]
            if "cls" in tunnel[2].keys():
                cls = tunnel[2]["cls"]
                del tunnel[2]["cls"]
            self.addTunnel(tunnel[0], tunnel[1], port, cls, **tunnel[2])
        self.logger.info("Starting Mininet...")
        self.net.start()
        #print "Dumping host connections"
        dumpNodeConnections(self.net.hosts)
        self.logger.info("Startup complete.")
        # print "Testing network connectivity"
        # self.net.pingAll()
        # self.net.stop()
        # print "net created, pingAll finished!"
        #return net     # to do: it seems we get in trouble with serializing Mininet objects

    def getHosts(self):
        # todo just return the hosts names not the objects themselves they are not serializable
        hosts = self.net.hosts
        self.logger.debug('hosts type: ', type(hosts), ' ||| elem type:', type(hosts[0]))
        return hosts

    def setLogLevel(self, level='info'):
        '''
            set worker's mininet instance log level
        '''
        mnSetLogLevel(level)

    def configLinkStatus(self,src,dst,status):
        self.net.configLinkStatus(src,dst,status)

    def rpc(self, hostname, cmd, *params1, **params2):
        h = self.net.get(hostname)
        return getattr(h,cmd)(*params1, **params2)

    def attr(self, hostname, name):
        h = self.net.get(hostname)
        return getattr(h,name)

    def addHost(self,name, cls=None,**params):
        self.net.addHost(name,cls, **params)
        return name

    def addSwitch(self,name,cls=None, **params):
        self.net.addSwitch(name, cls, **params)
        self.net.get(name).start(self.net.controllers) #TODO: This should not be done here
        return name

    def addController(self,name="c0", controller=None,**params):
        self.net.addController(name, controller,**params)
        return name

    def addTunnel(self, name, switch, port, cls, **params):
        switch=self.net.get(switch)
        #self.net.addTunnel(name, switch, port, cls, **params)
        if not cls:
            cls=TCIntf
        cls(name, node=switch, port=port, link=None, **params)
    def tunnelX11(self, node,display):
        node = self.net.get(node)
        mininet.term.tunnelX11(node,display)
        
    def addLink(self, node1, node2, port1 = None, port2 = None, cls = None, **params):
        node1=self.net.get(node1)
        node2=self.net.get(node2)
        l=self.net.addLink(node1,node2,port1,port2,cls,**params)
        return ((node1.name,l.intf1.name),(node2.name,l.intf2.name))
    
    def runCmdOnHost(self, hostname, command, noWait=False):
        '''
            e.g. runCmdOnHost('h1', 'ifconfig')
        '''
        h1 = self.net.get(hostname)
        if noWait:
            return h1.sendCmd(command)
        else:
            return h1.cmd(command)

    def getNodePID(self, nodename):
#.........这里部分代码省略.........
开发者ID:wette,项目名称:MaxiNet,代码行数:103,代码来源:services.py


注:本文中的mininet.net.Mininet.configLinkStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。