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


Python log.error函数代码示例

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


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

示例1: startShell

 def startShell( self ):
     "Start a shell process for running commands"
     if self.shell:
         error( "%s: shell is already running" )
         return
     # mnexec: (c)lose descriptors, (d)etach from tty,
     # (p)rint pid, and run in (n)amespace
     opts = '-cdp'
     if self.inNamespace:
         opts += 'n'
     # bash -m: enable job control
     cmd = [ 'mnexec', opts, 'bash', '-m' ]
     self.shell = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
                         close_fds=True )
     self.stdin = self.shell.stdin
     self.stdout = self.shell.stdout
     self.pid = self.shell.pid
     self.pollOut = select.poll()
     self.pollOut.register( self.stdout )
     # Maintain mapping between file descriptors and nodes
     # This is useful for monitoring multiple nodes
     # using select.poll()
     self.outToNode[ self.stdout.fileno() ] = self
     self.inToNode[ self.stdin.fileno() ] = self
     self.execed = False
     self.lastCmd = None
     self.lastPid = None
     self.readbuf = ''
     self.waiting = False
开发者ID:RimHaw,项目名称:mn-ccnx,代码行数:29,代码来源:node.py

示例2: startShell

    def startShell( self ):
        if self.shell:
            error( "%s: shell is already running" )
            return
        subprocess.call(["docker stop "+self.name], shell=True, stdout=output)
        subprocess.call(["docker rm -f "+self.name], shell=True, stdout=output)

        cmd = ["docker","run","--privileged","-h",self.name ,"--name="+self.name,"-v", "/vagrant:/home/ubuntu"]
        if self.dargs is not None:
            cmd.extend([self.dargs])
        cmd.extend(["--net='none'",self.image, self.startString])

        self.shell = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True )
        self.stdin = self.shell.stdin
        self.stdout = self.shell.stdout
        self.pid = self.shell.pid
        self.pollOut = select.poll()
        self.pollOut.register( self.stdout )
        self.outToNode[ self.stdout.fileno() ] = self
        self.inToNode[ self.stdin.fileno() ] = self
        self.execed = False
        self.lastCmd = None
        self.lastPid = None
        self.readbuf = ''
        self.waiting = False
        call("sleep 1", shell=True)
        pid_cmd = ["docker","inspect","--format='{{ .State.Pid }}'",""+self.name]
        pidp = Popen( pid_cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=False )
        ps_out = pidp.stdout.readlines()
        self.pid = int(ps_out[0])
开发者ID:thomasameisel,项目名称:cloud-computing,代码行数:30,代码来源:networking_application.py

示例3: configureRoutedControlNetwork

 def configureRoutedControlNetwork(self, ip="192.168.123.1", prefixLen=16):
     """Configure a routed control network on controller and switches.
        For use with the user datapath only right now."""
     controller = self.controllers[0]
     info(controller.name + " <->")
     cip = ip
     snum = ipParse(ip)
     for switch in self.switches:
         info(" " + switch.name)
         link = self.link(switch, controller, port1=0)
         sintf, cintf = link.intf1, link.intf2
         switch.controlIntf = sintf
         snum += 1
         while snum & 0xFF in [0, 255]:
             snum += 1
         sip = ipStr(snum)
         cintf.setIP(cip, prefixLen)
         sintf.setIP(sip, prefixLen)
         controller.setHostRoute(sip, cintf)
         switch.setHostRoute(cip, sintf)
     info("\n")
     info("*** Testing control network\n")
     while not cintf.isUp():
         info("*** Waiting for", cintf, "to come up\n")
         sleep(1)
     for switch in self.switches:
         while not sintf.isUp():
             info("*** Waiting for", sintf, "to come up\n")
             sleep(1)
         if self.ping(hosts=[switch, controller]) != 0:
             error("*** Error: control network test failed\n")
             exit(1)
     info("\n")
开发者ID:ruifcardoso,项目名称:mininet,代码行数:33,代码来源:net.py

示例4: do_detach

 def do_detach( self, line ):
     "Detach a host from a switch"
     args = line.split()
     if len(args) < 1 or len(args) > 2:
         error( 'invalid number of args: detach host [switch]\n' )
     else:
         self.mn.detachHost(*args)
开发者ID:sandeephebbani,项目名称:mininet,代码行数:7,代码来源:cli.py

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

示例6: _parsePingFull

 def _parsePingFull(pingOutput):
     "Parse ping output and return all data."
     errorTuple = (1, 0, 0, 0, 0, 0)
     # Check for downed link
     r = r"[uU]nreachable"
     m = re.search(r, pingOutput)
     if m is not None:
         return errorTuple
     r = r"(\d+) packets transmitted, (\d+) received"
     m = re.search(r, pingOutput)
     if m is None:
         error("*** Error: could not parse ping output: %s\n" % pingOutput)
         return errorTuple
     sent, received = int(m.group(1)), int(m.group(2))
     r = r"rtt min/avg/max/mdev = "
     r += r"(\d+\.\d+)/(\d+\.\d+)/(\d+\.\d+)/(\d+\.\d+) ms"
     m = re.search(r, pingOutput)
     if m is None:
         error("*** Error: could not parse ping output: %s\n" % pingOutput)
         return errorTuple
     rttmin = float(m.group(1))
     rttavg = float(m.group(2))
     rttmax = float(m.group(3))
     rttdev = float(m.group(4))
     return sent, received, rttmin, rttavg, rttmax, rttdev
开发者ID:ruifcardoso,项目名称:mininet,代码行数:25,代码来源:net.py

示例7: detachHost

 def detachHost( self, hostName, switchName=None ):
     if hostName not in self.nameToNode:
         error( 'host not in network: %s\n' % hostName )
         return
         
     host = self.nameToNode[hostName]
     if not isinstance(host, Host):
         error('%s is not a host' % hostName)
         return
     
     if switchName:
         if switchName not in self.nameToNode:
             error( 'switch not in network: %s\n' % switchName )
             return
             
         sw = self.nameToNode[switchName]
         if not isinstance(sw, Switch):
             error('%s is not a switch' % switchName)
             return
             
         if not isinstance(sw, OVSKernelSwitch) and not isinstance(sw, OVSKernelSwitchNew):
             error('attachHost only works with OVS kernel switches')
             return
     else:
         sw = None
         
     host.unlinkFrom(sw)
开发者ID:meiyangbigswitch,项目名称:mininet,代码行数:27,代码来源:net.py

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

示例9: configureRoutedControlNetwork

 def configureRoutedControlNetwork( self, ip='192.168.123.1',
     prefixLen=16 ):
     """Configure a routed control network on controller and switches.
        For use with the user datapath only right now.
        """
     controller = self.controllers[ 0 ]
     info( controller.name + ' <->' )
     cip = ip
     snum = ipParse( ip )
     for switch in self.switches:
         info( ' ' + switch.name )
         sintf, cintf = createLink( switch, controller )
         snum += 1
         while snum & 0xff in [ 0, 255 ]:
             snum += 1
         sip = ipStr( snum )
         controller.setIP( cintf, cip, prefixLen )
         switch.setIP( sintf, sip, prefixLen )
         controller.setHostRoute( sip, cintf )
         switch.setHostRoute( cip, sintf )
     info( '\n' )
     info( '*** Testing control network\n' )
     while not controller.intfIsUp( cintf ):
         info( '*** Waiting for', cintf, 'to come up\n' )
         sleep( 1 )
     for switch in self.switches:
         while not switch.intfIsUp( sintf ):
             info( '*** Waiting for', sintf, 'to come up\n' )
             sleep( 1 )
         if self.ping( hosts=[ switch, controller ] ) != 0:
             error( '*** Error: control network test failed\n' )
             exit( 1 )
     info( '\n' )
开发者ID:meiyangbigswitch,项目名称:mininet,代码行数:33,代码来源:net.py

示例10: attachHost

 def attachHost( self, hostName, switchName ):
     if hostName not in self.nameToNode:
         error( 'host not in network: %s\n' % hostName )
         return
         
     if switchName not in self.nameToNode:
         error( 'switch not in network: %s\n' % switchName )
         return
         
     host = self.nameToNode[hostName]
     if not isinstance(host, Host):
         error('%s is not a host' % hostName)
         return
         
     sw = self.nameToNode[switchName]
     if not isinstance(sw, Switch):
         error('%s is not a switch' % switchName)
         return
         
     if not isinstance(sw, OVSKernelSwitch) and not isinstance(sw, OVSKernelSwitchNew):
         error('attachHost only works with OVS kernel switches')
         return
         
     hostIntf, swIntf = host.linkTo(sw)
     
     host.setIP( hostIntf, host.defaultIP, self.cparams.prefixLen )
     host.setDefaultRoute( hostIntf )
     if self.autoSetMacs:
         host.setMAC( hostIntf, host.defaultMAC )
开发者ID:meiyangbigswitch,项目名称:mininet,代码行数:29,代码来源:net.py

示例11: ping

    def ping( self, hosts=None, timeout=None ):
        """Ping between all specified hosts.
           hosts: list of hosts
           timeout: time to wait for a response, as string
           returns: ploss packet loss percentage"""
        # should we check if running?
        packets = 0
        lost = 0
        ploss = None
	if not hosts:
            hosts = self.hosts[1:]
            output( '*** Ping: testing ping reachability\n' )
        for node in hosts:
            output( '%s -> ' % node.name )
            for dest in hosts:
                if node != dest:
                    opts = ''
                    if timeout:
                        opts = '-W %s' % timeout
		    result = node.cmd( 'ping -c1 %s %s' % (opts, dest.IP()) )
		    sent, received = self._parsePing( result )
                    packets += sent
                    if received > sent:
                        error( '*** Error: received too many packets' )
                        error( '%s' % result )
                        node.cmdPrint( 'route' )
                        exit( 1 )
                    lost += sent - received
                    output( ( '%s ' % dest.name ) if received else 'X ' )
            output( '\n' )
            ploss = 100 * lost / packets
        output( "*** Results: %i%% dropped (%d/%d lost)\n" %
                ( ploss, lost, packets ) )
        return ploss
开发者ID:arjunkrishnapr,项目名称:mininet,代码行数:34,代码来源:net.py

示例12: __init__

 def __init__(self, name, sw_path = None, json_path = None,
              thrift_port = None,
              pcap_dump = False,
              log_console = False,
              verbose = False,
              device_id = None,
              enable_debugger = False,
              **kwargs):
     Switch.__init__(self, name, **kwargs)
     assert(sw_path)
     assert(json_path)
     # make sure that the provided sw_path is valid
     pathCheck(sw_path)
     # make sure that the provided JSON file exists
     if not os.path.isfile(json_path):
         error("Invalid JSON file.\n")
         exit(1)
     self.sw_path = sw_path
     self.json_path = json_path
     self.verbose = verbose
     logfile = "/tmp/p4s.{}.log".format(self.name)
     self.output = open(logfile, 'w')
     self.thrift_port = thrift_port
     self.pcap_dump = pcap_dump
     self.enable_debugger = enable_debugger
     self.log_console = log_console
     if device_id is not None:
         self.device_id = device_id
         P4Switch.device_id = max(P4Switch.device_id, device_id)
     else:
         self.device_id = P4Switch.device_id
         P4Switch.device_id += 1
     self.nanomsg = "ipc:///tmp/bm-{}-log.ipc".format(self.device_id)
开发者ID:wysamuel,项目名称:behavioral-model,代码行数:33,代码来源:p4_mininet.py

示例13: _configLinkIntfs

 def _configLinkIntfs(srcIntf, dstIntf, status):
     result = srcIntf.ifconfig( status )
     if result:
         error( 'link src status change failed: %s\n' % result )
     result = dstIntf.ifconfig( status )
     if result:
         error( 'link dst status change failed: %s\n' % result )
开发者ID:kanud,项目名称:mininet,代码行数:7,代码来源:net.py

示例14: do_info

 def do_info( self, line ):
     "Noise node info."
     args = line.split()
     if len(args) != 1:
         error( 'invalid number of args: info [device]\n' )
     else:
         self.mn.deviceInfo( *args )
开发者ID:MGKhKhD,项目名称:mininet-wifi,代码行数:7,代码来源:cli.py

示例15: findTap

    def findTap(node, port, path=None):
        """utility function to parse through a sys.config
           file to find tap interfaces for a switch"""
        switch = False
        portLine = ""
        intfLines = []

        if path is None:
            path = "%s/rel/linc/releases/1.0/sys.config" % LINCSwitch.lincDir

        with open(path) as f:
            for line in f:
                if "tap" in line:
                    intfLines.append(line)
                if node.dpid in line.translate(None, ":"):
                    switch = True
                    continue
                if switch:
                    if "switch" in line:
                        switch = False
                    if "port_no,%s}" % port in line:
                        portLine = line
                        break

        if portLine:
            m = re.search("port,\d+", portLine)
            port = m.group(0).split(",")[1]
        else:
            error("***ERROR: Could not find any ports in sys.config\n")
            return

        for intfLine in intfLines:
            if "port,%s" % port in intfLine:
                return re.findall("tap\d+", intfLine)[0]
开发者ID:suhasmane02,项目名称:onos,代码行数:34,代码来源:opticalUtils.py


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