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

Python log.info函数代码示例

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

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



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

示例1: bwtest

def bwtest(cpuLimits, period_us=100000, seconds=5):
    """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":
        print "*** Testing with", sched, "bandwidth limiting"
        for cpu in cpuLimits:
            host = custom(CPULimitedHost, sched=sched, period_us=period_us, cpu=cpu)
            try:
                net = Mininet(topo=topo, host=host)
            except:
                info("*** Skipping host %s\n" % sched)
                break
            net.start()
            net.pingAll()
            hosts = [net.getNodeByName(h) for h in topo.hosts()]
            client, server = hosts[0], hosts[-1]
            server.cmd("iperf -s -p 5001 &")
            waitListening(client, server, 5001)
            result = client.cmd("iperf -yc -t %s -c %s" % (seconds, server.IP())).split(",")
            bps = float(result[-1])
            server.cmdPrint("kill %iperf")
            net.stop()
            updated = results.get(sched, [])
            updated += [(cpu, bps)]
            results[sched] = updated

    return results
开发者ID:jplsegers,项目名称:SDN-TEST,代码行数:32,代码来源:cpu.py


示例2: start_oe

 def start_oe(self):
     '''
     start the existing LINC switch
     '''
     #starting Switch
     cmd = "linc:start_switch({}).\r\n".format(self.lincId)
     self.write_to_cli(cmd)
     #hanlding taps interfaces related to the switch
     crossConnectJSON = {}
     linkConfig = []
     for i in range(0,len(self.deletedCrossConnects)):
         crossConnect = self.deletedCrossConnects.pop()
         tap = None
         if isinstance(crossConnect.intf1.node, LINCSwitch):
             intf = crossConnect.intf2
             tapPort = crossConnect.intf1.port
         else:
             intf = crossConnect.intf1
             tapPort = crossConnect.intf2.port
         tap = LINCSwitch.findTap(self, tapPort)
         if tap:
             LINCSwitch.setupInts([tap])
             intf.node.attach(tap)
         self.crossConnects.append(crossConnect)
         linkConfig.append(crossConnect.json())
     #Sending crossConnect info to the ONOS.
     crossConnectJSON['links'] = linkConfig
     with open("crossConnect.json", 'w') as fd:
         json.dump(crossConnectJSON, fd, indent=4, separators=(',', ': '))
     info('*** Pushing crossConnect.json to ONOS\n')
     output = quietRun('%s/tools/test/bin/onos-topo-cfg %s\
      Topology.json' % (self.onosDir, self.controllers[ 0 ].ip), shell=True)
开发者ID:java66liu,项目名称:onos,代码行数:32,代码来源:opticalUtils.py


示例3: host3

def host3(net):
  info('Configuring host 3\n')
  host = net.getNodeByName('h3')
  host.setMAC('00:00:00:00:01:03')
  gw('LAN',host)
  #apagar = raw_input('Deseja zerar arquivos de log do IDS? sim|nao (um backup sera feito)\n')
  ids(host, 'sim')
开发者ID:gomex,项目名称:Of-IDPS,代码行数:7,代码来源:cenarioTesteLAN-WAN.py


示例4: sdnnet

def sdnnet(opt):
    topo = SDNTopo()
    info( '*** Creating network\n' )
    net = Mininet( topo=topo, controller=MyController, link=TCLink)

    host = []
    for i in range (8):
      host.append(net.get( 'host%d' % i ))

    net.start()

    core_sw = []
    for i in range (2):
        name_suffix = '%s' % NWID + '0c' + '%02d' % i
        net.get('sw' + name_suffix).attach('tap%s0' % NWID)

    for i in range (8):
        host[i].defaultIntf().setIP('192.168.10.10%d/24' % i) 

    root = []
    for i in range (8):
        root.append(net.get( 'root%d' % i ))

    for i in range (8):
        host[i].intf('host%d-eth1' % i).setIP('1.1.%d.1/24' % i)
        root[i].intf('root%d-eth0' % i).setIP('1.1.%d.2/24' % i)

    stopsshd ()
    startsshds ( host )

    if opt=="cli":
        CLI(net)
        stopsshd()
        net.stop()
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:34,代码来源:fat_tree.py


示例5: sdnTopo

def sdnTopo(interface_name):

    CONTROLLER_IP='10.0.0.200'

    net = Mininet( topo=None, build=False)

    # Create nodes
    h1 = net.addHost( 'h1', ip='10.0.0.1/8' )
    h2 = net.addHost( 'h2', ip='10.0.0.2/8' )

    # Create switches
    s1 = net.addSwitch( 's1')

    net.addLink(h1, s1, )
    net.addLink(h2, s1, )

    # Add Controllers
    odl_ctrl = net.addController( 'c0', controller=RemoteController, ip=CONTROLLER_IP)


    info( "*** Creation de l'architecture réseau\n" )
    net.build()

    # Connect each switch to a different controller
    s1.start( [odl_ctrl] )


    info( "*** Ajout de l'interface",interface_name,"au switch" )
    _intf = Intf( interface_name, node=s1)
    net.start()
    CLI( net )
    net.stop()
开发者ID:LeGaulois,项目名称:pox_nac,代码行数:32,代码来源:sdn.py


示例6: run

 def run(self, test, *args, **kwargs):
     "Perform a complete start/test/stop cycle."
     self.start()
     info("*** Running test\n")
     result = test(*args, **kwargs)
     self.stop()
     return result
开发者ID:ruifcardoso,项目名称:mininet,代码行数:7,代码来源:net.py


示例7: __init__

 def __init__( self, mininet, stdin=sys.stdin, script=None ):
     self.mn = mininet
     self.nodelist = self.mn.controllers + self.mn.switches + self.mn.hosts
     self.nodemap = {}  # map names to Node objects
     for node in self.nodelist:
         self.nodemap[ node.name ] = node
     # Attempt to handle input
     self.stdin = stdin
     self.inPoller = poll()
     self.inPoller.register( stdin )
     self.inputFile = script
     Cmd.__init__( self )
     info( '*** Starting CLI:\n' )
     if self.inputFile:
         self.do_source( self.inputFile )
         return
     while True:
         try:
             # Make sure no nodes are still waiting
             for node in self.nodelist:
                 while node.waiting:
                     node.sendInt()
                     node.monitor()
             if self.isatty():
                 quietRun( 'stty sane' )
             self.cmdloop()
             break
         except KeyboardInterrupt:
             output( '\nInterrupt\n' )
开发者ID:sandeephebbani,项目名称:mininet,代码行数:29,代码来源:cli.py


示例8: run

  def run (self):
    setLogLevel("info")
    OVSKernelSwitch.setup()#"Make sure Open vSwitch is installed and working"

    info("****creating network****\n")
    self.net = Mininet(listenPort = 6666)

    controller = RemoteController("mirrorController",   ip = "127.0.0.1")
    self.net.addController(controller)
    while core.running:
      try:
        time.sleep(3)
        if not core.running: break
        '''
        self.net.pingAll()
        if len(self.addswitches)!=0:
          for i in self.addswitches:
            print self.addswitches[i].dpctl('show')
        '''
        if self.rectopolyreply==1:
          mutex.acquire()
          self.createtoptly()
          self.rectopolyreply=0
          mutex.release()
      except exceptions.KeyboardInterrupt:
        break
      except:
        log.exception("Exception SendMes running ")
        break
    self.net.stop()
开发者ID:iiisthu,项目名称:MMD-pro,代码行数:30,代码来源:SendMessage.py


示例9: waitListening

def waitListening( client=None, server='127.0.0.1', port=80, timeout=None ):
    """Wait until server is listening on port.
       returns True if server is listening"""
    runCmd = ( client.cmd if client else
               partial( quietRun, shell=True ) )
    if not runCmd( 'which telnet' ):
        raise Exception('Could not find telnet' )
    # pylint: disable=maybe-no-member
    serverIP = server if isinstance( server, basestring ) else server.IP()
    cmd = ( 'echo A | telnet -e A %s %s' % ( serverIP, port ) )
    time = 0
    result = runCmd( cmd )
    while 'Connected' not in result:
        if 'No route' in result:
            rtable = runCmd( 'route' )
            error( 'no route to %s:\n%s' % ( server, rtable ) )
            return False
        if timeout and time >= timeout:
            error( 'could not connect to %s on port %d\n' % ( server, port ) )
            return False
        debug( 'waiting for', server, 'to listen on port', port, '\n' )
        info( '.' )
        sleep( .5 )
        time += .5
        result = runCmd( cmd )
    return True
开发者ID:NvanAdrichem,项目名称:mininet,代码行数:26,代码来源:util.py


示例10: test_ping_with_background_traffice

def test_ping_with_background_traffice(network, round_count=1, round_duration=5, ping_interval=1.0, background=True):
    """
    h1 执行 ping 测试延时
    h2 执行 netperf 测试带宽利用率
    :param background:
    :param network: mininet class
    :param round_count:    循环次数
    :param round_duration: 循环时间每轮
    :param ping_interval:  ping包采样间隔
    :return:
    """
    result = ""
    h1 = network.get("h1")
    popens = {}
    if background:  # backgroud traffice, 每轮增加10秒时延
        h1.cmd("netperf -H h3 -l %s &" % (round_count * (round_duration + 5)))
    sleep(3)  # wait 2 second to reach tcp max output
    for r in range(round_count):
        print ("*** ROUND %s" % r)
        for h in [h1]:
            ping_cmd = "ping -c%s -i%s h3 " % (int(round_duration / ping_interval), ping_interval)
            info("<%s>: popen cmd: %s \n" % (h.name, ping_cmd))
            popens[h] = h.popen(ping_cmd)

        # Monitor them and print output
        for host, line in pmonitor(popens):
            if host:
                if line.find("icmp_seq") != -1:
                    debug("<%s>: %s\n" % (host.name, line.strip()))  # suppressed ping output to debug level
                else:
                    info("<%s>: %s\n" % (host.name, line.strip()))
                    result += "<%s>: %s\n" % (host.name, line.strip())

    debug("\n".join(os.popen('tc -s -d qdisc show dev s1-eth3').readlines()))
    return result
开发者ID:chenzheng128,项目名称:ArsenalPython,代码行数:35,代码来源:ecn_test_case.py


示例11: test01_04_ecn_red

def test01_04_ecn_red(network, bw=10, latency=50, qlen=200, duration=10):
    """

    测试结果记录在 ecn_result/2016-06-28_ecn_red.txt

    # 设置 使用 red ecn 以及不使用, 并使用 mesure_delay_and_output() 测试
    :param network:
    :param bw:          # 10Mbps 带宽
    :param latency:     # 50ms 延时
    :param qlen:        # 队列长度
    :param duration:    # 运行时间
    :return:
    """
    # print_mininet_objs(net)
    result_all = {}

    # result_all dict 追加入01 结果
    result_all.update(test01_base(network, "TEST01", bw=bw, latency=latency, qlen=qlen, duration=duration))

    # result_all dict 追加入03 04 05 结果
    for testname, redminmax in zip(["TEST02", "TEST03", "TEST04"],
                                   ["min 50000  max  150000 avpkt 1500",
                                    "min 65000  max  150000 avpkt 1500",
                                    "min 75000  max  150000 avpkt 1500"
                                    ]):
        # result_all = result1.copy()
        # if testname == "TEST02": continue
        result_all.update(
            test02_04_base_ecn_red(network, testname, redminmax, bw=bw, latency=latency, qlen=qlen, duration=duration))

    info("\n\n\n*** all result here ***\n\n\b")
    ecn_util.dump_result(result_all)
    return result_all
开发者ID:chenzheng128,项目名称:ArsenalPython,代码行数:33,代码来源:ecn_test_case.py


示例12: test02_04_base_ecn_red

def test02_04_base_ecn_red(network, testname, redminmax, bw=10, latency=50, qlen=200, duration=10):
    """
    独立复制出的 03 04 实验, 用于enc抓包测试
    :param redminmax:      # red参数设置
    :param testname:       # 测试名称
    :param network:
    :param bw:
    :param latency:
    :param qlen:
    :param duration:
    :return:
    """

    result = {}

    def run_this_bench():
        return ecn_util.mesure_ping_and_netperf(network, round_count=1, round_duration=duration, ping_interval=0.1)

    # ecn 参数变化测试 02 03 04
    testfullname = "%s ECN:%s qlen:%s bw:%sMbps lat:%sms redminmax:%s" % (
        testname, True, qlen, bw, latency, redminmax)
    info("*** setup %s \n" % testfullname)
    test01_06_setup_queue_and_latency(network, ecn=True, bw=bw, queue_len=qlen, latency=latency,
                                      redminmax=redminmax)
    info("*** running %s ...\n" % testfullname)
    result[testfullname] = run_this_bench()

    ecn_util.dump_result(result)
    return result
开发者ID:chenzheng128,项目名称:ArsenalPython,代码行数:29,代码来源:ecn_test_case.py


示例13: test01_base

def test01_base(network, testname, bw=10, latency=50, qlen=200, duration=10):
    """
    # 设置 使用 red ecn 以及不使用, 并使用 mesure_delay_and_output() 测试
    :param testname:    # 测试名称
    :param network:
    :param bw:          # 10Mbps 带宽
    :param latency:     # 50ms 延时
    :param qlen:        # 队列长度
    :param duration:    # 运行时间
    :return:
    """
    # print_mininet_objs(net)
    result = {}
    red_ecn = False

    def run_this_bench():
        return ecn_util.mesure_ping_and_netperf(network, round_count=1, round_duration=duration, ping_interval=0.1)

    # 无ecn测试 TEST01
    default_minmax = ""
    testfullname = "%s ECN:%s qlen:%s bw:%sMbps lat:%sms no red:%s" % (
        testname, red_ecn, qlen, bw, latency, "")
    info("*** setup %s\n" % testfullname)
    test01_06_setup_queue_and_latency(network, ecn=red_ecn, bw=bw, queue_len=qlen, latency=latency,
                                      redminmax=default_minmax)
    info("*** running %s ...\n" % testfullname)
    result[testfullname] = run_this_bench()

    ecn_util.dump_result(result)
    return result
开发者ID:chenzheng128,项目名称:ArsenalPython,代码行数:30,代码来源:ecn_test_case.py


示例14: assign_iface

 def assign_iface(cls, nodes, phys, **params):
     """Assign virtual interfaces for all nodes
     
     :param nodes: list of wireless nodes
     :param phys: list of phys
     :param **params: ifb -  Intermediate Functional Block device"""
     log_filename = '/tmp/mininetwifi-fakelb.log'
     cls.logging_to_file("%s" % log_filename)
     try:
         debug("\n*** Configuring interfaces with appropriated network"
               "-namespaces...\n")
         for node in nodes:
             for wlan in range(0, len(node.params['wpan'])):
                 node.wpanPhyID[wlan] = cls.wpanPhyID
                 cls.wpanPhyID += 1
                 phy = cls.getPhy(phys[0])
                 os.system('iwpan phy phy%s set netns %s' % (phy, node.pid))
                 node.cmd('ip link set %s down' % cls.wlan_list[0])
                 node.cmd('ip link set %s name %s'
                          % (cls.wlan_list[0], node.params['wpan'][wlan]))
                 cls.wlan_list.pop(0)
     except:
         logging.exception("Warning:")
         info("Warning! Error when loading fakelb. "
              "Please run sudo 'mn -c' before running your code.\n")
         info("Further information available at %s.\n" % log_filename)
         exit(1)
开发者ID:intrig-unicamp,项目名称:mininet-wifi,代码行数:27,代码来源:module.py


示例15: moduleDeps

def moduleDeps( subtract=None, add=None ):
    """Handle module dependencies.
       subtract: string or list of module names to remove, if already loaded
       add: string or list of module names to add, if not already loaded"""
    subtract = subtract if subtract is not None else []
    add = add if add is not None else []
    if type( subtract ) is str:
        subtract = [ subtract ]
    if type( add ) is str:
        add = [ add ]
    for mod in subtract:
        if mod in lsmod():
            info( '*** Removing ' + mod + '\n' )
            rmmodOutput = rmmod( mod )
            if rmmodOutput:
                error( 'Error removing ' + mod + ': "%s">\n' % rmmodOutput )
                exit( 1 )
            if mod in lsmod():
                error( 'Failed to remove ' + mod + '; still there!\n' )
                exit( 1 )
    for mod in add:
        if mod not in lsmod():
            info( '*** Loading ' + mod + '\n' )
            modprobeOutput = modprobe( mod )
            if modprobeOutput:
                error( 'Error inserting ' + mod +
                       ' - is it installed and available via modprobe?\n' +
                       'Error was: "%s"\n' % modprobeOutput )
            if mod not in lsmod():
                error( 'Failed to insert ' + mod + ' - quitting.\n' )
                exit( 1 )
        else:
            debug( '*** ' + mod + ' already loaded\n' )
开发者ID:aimonb,项目名称:miniNeXT,代码行数:33,代码来源:moduledeps.py


示例16: errRun

def errRun( *cmd, **kwargs ):
    """Run a command and return stdout, stderr and return code
       cmd: string or list of command and args
       stderr: STDOUT to merge stderr with stdout
       shell: run command using shell
       echo: monitor output to console"""
    # By default we separate stderr, don't run in a shell, and don't echo
    stderr = kwargs.get( 'stderr', PIPE )
    shell = kwargs.get( 'shell', False )
    echo = kwargs.get( 'echo', False )
    if echo:
        # cmd goes to stderr, output goes to stdout
        info( cmd, '\n' )
    if len( cmd ) == 1:
        cmd = cmd[ 0 ]
    # Allow passing in a list or a string
    if isinstance( cmd, str ) and not shell:
        cmd = cmd.split( ' ' )
        cmd = [ str( arg ) for arg in cmd ]
    elif isinstance( cmd, list ) and shell:
        cmd = " ".join( arg for arg in cmd )
    debug( '*** errRun:', cmd, '\n' )
    popen = Popen( cmd, stdout=PIPE, stderr=stderr, shell=shell )
    # We use poll() because select() doesn't work with large fd numbers,
    # and thus communicate() doesn't work either
    out, err = '', ''
    poller = poll()
    poller.register( popen.stdout, POLLIN )
    fdtofile = { popen.stdout.fileno(): popen.stdout }
    outDone, errDone = False, True
    if popen.stderr:
        fdtofile[ popen.stderr.fileno() ] = popen.stderr
        poller.register( popen.stderr, POLLIN )
        errDone = False
    while not outDone or not errDone:
        readable = poller.poll()
        for fd, event in readable:
            f = fdtofile[ fd ]
            if event & POLLIN:
                data = f.read( 1024 )
                if echo:
                    output( data )
                if f == popen.stdout:
                    out += data
                    if data == '':
                        outDone = True
                elif f == popen.stderr:
                    err += data
                    if data == '':
                        errDone = True
            else:  # POLLHUP or something unexpected
                if f == popen.stdout:
                    outDone = True
                elif f == popen.stderr:
                    errDone = True
                poller.unregister( fd )

    returncode = popen.wait()
    debug( out, err, returncode )
    return out, err, returncode
开发者ID:NvanAdrichem,项目名称:mininet,代码行数:60,代码来源:util.py


示例17: __init__

 def __init__( self, mininet, stdin=sys.stdin, script=None ):
     self.mn = mininet
     # Local variable bindings for py command
     self.locals = { 'net': mininet }
     # Attempt to handle input
     self.stdin = stdin
     self.inPoller = poll()
     self.inPoller.register( stdin )
     self.inputFile = script
     Cmd.__init__( self )
     info( '*** Starting CLI:\n' )
     if self.inputFile:
         self.do_source( self.inputFile )
         return
     while True:
         try:
             # Make sure no nodes are still waiting
             for node in self.mn.values():
                 while node.waiting:
                     node.sendInt()
                     node.monitor()
             if self.isatty():
                 quietRun( 'stty sane' )
             self.cmdloop()
             break
         except KeyboardInterrupt:
             output( '\nInterrupt\n' )
开发者ID:FlowForwarding,项目名称:mininet,代码行数:27,代码来源:cli.py


示例18: startTerms

 def startTerms( self ):
     "Start a terminal for each node."
     info( "*** Running terms on %s\n" % os.environ[ 'DISPLAY' ] )
     cleanUpScreens()
     self.terms += makeTerms( self.controllers, 'controller' )
     self.terms += makeTerms( self.switches, 'switch' )
     self.terms += makeTerms( self.hosts, 'host' )
开发者ID:arjunkrishnapr,项目名称:mininet,代码行数:7,代码来源:net.py


示例19: runCpuLimitTest

 def runCpuLimitTest(self, cpu, duration=5):
     """run CPU limit test with 'while true' processes.
     cpu: desired CPU fraction of each host
     duration: test duration in seconds
     returns a single list of measured CPU fractions as floats.
     """
     pct = cpu * 100
     info("*** Testing CPU %.0f%% bandwidth limit\n" % pct)
     hosts = self.hosts
     for h in hosts:
         h.cmd("while true; do a=1; done &")
     pids = [h.cmd("echo $!").strip() for h in hosts]
     pids_str = ",".join(["%s" % pid for pid in pids])
     cmd = "ps -p %s -o pid,%%cpu,args" % pids_str
     # It's a shame that this is what pylint prefers
     outputs = []
     for _ in range(duration):
         sleep(1)
         outputs.append(quietRun(cmd).strip())
     for h in hosts:
         h.cmd("kill $!")
     cpu_fractions = []
     for test_output in outputs:
         # Split by line.  Ignore first line, which looks like this:
         # PID %CPU COMMAND\n
         for line in test_output.split("\n")[1:]:
             r = r"\d+\s*(\d+\.\d+)"
             m = re.search(r, line)
             if m is None:
                 error("*** Error: could not extract CPU fraction: %s\n" % line)
                 return None
             cpu_fractions.append(float(m.group(1)))
     output("*** Results: %s\n" % cpu_fractions)
     return cpu_fractions
开发者ID:ruifcardoso,项目名称:mininet,代码行数:34,代码来源:net.py


示例20: emptyNet

def emptyNet() :
        l=[int(i) for i in raw_input().split()]
        X=l[0]
        Y=l[1]
        net=Mininet(controller=Controller,link=TCLink)
        net.addController('c0')
        info('Adding Switches\n')
        S=[]
        for i in range(Y) :
                switchname='S'+str(i)
                S.append(net.addSwitch(switchname))
        k=0
        H=[]
        info('Adding Hosts\n')
	 for i in range(Y) :
                for j in range(X) :
                        if k%2 == 0 :
                                hostname='H'+str(k)
                                ipaddr='10.0.0.'+str(k+1)+'/24'
                                H.append(net.addHost(hostname,ip=ipaddr))        
                        else :
                                hostname='H'+str(k)
                                ipaddr='10.0.1.'+str(k+1)+'/24'
                                H.append(net.addHost(hostname,ip=ipaddr))
                        k=k+1
开发者ID:VikneshwarE,项目名称:201405610_cloud_assignments,代码行数:25,代码来源:mymininet.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python log.output函数代码示例发布时间:2022-05-27
下一篇:
Python log.error函数代码示例发布时间: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