• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python clean.cleanup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mininet.clean.cleanup函数的典型用法代码示例。如果您正苦于以下问题:Python cleanup函数的具体用法?Python cleanup怎么用?Python cleanup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: runMPI

def runMPI():
    # Create network
    topo = TestTopo()
    net = Mininet(topo=topo, controller=lambda name: RemoteController(name, ip='127.0.0.1'), link=TCLink)
    # net = Mininet(topo=topo, controller=OVSController, link=TCLink)
    net.start()

    for host in net.hosts:
        host.cmd('../../tiny-lldpd/tlldpd -d -i 1')

    sleep(5)

    # Launch sshd on each hosts and output host IPs to machinefile
    pids = []
    f = open('./machines', 'w')
    for h in net.hosts:
        h.cmd('/usr/sbin/sshd -D -o UseDNS=no -u0 &')
        pid = int(h.cmd('echo $!'))
        pids.append(pid)
        f.write('%s\n' % h.IP())
    f.close()

    # Launch MPI application
    print "Starting MPI application:"
    print "----------------------------------------"
    net.hosts[0].cmdPrint('mpirun --machinefile ./machines --mca coll_tuned_priority 100 --mca coll_tuned_allreduce_algorithm 3 --mca coll_tuned_use_dynamic_rules 1 --mca coll_base_verbose 1 ./mpitest');
    print "----------------------------------------"
    print "MPI application finished."

    for pid in pids:
        h.cmd('kill -9 %s' % pid)
    net.hosts[0].cmd('killall -9 tlldpd')

    net.stop()
    cleanup()
开发者ID:evelinad,项目名称:sdn-mpi,代码行数:35,代码来源:virtual_cluster4.py


示例2: perfTest

def perfTest():
    topo = TestTopo()
    net = Mininet(topo=topo, controller=lambda name: RemoteController(name, ip='127.0.0.1'), link=TCLink)
    net.start()
    print "Dumping connections"
    dumpNodeConnections(net.hosts)

    print "Launching LLDP daemons"
    for host in net.hosts:
        host.cmd('../../tiny-lldpd/tlldpd -d -i 1')

    sleep(3)

    net.pingAll()

    net.get('h3').cmd('iperf -sD')
    net.get('h4').cmd('iperf -sD')

    net.get('h1').cmd('iperf -c %s > /tmp/h1.txt &' % net.get('h3').IP())
    net.get('h2').cmd('sleep 1; iperf -c %s > /tmp/h2.txt &' % net.get('h4').IP())

    net.get('h1').cmd('wait $!')
    net.get('h2').cmd('wait $!')

    net.get('h1').cmdPrint("awk 'NR == 7 {print $7 $8}' /tmp/h1.txt")
    net.get('h2').cmdPrint("awk 'NR == 7 {print $7 $8}' /tmp/h2.txt")


    net.hosts[0].cmd('killall -9 tlldpd')
    net.hosts[0].cmd('killall -9 iperf')

    net.stop()
    cleanup()
开发者ID:evelinad,项目名称:sdn-mpi,代码行数:33,代码来源:fat_tree_dlb.py


示例3: launch_network

def launch_network(k=4, bw=10, ip_alias=True, fair_queues=False, cli=False):
    signal.signal(signal.SIGTERM, signal_term_handler)

    # Cleanup the network
    cleanup()
    sh("killall ospfd zebra getLoads.py nc")

    # Remove tmp files and old namespaces
    subprocess.call(['rm', '/tmp/*.log', '/tmp/*.pid', '/tmp/mice*'])
    subprocess.call(['rm', '/var/run/netns/*'])

    # Flush root namespace mangle table
    subprocess.call(["iptables", "-t", "mangle" ,"-F"])
    subprocess.call(["iptables", "-t", "mangle" ,"-X"])

    # Topology
    topo = FatTree(k=k, sflow=False, ovs_switches=False)

    # Interfaces
    if fair_queues:
        print("*** Using FairQueues at the network interfaces")
        intf = custom(DCTCIntf, bw=bw)
    else:
        print("*** Using normal pFIFO queues at the network interfaces")
        intf = custom(PrioFifoIntf, bw=bw)

    # Network
    net = IPNet(topo=topo, debug=_lib.DEBUG_FLAG, intf=intf)

    # Save the TopoDB object
    TopologyDB(net=net).save(cfg.DB_path)

    # Start the network
    net.start()

    # Setup hash seeds
    setupHashSeeds(topo)

    # Start intreface collectors
    startCounterCollectors(topo, interval=1)

    if ip_alias:
        setupSecondaryIps(net)

    if cli:
        # Start the Fibbing CLI
        FibbingCLI(net)
    else:
        print("*** Looping forever. Press CTRL+C to quit")
        while True:
            try:
                time.sleep(2)
            except KeyboardInterrupt:
                print("*** KeyboardInterrupt catched! Shutting down")
                break

    net.stop()

    stopCounterCollectors(topo)
开发者ID:lferran,项目名称:fibte,代码行数:59,代码来源:network_example.py


示例4: stop_mininet

 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)
开发者ID:michaelsenin,项目名称:odl-test-framework,代码行数:8,代码来源:MininetWrapper.py


示例5: runTests

def runTests( testDir, verbosity=1 ):
    "discover and run all tests in testDir"
    # ensure root and cleanup before starting tests
    cleanup()
    # discover all tests in testDir
    testSuite = defaultTestLoader.discover( testDir )
    # run tests
    TextTestRunner( verbosity=verbosity ).run( testSuite )
开发者ID:Stratoscale,项目名称:mininet,代码行数:8,代码来源:runner.py


示例6: runTests

def runTests( testDir, verbosity=1 ):
    "discover and run all tests in testDir"
    # cleanup before starting tests
    cleanup()
    # discover all tests in testDir
    testSuite = unittest.defaultTestLoader.discover( testDir )
    # run tests
    MininetTestRunner( verbosity=verbosity ).run( testSuite )
开发者ID:Stratoscale,项目名称:mininet,代码行数:8,代码来源:runner.py


示例7: tearDown

 def tearDown():
     cleanup()
     # make sure that all pending docker containers are killed
     with open(os.devnull, 'w') as devnull:
         subprocess.call(
             "sudo docker rm -f $(sudo docker ps --filter 'label=com.containernet' -a -q)",
             stdout=devnull,
             stderr=devnull,
             shell=True)
开发者ID:hadik3r,项目名称:son-emu,代码行数:9,代码来源:base.py


示例8: runTests

def runTests( testDir, verbosity=1 ):
    "discover and run all tests in testDir"
    # ensure root and cleanup before starting tests
    ensureRoot()
    cleanup()
    # discover all tests in testDir
    testSuite = unittest.defaultTestLoader.discover( testDir )
    # run tests
    success = MininetTestRunner( verbosity=verbosity ).run( testSuite ).wasSuccessful()
    sys.exit( 0 if success else 1 )
开发者ID:MatheusRagoso,项目名称:mininet,代码行数:10,代码来源:runner.py


示例9: destroy_mininet

 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()
         # remove mininet instance and running docker container
         cleanup()
         self.logger.info("mininet instance terminated")
         self.net = None
开发者ID:setchring,项目名称:MaxiNet,代码行数:12,代码来源:server.py


示例10: __init__

    def __init__(self, topo=None):
        cleanUpScreens()
        cleanup()

        if topo is None:
            topo = LinearTopo(N)

        self.net = Mininet(controller=partial(RemoteController, ip='101.6.30.40', port=6653),
                           topo=topo,
                           #host=CPULimitedHost,
                           #link=TCLink
                           )
开发者ID:zy-sdn,项目名称:savi-test,代码行数:12,代码来源:mn.py


示例11: httpTest

def httpTest( N=2 ):
    "Run pings and monitor multiple hosts using pmonitor"

    ## SET LOGGING AND CLEANUP PREVIOUS MININET STATE, IF ANY
    lg.setLogLevel('info')
    cleanup()

    ## INSTEAD OF RUNNING PYRETIC HUB, UNCOMMENT LINE 
    ## TO SEE THAT THIS WORKS FINE WHEN RUNNING REFERENCE CONTROLLER
#    call('controller ptcp: &', shell=True)

    ## SET UP TOPOLOGY
    topo = LinearTopo( N )        ## (tcp parse) warning TCP data offset too long or too short
#    topo = SingleSwitchTopo( N ) ## SILENT STALL


    ## SET UP MININET INSTANCE AND START
    net = Mininet( topo, switch=OVSKernelSwitch, host=Host, controller=RemoteController )
    net.start()

    print "Starting test..."

    ## GET THE HOST AND SERVER NAMES
    hosts = net.hosts
    client = hosts[ 0 ]
    server = hosts[ 1 ]
    
    ## DICTS FOR USE W/ PMONITOR
    spopens = {}
    cpopens = {}

    ## WARMUP SERVER 
    spopens[server] = server.popen('python', '-m', 'SimpleHTTPServer', '80')
    sleep(1)

    ## CLIENT REQUEST
    cpopens[client] = client.popen('wget', '-O', '-', server.IP(), stdout=PIPE, stderr=STDOUT)

    ## MONITOR OUTPUT
    for h, line in pmonitor( cpopens, timeoutms=5000 ):
        if h and line:
            print '%s: %s' % ( h.name, line ),

    ## TO USE THE COMMAND LINE INTERFACE, BEFORE FINISHING, UNCOMMENT
#    CLI( net )

    ## SHUTDOWN SERVER
    spopens[server].send_signal( SIGINT )
    
    ## SHUTDOWN MININET
    net.stop()
开发者ID:cryptobanana,项目名称:pyretic,代码行数:51,代码来源:http_test.py


示例12: runTests

def runTests(testDir, verbosity=1, dockeronly=False):
    "discover and run all tests in testDir"
    # ensure root and cleanup before starting tests
    ensureRoot()
    cleanup()
    # discover all tests in testDir
    testSuite = defaultTestLoader.discover(testDir)
    if dockeronly:
        testSuiteFiltered = [s for s in testSuite if "Docker" in str(s)]
        testSuite = TestSuite()
        testSuite.addTests(testSuiteFiltered)

    # run tests
    TextTestRunner(verbosity=verbosity).run(testSuite)
开发者ID:Shrq,项目名称:dockernet,代码行数:14,代码来源:runner.py


示例13: perfTest

def perfTest():
    topo = TestTopo()
    net = Mininet(topo=topo, controller=lambda name: RemoteController(name, ip='127.0.0.1'), link=TCLink)
    net.start()
    print "Dumping connections"
    dumpNodeConnections(net.hosts)

    for host in net.hosts:
        host.cmdPrint('../../tiny-lldpd/tlldpd -d -i 1')

    CLI(net)

    for host in net.hosts:
        host.cmdPrint('killall tlldpd')

    net.stop()
    cleanup()
开发者ID:evelinad,项目名称:sdn-mpi,代码行数:17,代码来源:lldp_test.py


示例14: bwtest

def bwtest( cpuLimits, period_us=100000, seconds=10 ):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo( depth=1, fanout=2 )

    results = {}

    for sched in 'rt', 'cfs':
        info( '*** Testing with', sched, 'bandwidth limiting\n' )
        for cpu in cpuLimits:
            # cpu is the cpu fraction for all hosts, so we divide
            # it across two hosts
            host = custom( CPULimitedHost, sched=sched,
                           period_us=period_us,
                           cpu=.5*cpu )
            try:
                net = Mininet( topo=topo, host=host )
            # pylint: disable=bare-except
            except:
                info( '*** Skipping scheduler %s and cleaning up\n' % sched )
                cleanup()
                break
            net.start()
            net.pingAll()
            hosts = [ net.getNodeByName( h ) for h in topo.hosts() ]
            client, server = hosts[ 0 ], hosts[ -1 ]
            info( '*** Starting iperf with %d%% of CPU allocated to hosts\n' %
                  ( 100.0 * cpu ) )
            # We measure at the server because it doesn't include
            # the client's buffer fill rate
            popen = server.popen( 'iperf -yc -s -p 5001' )
            waitListening( client, server, 5001 )
            # ignore empty result from waitListening/telnet
            popen.stdout.readline()
            client.cmd( 'iperf -yc -t %s -c %s' % ( seconds, server.IP() ) )
            result = decode( popen.stdout.readline() ).split( ',' )
            bps = float( result[ -1 ] )
            popen.terminate()
            net.stop()
            updated = results.get( sched, [] )
            updated += [ ( cpu, bps ) ]
            results[ sched ] = updated

    return results
开发者ID:MatheusRagoso,项目名称:mininet,代码行数:45,代码来源:cpu.py


示例15: cleanup

def cleanup():
    """Cleanup all possible junk that we may have started."""
    log.setLogLevel('info')
    # Standard mininet cleanup
    mnclean.cleanup()
    # Cleanup any leftover daemon
    patterns = []
    for d in daemons.__all__:
        obj = getattr(daemons, d)
        killp = getattr(obj, 'KILL_PATTERNS', None)
        if not killp:
            continue
        if not is_container(killp):
            killp = [killp]
        patterns.extend(killp)
    log.info('*** Cleaning up daemons:\n')
    for pattern in patterns:
        mnclean.killprocs('"%s"' % pattern)
    log.info('\n')
开发者ID:oliviertilmans,项目名称:ipmininet,代码行数:19,代码来源:clean.py


示例16: multiPath

def multiPath():

    net = fatTree()

    info('*** Starting network\n')
    net.start()

    #info('*** Performing basic tests\n')
    #perfTest(net)

    #info("*** Configuring Flows")
    #flClient = StaticFlowPusher("127.0.0.1")

    info('*** Running CLI\n')
    CLI(net)

    info('*** Stopping network')
    net.stop()
    cleanup()
开发者ID:gzamboni,项目名称:sdnResilience,代码行数:19,代码来源:multipath.py


示例17: main

def main():
    lg.setLogLevel('info')

    context = Context()
    if not get_cmd_line_args(context):
        return

    print 'Starting with [%s] switches' % context.switch_number

    # Create the topology with the context args taken from the cmd-line
    myTopo = create_topology(context)

    # The network
    myNet = Mininet(myTopo)

    # The SDN-remote_controller connection
    mySDNController = myNet.addController(
        context.remote_controller_name,
        customConstructor({'remote': RemoteController},
                          context.remote_controller_args))
    myLocalController = myNet.addController('c1', controller=OVSController)
    myLocalController.start()

    dump_hosts(myNet)

    # This will output the nodes port connections to MININET_NET_FILE
    dumpNodeConnections(myNet.values())
    # This will output the nodes port connections to MININET_DUMP_FILE
    dumpNodes(myNet.values())

    # start_gateways(myNet)
    start_switches(context, myNet, mySDNController, myLocalController)

    # Insert ovs-ofctl rules
    print 'Inserting flows into the switches...'
    init_flows(context)

    # Start the command line
    CLI(myNet)

    cleanup()
开发者ID:CiscoDevNet,项目名称:iOAM,代码行数:41,代码来源:sfc-openflow-renderer_mininet.py


示例18: runTest

def runTest(file_name, controller, tdf, size, set_cpu, set_bw, set_delay="10us"):
    lg.setLogLevel( 'info' )
    if controller == "POX":
        controller = partial( RemoteController, ip = '127.0.0.1', port=6633 )
    else:
        controller = DefaultController
    link = partial( TCLink, bw=set_bw, delay=set_delay )

    """config host's cpu share and time dilation factor"""
    host = custom(CPULimitedHost, inNamespace=True,
                  sched='cfs', period_us=100000, cpu=set_cpu)

    """with w option, it automatically overwrite everytime"""
    data_file = open('%s.log' % file_name, 'w')
    print "Results are written to %s.log file" % file_name
    data_file.write("********* Running stringBandwidthTest *********\n")
    data_file.flush()

    # seems mininet cannot handle more than 640 switches
    print "******* Running with %d switches, TDF = %d *******" % (size, tdf)
    client_avg, client_stdev = stringBandwidthTest(host, controller, link,
                                                   size, tdf, data_file)
    cleanup()
    return client_avg, client_stdev
开发者ID:XianliangJ,项目名称:VirtualTimeKernel,代码行数:24,代码来源:vtmn_fidelity_tcp.py


示例19: runMPI

def runMPI():
    # Create network
    topo = TestTopo()
    net = Mininet(topo=topo, controller=lambda name: RemoteController(name, ip='127.0.0.1'), link=TCLink)
    # net = Mininet(topo=topo, controller=OVSController, link=TCLink)
    net.start()

    print "Dumping host connections"
    dumpNodeConnections(net.hosts)

    for host in net.hosts:
        host.cmdPrint('../../tiny-lldpd/tlldpd -d -i 1')

    sleep(5)

    print "Testing network connectivity"
    net.pingAll()

    # Launch sshd on each hosts and output host IPs to machinefile
    f = open('./machines', 'w')
    for h in net.hosts:
        h.cmd('/usr/sbin/sshd -o UseDNS=no -u0')
        f.write('%s\n' % h.IP())
    f.close()

    # Launch MPI application
    print "Starting MPI application:"
    print "----------------------------------------"
    net.hosts[0].cmdPrint('mpirun --machinefile ./machines ./mpitest');
    print "----------------------------------------"
    print "MPI application finished."

    net.hosts[0].cmdPrint('sudo killall -9 tlldpd')

    net.stop()
    cleanup()
开发者ID:evelinad,项目名称:sdn-mpi,代码行数:36,代码来源:virtual_cluster8.py


示例20: stringBandwidthTest

def stringBandwidthTest(host_class, controller_class,
                        link_class, size, tdf, data_file):
    "Check bandwidth at various lengths along a switch chain."
    topo_class = StringTestTopo(size)
    net = Mininet(topo=topo_class, host=host_class,
                  switch=OVSKernelSwitch, controller=controller_class,
                  waitConnected=False, link=link_class)
    net.start()

    if tdf != 1:
        net.dilateEmulation(tdf)
    
    print "*** testing basic connectivity\n"
    src, dst = net.hosts
    num_pings = 3
    for i in irange(1, num_pings):
        ping_result = list(net.pingFull( [ src, dst ] ))
        # ping_result=[(host1), (host2)]
        # host = (src, dst, data)
        # data = (#sent, #received, rttmin, rttavg, rttmax, rttdev)
        print "Ping avg rtt = %s\n" % ping_result[0][2][3]
        rttavg = ping_result[0][2][3]
    data_file.write( "RTT Avg = %s ms\n" % rttavg)

    print "*** testing bandwidth\n"
    num_rounds = 2
    client_history = []
    time = 10
    for i in irange(1, num_rounds):
        net.showDilation()
        bandwidth = net.iperf( [src, dst], l4Type = 'TCP',
                              fmt = 'm', seconds=time,
                              clifile=data_file, serfile=data_file )
        # bandwidth = net.iperf( [src, dst], l4Type = 'UDP',
                              # fmt = 'm', seconds=time,
                              # clifile=data_file, serfile=data_file )
        flush()
        net.showDilation()
 
        serout = bandwidth[0]
        cliout = bandwidth[1]

        if len(serout) > 0 and len(cliout) > 0:
            serDataStr, unit = serout.split(" ")
            serData = float(serDataStr)

            cliDataStr, unit = cliout.split(" ")
            cliData = float(cliDataStr)
            client_history.append(cliData)
            data_file.write("%s\t%f\t%s\t%s\n" % (size, tdf, serData, cliData))


    client_mean = numpy.mean(client_history)
    client_stdev = numpy.std(client_history)
    data_file.write( "Avg Throughtput = %f\n" % client_mean )
    data_file.write( "STD Throughput = %f\n" % client_stdev )
    print "AVG = %f " % client_mean
    print "STD = %f " % client_stdev
    data_file.write('\n\n')
    # CLI(net)

    net.stop()
    cleanup()
    return client_mean, client_stdev
开发者ID:XianliangJ,项目名称:VirtualTimeKernel,代码行数:64,代码来源:vtmn_fidelity_tcp.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python link.Link类代码示例发布时间:2022-05-27
下一篇:
Python minimock.restore函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap