本文整理汇总了Python中mininet.log.info方法的典型用法代码示例。如果您正苦于以下问题:Python log.info方法的具体用法?Python log.info怎么用?Python log.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.log
的用法示例。
在下文中一共展示了log.info方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildLinks
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [as 别名]
def buildLinks( self, net):
# Make links
info( "Getting Links.\n" )
for key,link in self.links.iteritems():
tags = self.canvas.gettags(key)
if 'data' in tags:
src=link['src']
dst=link['dest']
linkopts=link['linkOpts']
srcName, dstName = src[ 'text' ], dst[ 'text' ]
srcNode, dstNode = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
if linkopts:
net.addLink(srcNode, dstNode, cls=TCLink, **linkopts)
else:
# debug( str(srcNode) )
# debug( str(dstNode), '\n' )
net.addLink(srcNode, dstNode)
self.canvas.itemconfig(key, dash=())
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:20,代码来源:miniedit.py
示例2: main
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [as 别名]
def main():
args = get_args()
# set logging level
setLogLevel('info')
# clean
cleanup()
# remove cli logs
sh('find -type f -regex ".*cli_output.*" | xargs rm')
if args.clean or args.clean_dir:
# removes first level pcap and log dirs
sh("rm -rf %s" % args.pcap_dir)
sh("rm -rf %s" % args.log_dir)
# tries to recursively remove all pcap and log dirs if they are named 'log' and 'pcap'
sh('find -type d -regex ".*pcap" | xargs rm -rf')
sh('find -type d -regex ".*log" | xargs rm -rf')
# removes topologies files
sh('find -type f -regex ".*db" | xargs rm')
# remove compiler outputs
sh('find -type f -regex ".*\(p4i\|p4rt\)" | xargs rm')
# remove all the jsons that come from a p4
out = sh('find -type f -regex ".*p4"')
p4_files = [x.split("/")[-1].strip() for x in out.split("\n") if x]
for p4_file in p4_files:
tmp = p4_file.replace("p4", "json")
reg_str = ".*{}".format(tmp)
sh('find -type f -regex {} | xargs rm -f'.format(reg_str))
if args.clean_dir:
return
app = AppRunner(args.config, args.log_dir,
args.pcap_dir, args.cli, args.quiet)
app.run_app()
示例3: getOvsVersion
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [as 别名]
def getOvsVersion():
"Return OVS version"
outp = quietRun("ovs-vsctl --version")
r = r'ovs-vsctl \(Open vSwitch\) (.*)'
m = re.search(r, outp)
if m is None:
warn( 'Version check failed' )
return None
else:
info( 'Open vSwitch version is '+m.group(1), '\n' )
return m.group(1)
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:13,代码来源:miniedit.py
示例4: hostDetails
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [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
示例5: switchDetails
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [as 别名]
def switchDetails( 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 'Switch' not in tags:
return
prefDefaults = self.switchOpts[name]
switchBox = SwitchDialog(self, title='Switch Details', prefDefaults=prefDefaults)
self.master.wait_window(switchBox.top)
if switchBox.result:
newSwitchOpts = {'nodeNum':self.switchOpts[name]['nodeNum']}
newSwitchOpts['switchType'] = switchBox.result['switchType']
newSwitchOpts['controllers'] = self.switchOpts[name]['controllers']
if len(switchBox.result['startCommand']) > 0:
newSwitchOpts['startCommand'] = switchBox.result['startCommand']
if len(switchBox.result['stopCommand']) > 0:
newSwitchOpts['stopCommand'] = switchBox.result['stopCommand']
if len(switchBox.result['dpctl']) > 0:
newSwitchOpts['dpctl'] = switchBox.result['dpctl']
if len(switchBox.result['dpid']) > 0:
newSwitchOpts['dpid'] = switchBox.result['dpid']
if len(switchBox.result['hostname']) > 0:
newSwitchOpts['hostname'] = switchBox.result['hostname']
name = switchBox.result['hostname']
widget[ 'text' ] = name
if len(switchBox.result['externalInterfaces']) > 0:
newSwitchOpts['externalInterfaces'] = switchBox.result['externalInterfaces']
newSwitchOpts['switchIP'] = switchBox.result['switchIP']
newSwitchOpts['sflow'] = switchBox.result['sflow']
newSwitchOpts['netflow'] = switchBox.result['netflow']
self.switchOpts[name] = newSwitchOpts
info( 'New switch details for ' + name + ' = ' + str(newSwitchOpts), '\n' )
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:39,代码来源:miniedit.py
示例6: prefDetails
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [as 别名]
def prefDetails( self ):
prefDefaults = self.appPrefs
prefBox = PrefsDialog(self, title='Preferences', prefDefaults=prefDefaults)
info( 'New Prefs = ' + str(prefBox.result), '\n' )
if prefBox.result:
self.appPrefs = prefBox.result
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:8,代码来源:miniedit.py
示例7: controllerDetails
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [as 别名]
def controllerDetails( self ):
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 )
oldName = name
if 'Controller' not in tags:
return
ctrlrBox = ControllerDialog(self, title='Controller Details', ctrlrDefaults=self.controllers[name])
if ctrlrBox.result:
# debug( 'Controller is ' + ctrlrBox.result[0], '\n' )
if len(ctrlrBox.result['hostname']) > 0:
name = ctrlrBox.result['hostname']
widget[ 'text' ] = name
else:
ctrlrBox.result['hostname'] = name
self.controllers[name] = ctrlrBox.result
info( 'New controller details for ' + name + ' = ' + str(self.controllers[name]), '\n' )
# Find references to controller and change name
if oldName != name:
for widget in self.widgetToItem:
switchName = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] )
if 'Switch' in tags:
switch = self.switchOpts[switchName]
if oldName in switch['controllers']:
switch['controllers'].remove(oldName)
switch['controllers'].append(name)
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:34,代码来源:miniedit.py
示例8: start
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [as 别名]
def start( self ):
"Start network."
if self.net is None:
self.net = self.build()
# Since I am going to inject per switch controllers.
# I can't call net.start(). I have to replicate what it
# does and add the controller options.
#self.net.start()
info( '**** Starting %s controllers\n' % len( self.net.controllers ) )
for controller in self.net.controllers:
info( str(controller) + ' ')
controller.start()
info('\n')
info( '**** Starting %s switches\n' % len( self.net.switches ) )
#for switch in self.net.switches:
# info( switch.name + ' ')
# switch.start( self.net.controllers )
for widget in self.widgetToItem:
name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] )
if 'Switch' in tags:
opts = self.switchOpts[name]
switchControllers = []
for ctrl in opts['controllers']:
switchControllers.append(self.net.get(ctrl))
info( name + ' ')
# Figure out what controllers will manage this switch
self.net.get(name).start( switchControllers )
if 'LegacySwitch' in tags:
self.net.get(name).start( [] )
info( name + ' ')
info('\n')
self.postStartSetup()
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:37,代码来源:miniedit.py
示例9: start
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [as 别名]
def start():
global net, attacker, running
if running:
return '\nServer already running.\n'
setLogLevel('info')
topo = MixTopo()
net = Mininet(topo=topo)
s1 = net['s1']
plc2 = net['plc2']
plc3 = net['plc3']
s2, rtu2a, scada = net.get('s2', 'rtu2a', 'scada')
rtu2b, attacker2 = net.get('rtu2b', 'attacker2')
s3 = net.get('s3')
# NOTE: root-eth0 interface on the host
root = Node('root', inNamespace=False)
intf = net.addLink(root, s3).intf1
print('DEBUG root intf: {}'.format(intf))
root.setIP('10.0.0.30', intf=intf)
# NOTE: all packet from root to the 10.0.0.0 network
root.cmd('route add -net ' + '10.0.0.0' + ' dev ' + str(intf))
net.start()
info('Welcome')
# NOTE: use for debugging
#s1.cmd('tcpdump -i s1-eth1 -w /tmp/s1-eth1.pcap &')
#s1.cmd('tcpdump -i s1-eth2 -w /tmp/s1-eth2.pcap &')
SLEEP = 0.5
# NOTE: swat challenge 1 and 2
plc3.cmd(sys.executable + ' plc3.py &')
sleep(SLEEP)
plc2.cmd(sys.executable + ' plc2.py &')
sleep(SLEEP)
# NOTE: wadi challenge 1
scada.cmd(sys.executable + ' scada.py &')
sleep(SLEEP)
rtu2a.cmd(sys.executable + ' rtu2a.py &')
sleep(SLEEP)
# NOTE: wadi challenge 2
rtu2b.cmd(sys.executable + ' rtu2b.py &')
sleep(SLEEP)
running = True
return '\nServer started.\n'
示例10: myNetwork
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [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
示例11: myNetwork
# 需要导入模块: from mininet import log [as 别名]
# 或者: from mininet.log import info [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