本文整理汇总了Python中mininet.log.lg.setLogLevel函数的典型用法代码示例。如果您正苦于以下问题:Python setLogLevel函数的具体用法?Python setLogLevel怎么用?Python setLogLevel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setLogLevel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.options = None
self.args = None
self.parseArgs()
lg.setLogLevel('info')
self.runDemo()
示例2: start
def start(ip="127.0.0.1",port=6633):
#def start(ip="127.0.0.1",port=6653):
ctrlr = lambda n: RemoteController(n, ip=ip, port=port, inNamespace=False)
net = Mininet(switch=OVSSwitch, controller=ctrlr, autoStaticArp=False)
c1 = net.addController('c1')
gates_agraph = pgv.AGraph("simplified_gates_topology.dot")
for sw in gates_agraph.nodes():
net.addSwitch(sw, dpid = hex( int(sw.attr['dpid']) )[2:])
for link in gates_agraph.edges():
(src_switch, dst_switch) = link
net.addLink(src_switch, dst_switch, int(link.attr['src_port']), int(link.attr['dport']) )
# Only one host and an Internet Router disguised as a host for now (because it's not part of the OF network)
h0 = net.addHost('h0', cls=VLANHost, mac='d4:c9:ef:b2:1b:80', ip='128.253.154.1', vlan=1356)
net.addLink("s_bdf", h0, 1, 0)
# To test DHCP functionality, ucnomment this line and comment out the fixed IP line. Then when mininet
# starts you issue:
# mininet> h1 dhclient -v -d -1 h1-eth0.1356
# and make sure it gets its IP by going through all protocol steps.
#h1 = net.addHost('h1', cls=VLANHost, mac='00:00:01:00:00:11', ip='0.0.0.0', vlan=1356)
h1 = net.addHost('h1', cls=VLANHost, mac='00:00:01:00:00:11', ip='128.253.154.100', vlan=1356)
net.addLink("s_f3a", h1, 32, 0)
# h4{a,b,c} are wireless nodes supposedly hooked up to a dumb AP. You can't just hook them up
# to the same mininet port. Y
h4a = net.addHost('h4a', cls=VLANHost, mac='00:00:01:00:00:14', ip='128.253.154.104', vlan=1356)
net.addLink("s_f3a", h4a, 33, 0)
#net.addHost('h4b', cls=VLANHost, mac='00:00:01:00:00:14', ip='128.253.154.104', vlan=1356)
#net.addHost('h4c', cls=VLANHost, mac='00:00:01:00:00:14', ip='128.253.154.104', vlan=1356)
# h2 is a syslab PC
h2 = net.addHost('h2', cls=VLANHost, mac='00:00:01:00:00:13', ip='128.253.154.102', vlan=1356)
net.addLink("s_lab_r6", h2, 1, 0)
# MAC spoofing attempt of h2
h3 = net.addHost('h3', cls=VLANHost, mac='00:00:01:00:00:13', ip='128.253.154.102', vlan=1356)
net.addLink("s_lab_r6", h3, 2, 0)
###### Start of static Mininet epilogue ######
# Set up logging etc.
lg.setLogLevel('info')
lg.setLogLevel('output')
# Start the network
net.start()
# Start the DHCP server on Internet Router. This will actually be a DHCP proxy in the real setup.
#startDHCPserver( h0, gw='128.253.154.1', dns='8.8.8.8')
# Enter CLI mode
output("Network ready\n")
output("Press Ctrl-d or type exit to quit\n")
CLI(net)
示例3: setup
def setup( self ):
"Setup and validate environment."
# set logging verbosity
if LEVELS[self.options.verbosity] > LEVELS['output']:
print ( '*** WARNING: selected verbosity level (%s) will hide CLI '
'output!\n'
'Please restart Mininet with -v [debug, info, output].'
% self.options.verbosity )
lg.setLogLevel( self.options.verbosity )
示例4: __init__
def __init__(self, tableIP, verbose=False):
Mininet.__init__(self, build=False)
self.tableIP = tableIP
self.vsfs = []
self.rootnodes = []
self.verbose = verbose
lg.setLogLevel('info')
self.name_to_root_nodes = {}
self.node_to_pw_data = defaultdict(list)
示例5: pingall_test
def pingall_test(folder, exe, topo=SingleSwitchTopo(4), custom_topo=None, custom_test=None, expect_pct=0):
ip="127.0.0.1"
port=6633
if not VERBOSE:
lg.setLogLevel('critical')
ctrlr = lambda n: RemoteController(n, ip=ip, port=port, inNamespace=False)
net = Mininet(switch=OVSSwitch, controller=ctrlr, autoStaticArp=False,cleanup=True)
c1 = net.addController('c1')
if custom_topo:
custom_topo.build(net)
else:
net.buildFromTopo(topo)
# Start the network
net.start()
# Fork off Frenetic process
devnull = None if VERBOSE else open(os.devnull, 'w')
frenetic_proc = Popen(
['/home/vagrant/src/frenetic/frenetic.native', 'http-controller','--verbosity','debug'],
stdout=devnull, stderr=devnull
)
# Wait a few seconds for frenetic to initialize, otherwise
time.sleep(5)
# And fork off application
app_proc = Popen(
['/usr/bin/python2.7',exe],
stdout=devnull, stderr=devnull, cwd=CODE_ROOT+folder
)
if custom_test:
got_pct = int(custom_test(net))
else:
got_pct = int(net.pingAll())
expected_msg = " expected "+str(expect_pct)+"% dropped got "+str(got_pct)+"% dropped"
print exe + ("...ok" if expect_pct==got_pct else expected_msg)
frenetic_proc.kill()
app_proc.kill()
# Ocassionally shutting down the network throws an error, which is superfluous because
# the net is already shut down. So ignore.
try:
net.stop()
except OSError:
pass
示例6: main
def main():
args = parse_args()
#setup args from parser
setup(args)
exp = importlib.import_module("."+args.open,package="experiment")
lg.setLogLevel('info')
topo = khalili2hosts()
run_MPTCP(args,topo,exp,end) #launch Test
示例7: main
def main(argv):
args = parse_args()
lg.setLogLevel('info')
"Create and run experiment"
topo = MyTopo()
net = Mininet(topo=topo, link=TCLink, controller = OVSController)
net.start()
Config(net,args)
#dumpNodeConnections(net.hosts)
net.stop()
示例8: httpTest
def httpTest( N=2 ):
"Run pings and monitor multiple hosts using pmonitor"
## SET LOGGING AND CLEANUP PREVIOUS MININET STATE, IF ANY
lg.setLogLevel('info')
cleanup()
## INSTEAD OF RUNNING PYRETIC HUB, UNCOMMENT LINE
## TO SEE THAT THIS WORKS FINE WHEN RUNNING REFERENCE CONTROLLER
# call('controller ptcp: &', shell=True)
## SET UP TOPOLOGY
topo = LinearTopo( N ) ## (tcp parse) warning TCP data offset too long or too short
# topo = SingleSwitchTopo( N ) ## SILENT STALL
## SET UP MININET INSTANCE AND START
net = Mininet( topo, switch=OVSKernelSwitch, host=Host, controller=RemoteController )
net.start()
print "Starting test..."
## GET THE HOST AND SERVER NAMES
hosts = net.hosts
client = hosts[ 0 ]
server = hosts[ 1 ]
## DICTS FOR USE W/ PMONITOR
spopens = {}
cpopens = {}
## WARMUP SERVER
spopens[server] = server.popen('python', '-m', 'SimpleHTTPServer', '80')
sleep(1)
## CLIENT REQUEST
cpopens[client] = client.popen('wget', '-O', '-', server.IP(), stdout=PIPE, stderr=STDOUT)
## MONITOR OUTPUT
for h, line in pmonitor( cpopens, timeoutms=5000 ):
if h and line:
print '%s: %s' % ( h.name, line ),
## TO USE THE COMMAND LINE INTERFACE, BEFORE FINISHING, UNCOMMENT
# CLI( net )
## SHUTDOWN SERVER
spopens[server].send_signal( SIGINT )
## SHUTDOWN MININET
net.stop()
示例9: start
def start(ip="127.0.0.1",port=6633):
ctrlr = lambda n: RemoteController(n,
defaultIP=ip,
port=port,
inNamespace=False)
net = Mininet(switch=UserSwitch, controller=ctrlr, intf=VLANIntf, autoStaticArp=True)
c1 = net.addController('c1')
####### End of static Mininet prologue ######
eth1 = '00:00:00:00:00:01'
eth2 = '00:00:00:00:00:02'
ip1 = '10.0.0.1'
ip2 = '10.0.0.2'
# -- s2 --
# / \
# h1 - s1 s3 - h2
# \ /
# -- s4 --
# Ports to host are numbered 1, then clockwise
h1 = net.addHost('h1', mac=eth1, ip=ip1)
h2 = net.addHost('h2', mac=eth2, ip=ip2)
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
s3 = net.addSwitch('s3')
s4 = net.addSwitch('s4')
net.addLink(h1, s1, 0, 1)
net.addLink(h2, s3, 0, 1)
net.addLink(s1, s2, 2, 1)
net.addLink(s2, s3, 2, 3)
net.addLink(s3, s4, 2, 2)
net.addLink(s4, s1, 1, 3)
###### Start of static Mininet epilogue ######
# Set up logging etc.
lg.setLogLevel('info')
lg.setLogLevel('output')
# Start the network and prime other ARP caches
net.start()
h1.setDefaultRoute('h1-eth0')
h2.setDefaultRoute('h2-eth0')
# Enter CLI mode
output("Network ready\n")
output("Press Ctrl-d or type exit to quit\n")
CLI(net)
net.stop()
示例10: __init__
def __init__(self, verbose=False):
self.checkPATHs()
Mininet.__init__(self, build=False)
self.cr_oshis = []
self.pe_oshis = []
self.ce_routers = []
self.ctrls = []
self.nodes_in_rn = []
self.node_to_data = defaultdict(list)
self.node_to_node = {}
self.node_to_default_via = {}
self.coex = {}
self.verbose = verbose
lg.setLogLevel('info')
self.vlls = []
self.node_to_pw_data = defaultdict(list)
self.pws = []
self.cer_to_customer = {}
self.customer_to_vtepallocator = {}
self.vsfs = []
self.pe_cer_to_vsf = {}
self.is_vs = False
self.vss = []
self.vss_data = []
self.id_peo_to_vs = {}
self.last_ipnet = IPv4Network(u'0.0.0.0/24')
self.id_to_node = {}
self.ip_to_mac = {}
self.overall_info = {}
self.mgmt = None
root = Node( 'root', inNamespace=False )
root.cmd('/etc/init.d/network-manager stop')
mylog("*** Stop Network Manager\n")
self.cluster_to_ctrl = defaultdict(list)
self.cluster_to_nodes = defaultdict(list)
self.nodes_to_cluster = {}
示例11: start
def start(controllers=[{'ip':'127.0.0.1', 'port': 6633}]):
# Set up logging
lg.setLogLevel('info')
lg.setLogLevel('output')
net = Mininet(switch=OVSSwitch, controller=None, autoStaticArp=True, listenPort=6634)
for indx, ctl in enumerate(controllers):
print("Adding controller", (1+indx))
net.addController(('c%d' % indx), controller=RemoteController, ip=ctl['ip'], port=ctl['port'])
# Add hosts
h1 = net.addHost('h1')
h2 = net.addHost('h2')
#physical_intf = 'eth1'
#Add switch that accepts only OpenFlow 1.0
s1 = net.addSwitch('s1', dpid='00:00:00:00:00:00:00:01', protocols='OpenFlow10')
#Will accept both OpenFlow 1.0 and 1.3
#s2 = net.addSwitch('s2', dpid='00:00:00:00:00:00:00:02', protocols='OpenFlow10,OpenFlow13')
#Will accept all protocols support by openvswitch
#s3 = net.addSwitch('s2', dpid='00:00:00:00:00:00:00:02')
# Connect physical interface
#print "Adding physical hosts to mininet network..."
#_intf1 = Intf( physical_intf, node=s1, port=1 )
net.addLink(h1, s1)
net.addLink(h2, s1)
# Start the network and prime other ARP caches
net.start()
net.staticArp()
# Enter CLI mode
output("Network ready\n")
output("Getting results...")
time.sleep(60)
process_results()
#output("Press Ctrl-d or type exit to quit\n")
net.stop()
示例12: main
def main():
lg.setLogLevel( 'info')
c = lambda name: RemoteController(name, defaultIP='132.239.17.35')
if 'fattree' in sys.argv:
net = FatTreeNet(switch=OVSKernelSwitch, controller=c)
elif 'linear' in sys.argv:
net = LinearNet(switch=OVSKernelSwitch, controller=c)
else:
print >> sys.stderr, 'Specify either "fattree" or "linear" as the sole argument.'
return
net.start()
CLI(net)
net.stop()
示例13: go
def go(cargs=None):
global GOPTS
lg.setLogLevel('output')
parser = CommonParser('connectivity_test.py')
parser.add_option('-p', '--num-passes', action="store",dest='passes', type='int', default=2,
help="Number of passes through the network.")
(options, args) = parser.parse_args(cargs)
if options.remote_nox and options.nox_test:
parser.error("Run reference NOX test without the -r option.")
if (options.numhosts < 2 or options.numhosts > MAXHOSTS):
parser.error("Need at least 2 hosts. Maximum of %s" % str(MAXHOSTS))
if not(options.remote_nox) and options.controller != '127.0.0.1:6633':
parser.error("Specified a remote controller address, but -r remote NOX mode not specified.")
if not(options.forwarding.lower() in validforwarding):
parser.error("Please specify a valid forwarding policy for the experiment. hub | lsw | flw.")
(ip,port) = check_controller(options.controller)
if (ip,port) == (None,None):
parser.error("Bad IP:Port specified for controller.")
GOPTS = setFlags(dump_flows=options.dump_flows,nox_test=options.nox_test,
remote_nox=options.remote_nox,flow_size=options.flow_size,
debugp=options.debug,interrupt=options.interrupt,quiet=options.quiet,
agg=options.agg,full_arp=options.arp,verify=options.verify)
GOPTS['interrupt'] = options.interrupt
interval = options.interval
# QUIET mode trumps many options
if GOPTS['quiet']:
GOPTS['debug'] = False
GOPTS['dump'] = False
GOPTS['interrupt'] = False
numpasses = 2
GOPTS['flowsize'] = 56
interval = 1
GOPTS['start'] = time.time()
# Initialize and run
init()
retcode = start(options.numhosts, options.numswitches, options.st,
ip, port, interval, options.forwarding.lower(), options.passes)
return retcode
示例14: launch
def launch(topo = None, routing = None, mode = None):
"""
Args in format toponame,arg1,arg2,...
"""
print("mininet_stuffs")
if not mode:
mode = DEF_MODE
# Instantiate a topo object from the passed-in file.
if not topo:
raise Exception("please specify topo and args on cmd line")
else:
t = buildTopo(topo, topos)
r = getRouting(routing, t)
core.registerNew(RipLController, t, r, mode)
lg.setLogLevel('info')
log.info("RipL-POX running with topo=%s." % topo)
示例15: cleanup
def cleanup():
"""Cleanup all possible junk that we may have started."""
log.setLogLevel('info')
# Standard mininet cleanup
mnclean.cleanup()
# Cleanup any leftover daemon
patterns = []
for d in daemons.__all__:
obj = getattr(daemons, d)
killp = getattr(obj, 'KILL_PATTERNS', None)
if not killp:
continue
if not is_container(killp):
killp = [killp]
patterns.extend(killp)
log.info('*** Cleaning up daemons:\n')
for pattern in patterns:
mnclean.killprocs('"%s"' % pattern)
log.info('\n')