当前位置: 首页>>代码示例>>Python>>正文


Python Node.deleteIntfs方法代码示例

本文整理汇总了Python中mininet.node.Node.deleteIntfs方法的典型用法代码示例。如果您正苦于以下问题:Python Node.deleteIntfs方法的具体用法?Python Node.deleteIntfs怎么用?Python Node.deleteIntfs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mininet.node.Node的用法示例。


在下文中一共展示了Node.deleteIntfs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: scratchNetUser

# 需要导入模块: from mininet.node import Node [as 别名]
# 或者: from mininet.node.Node import deleteIntfs [as 别名]
def scratchNetUser( cname='controller', cargs='ptcp:' ):
    "Create network from scratch using user switch."

    # It's not strictly necessary for the controller and switches
    # to be in separate namespaces. For performance, they probably
    # should be in the root namespace. However, it's interesting to
    # see how they could work even if they are in separate namespaces.

    info( '*** Creating Network\n' )
    controller = Node( 'c0' )
    switch = Node( 's0')
    h0 = Node( 'h0' )
    h1 = Node( 'h1' )
    cintf, sintf = createLink( controller, switch )
    h0intf, sintf1 = createLink( h0, switch )
    h1intf, sintf2 = createLink( h1, switch )

    info( '*** Configuring control network\n' )
    controller.setIP( cintf, '10.0.123.1', 24 )
    switch.setIP( sintf, '10.0.123.2', 24 )

    info( '*** Configuring hosts\n' )
    h0.setIP( h0intf, '192.168.123.1', 24 )
    h1.setIP( h1intf, '192.168.123.2', 24 )

    info( '*** Network state:\n' )
    for node in controller, switch, h0, h1:
        info( str( node ) + '\n' )

    info( '*** Starting controller and user datapath\n' )
    controller.cmd( cname + ' ' + cargs + '&' )
    switch.cmd( 'ifconfig lo 127.0.0.1' )
    intfs = [ sintf1, sintf2 ]
    switch.cmd( 'ofdatapath -i ' + ','.join( intfs ) + ' ptcp: &' )
    switch.cmd( 'ofprotocol tcp:' + controller.IP() + ' tcp:localhost &' )

    info( '*** Running test\n' )
    h0.cmdPrint( 'ping -c1 ' + h1.IP() )

    info( '*** Stopping network\n' )
    controller.cmd( 'kill %' + cname )
    switch.cmd( 'kill %ofdatapath' )
    switch.cmd( 'kill %ofprotocol' )
    switch.deleteIntfs()
    info( '\n' )
开发者ID:09zwcbupt,项目名称:mininet,代码行数:47,代码来源:scratchnetuser.py

示例2: scratchNet

# 需要导入模块: from mininet.node import Node [as 别名]
# 或者: from mininet.node.Node import deleteIntfs [as 别名]
def scratchNet( cname='controller', cargs='-v ptcp:' ):
    "Create network from scratch using Open vSwitch."

    info( "*** Creating nodes\n" )
    controller = Node( 'c0', inNamespace=False )
    switch = Node( 's0', inNamespace=False )
    h0 = Node( 'h0' )
    h1 = Node( 'h1' )

    info( "*** Creating links\n" )
    Link( h0, switch )
    Link( h1, switch )

    info( "*** Configuring hosts\n" )
    h0.setIP( '192.168.123.1/24' )
    h1.setIP( '192.168.123.2/24' )
    info( str( h0 ) + '\n' )
    info( str( h1 ) + '\n' )

    info( "*** Starting network using Open vSwitch\n" )
    controller.cmd( cname + ' ' + cargs + '&' )
    switch.cmd( 'ovs-vsctl del-br dp0' )
    switch.cmd( 'ovs-vsctl add-br dp0' )
    for intf in switch.intfs.values():
        print switch.cmd( 'ovs-vsctl add-port dp0 %s' % intf )

    # Note: controller and switch are in root namespace, and we
    # can connect via loopback interface
    switch.cmd( 'ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633' )

    info( '*** Waiting for switch to connect to controller' )
    while 'is_connected' not in quietRun( 'ovs-vsctl show' ):
        sleep( 1 )
        info( '.' )
    info( '\n' )

    info( "*** Running test\n" )
    h0.cmdPrint( 'ping -c1 ' + h1.IP() )

    info( "*** Stopping network\n" )
    controller.cmd( 'kill %' + cname )
    switch.cmd( 'ovs-vsctl del-br dp0' )
    switch.deleteIntfs()
    info( '\n' )
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:46,代码来源:scratchnet.py

示例3: scratchNet

# 需要导入模块: from mininet.node import Node [as 别名]
# 或者: from mininet.node.Node import deleteIntfs [as 别名]
def scratchNet(cname="controller", cargs="-v ptcp:"):
    "Create network from scratch using Open vSwitch."

    info("*** Creating nodes\n")
    controller = Node("c0", inNamespace=False)
    switch = Node("s0", inNamespace=False)
    h0 = Node("h0")
    h1 = Node("h1")

    info("*** Creating links\n")
    Link(h0, switch)
    Link(h1, switch)

    info("*** Configuring hosts\n")
    h0.setIP("192.168.123.1/24")
    h1.setIP("192.168.123.2/24")
    info(str(h0) + "\n")
    info(str(h1) + "\n")

    info("*** Starting network using Open vSwitch\n")
    controller.cmd(cname + " " + cargs + "&")
    switch.cmd("ovs-vsctl del-br dp0")
    switch.cmd("ovs-vsctl add-br dp0")
    for intf in switch.intfs.values():
        print(switch.cmd("ovs-vsctl add-port dp0 %s" % intf))

    # Note: controller and switch are in root namespace, and we
    # can connect via loopback interface
    switch.cmd("ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633")

    info("*** Waiting for switch to connect to controller")
    while "is_connected" not in quietRun("ovs-vsctl show"):
        sleep(1)
        info(".")
    info("\n")

    info("*** Running test\n")
    h0.cmdPrint("ping -c1 " + h1.IP())

    info("*** Stopping network\n")
    controller.cmd("kill %" + cname)
    switch.cmd("ovs-vsctl del-br dp0")
    switch.deleteIntfs()
    info("\n")
开发者ID:jhall11,项目名称:mininet,代码行数:46,代码来源:scratchnet.py

示例4: scratchNet

# 需要导入模块: from mininet.node import Node [as 别名]
# 或者: from mininet.node.Node import deleteIntfs [as 别名]
def scratchNet( cname='controller', cargs='ptcp:' ):
    "Create network from scratch using kernel switch."

    info( "*** Creating nodes\n" )
    controller = Node( 'c0', inNamespace=False )
    switch = Node( 's0', inNamespace=False )
    h0 = Node( 'h0' )
    h1 = Node( 'h1' )

    info( "*** Creating links\n" )
    createLink( node1=h0, node2=switch, port1=0, port2=0 )
    createLink( node1=h1, node2=switch, port1=0, port2=1 )

    info( "*** Configuring hosts\n" )
    h0.setIP( h0.intfs[ 0 ], '192.168.123.1', 24 )
    h1.setIP( h1.intfs[ 0 ], '192.168.123.2', 24 )
    info( str( h0 ) + '\n' )
    info( str( h1 ) + '\n' )

    info( "*** Starting network using Open vSwitch kernel datapath\n" )
    controller.cmd( cname + ' ' + cargs + '&' )
    switch.cmd( 'ovs-dpctl del-dp dp0' )
    switch.cmd( 'ovs-dpctl add-dp dp0' )
    for intf in switch.intfs.values():
        print switch.cmd( 'ovs-dpctl add-if dp0 ' + intf )
    print switch.cmd( 'ovs-openflowd dp0 tcp:127.0.0.1 &' )

    info( "*** Running test\n" )
    h0.cmdPrint( 'ping -c1 ' + h1.IP() )

    info( "*** Stopping network\n" )
    controller.cmd( 'kill %' + cname )
    switch.cmd( 'ovs-dpctl del-dp dp0' )
    switch.cmd( 'kill %ovs-openflowd' )
    switch.deleteIntfs()
    info( '\n' )
开发者ID:09zwcbupt,项目名称:mininet,代码行数:38,代码来源:scratchnet.py


注:本文中的mininet.node.Node.deleteIntfs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。