def _saveQemuVMs(self): """ Saves the QEMU VMs to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, {"vms": list(self._qemu_vms.values())})
def _saveIOSRouters(self): """ Saves the IOS routers to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, {"routers": list(self._ios_routers.values())})
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings)
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
def _exportDebugCallback(self, result, error=False, **kwargs): log.info("Export debug information to %s", self._path) try: with ZipFile(self._path, 'w') as zip: zip.writestr("debug.txt", self._getDebugData()) dir = LocalConfig.instance().configDirectory() for filename in os.listdir(dir): path = os.path.join(dir, filename) if os.path.isfile(path): zip.write(path, filename) dir = os.path.join(LocalConfig.instance().configDirectory(), "debug") if os.path.exists(dir): for filename in os.listdir(dir): path = os.path.join(dir, filename) if os.path.isfile(path): zip.write(path, filename) if self._project: dir = self._project.filesDir() if dir: for filename in os.listdir(dir): path = os.path.join(dir, filename) if os.path.isfile(path): zip.write(path, filename) except OSError as e: QtWidgets.QMessageBox.critical(self, "Debug", "Can't export debug information: {}".format(str(e))) self.accept()
def _saveIOUDevices(self): """ Saves the IOU devices to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, {"devices": list(self._iou_devices.values())})
def _saveVirtualBoxVMs(self): """ Saves the VirtualBox VMs to the client settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, {"vms": list(self._virtualbox_vms.values())})
def removePushButtonClickedSlot(self): """ Remove the custom command from the custom list """ self._settings[self._console_type].pop(self.uiCommandComboBox.currentText()) LocalConfig.instance().saveSectionSettings("CustomConsoleCommands", self._settings) self._current = None self._refreshList()
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) server_settings = {"enable_hardware_acceleration": self._settings["enable_hardware_acceleration"], "require_hardware_acceleration": self._settings["require_hardware_acceleration"]} LocalServerConfig.instance().saveSettings(self.__class__.__name__, server_settings)
def savePushButtonClickedSlot(self): """ Save a custom command to the list """ name, ok = QtWidgets.QInputDialog.getText(self, "Add a command", "Command name:", QtWidgets.QLineEdit.Normal) command = self.uiCommandPlainTextEdit.toPlainText().strip() if ok and len(command) > 0: if command not in self._consoles.values(): self._settings[self._console_type][name] = command self._current = command LocalConfig.instance().saveSectionSettings("CustomConsoleCommands", self._settings) self._refreshList()
def _saveSettings(self): """ Saves the settings to the server settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) # save some settings to the local server config file if self._settings["vboxmanage_path"]: server_settings = {"vboxmanage_path": os.path.normpath(self._settings["vboxmanage_path"])} LocalServerConfig.instance().saveSettings(self.__class__.__name__, server_settings)
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) if self._settings["vpcs_path"]: # save some settings to the server config file server_settings = {"vpcs_path": os.path.normpath(self._settings["vpcs_path"])} config = LocalServerConfig.instance() config.saveSettings(self.__class__.__name__, server_settings)
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) # save some settings to the local server config file if sys.platform.startswith("linux"): server_settings = { "enable_kvm": self._settings["enable_kvm"], } LocalServerConfig.instance().saveSettings(self.__class__.__name__, server_settings)
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) server_settings = {} config = LocalServerConfig.instance() if self._settings["default_nat_interface"]: # save some settings to the local server config file server_settings["default_nat_interface"] = self._settings["default_nat_interface"] config.saveSettings(self.__class__.__name__, server_settings) else: config.deleteSetting(self.__class__.__name__, "default_nat_interface")
def startLocalServer(self): """ Starts the local server process. """ self._stopping = False path = self.localServerPath() command = '"{executable}" --local'.format(executable=path) if LocalConfig.instance().profile(): command += " --profile {}".format(LocalConfig.instance().profile()) if self._settings["allow_console_from_anywhere"]: # allow connections to console from remote addresses command += " --allow" if logging.getLogger().isEnabledFor(logging.DEBUG): command += " --debug" settings_dir = self._config_directory if os.path.isdir(settings_dir): # save server logging info to a file in the settings directory logpath = os.path.join(settings_dir, "gns3_server.log") if os.path.isfile(logpath): # delete the previous log file try: os.remove(logpath) except FileNotFoundError: pass except OSError as e: log.warn("could not delete server log file {}: {}".format(logpath, e)) command += ' --log="{}" --pid="{}"'.format(logpath, self._pid_path()) log.info("Starting local server process with {}".format(command)) try: if sys.platform.startswith("win"): # use the string on Windows self._local_server_process = subprocess.Popen(command, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, stderr=subprocess.PIPE) else: # use arguments on other platforms args = shlex.split(command) self._local_server_process = subprocess.Popen(args, stderr=subprocess.PIPE) except (OSError, subprocess.SubprocessError) as e: log.warning('Could not start local server "{}": {}'.format(command, e)) return False log.info("Local server process has started (PID={})".format(self._local_server_process.pid)) return True
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ local_config = LocalConfig.instance() self._settings = local_config.loadSectionSettings(self.__class__.__name__, BUILTIN_SETTINGS)
def __init__(self, parent=None): if parent is None: self._main = QtWidgets.QMainWindow() self._main.hide() parent = self._main super().__init__(parent) self.setupUi(self) self.uiNewPushButton.clicked.connect(self._newPushButtonSlot) self.uiDeletePushButton.clicked.connect(self._deletePushButtonSlot) # Center on screen screen = QtWidgets.QApplication.desktop().screenGeometry() self.move(screen.center() - self.rect().center()) if sys.platform.startswith("win"): appdata = os.path.expandvars("%APPDATA%") path = os.path.join(appdata, "GNS3") else: home = os.path.expanduser("~") path = os.path.join(home, ".config", "GNS3") self.profiles_path = os.path.join(path, "profiles") self.uiShowAtStartupCheckBox.setChecked(LocalConfig.instance().multiProfiles()) self._refresh()
def __init__(self, parent=None): super().__init__() self.setupUi(self) self._remote_servers = {} self._preferences_dialog = parent # Display the path of the config file config_file_path = LocalConfig.instance().configFilePath() self.uiConfigurationFileLabel.setText(config_file_path) self.uiProjectsPathToolButton.clicked.connect(self._projectsPathSlot) self.uiSymbolsPathToolButton.clicked.connect(self._symbolsPathSlot) self.uiImagesPathToolButton.clicked.connect(self._imagesPathSlot) self.uiConfigsPathToolButton.clicked.connect(self._configsPathSlot) self.uiImportConfigurationFilePushButton.clicked.connect(self._importConfigurationFileSlot) self.uiExportConfigurationFilePushButton.clicked.connect(self._exportConfigurationFileSlot) self.uiRestoreDefaultsPushButton.clicked.connect(self._restoreDefaultsSlot) self.uiTelnetConsolePreconfiguredCommandPushButton.clicked.connect(self._telnetConsolePreconfiguredCommandSlot) self.uiSerialConsolePreconfiguredCommandPushButton.clicked.connect(self._serialConsolePreconfiguredCommandSlot) self.uiVNCConsolePreconfiguredCommandPushButton.clicked.connect(self._vncConsolePreconfiguredCommandSlot) self.uiDefaultLabelFontPushButton.clicked.connect(self._setDefaultLabelFontSlot) self.uiDefaultLabelColorPushButton.clicked.connect(self._setDefaultLabelColorSlot) self._default_label_color = QtGui.QColor(QtCore.Qt.black) self.uiStyleComboBox.addItems(STYLES)
def __init__(self): self._id = None self._closed = True self._closing = False self._files_dir = None self._images_dir = None self._auto_start = False self._auto_open = False self._auto_close = False graphic_settings = LocalConfig.instance().loadSectionSettings(self.__class__.__name__, GRAPHICS_VIEW_SETTINGS) self._scene_width = graphic_settings["scene_width"] self._scene_height = graphic_settings["scene_height"] self._zoom = graphic_settings.get("zoom", None) self._show_layers = graphic_settings.get("show_layers", False) self._snap_to_grid = graphic_settings.get("snap_to_grid", False) self._show_grid = graphic_settings.get("show_grid", False) self._show_interface_labels = graphic_settings.get("show_interface_labels", False) self._name = "untitled" self._filename = None # Due to bug in Qt on some version we need a dedicated network manager self._notification_network_manager = QtNetwork.QNetworkAccessManager() self._notification_stream = None super().__init__()
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ local_config = LocalConfig.instance() # restore the VPCS settings from QSettings (for backward compatibility) legacy_settings = {} settings = QtCore.QSettings() settings.beginGroup(self.__class__.__name__) for name in VPCS_SETTINGS.keys(): if settings.contains(name): legacy_settings[name] = settings.value(name, type=VPCS_SETTING_TYPES[name]) settings.remove("") settings.endGroup() if legacy_settings: local_config.saveSectionSettings(self.__class__.__name__, legacy_settings) self._settings = local_config.loadSectionSettings(self.__class__.__name__, VPCS_SETTINGS) if not self._settings["base_script_file"]: self._settings["base_script_file"] = get_default_base_config(get_resource(os.path.join("configs", "vpcs_base_config.txt"))) if not os.path.exists(self._settings["vpcs_path"]): self._settings["vpcs_path"] = self._findVPCS(self) # keep the config file sync self._saveSettings()
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ local_config = LocalConfig.instance() # restore the Dynamips settings from QSettings (for backward compatibility) legacy_settings = {} settings = QtCore.QSettings() settings.beginGroup(self.__class__.__name__) for name in DYNAMIPS_SETTINGS.keys(): if settings.contains(name): legacy_settings[name] = settings.value(name, type=DYNAMIPS_SETTING_TYPES[name]) settings.remove("") settings.endGroup() if legacy_settings: local_config.saveSectionSettings(self.__class__.__name__, legacy_settings) self._settings = local_config.loadSectionSettings(self.__class__.__name__, DYNAMIPS_SETTINGS) if not os.path.exists(self._settings["dynamips_path"]): self._settings["dynamips_path"] = self._findDynamips(self) # keep the config file sync self._saveSettings()
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ self._settings = LocalConfig.instance().loadSectionSettings(self.__class__.__name__, QEMU_SETTINGS) self._loadQemuVMs()
def _loadSettings(self): """ Loads the settings from the server settings file. """ local_config = LocalConfig.instance() # restore the VirtualBox settings from QSettings (for backward compatibility) legacy_settings = {} settings = QtCore.QSettings() settings.beginGroup(self.__class__.__name__) for name in VBOX_SETTINGS.keys(): if settings.contains(name): legacy_settings[name] = settings.value(name, type=VBOX_SETTING_TYPES[name]) settings.remove("") settings.endGroup() if legacy_settings: local_config.saveSectionSettings(self.__class__.__name__, legacy_settings) self._settings = local_config.loadSectionSettings(self.__class__.__name__, VBOX_SETTINGS) if not os.path.exists(self._settings["vboxmanage_path"]): self._settings["vboxmanage_path"] = self._findVBoxManage(self) # keep the config file sync self._saveSettings()
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ local_config = LocalConfig.instance() # restore the IOU settings from QSettings (for backward compatibility) legacy_settings = {} settings = QtCore.QSettings() settings.beginGroup(self.__class__.__name__) for name in IOU_SETTINGS.keys(): if settings.contains(name): legacy_settings[name] = settings.value(name, type=IOU_SETTING_TYPES[name]) if "iourc" in legacy_settings: legacy_settings["iourc_path"] = legacy_settings["iourc"] del legacy_settings["iourc"] settings.remove("") settings.endGroup() if legacy_settings: local_config.saveSectionSettings(self.__class__.__name__, legacy_settings) self._settings = local_config.loadSectionSettings(self.__class__.__name__, IOU_SETTINGS) if sys.platform.startswith("linux") and not os.path.exists(self._settings["iouyap_path"]): iouyap_path = shutil.which("iouyap") if iouyap_path: self._settings["iouyap_path"] = iouyap_path # keep the config file sync self._saveSettings()
def __init__(self, parent=None): QtGui.QWidget.__init__(self) self.setupUi(self) self._remote_servers = {} self._preferences_dialog = parent # Load the pre-configured console commands for name, cmd in sorted(PRECONFIGURED_TELNET_CONSOLE_COMMANDS.items()): self.uiTelnetConsolePreconfiguredCommandComboBox.addItem(name, cmd) for name, cmd in sorted(PRECONFIGURED_SERIAL_CONSOLE_COMMANDS.items()): self.uiSerialConsolePreconfiguredCommandComboBox.addItem(name, cmd) # Display the path of the config file config_file_path = LocalConfig.instance().configFilePath() self.uiConfigurationFileLabel.setText(config_file_path) self.uiProjectsPathToolButton.clicked.connect(self._projectsPathSlot) self.uiImagesPathToolButton.clicked.connect(self._imagesPathSlot) self.uiImportConfigurationFilePushButton.clicked.connect(self._importConfigurationFileSlot) self.uiExportConfigurationFilePushButton.clicked.connect(self._exportConfigurationFileSlot) self.uiRestoreDefaultsPushButton.clicked.connect(self._restoreDefaultsSlot) self.uiTelnetConsolePreconfiguredCommandPushButton.clicked.connect(self._telnetConsolePreconfiguredCommandSlot) self.uiSerialConsolePreconfiguredCommandPushButton.clicked.connect(self._serialConsolePreconfiguredCommandSlot) self.uiDefaultLabelFontPushButton.clicked.connect(self._setDefaultLabelFontSlot) self.uiDefaultLabelColorPushButton.clicked.connect(self._setDefaultLabelColorSlot) self._default_label_color = QtGui.QColor(QtCore.Qt.black) self.uiStyleComboBox.addItems(STYLES)
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) # save some settings to the local server config file server_settings = { "iourc_path": self._settings["iourc_path"], "iouyap_path": self._settings["iouyap_path"], "license_check": self._settings["license_check"] } config = LocalServerConfig.instance() config.saveSettings(self.__class__.__name__, server_settings)
def checkExperimentalFeaturesEnabled(self): """Checking if experimental features are not enabled""" if LocalConfig.instance().experimental(): return ( 1, "Experimental features are enabled. Turn them off by going to Preferences -> General -> Miscellaneous." ) return (0, None)
def local_config(): from gns3.local_config import LocalConfig (fd, config_path) = tempfile.mkstemp() os.close(fd) LocalConfig._instance = LocalConfig(config_file=config_path) return LocalConfig.instance()
def local_config(): from gns3.local_config import LocalConfig (fd, config_path) = tempfile.mkstemp() os.close(fd) LocalConfig._instance = LocalConfig(config_file=config_path) return LocalConfig.instance()
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ self._settings = LocalConfig.instance().loadSectionSettings( self.__class__.__name__, QEMU_SETTINGS) self._loadQemuVMs()
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ local_config = LocalConfig.instance() self._settings = local_config.loadSectionSettings( self.__class__.__name__, BUILTIN_SETTINGS)
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) # save some settings to the local server config file if sys.platform.startswith("linux"): server_settings = { "enable_kvm": self._settings["enable_kvm"], } LocalServerConfig.instance().saveSettings(self.__class__.__name__, server_settings)
def _saveSettings(self): """ Saves the settings to the server settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) # save some settings to the local server config file if self._settings["vboxmanage_path"]: server_settings = { "vboxmanage_path": os.path.normpath(self._settings["vboxmanage_path"]) } LocalServerConfig.instance().saveSettings(self.__class__.__name__, server_settings)
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) # save some settings to the local server config file server_settings = { "iourc_path": self._settings["iourc_path"], "iouyap_path": self._settings["iouyap_path"], "license_check": self._settings["license_check"] } config = LocalServerConfig.instance() config.saveSettings(self.__class__.__name__, server_settings)
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) server_settings = {} config = LocalServerConfig.instance() if self._settings["default_nat_interface"]: # save some settings to the local server config file server_settings["default_nat_interface"] = self._settings[ "default_nat_interface"] config.saveSettings(self.__class__.__name__, server_settings) else: config.deleteSetting(self.__class__.__name__, "default_nat_interface")
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ self._settings = LocalConfig.instance().loadSectionSettings(self.__class__.__name__, QEMU_SETTINGS) # migrate VM settings to the controller (templates are managed on server side starting with version 2.0) Controller.instance().connected_signal.connect(self._migrateOldVMs)
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) # save some settings to the local server config file server_settings = { "allocate_aux_console_ports": self._settings["allocate_aux_console_ports"], "ghost_ios_support": self._settings["ghost_ios_support"], "sparse_memory_support": self._settings["sparse_memory_support"], "mmap_support": self._settings["mmap_support"], } if self._settings["dynamips_path"]: server_settings["dynamips_path"] = os.path.normpath(self._settings["dynamips_path"]) config = LocalServerConfig.instance() config.saveSettings(self.__class__.__name__, server_settings)
def _saveSettings(self): """ Saves the settings to the server settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) # save some settings to the local server config file server_settings = { "host_type": self._settings["host_type"], "vmnet_start_range": self._settings["vmnet_start_range"], "vmnet_end_range": self._settings["vmnet_end_range"], } if self._settings["vmrun_path"]: server_settings["vmrun_path"] = os.path.normpath(self._settings["vmrun_path"]) config = LocalServerConfig.instance() config.saveSettings(self.__class__.__name__, server_settings)
def _saveSettings(self): """ Saves the settings to the persistent settings file. """ # save the settings LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings) # save some settings to the local server config file server_settings = { "allocate_aux_console_ports": self._settings["allocate_aux_console_ports"], "ghost_ios_support": self._settings["ghost_ios_support"], "sparse_memory_support": self._settings["sparse_memory_support"], "mmap_support": self._settings["mmap_support"], } if self._settings["dynamips_path"]: server_settings["dynamips_path"] = os.path.normpath(self._settings["dynamips_path"]) config = LocalServerConfig.instance() config.saveSettings(self.__class__.__name__, server_settings)
def _loadSettings(self): """ Loads the settings from the server settings file. """ self._settings = LocalConfig.instance().loadSectionSettings(self.__class__.__name__, VBOX_SETTINGS) if not os.path.exists(self._settings["vboxmanage_path"]): self._settings["vboxmanage_path"] = self._findVBoxManage(self) self._loadVirtualBoxVMs()
def _loadSettings(self): """ Loads the settings from the server settings file. """ local_config = LocalConfig.instance() self._settings = local_config.loadSectionSettings(self.__class__.__name__, VMWARE_SETTINGS) if not os.path.exists(self._settings["vmrun_path"]): self._settings["vmrun_path"] = self.findVmrun() self._settings["host_type"] = self._determineHostType() self._loadVMwareVMs()
def _loadSettings(self): """ Loads the settings from the server settings file. """ self._settings = LocalConfig.instance().loadSectionSettings(self.__class__.__name__, VBOX_SETTINGS) if not os.path.exists(self._settings["vboxmanage_path"]): self._settings["vboxmanage_path"] = self._findVBoxManage(self) self._loadVirtualBoxVMs()
def preferencePages(): """ :returns: QWidget object list """ from .pages.docker_preferences_page import DockerPreferencesPage from .pages.docker_vm_preferences_page import DockerVMPreferencesPage from gns3.local_config import LocalConfig if not LocalConfig.instance().experimental(): return [] return [DockerPreferencesPage, DockerVMPreferencesPage]
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ self._settings = LocalConfig.instance().loadSectionSettings( self.__class__.__name__, TRACENG_SETTINGS) if not os.path.exists(self._settings["traceng_path"]): traceng_path = shutil.which("traceng") if traceng_path: self._settings["traceng_path"] = os.path.abspath(traceng_path) else: self._settings["traceng_path"] = ""
def _loadSettings(self): """ Loads the settings from the server settings file. """ self._settings = LocalConfig.instance().loadSectionSettings( self.__class__.__name__, VBOX_SETTINGS) if not os.path.exists(self._settings["vboxmanage_path"]): self._settings["vboxmanage_path"] = self._findVBoxManage(self) # migrate VM settings to the controller (templates are managed on server side starting with version 2.0) Controller.instance().connected_signal.connect(self._migrateOldVMs)
def _loadBuilinNodesPerType(self, node_dict, node_type, default_settings): settings = LocalConfig.instance().settings() if node_type in settings.get(self.__class__.__name__, {}): for device in settings[self.__class__.__name__][node_type]: name = device.get("name") server = device.get("server") key = "{server}:{name}".format(server=server, name=name) if key in node_dict or not name or not server: continue node_settings = default_settings.copy() node_settings.update(device) node_dict[key] = node_settings
def _importConfigurationFileSlot(self): """ Slot to import a configuration file. """ configuration_file_path = LocalConfig.instance().configFilePath() directory = os.path.dirname(configuration_file_path) path = QtGui.QFileDialog.getOpenFileName(self, "Import configuration file", directory, "Configuration file (*.ini *.conf);;All files (*.*)") if not path: return try: with open(path, encoding="utf-8") as f: config_file = json.load(f) if "type" not in config_file or config_file["type"] != "settings": QtGui.QMessageBox.critical(self, "Import configuration file", "Not a GNS3 configuration file: {}".format(path)) return except OSError as e: QtGui.QMessageBox.critical(self, "Import configuration file", "Could not load configuration file {}: {}".format(os.path.basename(path), e)) return except ValueError as e: QtGui.QMessageBox.critical(self, "Import configuration file", "Invalid file: {}".format(e)) return try: shutil.copyfile(path, configuration_file_path) except (shutil.Error, IOError) as e: QtGui.QMessageBox.critical(self, "Import configuration file", "Cannot import configuration file: {}".format(e)) return QtGui.QMessageBox.information(self, "Configuration file", "Configuration file imported, default settings will be applied after a restart") # TODO: implement restart # QtCore.QProcess.startDetached(QtGui.QApplication.arguments()[0], QtGui.QApplication.arguments()) # QtGui.QApplication.quit() LocalConfig.instance().setConfigFilePath(configuration_file_path) self._preferences_dialog.reject()
def _loadSettings(self): """ Loads the settings from the server settings file. """ local_config = LocalConfig.instance() self._settings = local_config.loadSectionSettings( self.__class__.__name__, VMWARE_SETTINGS) if not os.path.exists(self._settings["vmrun_path"]): self._settings["vmrun_path"] = self.findVmrun() self._settings["host_type"] = self._determineHostType() # migrate VM settings to the controller (templates are managed on server side starting with version 2.0) Controller.instance().connected_signal.connect(self._migrateOldVMs)
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ self._settings = LocalConfig.instance().loadSectionSettings(self.__class__.__name__, DYNAMIPS_SETTINGS) if not os.path.exists(self._settings["dynamips_path"]): dynamips_path = shutil.which("dynamips") if dynamips_path: self._settings["dynamips_path"] = os.path.abspath(dynamips_path) else: self._settings["dynamips_path"] = "" self._loadIOSRouters()
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ self._settings = LocalConfig.instance().loadSectionSettings(self.__class__.__name__, VPCS_SETTINGS) if not os.path.exists(self._settings["vpcs_path"]): vpcs_path = shutil.which("vpcs") if vpcs_path: self._settings["vpcs_path"] = os.path.abspath(vpcs_path) else: self._settings["vpcs_path"] = "" # migrate node settings to the controller (templates are managed on server side starting with version 2.0) Controller.instance().connected_signal.connect(self._migrateOldNodes)
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ self._settings = LocalConfig.instance().loadSectionSettings(self.__class__.__name__, IOU_SETTINGS) if sys.platform.startswith("linux") and not os.path.exists(self._settings["iouyap_path"]): iouyap_path = shutil.which("iouyap") if iouyap_path: self._settings["iouyap_path"] = os.path.abspath(iouyap_path) else: self._settings["iouyap_path"] = "" self._loadIOUDevices()
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ self._settings = LocalConfig.instance().loadSectionSettings( self.__class__.__name__, VPCS_SETTINGS) if not os.path.exists(self._settings["vpcs_path"]): vpcs_path = shutil.which("vpcs") if vpcs_path: self._settings["vpcs_path"] = os.path.abspath(vpcs_path) else: self._settings["vpcs_path"] = "" self._loadVPCSNodes()
def _loadDockerImages(self): """Load the Docker images from the persistent settings file.""" local_config = LocalConfig.instance() settings = local_config.settings() if "images" in settings.get(self.__class__.__name__, {}): for image in settings[self.__class__.__name__]["images"]: name = image.get("name") server = image.get("server") key = "{server}:{name}".format(server=server, name=name) if key in self._docker_images or not name or not server: continue container_settings = DOCKER_CONTAINER_SETTINGS.copy() container_settings.update(image) self._docker_images[key] = container_settings
def checkForUpdate(self, parent, silent): """ Check for update. Start by asking PyPi for minor upgrade and next GNS3 for major upgrade. :param parent: Parent Windows :param silent: Display or not the notifications """ self._silent = silent self._parent = parent if hasattr(sys, "frozen") and LocalConfig.instance().experimental(): url = 'https://pypi.python.org/pypi/gns3-gui/json' self._get(url, self._pypiReplySlot) else: self._get('http://update.gns3.net', self._gns3UpdateReplySlot)
def _loadSettings(self): """ Loads the settings from the persistent settings file. """ self._settings = LocalConfig.instance().loadSectionSettings(self.__class__.__name__, VPCS_SETTINGS) if not self._settings["base_script_file"]: self._settings["base_script_file"] = get_default_base_config(get_resource(os.path.join("configs", "vpcs_base_config.txt"))) if not os.path.exists(self._settings["vpcs_path"]): vpcs_path = shutil.which("vpcs") if vpcs_path: self._settings["vpcs_path"] = os.path.abspath(vpcs_path) else: self._settings["vpcs_path"] = ""
def _loadSettings(self): """Loads the settings from the persistent settings file.""" local_config = LocalConfig.instance() self._settings = local_config.loadSectionSettings( self.__class__.__name__, DOCKER_SETTINGS) if "containers" in self._settings: for image in self._settings["containers"]: name = image.get("name") server = image.get("server") key = "{server}:{name}".format(server=server, name=name) if key in self._docker_containers or not name or not server: continue container_settings = DOCKER_CONTAINER_SETTINGS.copy() container_settings.update(image) self._docker_containers[key] = container_settings
def __init__(self, parent=None): super().__init__() self.setupUi(self) self._remote_servers = {} self._preferences_dialog = parent # Display the path of the config file config_file_path = LocalConfig.instance().configFilePath() self.uiConfigurationFileLabel.setText(config_file_path) self.uiProjectsPathToolButton.clicked.connect(self._projectsPathSlot) self.uiSymbolsPathToolButton.clicked.connect(self._symbolsPathSlot) self.uiImagesPathToolButton.clicked.connect(self._imagesPathSlot) self.uiConfigsPathToolButton.clicked.connect(self._configsPathSlot) self.uiAppliancesPathToolButton.clicked.connect( self._appliancesPathSlot) self.uiImportConfigurationFilePushButton.clicked.connect( self._importConfigurationFileSlot) self.uiExportConfigurationFilePushButton.clicked.connect( self._exportConfigurationFileSlot) self.uiRestoreDefaultsPushButton.clicked.connect( self._restoreDefaultsSlot) self.uiTelnetConsolePreconfiguredCommandPushButton.clicked.connect( self._telnetConsolePreconfiguredCommandSlot) self.uiVNCConsolePreconfiguredCommandPushButton.clicked.connect( self._vncConsolePreconfiguredCommandSlot) self.uiSPICEConsolePreconfiguredCommandPushButton.clicked.connect( self._spiceConsolePreconfiguredCommandSlot) self.uiDefaultLabelFontPushButton.clicked.connect( self._setDefaultLabelFontSlot) self.uiDefaultLabelColorPushButton.clicked.connect( self._setDefaultLabelColorSlot) self.uiDefaultNoteFontPushButton.clicked.connect( self._setDefaultNoteFontSlot) self.uiDefaultNoteColorPushButton.clicked.connect( self._setDefaultNoteColorSlot) self.uiBrowseConfigurationPushButton.clicked.connect( self._browseConfigurationDirectorySlot) self._default_label_color = QtGui.QColor(QtCore.Qt.black) self.uiStyleComboBox.addItems(STYLES) self.uiSymbolThemeComboBox.addItems(SYMBOL_THEMES) self.uiImageDirectoriesAddPushButton.clicked.connect( self._imageDirectoriesAddPushButtonSlot) self.uiImageDirectoriesDeletePushButton.clicked.connect( self._imageDirectoriesDeletePushButtonSlot)
def _loadVPCSNodes(self): """ Load the VPCS nodes from the persistent settings file. """ self._vpcs_nodes = {} settings = LocalConfig.instance().settings() if "nodes" in settings.get(self.__class__.__name__, {}): for node in settings[self.__class__.__name__]["nodes"]: name = node.get("name") server = node.get("server") key = "{server}:{name}".format(server=server, name=name) if key in self._vpcs_nodes or not name or not server: continue node_settings = VPCS_NODES_SETTINGS.copy() node_settings.update(node) self._vpcs_nodes[key] = node_settings
def _exportConfigurationFileSlot(self): """ Slot to export a configuration file. """ configuration_file_path = LocalConfig.instance().configFilePath() directory = os.path.dirname(configuration_file_path) path = QtGui.QFileDialog.getSaveFileName(self, "Export configuration file", directory, "Configuration file (*.ini *.conf);;All files (*.*)") if not path: return try: shutil.copyfile(configuration_file_path, path) except (shutil.Error, IOError) as e: QtGui.QMessageBox.critical(self, "Export configuration file", "Cannot export configuration file: {}".format(e)) return