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


Python node.Host类代码示例

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


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

示例1: __init__

 def __init__(self, name, *args, **kwargs ):
     """privateDirs: list of private directories
        remounts: dirs to remount
        unmount: unmount dirs in cleanup? (True)
        Note: if unmount is False, you must call unmountAll()
        manually."""
     self.privateDirs = kwargs.pop( 'privateDirs', [] )
     self.remounts = kwargs.pop( 'remounts', [] )
     self.unmount = kwargs.pop( 'unmount', True )
     Host.__init__( self, name, *args, **kwargs )
     self.rundir = '%s/%s' % ( self.mnRunDir, name )
     self.root, self.private = None, None  # set in createBindMounts
     if self.privateDirs:
         self.privateDirs = [ realpath( d ) for d in self.privateDirs ]
         self.createBindMounts()
     # These should run in the namespace before we chroot,
     # in order to put the right entries in /etc/mtab
     # Eventually this will allow a local pid space
     # Now we chroot and cd to wherever we were before.
     pwd = self.cmd( 'pwd' ).strip()
     self.sendCmd( 'exec chroot', self.root, 'bash -ms mininet:'
                    + self.name )
     self.waiting = False
     self.cmd( 'cd', pwd )
     # In order for many utilities to work,
     # we need to remount /proc and /sys
     self.cmd( 'mount /proc' )
     self.cmd( 'mount /sys' )
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:28,代码来源:bind.py

示例2: terminate

    def terminate(self):
        #I don't think it works because it does not read pid number
        #self.cmd("ps ax | egrep 'bgpd%s.pid|zebra%s.pid' | awk '{print $1}' | xargs kill" % (self.name, self.name))
        self.cmd("kill `cat %s/bgpd%s.pid`" % (QUAGGA_RUN_DIR, self.name))
        self.cmd("kill `cat %s/zebra%s.pid`" % (QUAGGA_RUN_DIR, self.name))

        Host.terminate(self)
开发者ID:piotrekz79,项目名称:demo_invitation,代码行数:7,代码来源:coco_multidomain_invitation.py

示例3: __init__

 def __init__(self, name, ips, ce_mac_address=None, gw=None, *args, **kwargs ):
   dirs = ['/var/log/', '/var/log/quagga', '/var/run', '/var/run/quagga']
   Host.__init__(self, name, privateDirs=dirs, *args, **kwargs )
   self.ips = ips
   self.ce_mac_address = ce_mac_address
   self.gw = gw
   self.path_quagga = "%s/%s/quagga" %(self.baseDIR, self.name)
开发者ID:santiagovidal,项目名称:P2015_44,代码行数:7,代码来源:rau_nodes.py

示例4: __init__

	def __init__(self, name, loopback, CR, cluster_id, *args, **kwargs ):
		dirs = ['/var/log/', '/var/log/quagga', '/var/run', '/var/run/quagga', '/var/run/openvswitch', '/var/run/sshd']
		Host.__init__(self, name, privateDirs=dirs, *args, **kwargs )
		self.loopback = loopback

		if cluster_id == "default":
			cluster_id = "0"
		cluster_id = int(cluster_id)
		if CR:
			cluster_id = cluster_id + 128	
	
		extrainfo = '%02x000000' % cluster_id

		self.dpid = self.loopbackDpid(self.loopback, extrainfo)
		self.mac = self.loopbackMac(self.loopback,"0200")
		self.path_ovs = "%s/%s/ovs" %(self.baseDIR, self.name)
		self.path_quagga =  "%s/%s/quagga" %(self.baseDIR, self.name)
		self.path_fpm = "%s/%s/fpm-of" %(self.baseDIR, self.name)
		if OSHI.checked == False:
			self.checkQuagga()
			if self.OF_V == "OpenFlow13":
				self.checkOVS()
			if OSHI.SR == True:
				self.checkSR()
			OSHI.checked = True
开发者ID:netgroup,项目名称:Dreamer-Mininet-Extensions,代码行数:25,代码来源:nodes.py

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

示例6: config

    def config(self, **kwargs):
        Host.config(self, **kwargs)
        self.cmd('sysctl net.ipv4.ip_forward=1')

        for intf, attrs in self.intfDict.items():
            self.cmd('ip addr flush dev %s' % intf)
            if 'mac' in attrs:
                self.cmd('ip link set %s down' % intf)
                self.cmd('ip link set %s address %s' % (intf, attrs['mac']))
                self.cmd('ip link set %s up ' % intf)
                self.nameToIntf[intf].mac=attrs['mac']
            # for addr in attrs['ipAddrs']:
            if 'vlan' in attrs:
                # self.cmd('ip addr flush dev %s')
                self.cmd('ip link add link %s name %s.%s type vlan id %s' % (intf, intf, attrs['vlan'], attrs['vlan']))
                self.cmd('ip addr add %s dev %s.%s' % (attrs['ipAddrs'], intf, attrs['vlan']))
                self.cmd('ip link set dev %s.%s up' % (intf, attrs['vlan']))
            if ('ipAddrs' in attrs) & ('vlan' not in attrs):
                self.cmd('ip addr add %s dev %s' % (attrs['ipAddrs'], intf))
                self.nameToIntf[intf].ip=attrs['ipAddrs'].split('/')[0]
                self.nameToIntf[intf].prefixLen=attrs['ipAddrs'].split('/')[1]


        self.cmd('%s/zebra -d -f %s -z %s/zebra%s.api -i %s/zebra%s.pid' % (
        QUAGGA_DIR, self.zebraConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
        self.cmd('%s/bgpd -d -f %s -z %s/zebra%s.api -i %s/bgpd%s.pid' % (
        QUAGGA_DIR, self.quaggaConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))

        for attrs in self.ARPDict.itervalues():
            if 'localdev' in attrs:
                self.cmd('ip route add %s%s dev %s' % (attrs['remoteIP'], attrs['remoteMask'], attrs['localdev']))
                self.setARP(attrs['remoteIP'], attrs['remoteMAC'])
            elif 'nexthop' in attrs:
                self.cmd('ip route add %s%s via %s' % (attrs['remoteIP'], attrs['remoteMask'], attrs['nexthop']))
                self.setARP(attrs['nexthop'], attrs['remoteMAC'])
开发者ID:piotrekz79,项目名称:demo_invitation,代码行数:35,代码来源:coco_multidomain_invitation.py

示例7: __init__

    def __init__(self, name, quaggaConfFile, zebraConfFile, intfDict, ARPDict, *args, **kwargs):
        Host.__init__(self, name, *args, **kwargs)

        self.quaggaConfFile = quaggaConfFile
        self.zebraConfFile = zebraConfFile
        self.intfDict = intfDict
        # TODO should be optional?
        self.ARPDict = ARPDict
开发者ID:piotrekz79,项目名称:demo_invitation,代码行数:8,代码来源:coco_multidomain_invitation.py

示例8: cleanup

 def cleanup( self ):
     """Clean up, then unmount bind mounts
        unmount: actually unmount bind mounts?"""
     # Wait for process to actually terminate
     self.shell.wait()
     Host.cleanup( self )
     if self.unmount:
         self.unmountBindMounts()
         errFail( 'rmdir ' + self.root )
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:9,代码来源:bind.py

示例9: __init__

 def __init__( self, name, image='myace:v1', dargs=None, startString=None, **kwargs ):
     self.image = image
     self.dargs = dargs
     if startString is None:
         self.startString = "/bin/bash"
         self.dargs = "-ti"
     else:
         self.startString = startString
     Host.__init__( self, name, **kwargs )
开发者ID:thomasameisel,项目名称:cloud-computing,代码行数:9,代码来源:networking_application.py

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

示例11: __init__

    def __init__(self, name, **kwargs):

        Host.__init__(self, name, **kwargs)
        if not NdnHost.inited:
            NdnHostCommon.init()

        self.nfd = Nfd(self)
        self.nfd.start()

        self.peerList = {}
开发者ID:gitter-badger,项目名称:mini-ndn,代码行数:10,代码来源:ndn_host.py

示例12: __init__

    def __init__(self, name, ip=None, inNamespace=True,
                 root_dir=None, ssh_template=None,
                 auth_keys=None, **kwargs):

        self.name = name
        self.ssh_template = ssh_template
        self.auth_keys = auth_keys
        self.root_dir = root_dir
        self.ssh_pid_file = None
        self.mounted_dirs = []

        Host.__init__(self, name, inNamespace, **kwargs)
开发者ID:ericgarrigues,项目名称:minilab,代码行数:12,代码来源:minilab.py

示例13: __init__

    def __init__(self, name, **kwargs):
        privateDirs = [('/usr/local/etc/ndn', '/tmp/%(name)s/usr/local/etc/ndn'),  ]
        kwargs['privateDirs'] = privateDirs

        Host.__init__(self, name, **kwargs)
        if not NdnHost.inited:
            NdnHostCommon.init()

        self.nfd = Nfd(self)
        self.nfd.start()

        self.peerList = {}
开发者ID:ndncomm,项目名称:mini-ndn,代码行数:12,代码来源:ndn_host.py

示例14: config

 def config(self, **kwargs):
     Host.config(self, **kwargs)
     self.cmd('sysctl net.ipv4.ip_forward=1')
     for intf, attrs in self.intfDict.items():
         self.cmd('ip addr flush dev %s' % intf)
         if 'mac' in attrs:
             self.cmd('ip link set %s down' % intf)
             self.cmd('ip link set %s address %s' % (intf, attrs['mac']))
             self.cmd('ip link set %s up ' % intf)
         for addr in attrs['ipAddrs']:
             self.cmd('ip addr add %s dev %s' % (addr, intf))
     self.cmd('/usr/lib/quagga/zebra -d -f %s -z %s/zebra%s.api -i %s/zebra%s.pid' % (self.zebraConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
     self.cmd('/usr/lib/quagga/bgpd -d -f %s -z %s/zebra%s.api -i %s/bgpd%s.pid' % (self.quaggaConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
开发者ID:hyunsun,项目名称:mininet-scripts,代码行数:13,代码来源:sdnip.py

示例15: config

    def config(self, **kwargs):
        Host.config(self, **kwargs)
        intf = self.defaultIntf()
        self.vlanIntf = "%s.%s" % (intf, self.vlan)
        self.cmd('ip -4 addr flush dev %s' % intf)
        self.cmd('ip link add link %s name %s type vlan id %s' % (intf, self.vlanIntf, self.vlan))
        self.cmd('ip link set up %s' % self.vlanIntf)

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

        self.cmd('ip route add default via %s' % self.gateway)
        intf.name = self.vlanIntf
        self.nameToIntf[self.vlanIntf] = intf
开发者ID:opennetworkinglab,项目名称:OnosSystemTest,代码行数:14,代码来源:trellislib.py


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