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


Python Topology.instance方法代码示例

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


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

示例1: _idlePCFinderSlot

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
 def _idlePCFinderSlot(self):
     """
     Slot for the idle-PC finder.
     """
     if Topology.instance().project() is None:
         project = Topology.instance().createLoadProject({"project_name": str(uuid.uuid4())})
         project.project_updated_signal.connect(self._projectCreatedSlot)
     else:
         self._projectCreatedSlot()
开发者ID:maherja,项目名称:gns3-gui,代码行数:11,代码来源:ios_router_wizard.py

示例2: _projectClosedCallback

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
    def _projectClosedCallback(self, result, error=False, server=None, **kwargs):

        # Status 404 could be when someone else already closed the project
        if error and "status" in result and result["status"] != 404:
            log.error("Error while closing project {}: {}".format(self._id, result["message"]))
        else:
            self.stopListenNotifications()
            log.debug("Project {} closed".format(self._id))

        self._closed = True
        self.project_closed_signal.emit()
        Topology.instance().setProject(None)
开发者ID:athmane,项目名称:gns3-gui,代码行数:14,代码来源:project.py

示例3: _event_received

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
    def _event_received(self, result, server=None, **kwargs):

        log.debug("Event received: %s", result)
        if result["action"] in ["vm.started", "vm.stopped"]:
            vm = Topology.instance().getVM(result["event"]["vm_id"])
            if vm is not None:
                if result["action"] == "vm.started":
                    vm.setStatus(Node.started)
                    vm.started_signal.emit()
                elif result["action"] == "vm.stopped":
                    vm.setStatus(Node.stopped)
                    vm.stopped_signal.emit()
        elif result["action"] == "log.error":
            log.error(result["event"]["message"])
            print("Error: " + result["event"]["message"])
        elif result["action"] == "log.warning":
            log.warning(result["event"]["message"])
            print("Warning: " + result["event"]["message"])
        elif result["action"] == "log.info":
            log.info(result["event"]["message"])
            print("Info: " + result["event"]["message"])
        elif result["action"] == "ping":
            # Compatible with 1.4.0 server
            if "event" in result:
                server.setSystemUsage(result["event"])
开发者ID:GNS3,项目名称:gns3-gui,代码行数:27,代码来源:project.py

示例4: _listDrawingsCallback

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
 def _listDrawingsCallback(self, result, error=False, **kwargs):
     if error:
         log.error("Error while listing drawings: {}".format(result["message"]))
         return
     topo = Topology.instance()
     for drawing in result:
         topo.createDrawing(drawing)
     self.project_loaded_signal.emit()
开发者ID:athmane,项目名称:gns3-gui,代码行数:10,代码来源:project.py

示例5: _listLinksCallback

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
 def _listLinksCallback(self, result, error=False, **kwargs):
     if error:
         log.error("Error while listing links: {}".format(result["message"]))
         return
     topo = Topology.instance()
     for link in result:
         topo.createLink(link)
     self.get("/drawings", self._listDrawingsCallback)
开发者ID:athmane,项目名称:gns3-gui,代码行数:10,代码来源:project.py

示例6: _listNodesCallback

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
 def _listNodesCallback(self, result, error=False, **kwargs):
     if error:
         log.error("Error while listing project: {}".format(result["message"]))
         return
     topo = Topology.instance()
     for node in result:
         topo.createNode(node)
     self.get("/links", self._listLinksCallback)
开发者ID:athmane,项目名称:gns3-gui,代码行数:10,代码来源:project.py

示例7: _projectCreatedSlot

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
    def _projectCreatedSlot(self, *args):
        if Topology.instance().project() is None:
            return
        try:
            Topology.instance().project().project_updated_signal.disconnect(self._projectCreatedSlot)
            self._project_created = True
        except TypeError:
            pass  # If the slot is not connected (project already created)

        module = Dynamips.instance()
        platform = self.uiPlatformComboBox.currentText()
        ios_image = self.uiIOSImageLineEdit.text()
        ram = self.uiRamSpinBox.value()
        router_class = PLATFORM_TO_CLASS[platform]

        self._router = router_class(module, ComputeManager.instance().getCompute(self._compute_id), Topology.instance().project())
        self._router.create(ios_image, ram, name="AUTOIDLEPC")
        self._router.created_signal.connect(self.createdSlot)
        self._router.server_error_signal.connect(self.serverErrorSlot)
        self.uiIdlePCFinderPushButton.setEnabled(False)
开发者ID:maherja,项目名称:gns3-gui,代码行数:22,代码来源:ios_router_wizard.py

示例8: _computeAutoIdlepcCallback

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
    def _computeAutoIdlepcCallback(self, result, error=False, *args, **kwargs):
        """
        Callback for computeAutoIdlepc.

        :param result: server response
        :param error: indicates an error (boolean)
        """

        if self._project_created:
            Topology.instance().deleteProject()
            self._project_created = False
            self._router = None
        elif self._router:
            self._router.delete()
            self._router = None
        if error:
            QtWidgets.QMessageBox.critical(self, "Idle-PC finder", "Error: {}".format(result["message"]))
        else:
            idlepc = result["idlepc"]
            self.uiIdlepcLineEdit.setText(idlepc)
            QtWidgets.QMessageBox.information(self, "Idle-PC finder", "Idle-PC value {} has been found suitable for your IOS image".format(idlepc))
开发者ID:maherja,项目名称:gns3-gui,代码行数:23,代码来源:ios_router_wizard.py

示例9: _event_received

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
    def _event_received(self, result, **kwargs):

        log.debug("Event received: %s", result)
        if result["action"] in ["vm.started", "vm.stopped"]:
            vm = Topology.instance().getVM(result["event"]["vm_id"])
            if vm is not None:
                if result["action"] == "vm.started":
                    vm.setStatus(Node.started)
                    vm.started_signal.emit()
                elif result["action"] == "vm.stopped":
                    vm.setStatus(Node.stopped)
                    vm.stopped_signal.emit()
        elif result["action"] == "log.error":
            log.error(result["event"]["message"])
            print("Error: " + result["event"]["message"])
        elif result["action"] == "log.warning":
            log.warning(result["event"]["message"])
            print("Warning: " + result["event"]["message"])
开发者ID:guili618,项目名称:gns3-gui,代码行数:20,代码来源:project.py

示例10: setUp

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
 def setUp(self):
     self.t = Topology.instance()
开发者ID:Jatinamin,项目名称:gns3-gui,代码行数:4,代码来源:test_topology.py

示例11: _event_received

# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import instance [as 别名]
 def _event_received(self, result, *args, **kwargs):
     # Log only relevant events
     if result["action"] not in ("ping", "compute.updated"):
         log.debug("Event received: %s", result)
     if result["action"] == "node.created":
         node = Topology.instance().getNodeFromUuid(result["event"]["node_id"])
         if node is None:
             Topology.instance().createNode(result["event"])
     elif result["action"] == "node.updated":
         node = Topology.instance().getNodeFromUuid(result["event"]["node_id"])
         if node is not None:
             node.updateNodeCallback(result["event"])
     elif result["action"] == "node.deleted":
         node = Topology.instance().getNodeFromUuid(result["event"]["node_id"])
         if node is not None:
             node.delete(skip_controller=True)
     elif result["action"] == "link.created":
         link = Topology.instance().getLinkFromUuid(result["event"]["link_id"])
         if link is None:
             Topology.instance().createLink(result["event"])
     elif result["action"] == "link.updated":
         link = Topology.instance().getLinkFromUuid(result["event"]["link_id"])
         if link is not None:
             link.updateLinkCallback(result["event"])
     elif result["action"] == "link.deleted":
         link = Topology.instance().getLinkFromUuid(result["event"]["link_id"])
         if link is not None:
             link.deleteLink(skip_controller=True)
     elif result["action"] == "drawing.created":
         drawing = Topology.instance().getDrawingFromUuid(result["event"]["drawing_id"])
         if drawing is None:
             Topology.instance().createDrawing(result["event"])
     elif result["action"] == "drawing.updated":
         drawing = Topology.instance().getDrawingFromUuid(result["event"]["drawing_id"])
         if drawing is not None:
             drawing.updateDrawingCallback(result["event"])
     elif result["action"] == "drawing.deleted":
         drawing = Topology.instance().getDrawingFromUuid(result["event"]["drawing_id"])
         if drawing is not None:
             drawing.delete(skip_controller=True)
     elif result["action"] == "project.closed":
         Topology.instance().setProject(None)
     elif result["action"] == "project.updated":
         self._projectUpdatedCallback(result["event"])
     elif result["action"] == "snapshot.restored":
         Topology.instance().createLoadProject({"project_id": result["event"]["project_id"]})
     elif result["action"] == "log.error":
         log.error(result["event"]["message"])
     elif result["action"] == "log.warning":
         log.warning(result["event"]["message"])
     elif result["action"] == "log.info":
         log.info(result["event"]["message"], extra={"show": True})
     elif result["action"] == "compute.created" or result["action"] == "compute.updated":
         cm = ComputeManager.instance()
         cm.computeDataReceivedCallback(result["event"])
     elif result["action"] == "settings.updated":
         LocalConfig.instance().refreshConfigFromController()
         ApplianceManager.instance().refresh()
     elif result["action"] == "ping":
         pass
开发者ID:athmane,项目名称:gns3-gui,代码行数:62,代码来源:project.py


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