本文整理汇总了Python中mininet.node.Host.cmd方法的典型用法代码示例。如果您正苦于以下问题:Python Host.cmd方法的具体用法?Python Host.cmd怎么用?Python Host.cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.node.Host
的用法示例。
在下文中一共展示了Host.cmd方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Host
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import cmd [as 别名]
root = Host( 'root', inNamespace=False )
print( "*** Creating links" )
h1.linkTo( root )
print( h1 )
print( "*** Configuring nodes" )
h1.setIP( '10.0.0.1', 8 )
root.setIP( '10.0.0.2', 8 )
print( "*** Creating banner file" )
f = open( '/tmp/%s.banner' % h1.name, 'w' )
f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
f.close()
print( "*** Running sshd" )
cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
# add arguments from the command line
if len( sys.argv ) > 1:
cmd += ' ' + ' '.join( sys.argv[ 1: ] )
h1.cmd( cmd )
listening = waitListening( server=h1, port=22, timeout=timeout )
if listening:
print( "*** You may now ssh into", h1.name, "at", h1.IP() )
else:
print( "*** Warning: after %s seconds, %s is not listening on port 22"
% ( timeout, h1.name ) )
示例2: Host
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import cmd [as 别名]
#!/usr/bin/python
"This example doesn't use OpenFlow, but attempts to run sshd in a namespace."
from mininet.node import Host
print "*** Creating nodes"
h1 = Host( 'h1' )
root = Host( 'root', inNamespace=False )
print "*** Creating links"
h1.linkTo( root )
print "*** Configuring nodes"
h1.setIP( h1.intfs[ 0 ], '10.0.0.1', 8 )
root.setIP( root.intfs[ 0 ], '10.0.0.2', 8 )
print "*** Creating banner file"
f = open( '/tmp/%s.banner' % h1.name, 'w' )
f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
f.close()
print "*** Running sshd"
h1.cmd( '/usr/sbin/sshd -o "Banner /tmp/%s.banner"' % h1.name )
print "*** You may now ssh into", h1.name, "at", h1.IP()
示例3: Host
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import cmd [as 别名]
#!/usr/bin/python
from mininet.topo import Topo
from mininet.node import Host, OVSSwitch, Controller
from mininet.link import Link
h1 = Host('h1')
h2 = Host('h2')
s1 = OVSSwitch('s1', inNamespace=False)
c0 = Controller('c0', inNamespace=False)
Link(h1,s1)
Link(h2,s1)
h1.setIP('10.1/8')
h2.setIP('10.2/8')
c0.start()
s1.start([c0])
print h1.cmd('ping -c1', h2.IP())
s1.stop()
c0.stop()
示例4: RemoteController
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import cmd [as 别名]
c3 = RemoteController( 'c3', ip = '10.108.101.48' )
l1 = Link( h0, s1 )
Link( h1, s1 )
Link( h2, s2 )
Link( h3, s3 )
Link( s0, s1 )
Link( s0, s2 )
Link( s0, s3 )
h0.setIP( '10.1.0.1/16' )
h1.setIP( '10.1.0.2/16' )
h2.setIP( '10.2.0.1/16' )
h3.setIP( '10.3.0.1/16' )
print h0.cmd('ifconfig')
c0.start()
c1.start()
c2.start()
c3.start()
s0.start( [ c0 ] )
s1.start( [ c1 ] )
s2.start( [ c2 ] )
s3.start( [ c3 ] )
dumpNodeConnections([s0,s1,s2,s3,h0,h1,h2,h3])
temp = l1.intf1
l1.delete()
h0.intfs = {}
示例5: isListeningOn
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import cmd [as 别名]
def isListeningOn(self, Host, port):
result = Host.cmd ('lsof -i %s'%port)
if result.find(':%s'%result.partition(':')[2]) == -1:
return False
else:
return True