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


Python log.debug函数代码示例

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


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

示例1: __init__

    def __init__(self, tcpdump_host, tcpdump_filter, funcs=None,
                 vflags='-v', timeout=10, packets=2, root_intf=False,
                 pcap_out=None, intf_name=None, blocking=True):
        self.intf_name = intf_name if intf_name else tcpdump_host.intf().name
        self.funcs = funcs
        if root_intf:
            self.intf_name = self.intf_name.split('.')[0]

        tcpdump_flags = vflags
        tcpdump_flags += ' -c %u' % packets if packets else ''
        tcpdump_flags += ' -w %s' % pcap_out if pcap_out else ''
        tcpdump_cmd = 'tcpdump -i %s %s -e -n -U %s' % (
            self.intf_name, tcpdump_flags, tcpdump_filter)
        pipe_cmd = tcpdump_cmd
        if timeout:
            pipe_cmd = mininet_test_util.timeout_soft_cmd(tcpdump_cmd, timeout)

        debug(pipe_cmd)
        self.pipe = tcpdump_host.popen(
            pipe_cmd,
            stdin=mininet_test_util.DEVNULL,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            close_fds=True,
            shell=False)

        if self.stream():
            debug('tcpdump_helper stream fd %s %s' % (
                self.stream().fileno(), self.intf_name))

        self.readbuf = ''
        self.set_blocking(blocking)
开发者ID:anarkiwi,项目名称:faucet,代码行数:32,代码来源:tcpdump_helper.py

示例2: addNodeLoopbackIntf

 def addNodeLoopbackIntf(self, loIntf, loNum):
     """Adds a loopback interface (called on instantiation an interface).
        loIntf: loopback interface."""
     self.nameToIntf[loIntf.name] = loIntf
     self.loIntfs[loIntf.name] = loNum
     debug('\n')
     debug('added intf %s to node %s\n' % (loIntf, self.name))
开发者ID:USC-NSL,项目名称:miniNExT,代码行数:7,代码来源:node.py

示例3: load_ifb

 def load_ifb(cls, wlans):
     """ Loads IFB
     
     :param wlans: Number of wireless interfaces
     """
     debug('\nLoading IFB: modprobe ifb numifbs=%s' % wlans)
     os.system('modprobe ifb numifbs=%s' % wlans)
开发者ID:intrig-unicamp,项目名称:mininet-wifi,代码行数:7,代码来源:module.py

示例4: config

    def config(self, **kwargs):
        Host.config(self, **kwargs)

        debug("configuring route %s" % self.route)

        self.cmd('ip addr add %s dev %s-eth0' % (self.ip, self.name))
        self.cmd('ip route add default via %s' % self.route)
开发者ID:CrazyCooper,项目名称:onos,代码行数:7,代码来源:tutorial_ipv6.py

示例5: waitListening

def waitListening( client=None, server='127.0.0.1', port=80, timeout=None,
                   callback=None, sleepSecs=.5 ):
    "Modified mininet.util.waitListening with callback, sleepSecs"
    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 ) )
    elapsed = 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 elapsed >= 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( '.' )
        if callback:
            callback()
        time.sleep( sleepSecs )
        elapsed += sleepSecs
        result = runCmd( cmd )
    return True
开发者ID:maheshraju-Huawei,项目名称:actn,代码行数:28,代码来源:onos.py

示例6: 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

示例7: load_module

    def load_module(cls, n_radios, nodes, alt_module, **params):
        """Load WiFi Module
        :param n_radios: number of wifi radios
        :param alt_module: dir of a mac80211_hwsim alternative module"""
        debug('Loading %s virtual wifi interfaces\n' % n_radios)
        if not cls.externally_managed:
            if alt_module:
                output_ = os.system('insmod %s radios=0 >/dev/null 2>&1'
                                    % alt_module)
            else:
                output_ = os.system('modprobe mac80211_hwsim radios=0 '
                                    '>/dev/null 2>&1')

            """output_ is different of zero in Kernel 3.13.x. radios=0 doesn't
             work in such kernel version"""
            if output_ == 0:
                cls.__create_hwsim_mgmt_devices(n_radios, nodes, **params)
            else:
                # Useful for kernel <= 3.13.x
                if n_radios == 0:
                    n_radios = 1
                if alt_module:
                    os.system('insmod %s radios=%s' % (alt_module,
                                                       n_radios))
                else:
                    os.system('modprobe mac80211_hwsim radios=%s' % n_radios)
        else:
            cls.devices_created_dynamically = True
            cls.__create_hwsim_mgmt_devices(n_radios, nodes, **params)
开发者ID:intrig-unicamp,项目名称:mininet-wifi,代码行数:29,代码来源:module.py

示例8: 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

示例9: start

    def start(self, controllers):
        "Start up a new P4 switch"
        info("Starting P4 switch {}.\n".format(self.name))
        args = [self.sw_path]
        for port, intf in self.intfs.items():
            if not intf.IP():
                args.extend(['-i', str(port) + "@" + intf.name])
        if self.pcap_dump:
            args.append("--pcap")
            # args.append("--useFiles")
        if self.thrift_port:
            args.extend(['--thrift-port', str(self.thrift_port)])
        if self.nanomsg:
            args.extend(['--nanolog', self.nanomsg])
        args.extend(['--device-id', str(self.device_id)])
        P4Switch.device_id += 1
        args.append(self.json_path)
        if self.enable_debugger:
            args.append("--debugger")
        if self.log_console:
            args.append("--log-console")
        logfile = "/tmp/p4s.{}.log".format(self.name)
        info(' '.join(args) + "\n")

        pid = None
        with tempfile.NamedTemporaryFile() as f:
            # self.cmd(' '.join(args) + ' > /dev/null 2>&1 &')
            self.cmd(' '.join(args) + ' >' + logfile + ' 2>&1 & echo $! >> ' + f.name)
            pid = int(f.read())
        debug("P4 switch {} PID is {}.\n".format(self.name, pid))
        if not self.check_switch_started(pid):
            error("P4 switch {} did not start correctly.\n".format(self.name))
            exit(1)
        info("P4 switch {} has been started.\n".format(self.name))
开发者ID:wysamuel,项目名称:behavioral-model,代码行数:34,代码来源:p4_mininet.py

示例10: precheck

 def precheck( self ):
     """Pre-check to make sure connection works and that
        we can call sudo without a password"""
     result = 0
     info( '*** Checking servers\n' )
     for server in self.servers:
         ip = self.serverIP[ server ]
         if not server or server == 'localhost':
             continue
         info( server, '' )
         dest = '%[email protected]%s' % ( self.user, ip )
         cmd = [ 'sudo', '-E', '-u', self.user ]
         cmd += self.sshcmd + [ '-n', dest, 'sudo true' ]
         debug( ' '.join( cmd ), '\n' )
         _out, _err, code = errRun( cmd )
         if code != 0:
             error( '\nstartConnection: server connection check failed '
                    'to %s using command:\n%s\n'
                     % ( server, ' '.join( cmd ) ) )
         result |= code
     if result:
         error( '*** Server precheck failed.\n'
                '*** Make sure that the above ssh command works'
                ' correctly.\n'
                '*** You may also need to run mn -c on all nodes, and/or\n'
                '*** use sudo -E.\n' )
         sys.exit( 1 )
     info( '\n' )
开发者ID:xiaozhou,项目名称:mininet,代码行数:28,代码来源:cluster.py

示例11: do_arp

 def do_arp( self, line ):
     "Send gratuitous arps from all data network hosts"
     startTime = time.time()
     try:
         count = int( line )
     except:
         count = 1
     # Technically this check should be on the host
     if '-U' not in quietRun( 'arping -h', shell=True ):
         warn( 'Please install iputils-arping.\n' )
         return
     # This is much faster if we do it in parallel
     for host in self.mn.net.hosts:
         intf = host.defaultIntf()
         # -b: keep using broadcasts; -f: quit after 1 reply
         # -U: gratuitous ARP update
         host.sendCmd( 'arping -bf -c', count, '-U -I',
                        intf.name, intf.IP() )
     for host in self.mn.net.hosts:
         # We could check the output here if desired
         host.waitOutput()
         info( '.' )
     info( '\n' )
     elapsed = time.time() - startTime
     debug( 'Completed in %.2f seconds\n' % elapsed )
开发者ID:Shashikanth-Huawei,项目名称:bmp,代码行数:25,代码来源:onos.py

示例12: _popen

 def _popen( self, cmd, sudo=True, tt=True, **params):
     """Spawn a process on a remote node
         cmd: remote command to run (list)
         **params: parameters to Popen()
         returns: Popen() object"""
     if type( cmd ) is str:
         cmd = cmd.split()
     if self.isRemote:
         if sudo:
             cmd = [ 'sudo', '-E' ] + cmd
         if tt:
             cmd = self.sshcmd + cmd
         else:
             # Hack: remove -tt
             sshcmd = list( self.sshcmd )
             sshcmd.remove( '-tt' )
             cmd = sshcmd + cmd
     else:
         if self.user and not sudo:
             # Drop privileges
             cmd = [ 'sudo', '-E', '-u', self.user ] + cmd
     params.update( preexec_fn=self._ignoreSignal )
     debug( '_popen', cmd, '\n' )
     popen = super( RemoteMixin, self )._popen( cmd, **params )
     return popen
开发者ID:xiaozhou,项目名称:mininet,代码行数:25,代码来源:cluster.py

示例13: makeTunnel

    def makeTunnel(self, node1, node2, intfname1, intfname2,
                       addr1=None, addr2=None):
        "Make a tunnel across switches on different servers"
        # We should never try to create a tunnel to ourselves!
        assert node1.server != node2.server
        if node2.server == 'localhost':
            return self.makeTunnel( node2, node1, intfname2, intfname1,
                                    addr2, addr1 )
        IP1, IP2 = node1.serverIP, node2.serverIP
        # GRE tunnel needs to be set up with the IP of the local interface
        # that connects the remote node, NOT '127.0.0.1' of localhost
        if node1.server == 'localhost':
            output = quietRun('ip route get %s' % node2.serverIP)
            IP1 = output.split(' src ')[1].split()[0]
        debug( '\n*** Make GRE tunnel ' + node1.server + ':' + intfname1 +
               ' == ' + node2.server + ':' + intfname2 )
        tun1 = 'local ' + IP1 + ' remote ' + IP2
        tun2 = 'local ' + IP2 + ' remote ' + IP1
        self.__class__.GRE_KEY += 1
        for (node, intfname, addr, tun) in [(node1, intfname1, addr1, tun1),
                                            (node2, intfname2, addr2, tun2)]:
            node.rcmd('ip link delete ' + intfname)
            result = node.rcmd('ip link add name ' + intfname + ' type gretap '
                               + tun + ' ttl 64 key '
                               + str( self.__class__.GRE_KEY) )
            if result:
                raise Exception('error creating gretap on %s: %s'
                                % (node, result))
            if addr:
                node.rcmd('ip link set %s address %s' % (intfname, addr))

            node.rcmd('ip link set dev %s up' % intfname)
            node.rcmd('ip link set dev %s mtu 1450' % intfname)
            if not self.moveIntf(intfname, node):
                raise Exception('interface move failed on node %s' % node)
开发者ID:MatheusRagoso,项目名称:mininet,代码行数:35,代码来源:cluster.py

示例14: fixLimits

def fixLimits():
    "Fix ridiculously small resource limits."
    debug( "*** Setting resource limits\n" )
    try:
        rlimitTestAndSet( RLIMIT_NPROC, 8192 )
        rlimitTestAndSet( RLIMIT_NOFILE, 16384 )
        #Increase open file limit
        sysctlTestAndSet( 'fs.file-max', 10000 )
        #Increase network buffer space
        sysctlTestAndSet( 'net.core.wmem_max', 16777216 )
        sysctlTestAndSet( 'net.core.rmem_max', 16777216 )
        sysctlTestAndSet( 'net.ipv4.tcp_rmem', '10240 87380 16777216' )
        sysctlTestAndSet( 'net.ipv4.tcp_wmem', '10240 87380 16777216' )
        sysctlTestAndSet( 'net.core.netdev_max_backlog', 5000 )
        #Increase arp cache size
        sysctlTestAndSet( 'net.ipv4.neigh.default.gc_thresh1', 4096 )
        sysctlTestAndSet( 'net.ipv4.neigh.default.gc_thresh2', 8192 )
        sysctlTestAndSet( 'net.ipv4.neigh.default.gc_thresh3', 16384 )
        #Increase routing table size
        sysctlTestAndSet( 'net.ipv4.route.max_size', 32768 )
        #Increase number of PTYs for nodes
        sysctlTestAndSet( 'kernel.pty.max', 20000 )
    except:
        warn( "*** Error setting resource limits. "
              "Mininet's performance may be affected.\n" )
开发者ID:Mo-hammad,项目名称:mininet,代码行数:25,代码来源:util.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


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