def _getQemuBinariesFromServerCallback(self, result, error=False, qemu_path=None, **kwargs): """ Callback for getQemuBinariesFromServer. :param result: server response :param error: indicates an error (boolean) """ if sip_is_deleted(self.uiQemuListComboBox) or sip_is_deleted(self): return if error: QtWidgets.QMessageBox.critical(self, "Qemu binaries", "{}".format(result["message"])) else: self.uiQemuListComboBox.clear() for qemu in result: if qemu["version"]: self.uiQemuListComboBox.addItem("{path} (v{version})".format(path=qemu["path"], version=qemu["version"]), qemu["path"]) else: self.uiQemuListComboBox.addItem("{path}".format(path=qemu["path"]), qemu["path"]) if qemu_path and "/" not in qemu_path and "\\" not in qemu_path: self.uiQemuListComboBox.addItem("{path}".format(path=qemu_path), qemu_path) index = self.uiQemuListComboBox.findData("{path}".format(path=qemu_path)) if index != -1: self.uiQemuListComboBox.setCurrentIndex(index) else: index = self.uiQemuListComboBox.findData("{path}".format(path=os.path.basename(qemu_path)), flags=QtCore.Qt.MatchEndsWith) self.uiQemuListComboBox.setCurrentIndex(index) if index == -1: QtWidgets.QMessageBox.warning(self, "Qemu","Could not find '{}' in the Qemu binaries list, please select a new binary".format(qemu_path)) else: QtWidgets.QMessageBox.warning(self, "Qemu","Could not find '{}' in the Qemu binaries list, an alternative path has been selected".format(qemu_path))
def _listEnginesCallback(self, result, error=False, ignore_error=False, **kwargs): if sip_is_deleted(self.uiGNS3VMEngineComboBox) or sip_is_deleted(self): return if error: if "message" in result: log.error( "Error while getting the list of GNS3 VM engines : {}". format(result["message"])) return self.uiGNS3VMEngineComboBox.clear() self._engines = result # We insert first the current engine to avoid triggering unexpected signals for engine in self._engines: if self._settings["engine"] == engine["engine_id"]: self.uiGNS3VMEngineComboBox.addItem(engine["name"], engine["engine_id"]) for engine in self._engines: if self._settings["engine"] != engine["engine_id"]: self.uiGNS3VMEngineComboBox.addItem(engine["name"], engine["engine_id"])
def _getQemuBinariesFromServerCallback(self, result, error=False, qemu_path=None, **kwargs): """ Callback for getQemuBinariesFromServer. :param result: server response :param error: indicates an error (boolean) """ if sip_is_deleted(self.uiQemuListComboBox) or sip_is_deleted(self): return if error: QtWidgets.QMessageBox.critical(self, "Qemu binaries", "{}".format(result["message"])) else: self.uiQemuListComboBox.clear() for qemu in result: if qemu["version"]: self.uiQemuListComboBox.addItem("{path} (v{version})".format(path=qemu["path"], version=qemu["version"]), qemu["path"]) else: self.uiQemuListComboBox.addItem("{path}".format(path=qemu["path"]), qemu["path"]) if qemu_path and "/" not in qemu_path and "\\" not in qemu_path: self.uiQemuListComboBox.addItem("{path}".format(path=qemu_path), qemu_path) index = self.uiQemuListComboBox.findData("{path}".format(path=qemu_path)) if index != -1: self.uiQemuListComboBox.setCurrentIndex(index) else: index = self.uiQemuListComboBox.findData("{path}".format(path=os.path.basename(qemu_path)), flags=QtCore.Qt.MatchEndsWith) self.uiQemuListComboBox.setCurrentIndex(index) if index == -1: QtWidgets.QMessageBox.warning(self, "Qemu","Could not find '{}' in the Qemu binaries list, please select a new binary".format(qemu_path)) else: QtWidgets.QMessageBox.warning(self, "Qemu","Could not find '{}' in the Qemu binaries list, an alternative path has been selected".format(qemu_path))
def _getSettingsCallback(self, result, error=False, **kwargs): if sip_is_deleted(self.uiRamSpinBox) or sip_is_deleted(self): return if error: if "message" in result: log.error( "Error while getting the GNS3 VM settings : {}".format( result["message"])) return self._old_settings = copy.copy(result) self._settings = result self.uiAllocatevCPUsRAMCheckBox.setChecked( self._settings["allocate_vcpus_ram"]) self.uiRamSpinBox.setValue(self._settings["ram"]) self.uiCpuSpinBox.setValue(self._settings["vcpus"]) self.uiPortSpinBox.setValue(self._settings.get("port", 3080)) self.uiEnableVMCheckBox.setChecked(self._settings["enable"]) if self._settings["when_exit"] == "keep": self.uiWhenExitKeepRadioButton.setChecked(True) elif self._settings["when_exit"] == "suspend": self.uiWhenExitSuspendRadioButton.setChecked(True) else: self.uiWhenExitStopRadioButton.setChecked(True) self.uiHeadlessCheckBox.setChecked(self._settings["headless"]) Controller.instance().get("/gns3vm/engines", self._listEnginesCallback)
def _listEnginesCallback(self, result, error=False, ignore_error=False, **kwargs): if sip_is_deleted(self.uiGNS3VMEngineComboBox) or sip_is_deleted(self): return if error: if "message" in result: log.error("Error while getting the list of GNS3 VM engines : {}".format(result["message"])) return self.uiGNS3VMEngineComboBox.clear() self._engines = result # We insert first the current engine to avoid triggering unexpected signals for engine in self._engines: if self._settings["engine"] == engine["engine_id"]: self.uiGNS3VMEngineComboBox.addItem(engine["name"], engine["engine_id"]) for engine in self._engines: if self._settings["engine"] != engine["engine_id"]: self.uiGNS3VMEngineComboBox.addItem(engine["name"], engine["engine_id"])
def _getSettingsCallback(self, result, error=False, **kwargs): if sip_is_deleted(self): return if error: if "message" in result: log.error("Error while getting settings : {}".format(result["message"])) return self._old_settings = copy.copy(result) self._populateWidgets(result)
def _getSettingsCallback(self, result, error=False, **kwargs): if sip_is_deleted(self): return if error: if "message" in result: log.error("Error while getting settings : {}".format( result["message"])) return self._old_settings = copy.copy(result) self._populateWidgets(result)
def _getSettingsCallback(self, result, error=False, **kwargs): if sip_is_deleted(self.uiRamSpinBox) or sip_is_deleted(self): return if error: if "message" in result: log.error("Error while getting settings : {}".format(result["message"])) return self._old_settings = copy.copy(result) self._settings = result self.uiRamSpinBox.setValue(self._settings["ram"]) self.uiCpuSpinBox.setValue(self._settings["vcpus"]) self.uiEnableVMCheckBox.setChecked(self._settings["enable"]) if self._settings["when_exit"] == "keep": self.uiWhenExitKeepRadioButton.setChecked(True) elif self._settings["when_exit"] == "suspend": self.uiWhenExitSuspendRadioButton.setChecked(True) else: self.uiWhenExitStopRadioButton.setChecked(True) self.uiHeadlessCheckBox.setChecked(self._settings["headless"]) Controller.instance().get("/gns3vm/engines", self._listEnginesCallback)
def _listVMsCallback(self, result, ignore_error=False, error=False, **kwargs): if error: if "message" in result: if not ignore_error: QtWidgets.QMessageBox.critical(self, "List vms", "Error while listing vms: {}".format(result["message"])) return if not sip_is_deleted(self.uiVMListComboBox): self.uiVMListComboBox.clear() for vm in result: self.uiVMListComboBox.addItem(vm["vmname"], vm["vmname"]) index = self.uiVMListComboBox.findText(self._settings["vmname"]) if index == -1: index = self.uiVMListComboBox.findText("GNS3 VM") if index == -1: index = 0 self.uiVMListComboBox.setCurrentIndex(index) self._initialized = True
def _listVMsCallback(self, result, ignore_error=False, error=False, **kwargs): if error: if "message" in result: if not ignore_error: QtWidgets.QMessageBox.critical( self, "List vms", "Error while listing vms: {}".format( result["message"])) return if not sip_is_deleted(self.uiVMListComboBox): self.uiVMListComboBox.clear() for vm in result: self.uiVMListComboBox.addItem(vm["vmname"], vm["vmname"]) index = self.uiVMListComboBox.findText(self._settings["vmname"]) if index == -1: index = self.uiVMListComboBox.findText("GNS3 VM") if index == -1: index = 0 self.uiVMListComboBox.setCurrentIndex(index) self._initialized = True