本文整理汇总了Python中mininet.node.Host方法的典型用法代码示例。如果您正苦于以下问题:Python node.Host方法的具体用法?Python node.Host怎么用?Python node.Host使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.node
的用法示例。
在下文中一共展示了node.Host方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: network_ips
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def network_ips(self) -> Dict[str, List[str]]:
"""Return all the addresses of the nodes connected directly or not
to this node"""
ips = {} # type: Dict[str, List[str]]
visited = set() # type: Set[str]
to_visit = [self]
while to_visit:
node = to_visit.pop()
if node.name in visited:
continue
visited.add(node.name)
if isinstance(node, (Host, IPNode)):
for i in node.intfList():
for ip in list(i.ips()) \
+ list(i.ip6s(exclude_lls=True)):
ips.setdefault(node.name, []).append(ip.ip.compressed)
for i in realIntfList(node):
adj_i = otherIntf(i)
if adj_i is not None:
to_visit.append(adj_i.node)
return ips
示例2: stop
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def stop( self ):
"Stop network."
if self.net is not None:
# Stop host details
for widget in self.widgetToItem:
name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] )
if 'Host' in tags:
newHost = self.net.get(name)
opts = self.hostOpts[name]
# Run User Defined Stop Command
if 'stopCommand' in opts:
newHost.cmdPrint(opts['stopCommand'])
if 'Switch' in tags:
newNode = self.net.get(name)
opts = self.switchOpts[name]
# Run User Defined Stop Command
if 'stopCommand' in opts:
newNode.cmdPrint(opts['stopCommand'])
self.net.stop()
cleanUpScreens()
self.net = None
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:25,代码来源:miniedit.py
示例3: config
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def config(self, **params):
r = super(Host, self).config(**params)
self.defaultIntf().rename("eth0")
for off in ["rx", "tx", "sg"]:
cmd = "/sbin/ethtool --offload eth0 %s off" % off
self.cmd(cmd)
# disable IPv6
self.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=1")
self.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=1")
self.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=1")
return r
示例4: isBroadcastDomainBoundary
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def isBroadcastDomainBoundary(node):
return isinstance(node, Host) or isinstance(node, IPRouter)
示例5: addNode
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def addNode( self, node, nodeNum, x, y, name=None):
"Add a new node to our canvas."
if 'Switch' == node:
self.switchCount += 1
if 'Host' == node:
self.hostCount += 1
if 'Controller' == node:
self.controllerCount += 1
if name is None:
name = self.nodePrefixes[ node ] + nodeNum
self.addNamedNode(node, name, x, y)
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:13,代码来源:miniedit.py
示例6: findItem
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def findItem( self, x, y ):
"Find items at a location in our canvas."
items = self.canvas.find_overlapping( x, y, x, y )
if len( items ) == 0:
return None
else:
return items[ 0 ]
# Canvas bindings for Select, Host, Switch and Link tools
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:11,代码来源:miniedit.py
示例7: clickHost
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def clickHost( self, event ):
"Add a new host to our canvas."
self.newNode( 'Host', event )
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:5,代码来源:miniedit.py
示例8: hostDetails
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def hostDetails( self, _ignore=None ):
if ( self.selection is None or
self.net is not None or
self.selection not in self.itemToWidget ):
return
widget = self.itemToWidget[ self.selection ]
name = widget[ 'text' ]
tags = self.canvas.gettags( self.selection )
if 'Host' not in tags:
return
prefDefaults = self.hostOpts[name]
hostBox = HostDialog(self, title='Host Details', prefDefaults=prefDefaults)
self.master.wait_window(hostBox.top)
if hostBox.result:
newHostOpts = {'nodeNum':self.hostOpts[name]['nodeNum']}
newHostOpts['sched'] = hostBox.result['sched']
if len(hostBox.result['startCommand']) > 0:
newHostOpts['startCommand'] = hostBox.result['startCommand']
if len(hostBox.result['stopCommand']) > 0:
newHostOpts['stopCommand'] = hostBox.result['stopCommand']
if len(hostBox.result['cpu']) > 0:
newHostOpts['cpu'] = float(hostBox.result['cpu'])
if len(hostBox.result['cores']) > 0:
newHostOpts['cores'] = hostBox.result['cores']
if len(hostBox.result['hostname']) > 0:
newHostOpts['hostname'] = hostBox.result['hostname']
name = hostBox.result['hostname']
widget[ 'text' ] = name
if len(hostBox.result['defaultRoute']) > 0:
newHostOpts['defaultRoute'] = hostBox.result['defaultRoute']
if len(hostBox.result['ip']) > 0:
newHostOpts['ip'] = hostBox.result['ip']
if len(hostBox.result['externalInterfaces']) > 0:
newHostOpts['externalInterfaces'] = hostBox.result['externalInterfaces']
if len(hostBox.result['vlanInterfaces']) > 0:
newHostOpts['vlanInterfaces'] = hostBox.result['vlanInterfaces']
if len(hostBox.result['privateDirectory']) > 0:
newHostOpts['privateDirectory'] = hostBox.result['privateDirectory']
self.hostOpts[name] = newHostOpts
info( 'New host details for ' + name + ' = ' + str(newHostOpts), '\n' )
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:43,代码来源:miniedit.py
示例9: xterm
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def xterm( self, _ignore=None ):
"Make an xterm when a button is pressed."
if ( self.selection is None or
self.net is None or
self.selection not in self.itemToWidget ):
return
name = self.itemToWidget[ self.selection ][ 'text' ]
if name not in self.net.nameToNode:
return
term = makeTerm( self.net.nameToNode[ name ], 'Host', term=self.appPrefs['terminalType'] )
if StrictVersion(MININET_VERSION) > StrictVersion('2.0'):
self.net.terms += term
else:
self.net.terms.append(term)
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:16,代码来源:miniedit.py
示例10: __init__
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def __init__(self):
"Create Fat tree Topology"
Topo.__init__(self)
#Add hosts
h7 = self.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None)
h8 = self.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None)
h1 = self.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
h2 = self.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
h4 = self.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
h3 = self.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
h5 = self.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
h6 = self.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
#Add switches
s10 = self.addSwitch('s10', cls=OVSKernelSwitch)
s3 = self.addSwitch('s3', cls=OVSKernelSwitch)
s17 = self.addSwitch('s17', cls=OVSKernelSwitch)
s4 = self.addSwitch('s4', cls=OVSKernelSwitch)
s18 = self.addSwitch('s18', cls=OVSKernelSwitch)
s1 = self.addSwitch('s1', cls=OVSKernelSwitch)
s11 = self.addSwitch('s11', cls=OVSKernelSwitch)
s21 = self.addSwitch('s21', cls=OVSKernelSwitch)
s22 = self.addSwitch('s22', cls=OVSKernelSwitch)
s2 = self.addSwitch('s2', cls=OVSKernelSwitch)
#Add links
self.addLink(h1, s1)
self.addLink(h2, s1)
self.addLink(h3, s2)
self.addLink(h4, s2)
self.addLink(h5, s3)
self.addLink(h6, s3)
self.addLink(h7, s4)
self.addLink(h8, s4)
self.addLink(s1, s21)
self.addLink(s21, s2)
self.addLink(s1, s10)
self.addLink(s2, s10)
self.addLink(s3, s11)
self.addLink(s4, s22)
self.addLink(s11, s4)
self.addLink(s3, s22)
self.addLink(s21, s17)
self.addLink(s11, s17)
self.addLink(s10, s18)
self.addLink(s22, s18)
示例11: myNetwork
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def myNetwork():
net = Mininet( topo=None,
build=False,
ipBase='10.0.0.0/8')
info( '*** Adding controller\n' )
c0=net.addController(name='c0',
controller=RemoteController,
ip='127.0.0.1',
protocol='tcp',
port=6653)
info( '*** Add switches\n')
s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
s5 = net.addSwitch('s5', cls=OVSKernelSwitch, failMode='standalone')
info( '*** Add hosts\n')
h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
info( '*** Add links\n')
s1s2 = {'bw':400,'loss':0}
net.addLink(s1, s2, cls=TCLink , **s1s2)
s2h1 = {'bw':1000,'loss':10,'max_queue_size':10,'speedup':40}
net.addLink(s2, h1, cls=TCLink , **s2h1)
s2h2 = {'bw':120,'loss':0}
net.addLink(s2, h2, cls=TCLink , **s2h2)
s2h3 = {'bw':400,'loss':20}
net.addLink(s2, h3, cls=TCLink , **s2h3)
s1s5 = {'bw':200,'delay':'12','loss':10}
net.addLink(s1, s5, cls=TCLink , **s1s5)
s5h4 = {'bw':100,'loss':50}
net.addLink(s5, h4, cls=TCLink , **s5h4)
info( '*** Starting network\n')
net.build()
info( '*** Starting controllers\n')
for controller in net.controllers:
controller.start()
info( '*** Starting switches\n')
net.get('s2').start([c0])
net.get('s1').start([c0])
net.get('s5').start([])
info( '*** Post configure switches and hosts\n')
CLI(net)
net.stop()
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:55,代码来源:10_3_sdn_onos.py
示例12: myNetwork
# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import Host [as 别名]
def myNetwork():
net = Mininet( topo=None,
build=False,
ipBase='10.0.0.0/8')
info( '*** Adding controller\n' )
c0=net.addController(name='c0',
controller=RemoteController,
ip='127.0.0.1',
protocol='tcp',
port=6653)
info( '*** Add switches\n')
s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
s1 = net.addSwitch('s1', cls=IVSSwitch)
info( '*** Add hosts\n')
h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
info( '*** Add links\n')
s1s2 = {'bw':400,'loss':0}
net.addLink(s1, s2, cls=TCLink , **s1s2)
s2h1 = {'bw':1000,'loss':10,'max_queue_size':10,'speedup':40}
net.addLink(s2, h1, cls=TCLink , **s2h1)
s2h2 = {'bw':120,'loss':0}
net.addLink(s2, h2, cls=TCLink , **s2h2)
s2h3 = {'bw':400,'loss':20}
net.addLink(s2, h3, cls=TCLink , **s2h3)
info( '*** Starting network\n')
net.build()
info( '*** Starting controllers\n')
for controller in net.controllers:
controller.start()
info( '*** Starting switches\n')
net.get('s2').start([c0])
net.get('s1').start([c0])
info( '*** Post configure switches and hosts\n')
CLI(net)
net.stop()
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:48,代码来源:10_4_sdn_floodlight.py