當前位置: 首頁>>代碼示例>>Python>>正文


Python Containernet.ping方法代碼示例

本文整理匯總了Python中mininet.net.Containernet.ping方法的典型用法代碼示例。如果您正苦於以下問題:Python Containernet.ping方法的具體用法?Python Containernet.ping怎麽用?Python Containernet.ping使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mininet.net.Containernet的用法示例。


在下文中一共展示了Containernet.ping方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: topology

# 需要導入模塊: from mininet.net import Containernet [as 別名]
# 或者: from mininet.net.Containernet import ping [as 別名]
def topology():

    "Create a network with some docker containers acting as hosts."

    net = Containernet(controller=Controller)

    info('*** Adding controller\n')
    net.addController('c0')

    info('*** Adding hosts\n')
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')

    info('*** Adding docker containers\n')
    d1 = net.addDocker('d1', ip='10.0.0.251', dimage="ubuntu:trusty")
    d2 = net.addDocker('d2', ip='10.0.0.252', dimage="ubuntu:trusty", cpu_period=50000, cpu_quota=25000)
    d3 = net.addHost(
        'd3', ip='11.0.0.253', cls=Docker, dimage="ubuntu:trusty", cpu_shares=20)
    d5 = net.addDocker('d5', dimage="ubuntu:trusty", volumes=["/:/mnt/vol1:rw"])

    info('*** Adding switch\n')
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2', cls=OVSSwitch)
    s3 = net.addSwitch('s3')

    info('*** Creating links\n')
    net.addLink(h1, s1)
    net.addLink(s1, d1)
    net.addLink(h2, s2)
    net.addLink(d2, s2)
    net.addLink(s1, s2)
    #net.addLink(s1, s2, cls=TCLink, delay="100ms", bw=1, loss=10)
    # try to add a second interface to a docker container
    net.addLink(d2, s3, params1={"ip": "11.0.0.254/8"})
    net.addLink(d3, s3)

    info('*** Starting network\n')
    net.start()

    net.ping([d1, d2])

    # our extended ping functionality
    net.ping([d1], manualdestip="10.0.0.252")
    net.ping([d2, d3], manualdestip="11.0.0.254")

    info('*** Dynamically add a container at runtime\n')
    d4 = net.addDocker('d4', dimage="ubuntu:trusty")
    # we have to specify a manual ip when we add a link at runtime
    net.addLink(d4, s1, params1={"ip": "10.0.0.254/8"})
    # other options to do this
    #d4.defaultIntf().ifconfig("10.0.0.254 up")
    #d4.setIP("10.0.0.254")

    net.ping([d1], manualdestip="10.0.0.254")

    info('*** Running CLI\n')
    CLI(net)

    info('*** Stopping network')
    net.stop()
開發者ID:mpeuster,項目名稱:containernet,代碼行數:62,代碼來源:dockerhosts.py

示例2: setLogLevel

# 需要導入模塊: from mininet.net import Containernet [as 別名]
# 或者: from mininet.net.Containernet import ping [as 別名]
"""
from mininet.net import Containernet
from mininet.node import Controller
from mininet.cli import CLI
from mininet.link import TCLink
from mininet.log import info, setLogLevel
setLogLevel('info')

net = Containernet(controller=Controller)
info('*** Adding controller\n')
net.addController('c0')
info('*** Adding docker containers\n')
d1 = net.addDocker('d1', ip='10.0.0.251', dimage="ubuntu:trusty")
d2 = net.addDocker('d2', ip='10.0.0.252', dimage="ubuntu:trusty")
info('*** Adding switches\n')
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
info('*** Creating links\n')
net.addLink(d1, s1)
net.addLink(s1, s2, cls=TCLink, delay='100ms', bw=1)
net.addLink(s2, d2)
info('*** Starting network\n')
net.start()
info('*** Testing connectivity\n')
net.ping([d1, d2])
info('*** Running CLI\n')
CLI(net)
info('*** Stopping network')
net.stop()

開發者ID:stevenvanrossem,項目名稱:containernet,代碼行數:31,代碼來源:containernet_example.py

示例3: info

# 需要導入模塊: from mininet.net import Containernet [as 別名]
# 或者: from mininet.net.Containernet import ping [as 別名]
d5 = net.addDocker('d5', dimage="containernet_example:centos6")
d6 = net.addDocker('d6', dimage="containernet_example:centos7")

info('*** Adding switches\n')
s1 = net.addSwitch('s1')

info('*** Creating links\n')
net.addLink(d1, s1)
net.addLink(d2, s1)
net.addLink(d3, s1)
net.addLink(d4, s1)
net.addLink(d5, s1)
net.addLink(d6, s1)

info('*** Starting network\n')
net.start()

info('*** Testing connectivity\n')
net.ping([d2, d1])
net.ping([d3, d1])
net.ping([d4, d1])
net.ping([d5, d1])
net.ping([d6, d1])

info('*** Running CLI\n')
CLI(net)

info('*** Stopping network')
net.stop()

開發者ID:stevenvanrossem,項目名稱:containernet,代碼行數:31,代碼來源:containernet_container_test.py


注:本文中的mininet.net.Containernet.ping方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。