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


Python Controller.instance方法代码示例

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


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

示例1: _qemuVMEditSlot

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def _qemuVMEditSlot(self):
        """
        Edits a QEMU VM.
        """

        item = self.uiQemuVMsTreeWidget.currentItem()
        if item:
            key = item.data(0, QtCore.Qt.UserRole)
            qemu_vm = self._qemu_vms[key]
            dialog = ConfigurationDialog(qemu_vm["name"], qemu_vm, QemuVMConfigurationPage(), parent=self)
            dialog.show()
            if dialog.exec_():
                # update the icon
                Controller.instance().getSymbolIcon(qemu_vm["symbol"], qpartial(self._setItemIcon, item))

                if qemu_vm["name"] != item.text(0):
                    new_key = "{server}:{name}".format(server=qemu_vm["server"], name=qemu_vm["name"])
                    if new_key in self._qemu_vms:
                        QtWidgets.QMessageBox.critical(self, "QEMU VM", "QEMU VM name {} already exists for server {}".format(qemu_vm["name"],
                                                                                                                              qemu_vm["server"]))
                        qemu_vm["name"] = item.text(0)
                        return
                    self._qemu_vms[new_key] = self._qemu_vms[key]
                    del self._qemu_vms[key]
                    item.setText(0, qemu_vm["name"])
                    item.setData(0, QtCore.Qt.UserRole, new_key)

                self._refreshInfo(qemu_vm)
开发者ID:athmane,项目名称:gns3-gui,代码行数:30,代码来源:qemu_vm_preferences_page.py

示例2: _editVPCSSlot

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def _editVPCSSlot(self):
        """
        Edits a VPCS node template.
        """

        item = self.uiVPCSTreeWidget.currentItem()
        if item:
            key = item.data(0, QtCore.Qt.UserRole)
            vpcs_node = self._vpcs_nodes[key]
            dialog = ConfigurationDialog(vpcs_node["name"], vpcs_node, VPCSNodeConfigurationPage(), parent=self)
            dialog.show()
            if dialog.exec_():
                # update the icon
                Controller.instance().getSymbolIcon(vpcs_node["symbol"], qpartial(self._setItemIcon, item))
                if vpcs_node["name"] != item.text(0):
                    new_key = "{server}:{name}".format(server=vpcs_node["server"], name=vpcs_node["name"])
                    if new_key in self._vpcs_nodes:
                        QtWidgets.QMessageBox.critical(self, "VPCS node", "VPCS node name {} already exists for server {}".format(vpcs_node["name"],
                                                                                                                                  vpcs_node["server"]))
                        vpcs_node["name"] = item.text(0)
                        return
                    self._vpcs_nodes[new_key] = self._vpcs_nodes[key]
                    del self._vpcs_nodes[key]
                    item.setText(0, vpcs_node["name"])
                    item.setData(0, QtCore.Qt.UserRole, new_key)
                self._refreshInfo(vpcs_node)
开发者ID:athmane,项目名称:gns3-gui,代码行数:28,代码来源:vpcs_node_preferences_page.py

示例3: _iouDeviceCopySlot

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def _iouDeviceCopySlot(self):
        """
        Copies an IOU device.
        """

        item = self.uiIOUDevicesTreeWidget.currentItem()
        if item:
            key = item.data(0, QtCore.Qt.UserRole)
            copied_iou_device_settings = copy.deepcopy(self._iou_devices[key])
            new_name, ok = QtWidgets.QInputDialog.getText(self, "Copy IOU template", "Template name:", QtWidgets.QLineEdit.Normal, "Copy of {}".format(copied_iou_device_settings["name"]))
            if ok:
                key = "{server}:{name}".format(server=copied_iou_device_settings["compute_id"], name=new_name)
                if key in self._iou_devices:
                    QtWidgets.QMessageBox.critical(self, "IOU template", "IOU template name {} already exists".format(new_name))
                    return
                self._iou_devices[key] = IOU_DEVICE_SETTINGS.copy()
                self._iou_devices[key].update(copied_iou_device_settings)
                self._iou_devices[key]["name"] = new_name
                self._iou_devices[key].pop("template_id", None)

                item = QtWidgets.QTreeWidgetItem(self.uiIOUDevicesTreeWidget)
                item.setText(0, self._iou_devices[key]["name"])
                Controller.instance().getSymbolIcon(self._iou_devices[key]["symbol"], qpartial(self._setItemIcon, item))
                item.setData(0, QtCore.Qt.UserRole, key)
                self._items.append(item)
                self.uiIOUDevicesTreeWidget.setCurrentItem(item)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:28,代码来源:iou_device_preferences_page.py

示例4: _iouDeviceEditSlot

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def _iouDeviceEditSlot(self):
        """
        Edits an IOU device.
        """

        item = self.uiIOUDevicesTreeWidget.currentItem()
        if item:
            key = item.data(0, QtCore.Qt.UserRole)
            iou_device = self._iou_devices[key]
            dialog = ConfigurationDialog(iou_device["name"], iou_device, iouDeviceConfigurationPage(), parent=self)
            dialog.show()
            if dialog.exec_():
                # update the icon
                Controller.instance().getSymbolIcon(iou_device["symbol"], qpartial(self._setItemIcon, item))
                if iou_device["name"] != item.text(0):
                    new_key = "{server}:{name}".format(server=iou_device["compute_id"], name=iou_device["name"])
                    if new_key in self._iou_devices:
                        QtWidgets.QMessageBox.critical(self, "IOU device", "IOU device name {} already exists for server {}".format(iou_device["name"],
                                                                                                                                    iou_device["compute_id"]))
                        iou_device["name"] = item.text(0)
                        return
                    self._iou_devices[new_key] = self._iou_devices[key]
                    del self._iou_devices[key]
                    item.setText(0, iou_device["name"])
                    item.setData(0, QtCore.Qt.UserRole, new_key)
                self._refreshInfo(dialog.settings)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:28,代码来源:iou_device_preferences_page.py

示例5: updateLocalServerSettings

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def updateLocalServerSettings(self, new_settings):
        """
        Update the local server settings. Keep the key not in new_settings
        """
        old_settings = copy.copy(self._settings)
        if not self._settings:
            self._settings = new_settings
        else:
            self._settings.update(new_settings)
        self._port = self._settings["port"]
        LocalServerConfig.instance().saveSettings("Server", self._settings)

        # Settings have changed we need to restart the server
        if old_settings != self._settings:
            if self._settings["auto_start"]:
                # We restart the local server only if we really need. Auth can be hot change
                settings_require_restart = ('host', 'port', 'path')
                need_restart = False
                for s in settings_require_restart:
                    if old_settings.get(s) != self._settings.get(s):
                        need_restart = True

                if need_restart:
                    self.stopLocalServer(wait=True)

                self.localServerAutoStartIfRequire()
            # If the controller is remote:
            else:
                self.stopLocalServer(wait=True)

            if self._settings.get("host") is None:
                self._http_client = None
            else:
                self._http_client = HTTPClient(self._settings)
            Controller.instance().setHttpClient(self._http_client)
开发者ID:maherja,项目名称:gns3-gui,代码行数:37,代码来源:local_server.py

示例6: _downloadAppliancesSlot

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def _downloadAppliancesSlot(self):
        """
        Request server to update appliances from online registry.
        """

        ApplianceManager.instance().refresh(update=True)
        Controller.instance().clearStaticCache()
开发者ID:GNS3,项目名称:gns3-gui,代码行数:9,代码来源:new_template_wizard.py

示例7: savePreferences

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def savePreferences(self):
        """
        Saves the preferences on controller.
        """
        if not self._old_settings:
            return

        if self.uiWhenExitKeepRadioButton.isChecked():
            when_exit = "keep"
        elif self.uiWhenExitSuspendRadioButton.isChecked():
            when_exit = "suspend"
        else:
            when_exit = "stop"

        settings = {
            "enable": self.uiEnableVMCheckBox.isChecked(),
            "vmname": self.uiVMListComboBox.currentData(),
            "headless": self.uiHeadlessCheckBox.isChecked(),
            "when_exit": when_exit,
            "engine": self.uiGNS3VMEngineComboBox.currentData(),
            "ram": self.uiRamSpinBox.value(),
            "vcpus": self.uiCpuSpinBox.value()
        }
        if self._old_settings != settings:
            Controller.instance().put("/gns3vm", self._saveSettingsCallback, settings, timeout=60 * 5)
            self._old_settings = copy.copy(settings)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:28,代码来源:gns3_vm_preferences_page.py

示例8: _editEthernetHubSlot

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def _editEthernetHubSlot(self):
        """
        Edits an Ethernet hub.
        """

        item = self.uiEthernetHubsTreeWidget.currentItem()
        if item:
            key = item.data(0, QtCore.Qt.UserRole)
            ethernet_hub = self._ethernet_hubs[key]
            dialog = ConfigurationDialog(ethernet_hub["name"], ethernet_hub, EthernetHubConfigurationPage(), parent=self)
            dialog.show()
            if dialog.exec_():
                # update the icon
                Controller.instance().getSymbolIcon(ethernet_hub["symbol"], qpartial(self._setItemIcon, item))
                if ethernet_hub["name"] != item.text(0):
                    new_key = "{server}:{name}".format(server=ethernet_hub["compute_id"], name=ethernet_hub["name"])
                    if new_key in self._ethernet_hubs:
                        QtWidgets.QMessageBox.critical(self, "Ethernet hub", "Ethernet hub name {} already exists for server {}".format(ethernet_hub["name"],
                                                                                                                                        ethernet_hub["compute_id"]))
                        ethernet_hub["name"] = item.text(0)
                        return
                    self._ethernet_hubs[new_key] = self._ethernet_hubs[key]
                    del self._ethernet_hubs[key]
                    item.setText(0, ethernet_hub["name"])
                    item.setData(0, QtCore.Qt.UserRole, new_key)
                self._refreshInfo(ethernet_hub)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:28,代码来源:ethernet_hub_preferences_page.py

示例9: loadPreferences

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def loadPreferences(self):
        """
        Loads the IOU devices preferences.
        """

        self._iou_devices = {}
        templates = TemplateManager.instance().templates()
        for template_id, template in templates.items():
            if template.template_type() == "iou" and not template.builtin():
                name = template.name()
                server = template.compute_id()
                #TODO: use template id for the key
                key = "{server}:{name}".format(server=server, name=name)
                self._iou_devices[key] = copy.deepcopy(template.settings())

        self._items.clear()
        for key, iou_device in self._iou_devices.items():
            item = QtWidgets.QTreeWidgetItem(self.uiIOUDevicesTreeWidget)
            item.setText(0, iou_device["name"])
            Controller.instance().getSymbolIcon(iou_device["symbol"], qpartial(self._setItemIcon, item))

            item.setData(0, QtCore.Qt.UserRole, key)
            self._items.append(item)

        if self._items:
            self.uiIOUDevicesTreeWidget.setCurrentItem(self._items[0])
            self.uiIOUDevicesTreeWidget.sortByColumn(0, QtCore.Qt.AscendingOrder)
            self.uiIOUDevicesTreeWidget.setMaximumWidth(self.uiIOUDevicesTreeWidget.sizeHintForColumn(0) + 10)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:30,代码来源:iou_device_preferences_page.py

示例10: _dockerImageEditSlot

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def _dockerImageEditSlot(self):
        """
        Edits a Docker image.
        """

        item = self.uiDockerVMsTreeWidget.currentItem()
        if item:
            key = item.data(0, QtCore.Qt.UserRole)
            docker_container = self._docker_containers[key]
            dialog = ConfigurationDialog(docker_container["name"], docker_container, DockerVMConfigurationPage(), parent=self)
            dialog.show()
            if dialog.exec_():
                # update the icon
                Controller.instance().getSymbolIcon(docker_container["symbol"], qpartial(self._setItemIcon, item))
                if docker_container["name"] != item.text(0):
                    new_key = "{server}:{name}".format(server=docker_container["compute_id"], name=docker_container["name"])
                    if new_key in self._docker_containers:
                        QtWidgets.QMessageBox.critical(self, "Docker container", "Docker container name {} already exists for server {}".format(docker_container["name"],
                                                                                                                                                docker_container["compute_id"]))
                        docker_container["name"] = item.text(0)
                        return
                    self._docker_containers[new_key] = self._docker_containers[key]
                    del self._docker_containers[key]
                    item.setText(0, docker_container["name"])
                    item.setData(0, QtCore.Qt.UserRole, new_key)
                self._refreshInfo(docker_container)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:28,代码来源:docker_vm_preferences_page.py

示例11: _editCloudNodeSlot

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def _editCloudNodeSlot(self):
        """
        Edits a cloud node.
        """

        item = self.uiCloudNodesTreeWidget.currentItem()
        if item:
            key = item.data(0, QtCore.Qt.UserRole)
            cloud_node = self._cloud_nodes[key]
            dialog = ConfigurationDialog(cloud_node["name"], cloud_node, CloudConfigurationPage(), parent=self)
            dialog.show()
            if dialog.exec_():
                # update the icon
                Controller.instance().getSymbolIcon(cloud_node["symbol"], qpartial(self._setItemIcon, item))
                if cloud_node["name"] != item.text(0):
                    new_key = "{server}:{name}".format(server=cloud_node["compute_id"], name=cloud_node["name"])
                    if new_key in self._cloud_nodes:
                        QtWidgets.QMessageBox.critical(self, "Cloud node", "Cloud node name {} already exists for server {}".format(cloud_node["name"],
                                                                                                                                    cloud_node["compute_id"]))
                        cloud_node["name"] = item.text(0)
                        return
                    self._cloud_nodes[new_key] = self._cloud_nodes[key]
                    del self._cloud_nodes[key]
                    item.setText(0, cloud_node["name"])
                    item.setData(0, QtCore.Qt.UserRole, new_key)
                self._refreshInfo(cloud_node)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:28,代码来源:cloud_preferences_page.py

示例12: __init__

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def __init__(self, parent):

        super().__init__(parent)
        self.setupUi(self)

        self._gns3_vm_settings = {
            "enable": True,
            "headless": False,
            "when_exit": "stop",
            "engine": "vmware",
            "vcpus": 1,
            "ram": 2048,
            "vmname": "GNS3 VM"
        }

        self.setWizardStyle(QtWidgets.QWizard.ModernStyle)
        if sys.platform.startswith("darwin"):
            # we want to see the cancel button on OSX
            self.setOptions(QtWidgets.QWizard.NoDefaultButton)

        self.uiLocalServerToolButton.clicked.connect(self._localServerBrowserSlot)

        self.uiGNS3VMDownloadLinkUrlLabel.setText("")
        self.uiRefreshPushButton.clicked.connect(self._refreshVMListSlot)
        self.uiVmwareRadioButton.clicked.connect(self._listVMwareVMsSlot)
        self.uiVirtualBoxRadioButton.clicked.connect(self._listVirtualBoxVMsSlot)
        self.uiVMwareBannerButton.clicked.connect(self._VMwareBannerButtonClickedSlot)
        settings = parent.settings()
        self.uiShowCheckBox.setChecked(settings["hide_setup_wizard"])

        # by default all radio buttons are unchecked
        self.uiVmwareRadioButton.setAutoExclusive(False)
        self.uiVirtualBoxRadioButton.setAutoExclusive(False)
        self.uiVmwareRadioButton.setChecked(False)
        self.uiVirtualBoxRadioButton.setChecked(False)

        # Mandatory fields
        self.uiLocalServerWizardPage.registerField("path*", self.uiLocalServerPathLineEdit)

        # load all available addresses
        for address in QtNetwork.QNetworkInterface.allAddresses():
            if address.protocol() in [QtNetwork.QAbstractSocket.IPv4Protocol, QtNetwork.QAbstractSocket.IPv6Protocol]:
                address_string = address.toString()
                if address_string.startswith("169.254") or address_string.startswith("fe80"):
                    # ignore link-local addresses
                    continue
                self.uiLocalServerHostComboBox.addItem(address_string, address_string)

        if sys.platform.startswith("darwin"):
            self.uiVMwareBannerButton.setIcon(QtGui.QIcon(":/images/vmware_fusion_banner.png"))
        else:
            self.uiVMwareBannerButton.setIcon(QtGui.QIcon(":/images/vmware_workstation_banner.png"))

        if sys.platform.startswith("linux"):
            self.uiLocalRadioButton.setChecked(True)
            self.uiLocalLabel.setText("Dependencies like Dynamips and Qemu must be manually installed")

        Controller.instance().connected_signal.connect(self._refreshLocalServerStatusSlot)
        Controller.instance().connection_failed_signal.connect(self._refreshLocalServerStatusSlot)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:61,代码来源:setup_wizard.py

示例13: loadImagesList

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def loadImagesList(self, endpoint):
        """
        Fill the list box with available Images"

        :param endpoint: server endpoint with the list of Images
        """

        Controller.instance().getCompute(endpoint, self._compute_id, self._getImagesFromServerCallback)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:10,代码来源:vm_with_images_wizard.py

示例14: load

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
 def load(self, path=None):
     if not path:
         path = self.path()
     if path:
         body = {"path": path}
         Controller.instance().post("/projects/load", self._projectOpenCallback, body=body, timeout=None)
     else:
         self.post("/open", self._projectOpenCallback, timeout=None)
开发者ID:athmane,项目名称:gns3-gui,代码行数:10,代码来源:project.py

示例15: reload_all_nodes

# 需要导入模块: from gns3.controller import Controller [as 别名]
# 或者: from gns3.controller.Controller import instance [as 别名]
    def reload_all_nodes(self):
        """Reload all nodes belonging to this project"""

        # Don't do anything if the project doesn't exist on the server
        if self._id is None:
            return

        Controller.instance().post("/projects/{project_id}/nodes/reload".format(project_id=self._id), None, body={}, timeout=None)
开发者ID:athmane,项目名称:gns3-gui,代码行数:10,代码来源:project.py


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