本文整理汇总了Python中mininet.term.makeTerms函数的典型用法代码示例。如果您正苦于以下问题:Python makeTerms函数的具体用法?Python makeTerms怎么用?Python makeTerms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeTerms函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startTerms
def startTerms(self):
"Start a terminal for each node."
info("*** Running terms on %s\n" % os.environ["DISPLAY"])
cleanUpScreens()
self.terms += makeTerms(self.controllers, "controller")
self.terms += makeTerms(self.switches, "switch")
self.terms += makeTerms(self.hosts, "host")
示例2: startTerms
def startTerms( self ):
"Start a terminal for each node."
info( "*** Running terms on %s\n" % os.environ[ 'DISPLAY' ] )
cleanUpScreens()
self.terms += makeTerms( self.controllers, 'controller' )
self.terms += makeTerms( self.switches, 'switch' )
self.terms += makeTerms( self.hosts, 'host' )
示例3: run_exercise
def run_exercise():
#Create and start a new network with our custom topology
topo = SSHTopo()
net = Mininet(topo=topo)
net.start()
pids = []
net['httpd'].cmd('ip addr add fc00::5:80/64 dev httpd-eth0')
net['httpd'].cmd('ip addr add fc00::5:88/64 dev httpd-eth0')
net['httpd'].cmd('ip addr add fc00::5:8080/64 dev httpd-eth0')
net['httpd'].cmd('ip addr add fc00::5:8888/64 dev httpd-eth0')
net['httpd'].cmd('ip addr add fc00::5:8889/64 dev httpd-eth0')
for i in range(1,20):
net['proxy%i'%i].cmd('ip addr add fc00::5:%x/64 dev proxy%i-eth0'%(i*111, i))
pids.append(net["proxy%i"%i].popen('/usr/sbin/sshd', '-o', 'PermitTTY=no', '-o', 'ForceCommand=/usr/sbin/nologin').pid)
httpd_pid = net["httpd"].popen('nginx', '-c', '/home/vagrant/assignments/ssh/nginx.conf').pid
ssh1_sshd_pid = net["ssh1"].popen('/usr/sbin/sshd', '-o', 'Ciphers=3des-cbc', '-o', 'PrintMotd=yes').pid #, '-f', '/home/vagrant/assignments/ssh/ssh1_sshd.conf').pid
ssh3_sshd_pid = net["ssh3"].popen('/usr/sbin/sshd', '-o', 'PrintMotd=no').pid
pids += [httpd_pid, ssh1_sshd_pid, ssh3_sshd_pid]
makeTerms([net["you"]], title="term1")
makeTerms([net["you"]], title="term2")
state = ExerciseState(net, pids)
return state
示例4: startTerms
def startTerms(self):
"Start a terminal for each node."
if "DISPLAY" not in os.environ:
error("Error starting terms: Cannot connect to display\n")
return
info("*** Running terms on %s\n" % os.environ["DISPLAY"])
cleanUpScreens()
self.terms += makeTerms(self.controllers, "controller")
self.terms += makeTerms(self.switches, "switch")
self.terms += makeTerms(self.hosts, "host")
示例5: startTerms
def startTerms( self ):
"Start a terminal for each node."
if 'DISPLAY' not in os.environ:
error( "Error starting terms: Cannot connect to display\n" )
return
info( "*** Running terms on %s\n" % os.environ[ 'DISPLAY' ] )
cleanUpScreens()
self.terms += makeTerms( self.controllers, 'controller' )
self.terms += makeTerms( self.switches, 'switch' )
self.terms += makeTerms( self.hosts, 'host' )
示例6: run_exercise
def run_exercise():
#Create and start a new network with our custom topology
topo = TLSTopo()
net = Mininet(topo=topo)
net.start()
net.pingAll()
processes = []
#Start Nginx HTTP-server
processes.append(net["Server-1"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_1.conf'))
processes.append(net["Server-2"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_2.conf'))
processes.append(net["Server-3"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_3.conf'))
processes.append(net["Server-4"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_4.conf'))
processes.append(net["Server-5"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_5.conf'))
#Open wireshark
processes.append(net["A"].popen('wireshark'))
#Open terminals
processes.append(makeTerms([net["A"]], title="Student terminal")[0])
raw_input("Press Enter to exit....")
for process in processes:
process.kill()
Cleanup.cleanup()
示例7: dhcpdemo
def dhcpdemo( firefox=True , controller=None):
"Rogue DHCP server demonstration"
checkRequired()
topo = DHCPTopo()
net = Mininet( topo=topo, link=TCLink , switch=OVSSwitch, controller=controller)
h1, dhcp, evil = net.get( 'h1', 'dhcp', 'evil' )
# connectToInternet calls net.start() for us!
rootnode = connectToInternet( net, 's1' )
mountPrivateResolvconf( h1 )
# Set up a good but slow DHCP server
startDHCPserver( dhcp, gw=rootnode.IP(), dns='8.8.8.8')
startDHCPclient( h1 )
waitForIP( h1 )
# Make sure we can fetch the good google.com
info( '* Fetching google.com:\n' )
print h1.cmd( 'curl google.com' )
# For firefox, start it up and tell user what to do
if firefox:
net.terms += makeTerms( [ h1 ], 'h1' )
h1.cmd( 'firefox www.stanford.edu -geometry 400x400-50+50 &' )
print '*** You may want to do some DNS lookups using dig'
print '*** Please go to amazon.com in Firefox'
print '*** You may also wish to start up wireshark and look at bootp and/or dns'
prompt( "*** Press return to start up evil DHCP server: " )
# Now start up an evil but fast DHCP server
startDHCPserver( evil, gw=rootnode.IP(), dns=evil.IP() )
# And an evil fake DNS server
startFakeDNS( evil )
# And an evil web server
startEvilWebServer( evil )
h1.cmd( 'ifconfig', h1.defaultIntf(), '0' )
waitForIP( h1 )
info( '* New DNS result:\n' )
info( h1.cmd( 'host google.com' ) )
# Test http request
if firefox:
print "*** You may wish to look at DHCP and DNS results in wireshark"
print "*** You may also wish to do some DNS lookups using dig"
print "*** Please go to google.com in Firefox"
print "*** You may also want to try going back to amazon.com and hitting shift-refresh"
else:
info( '* Fetching google.com:\n' )
print h1.cmd( 'curl google.com' )
if firefox:
prompt( "*** Press return to shut down evil DHCP/DNS/Web servers: " )
# Clean up everything
stopFakeDNS( evil )
stopEvilWebServer( evil )
stopDHCPserver( evil )
if firefox:
print "*** Try going to some other web sites if you like"
prompt( "*** Press return to exit: " )
stopDHCPserver( dhcp )
stopDHCPclient( h1 )
stopNAT( rootnode )
unmountPrivateResolvconf( h1 )
net.stop()
示例8: do_xterm
def do_xterm( self, line, term='xterm' ):
"Spawn xterm(s) for the given node(s)."
args = line.split()
if not args:
error( 'usage: %s node1 node2 ...\n' % term )
else:
for arg in args:
if arg not in self.mn:
error( "node '%s' not in network\n" % arg )
else:
node = self.mn[ arg ]
self.mn.terms += makeTerms( [ node ], term = term )
示例9: do_xterm
def do_xterm( self, line, term='xterm' ):
"Spawn xterm(s) for the given component(s)."
args = line.split()
if not args:
error( 'usage: %s comp1 comp2 ...\n' % term )
else:
for arg in args:
if arg not in self.cn:
error( "component '%s' not in network\n" % arg )
else:
comp = self.cn[ arg ]
self.cn.terms += makeTerms( [ comp.node ], term = term )
示例10: process_message
def process_message(self, msg):
if msg == 'current_network':
self.send_network()
elif msg.startswith('link '):
self.mininet.configLinkStatus( *msg.split()[1:] )
elif msg.startswith('node xterm'):
node = self.mininet[msg.split()[-1]]
self.mininet.terms += makeTerms([node], term = 'xterm')
elif msg == 'port_stats_request':
self.handle_port_stats_request()
elif msg == 'flow_stats_request':
self.handle_flow_stats_request()
else:
self.log.warn('Unrecognized message from browser: %s' % msg)
示例11: newTerm
def newTerm( net=self.net, node=self.node, title=self.title ):
"Pop up a new terminal window for a node."
net.terms += makeTerms( [ node ], title )
示例12: _createHostAtDummy
def _createHostAtDummy( self, hostName, **params ):
"""
Add a host node to Mininet and link it to the dummy.
hostName: name of the host
params: parameters for host
"""
if self.debug_flag1:
print "EXEC: createHostAtDummy(%s):" % hostName
# Part 0: Main assertions.
assert hostName not in self.mn.nameToNode
assert self.mn.built
# Part 1: Getting dummy.
dummy = self.mn.nameToNode.get("dummy", None)
if dummy is None:
error('dummy node does not exist\n')
return
assert isinstance(dummy, Dummy)
# The following corresponds to code in self.build()
# if self.topo:
# self.buildFromTopo( self.topo )
info( '*** Adding host: %s\n' % hostName )
host = self.mn.addHost( hostName, **params )
info( '*** Adding link: (%s, %s)\n' % ( host.name, dummy.name ) )
hostPort = host.newPort()
dummyPort = dummy.newPort()
self.mn.addLink( host, dummy, hostPort, dummyPort )
# if ( self.inNamespace ):
# self.configureControlNetwork()
if ( self.mn.inNamespace ):
self.mn.configureControlNetwork()
# info( '*** Configuring hosts\n' )
# self.configHosts()
info( '*** Configuring host: %s\n' % host.name )
intf = host.defaultIntf()
if intf:
host.configDefault()
else: # Don't configure nonexistent intf
host.configDefault( ip=None, mac=None )
host.cmd( 'ifconfig lo up' )
# if self.xterms:
# self.startTerms()
if self.mn.xterms:
if 'DISPLAY' not in os.environ:
error( "Error starting terms: Cannot connect to display\n" )
return
info( "*** Running term on %s\n" % os.environ[ 'DISPLAY' ] )
self.mn.terms += makeTerms( [host], 'host' )
# if self.autoStaticArp:
# self.staticArp()
if self.mn.autoStaticArp:
for dst in self.mn.hosts:
if host != dst:
host.setARP( ip=dst.IP(), mac=dst.MAC() )
dst.setARP( ip=host.IP(), mac=host.MAC() )
# self.built = True
self.mn.built = True
return host
示例13: _tempStartDummy
def _tempStartDummy(self):
info( '\n*** Adding dummy:\n' )
dummy = self._addDummy()
self.mn.terms += makeTerms( [dummy], 'dummy' )