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


Python Mininet.removeHost方法代码示例

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


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

示例1: MininetManager

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import removeHost [as 别名]
class MininetManager(object):

    def __init__(self):
        self.logger = logging.getLogger(__name__)
        self.net = None

    @Pyro4.expose
    def create_mininet(self, topo, tunnels=[],  switch=UserSwitch,
                       controller=None, STT=False):
        if(not self.net is None):
            self.logger.warn("running mininet instance detected!\
                              Shutting it down...")
            self.destroy_mininet()

        self.logger.info("Creating mininet instance")
        if controller:
            self.net = Mininet(topo=topo, intf=TCIntf, link=TCLink,
                               switch=switch, controller=controller)
        else:
            self.net = Mininet(topo=topo, intf=TCIntf, link=TCLink,
                               switch=switch)
        if STT:
            self.logger.info("Starting Mininet...")
            self.net.start()
        self.logger.info("Adding tunnels to mininet instance")
        for tunnel in tunnels:
            port = None
            cls = None
            if "port" in tunnel[2].keys():
                port = tunnel[2]["port"]
                del tunnel[2]["port"]
            if "cls" in tunnel[2].keys():
                cls = tunnel[2]["cls"]
                del tunnel[2]["cls"]
            self.addTunnel(tunnel[0], tunnel[1], port, cls, STT=STT, **tunnel[2])
        if not STT:
            self.logger.info("Starting Mininet...")
            self.net.start()
        self.logger.info("Startup complete.")
        self.x11popens = []
        return True

    @Pyro4.expose
    def destroy_mininet(self):
        """shut down mininet instance"""
        if self.net:
            for popen in self.x11popens:
                popen.terminate()
                popen.communicate()
                popen.wait()
            self.net.stop()
            # remove mininet instance and running docker container
            cleanup()
            self.logger.info("mininet instance terminated")
            self.net = None

    @Pyro4.expose
    def configLinkStatus(self, src, dst, status):
        self.net.configLinkStatus(src, dst, status)

    @Pyro4.expose
    def rpc(self, hostname, cmd, *params1, **params2):
        h = self.net.get(hostname)
        return getattr(h, cmd)(*params1, **params2)

    @Pyro4.expose
    def attr(self, hostname, name):
        h = self.net.get(hostname)
        return getattr(h, name)

    @Pyro4.expose
    def addHost(self, name, cls=None, **params):
        self.net.addHost(name, cls, **params)
        return name

    @Pyro4.expose
    def removeHost(self, name, **params):
        # Method of Containernet to remove a host
        return self.net.removeHost(name, **params)

    @Pyro4.expose
    def addSwitch(self, name, cls=None, **params):
        self.net.addSwitch(name, cls, **params)
        #TODO: This should not be done here
        self.net.get(name).start(self.net.controllers)
        return name

    @Pyro4.expose
    def addController(self, name="c0", controller=None, **params):
        self.net.addController(name, controller, **params)
        return name

    @Pyro4.expose
    def addTunnel(self, name, switch, port, intf, STT=False, **params):
        switch_i = self.net.get(switch)
        if not intf:
            intf = TCIntf
        if STT:
            subprocess.check_output(["ovs-vsctl","add-port", switch, name])
        else:
#.........这里部分代码省略.........
开发者ID:setchring,项目名称:MaxiNet,代码行数:103,代码来源:server.py


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