本文整理汇总了Python中mininet.node.Host类的典型用法代码示例。如果您正苦于以下问题:Python Host类的具体用法?Python Host怎么用?Python Host使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Host类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: emptyNet
def emptyNet():
net = Mininet(switch=OVSSwitch, build=False)
#c0 = net.addController('c0', controller=RemoteController, port=6633)
#c1 = net.addController('c1', controller=RemoteController, port=6634)
c0 = net.addController('c0', controller=Controller, port=6634)
c1 = net.addController('c1', controller=Controller, port=6635)
h1 = net.addHost('host1', ip='192.168.0.2/24', mac='00:1e:65:15:fc:01')
h2 = net.addHost('host2', ip='192.168.0.3/24', mac='00:1e:65:15:fc:02')
s1 = net.addSwitch('br0')
net.addLink(h1, s1)
net.addLink(h2, s1)
h3 = net.addHost('host3', ip='172.168.0.2/24', mac='00:1e:65:15:fc:03')
h4 = net.addHost('host4', ip='172.168.0.3/24', mac='00:1e:65:15:fc:04')
s2 = net.addSwitch('br1')
net.addLink(h3, s2)
net.addLink(h4, s2)
# hide the gatway in net
gateway = Host('gateway')
net.addLink(s1, gateway)
net.addLink(s2, gateway)
gateway.intf("gateway-eth0").setIP('192.168.0.1/24')
gateway.intf("gateway-eth1").setIP('172.168.0.1/24')
# show gateway in net
#gateway = net.addHost('gateway', ip='192.168.0.1/24')
#net.addLink(s1, gateway)
#net.addLink(s2, gateway)
#gateway.intf("gateway-eth1").setIP('172.168.0.1/24')
net.build()
print h1.cmd('ip route add default via 192.168.0.1 dev host1-eth0')
print h2.cmd('ip route add default via 192.168.0.1 dev host2-eth0')
print h3.cmd('ip route add default via 172.168.0.1 dev host3-eth0')
print h4.cmd('ip route add default via 172.168.0.1 dev host4-eth0')
c0.start()
c1.start()
s1.start([c0])
s2.start([c1])
#s1.cmd('ovs-vsctl set bridge br0 protocols=OpenFlow13')
#s2.cmd('ovs-vsctl set bridge br1 protocols=OpenFlow13')
CLI( net )
net.stop()
开发者ID:exuuwen,项目名称:study,代码行数:50,代码来源:mininet_net.py
示例17: __init__
def __init__(self, name, **kwargs):
Host.__init__(self, name, **kwargs)
if not NdnHost.inited:
NdnHostCommon.init()
# Create home directory for a node
self.homeFolder = "%s/%s" % (self.params['workdir'], self.name)
self.cmd("mkdir -p %s" % self.homeFolder)
self.cmd("cd %s" % self.homeFolder)
self.nfd = Nfd(self)
self.nfd.start()
self.peerList = {}
开发者ID:alvyC,项目名称:mini-ndn,代码行数:15,代码来源:ndn_host.py
示例18: popen
def popen( self, *args, **kwargs ):
"""Return a Popen() object in node's namespace
args: Popen() args, single list, or string
kwargs: Popen() keyword args"""
# Tell mnexec to execute command in our cgroup
mncmd = [ 'docker', 'attach', "mininet-"+self.name ]
return Host.popen( self, *args, mncmd=mncmd, **kwargs )
开发者ID:michaelph,项目名称:mininet-lab,代码行数:7,代码来源:dockerHost.py
示例19: 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']:
print str(attrs)
mask = attrs['mask']
gateway = attrs['gateway']
# print str('ifconfig %s %s netmask %s' % (intf, addr, mask))
self.cmd('ifconfig %s %s netmask %s' % (intf, addr, mask))
self.cmd('route add default gw %s' % (gateway))
开发者ID:michaelph,项目名称:mininet-lab,代码行数:17,代码来源:wpgec2016.py
示例20: popen
def popen( self, *args, **kwargs ):
"Popen with chroot support"
chroot = kwargs.pop( 'chroot', True )
mncmd = kwargs.get( 'mncmd',
[ 'mnexec', '-a', str( self.pid ) ] )
if chroot:
mncmd = [ 'chroot', self.root ] + mncmd
kwargs[ 'mncmd' ] = mncmd
return Host.popen( self, *args, **kwargs )
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:9,代码来源:bind.py
注:本文中的mininet.node.Host类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论