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

Python log.debug函数代码示例

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

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



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


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


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


示例18: createUniqueFloodlightPropertiesFile

    def createUniqueFloodlightPropertiesFile(self):
        """
        Creates a unique properties file for the particular Floodlight instance.
        Each file is put in the 'properties' folder in the floodlight directory.
        Static class attributes keep track of the current port number to use.
        :return: None
        """

        # The path to the properties file to be copied and the name of the file
        old_path = Floodlight.fl_root_dir + 'src/main/resources/'
        old_file = 'floodlightdefault.properties'

        # The path where the new properties file will be located and the name of the file
        new_path = Floodlight.fl_root_dir + 'properties/'
        new_file = 'floodlight' + str(Floodlight.controller_number) + '.properties'

        # Set the instance attributes so that the instance can know where its associated properties file is
        self.properties_path = new_path
        self.properties_file = new_file

        # Check if the new path already exists. If not, then create it
        if not path.exists(new_path):
            makedirs(new_path)

        # Copy the old properties file to the new location with the new name
        shutil.copy(old_path + old_file,
                    new_path + new_file)

        # Open the new properties file and scan it for the ports that need to be changed
        with open(new_path + new_file) as fp:
            properties = jprops.load_properties(fp)

            http = [key for key, value in properties.items() if key.endswith('httpPort')][0]
            https = [key for key, value in properties.items() if key.endswith('httpsPort')][0]
            openflow = [key for key, value in properties.items() if key.endswith('openFlowPort')][0]
            syncmanager = [key for key, value in properties.items() if key.endswith('SyncManager.port')][0]

            properties[http] = str(Floodlight.http_port + 10)
            properties[https] = str(Floodlight.https_port + 10)
            properties[openflow] = str(Floodlight.openflow_port + 10)
            properties[syncmanager] = str(Floodlight.sync_manager_port + 10)

            # Update the class attributes so that everyone knows what ports are available now
            Floodlight.http_port += 10
            Floodlight.https_port += 10
            Floodlight.openflow_port += 10
            Floodlight.sync_manager_port += 10

            log.debug('Ports being used in controller ' + self.name + ' property file...\n')
            log.debug(http + ' = ' + properties[http] + '\n')
            log.debug(https + ' = ' + properties[https] + '\n')
            log.debug(openflow + ' = ' + properties[openflow] + '\n')
            log.debug(syncmanager + ' = ' + properties[syncmanager] + '\n')

        # Write the updated ports to the new properties file
        with open(new_path + new_file, 'w') as fp:
            # print 'Writing to file ' + new_file
            jprops.store_properties(fp, properties)
开发者ID:OpenFlow-Clemson,项目名称:EAGERProject,代码行数:58,代码来源:floodlight.py


示例19: config

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

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

        self.cmd('ip addr flush dev %s' % self.defaultIntf())
        for ip in self.ips:
            self.cmd('ip addr add %s dev %s' % (ip, self.defaultIntf()))

        self.cmd('ip route add default via %s' % self.gateway)
开发者ID:ckannan,项目名称:iSDX,代码行数:10,代码来源:sdnip.py


示例20: 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 != 'localhost' or node2.server != 'localhost'
     # And we can't ssh into this server remotely as 'localhost',
     # so try again swappping node1 and node2
     if node2.server == 'localhost':
         return self.makeTunnel( node2, node1, intfname2, intfname1,
                                 addr2, addr1 )
     # 1. Create tap interfaces
     for node in node1, node2:
         # For now we are hard-wiring tap9, which we will rename
         node.rcmd( 'ip link delete tap9', stderr=PIPE )
         cmd = 'ip tuntap add dev tap9 mode tap user ' + node.user
         node.rcmd( cmd )
         links = node.rcmd( 'ip link show' )
         # print 'after add, links =', links
         assert 'tap9' in links
     # 2. Create ssh tunnel between tap interfaces
     # -n: close stdin
     dest = '%[email protected]%s' % ( node2.user, node2.serverIP )
     cmd = [ 'ssh', '-n', '-o', 'Tunnel=Ethernet', '-w', '9:9',
             dest, 'echo @' ]
     self.cmd = cmd
     tunnel = node1.rpopen( cmd, sudo=False )
     # When we receive the character '@', it means that our
     # tunnel should be set up
     debug( 'Waiting for tunnel to come up...\n' )
     ch = tunnel.stdout.read( 1 )
     if ch != '@':
         error( 'makeTunnel:\n',
                'Tunnel setup failed for',
                '%s:%s' % ( node1, node1.dest ), 'to',
                '%s:%s\n' % ( node2, node2.dest ),
               'command was:', cmd, '\n' )
         tunnel.terminate()
         tunnel.wait()
         error( ch + tunnel.stdout.read() )
         error( tunnel.stderr.read() )
         sys.exit( 1 )
     # 3. Move interfaces if necessary
     for node in node1, node2:
         if node.inNamespace:
             retry( 3, .01, RemoteLink.moveIntf, 'tap9', node )
     # 4. Rename tap interfaces to desired names
     for node, intf, addr in ( ( node1, intfname1, addr1 ),
                         ( node2, intfname2, addr2 ) ):
         if not addr:
             node.cmd( 'ip link set tap9 name', intf )
         else:
             node.cmd( 'ip link set tap9 name', intf, 'address', addr )
     for node, intf in ( ( node1, intfname1 ), ( node2, intfname2 ) ):
         assert intf in node.cmd( 'ip link show' )
     return tunnel
开发者ID:hendrobeng2,项目名称:mininet,代码行数:55,代码来源:cluster.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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