def __clearConfiguration(self): reply = QtGui.QMessageBox.question( globals.preferencesWindow, translate("UiConfig_PreferencesGeneral", "Configuration file"), translate( "UiConfig_PreferencesGeneral", "All GNS3 configuration will be lost. Do you want to proceed?" ), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: from __main__ import VERSION ConfDB().clear() c = ConfDB() c.set('GNS3/version', VERSION) c.sync() QtGui.QMessageBox.information( globals.preferencesWindow, translate("UiConfig_PreferencesGeneral", "Configuration file"), translate( "UiConfig_PreferencesGeneral", "Configuration file cleared, default settings will be applied after a restart" )) globals.recordConfiguration = False globals.preferencesWindow.close()
def __clearConfiguration(self): reply = QtGui.QMessageBox.question( globals.preferencesWindow, translate("UiConfig_PreferencesGeneral", "Configuration file"), translate("UiConfig_PreferencesGeneral", "All GNS3 configuration will be lost. Do you want to proceed?"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No, ) if reply == QtGui.QMessageBox.Yes: from __main__ import VERSION ConfDB().clear() c = ConfDB() c.set("GNS3/version", VERSION) c.sync() QtGui.QMessageBox.information( globals.preferencesWindow, translate("UiConfig_PreferencesGeneral", "Configuration file"), translate( "UiConfig_PreferencesGeneral", "Configuration file cleared, default settings will be applied after a restart", ), ) globals.recordConfiguration = False globals.preferencesWindow.close()
def __clearConfiguration(self): ConfDB().clear() c = ConfDB() c.set('GNS3/version', VERSION_INTEGER) c.sync() QtGui.QMessageBox.information(globals.preferencesWindow, translate("UiConfig_PreferencesGeneral", "Configuration file"), translate("UiConfig_PreferencesGeneral", "Configuration file cleared, default settings will be applied after a restart")) globals.recordConfiguration = False globals.preferencesWindow.close()
def _startupLoading(self): confo = self.systconf['general'] force_clear_configuration = True version = ConfDB().get('GNS3/version', '0.0.1') try: # trick to test old version format (integer), before 0.8.2.1 release int(version) except ValueError: force_clear_configuration = False #for future releases if LooseVersion(VERSION) > str(version): # reset the tips dialog if self.mainWindow.tips_dialog: self.mainWindow.tips_dialog.checkBoxDontShowAgain.setChecked(False) if force_clear_configuration: self.mainWindow.raise_() reply = QMessageBox.question(self.mainWindow, translate("Application", "GNS3 configuration file"), translate("Application", "You have installed a new GNS3 version.\nIt is recommended to clear your old configuration, do you want to proceed?"), QMessageBox.Yes, QMessageBox.No) if reply == QMessageBox.Yes: ConfDB().clear() c = ConfDB() c.set('GNS3/version', VERSION) c.sync() globals.recordConfiguration = False QMessageBox.information(self.mainWindow, translate("Application", "GNS3 configuration file"), translate("Application", "Configuration cleared!\nPlease restart GNS3")) else: # if we cannot find our config file, we start the Wizard dialog configFile = unicode(ConfDB().fileName(), 'utf-8', errors='replace') if not os.access(configFile, os.F_OK): dialog = Wizard(parent=self.mainWindow) dialog.setModal(True) dialog.show() else: if self._file: self.mainWindow.load_netfile(self._file, load_instructions=True) elif confo.project_startup and os.access(configFile, os.F_OK): dialog = ProjectDialog(parent=self.mainWindow, newProject=True) dialog.setModal(True) dialog.show() if self.mainWindow.tips_dialog and self.mainWindow.tips_dialog.checkBoxDontShowAgain.isChecked() == False: self.showTipsDialog() else: self.mainWindow.createProject((None, None, None, False, False)) self.mainWindow.raise_() if self.mainWindow.tips_dialog and self.mainWindow.tips_dialog.checkBoxDontShowAgain.isChecked() == False: self.showTipsDialog()
def syncConf(self): """ Sync current application config with config file (gns3.{ini,conf}) """ c = ConfDB() c.set('GNS3/version', VERSION) # Apply general settings confo = self.systconf['general'] c.set('GNS3/lang', confo.lang) c.set('GNS3/project_startup', confo.project_startup) c.set('GNS3/relative_paths', confo.relative_paths) c.set('GNS3/auto_screenshot', confo.auto_screenshot) c.set('GNS3/slow_start', confo.slow_start) c.set('GNS3/autosave', confo.autosave) c.set('GNS3/console', confo.term_cmd) c.set('GNS3/serial_console', confo.term_serial_cmd) c.set('GNS3/term_close_on_delete', confo.term_close_on_delete) c.set('GNS3/use_shell', confo.use_shell) c.set('GNS3/bring_console_to_front', confo.bring_console_to_front) c.set('GNS3/gui_show_status_points', confo.status_points) c.set('GNS3/gui_use_manual_connection', confo.manual_connection) c.set('GNS3/gui_draw_selected_rectangle', confo.draw_selected_rectangle) c.set('GNS3/project_directory', confo.project_path) c.set('GNS3/ios_directory', confo.ios_path) c.set('GNS3/scene_width', confo.scene_width) c.set('GNS3/scene_height', confo.scene_height) c.set('GNS3/auto_check_for_update', confo.auto_check_for_update) c.set('GNS3/last_check_for_update', confo.last_check_for_update) c.set('GNS3/console_delay', confo.console_delay) c.set('GNS3/debug_level', globals.debugLevel) # Dynamips settings confo = self.systconf['dynamips'] c.set('Dynamips/hypervisor_path', confo.path) c.set('Dynamips/hypervisor_port', confo.port) c.set('Dynamips/hypervisor_baseUDP', confo.baseUDP) c.set('Dynamips/hypervisor_baseConsole', confo.baseConsole) c.set('Dynamips/hypervisor_baseAUX', confo.baseAUX) c.set('Dynamips/hypervisor_working_directory', confo.workdir) c.set('Dynamips/clean_working_directory', confo.clean_workdir) c.set('Dynamips/dynamips_ghosting', confo.ghosting) c.set('Dynamips/dynamips_sparsemem', confo.sparsemem) c.set('Dynamips/dynamips_jitsharing', confo.jitsharing) c.set('Dynamips/dynamips_mmap', confo.mmap) c.set('Dynamips/hypervisor_memory_usage_limit', confo.memory_limit) c.set('Dynamips/detected_version', confo.detected_version) c.set('Dynamips/hypervisor_udp_incrementation', confo.udp_incrementation) c.set('Dynamips/hypervisor_manager_import', confo.import_use_HypervisorManager) c.set('Dynamips/allocate_hypervisor_per_IOS', confo.allocateHypervisorPerIOS) c.set('Dynamips/hypervisor_manager_binding', confo.HypervisorManager_binding) # Qemu config confo = self.systconf['qemu'] c.set('Qemu/qemuwrapper_path', confo.qemuwrapper_path) c.set('Qemu/qemuwrapper_working_directory', confo.qemuwrapper_workdir) c.set('Qemu/qemu_path', confo.qemu_path) c.set('Qemu/qemu_img_path', confo.qemu_img_path) external_hosts = ','.join(confo.external_hosts) c.set('Qemu/external_hosts', external_hosts) c.set('Qemu/enable_QemuWrapperAdvOptions', confo.enable_QemuWrapperAdvOptions) c.set('Qemu/enable_QemuManager', confo.enable_QemuManager) c.set('Qemu/qemu_manager_import', confo.import_use_QemuManager) c.set('Qemu/qemu_manager_binding', confo.QemuManager_binding) c.set('Qemu/send_paths_external_Qemuwrapper', confo.send_path_external_QemuWrapper) c.set('Qemu/qemuwrapper_port', confo.qemuwrapper_port) c.set('Qemu/qemuwrapper_baseUDP', confo.qemuwrapper_baseUDP) c.set('Qemu/qemuwrapper_baseConsole', confo.qemuwrapper_baseConsole) # VBox config confo = self.systconf['vbox'] c.set('VBox/vboxwrapper_path', confo.vboxwrapper_path) c.set('VBox/vboxwrapper_working_directory', confo.vboxwrapper_workdir) external_hosts = ','.join(confo.external_hosts) c.set('VBox/external_hosts', external_hosts) c.set('VBox/use_VBoxVmnames', confo.use_VBoxVmnames) c.set('VBox/enable_VBoxWrapperAdvOptions', confo.enable_VBoxWrapperAdvOptions) c.set('VBox/enable_VBoxAdvOptions', confo.enable_VBoxAdvOptions) c.set('VBox/enable_GuestControl', confo.enable_GuestControl) c.set('VBox/enable_VBoxManager', confo.enable_VBoxManager) c.set('VBox/vbox_manager_import', confo.import_use_VBoxManager) c.set('VBox/vbox_manager_binding', confo.VBoxManager_binding) c.set('VBox/vboxwrapper_port', confo.vboxwrapper_port) c.set('VBox/vboxwrapper_baseUDP', confo.vboxwrapper_baseUDP) c.set('VBox/vboxwrapper_baseConsole', confo.vboxwrapper_baseConsole) # Capture settings confo = self.systconf['capture'] c.set('Capture/working_directory', confo.workdir) c.set('Capture/capture_reader_cmd', confo.cap_cmd) c.set('Capture/auto_start_cmd', confo.auto_start) # Clear IOS.hypervisors, IOS.images and QEMU.images group c.beginGroup("IOS.images") c.remove("") c.endGroup() c.beginGroup("IOS.hypervisors") c.remove("") c.endGroup() c.beginGroup("QEMU.images") c.remove("") c.endGroup() c.beginGroup("VBOX.images") c.remove("") c.endGroup() c.beginGroup("PIX.images") c.remove("") c.endGroup() c.beginGroup("JUNOS.images") c.remove("") c.endGroup() c.beginGroup("ASA.images") c.remove("") c.endGroup() c.beginGroup("AWP.images") c.remove("") c.endGroup() c.beginGroup("IDS.images") c.remove("") c.endGroup() # Clear Symbol.libraries group c.beginGroup("Symbol.libraries") c.remove("") c.endGroup() # Clear Recent.files group c.beginGroup("Recent.files") c.remove("") c.endGroup() # Clear Symbol.libraries group c.beginGroup("Symbol.settings") c.remove("") c.endGroup() # IOS Images for (key, o) in self.__iosimages.iteritems(): basekey = "IOS.images/" + str(o.id) c.set(basekey + "/filename", o.filename) c.set(basekey + "/chassis", o.chassis) c.set(basekey + "/platform", o.platform) c.set(basekey + "/baseconfig", o.baseconfig) hypervisors = '' for hypervisor in o.hypervisors: hypervisors += hypervisor + ' ' c.set(basekey + "/hypervisors", hypervisors.strip()) c.set(basekey + "/default_ram", o.default_ram) c.set(basekey + "/idlepc", o.idlepc) c.set(basekey + "/idlemax", o.idlemax) c.set(basekey + "/idlesleep", o.idlesleep) c.set(basekey + "/default", o.default) # Hypervisors for (key, o) in self.__hypervisors.iteritems(): basekey = "IOS.hypervisors/" + str(o.id) c.set(basekey + "/host", o.host) c.set(basekey + "/port", o.port) c.set(basekey + "/working_directory", o.workdir) c.set(basekey + "/base_udp", o.baseUDP) c.set(basekey + "/base_console", o.baseConsole) c.set(basekey + "/base_aux", o.baseAUX) # Qemu images for (key, o) in self.__qemuimages.iteritems(): basekey = "QEMU.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/usermod", o.usermod) c.set(basekey + "/nic", o.nic) c.set(basekey + "/flavor", o.flavor) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/monitor", o.monitor) # VBox images for (key, o) in self.__vboximages.iteritems(): basekey = "VBOX.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/first_nic_managed", o.first_nic_managed) c.set(basekey + "/headless_mode", o.headless_mode) c.set(basekey + "/console_support", o.console_support) c.set(basekey + "/console_telnet_server", o.console_telnet_server) c.set(basekey + "/guestcontrol_user", o.guestcontrol_user) c.set(basekey + "/guestcontrol_password", o.guestcontrol_password) # PIX images for (key, o) in self.__piximages.iteritems(): basekey = "PIX.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/key", o.key) c.set(basekey + "/serial", o.serial) # JunOS images for (key, o) in self.__junosimages.iteritems(): basekey = "JUNOS.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/usermod", o.usermod) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/monitor", o.monitor) # ASA images for (key, o) in self.__asaimages.iteritems(): basekey = "ASA.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/usermod", o.usermod) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/monitor", o.monitor) c.set(basekey + "/initrd", o.initrd) c.set(basekey + "/kernel", o.kernel) c.set(basekey + "/kernel_cmdline", o.kernel_cmdline) # AWP images for (key, o) in self.__awprouterimages.iteritems(): basekey = "AWP.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/initrd", o.initrd) c.set(basekey + "/kernel", o.kernel) c.set(basekey + "/rel", o.rel) c.set(basekey + "/kernel_cmdline", o.kernel_cmdline) # IDS images for (key, o) in self.__idsimages.iteritems(): basekey = "IDS.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/image1", o.image1) c.set(basekey + "/image2", o.image2) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/usermod", o.usermod) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/monitor", o.monitor) # Libraries id = 0 for (key, o) in self.__libraries.iteritems(): basekey = "Symbol.libraries/" + str(id) c.set(basekey + "/path", o.path) id += 1 # Recent Files id = 0 for o in self.__recentfiles: basekey = "Recent.files/" + str(id) c.set(basekey + "/path", o.path) id += 1 # Symbols id = 0 for symbol in SYMBOLS: if not symbol['translated']: basekey = "Symbol.settings/" + str(id) c.set(basekey + "/name", symbol['name']) c.set(basekey + "/type", SYMBOL_TYPES[symbol['object']]) c.set(basekey + "/normal_svg_file", symbol['normal_svg_file']) c.set(basekey + "/selected_svg_file", symbol['select_svg_file']) id += 1 c.sync()
def syncConf(self): """ Sync current application config with config file (gns3.{ini,conf}) """ c = ConfDB() c.set('GNS3/version', VERSION_INTEGER) # Apply general settings confo = self.systconf['general'] c.set('GNS3/lang', confo.lang) c.set('GNS3/project_startup', confo.project_startup) c.set('GNS3/relative_paths', confo.relative_paths) c.set('GNS3/slow_start', confo.slow_start) c.set('GNS3/autosave', confo.autosave) c.set('GNS3/console', confo.term_cmd) c.set('GNS3/use_shell', confo.use_shell) c.set('GNS3/gui_show_status_points', confo.status_points) c.set('GNS3/gui_use_manual_connection', confo.manual_connection) c.set('GNS3/gui_draw_selected_rectangle', confo.draw_selected_rectangle) c.set('GNS3/project_directory', confo.project_path) c.set('GNS3/ios_directory', confo.ios_path) c.set('GNS3/scene_width', confo.scene_width) c.set('GNS3/scene_height', confo.scene_height) # Dynamips settings confo = self.systconf['dynamips'] c.set('Dynamips/hypervisor_path', confo.path) c.set('Dynamips/hypervisor_port', confo.port) c.set('Dynamips/hypervisor_baseUDP', confo.baseUDP) c.set('Dynamips/hypervisor_baseConsole', confo.baseConsole) c.set('Dynamips/hypervisor_baseAUX', confo.baseAUX) c.set('Dynamips/hypervisor_working_directory', confo.workdir) c.set('Dynamips/clean_working_directory', confo.clean_workdir) c.set('Dynamips/dynamips_ghosting', confo.ghosting) c.set('Dynamips/dynamips_sparsemem', confo.sparsemem) c.set('Dynamips/dynamips_jitsharing', confo.jitsharing) c.set('Dynamips/dynamips_mmap', confo.mmap) c.set('Dynamips/hypervisor_memory_usage_limit', confo.memory_limit) c.set('Dynamips/hypervisor_udp_incrementation', confo.udp_incrementation) c.set('Dynamips/hypervisor_manager_import', confo.import_use_HypervisorManager) c.set('Dynamips/allocate_hypervisor_per_IOS', confo.allocateHypervisorPerIOS) c.set('Dynamips/hypervisor_manager_binding', confo.HypervisorManager_binding) # Qemu config confo = self.systconf['qemu'] c.set('Qemu/qemuwrapper_path', confo.qemuwrapper_path) c.set('Qemu/qemuwrapper_working_directory', confo.qemuwrapper_workdir) c.set('Qemu/qemu_path', confo.qemu_path) c.set('Qemu/qemu_img_path', confo.qemu_img_path) external_hosts = ','.join(confo.external_hosts) c.set('Qemu/external_hosts', external_hosts) c.set('Qemu/enable_QemuManager', confo.enable_QemuManager) c.set('Qemu/qemu_manager_import', confo.import_use_QemuManager) c.set('Qemu/qemu_manager_binding', confo.QemuManager_binding) c.set('Qemu/qemuwrapper_port', confo.qemuwrapper_port) c.set('Qemu/qemuwrapper_baseUDP', confo.qemuwrapper_baseUDP) c.set('Qemu/qemuwrapper_baseConsole', confo.qemuwrapper_baseConsole) # Capture settings confo = self.systconf['capture'] c.set('Capture/working_directory', confo.workdir) c.set('Capture/capture_reader_cmd', confo.cap_cmd) c.set('Capture/auto_start_cmd', confo.auto_start) # Clear IOS.hypervisors, IOS.images and QEMU.images group c.beginGroup("IOS.images") c.remove("") c.endGroup() c.beginGroup("IOS.hypervisors") c.remove("") c.endGroup() c.beginGroup("QEMU.images") c.remove("") c.endGroup() c.beginGroup("PIX.images") c.remove("") c.endGroup() c.beginGroup("JUNOS.images") c.remove("") c.endGroup() c.beginGroup("ASA.images") c.remove("") c.endGroup() c.beginGroup("IDS.images") c.remove("") c.endGroup() # Clear Symbol.libraries group c.beginGroup("Symbol.libraries") c.remove("") c.endGroup() # Clear Symbol.libraries group c.beginGroup("Symbol.settings") c.remove("") c.endGroup() # IOS Images for (key, o) in self.__iosimages.iteritems(): basekey = "IOS.images/" + str(o.id) c.set(basekey + "/filename", o.filename) c.set(basekey + "/chassis", o.chassis) c.set(basekey + "/platform", o.platform) c.set(basekey + "/baseconfig", o.baseconfig) hypervisors = '' for hypervisor in o.hypervisors: hypervisors += hypervisor + ' ' c.set(basekey + "/hypervisors", hypervisors.strip()) c.set(basekey + "/default_ram", o.default_ram) c.set(basekey + "/idlepc", o.idlepc) c.set(basekey + "/default", o.default) # Hypervisors for (key, o) in self.__hypervisors.iteritems(): basekey = "IOS.hypervisors/" + str(o.id) c.set(basekey + "/host", o.host) c.set(basekey + "/port", o.port) c.set(basekey + "/working_directory", o.workdir) c.set(basekey + "/base_udp", o.baseUDP) c.set(basekey + "/base_console", o.baseConsole) c.set(basekey + "/base_aux", o.baseAUX) # Qemu images for (key, o) in self.__qemuimages.iteritems(): basekey = "QEMU.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kqemu", o.kqemu) c.set(basekey + "/kvm", o.kvm) # PIX images for (key, o) in self.__piximages.iteritems(): basekey = "PIX.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kqemu", o.kqemu) c.set(basekey + "/key", o.key) c.set(basekey + "/serial", o.serial) # JunOS images for (key, o) in self.__junosimages.iteritems(): basekey = "JUNOS.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/filename", o.filename) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kqemu", o.kqemu) c.set(basekey + "/kvm", o.kvm) # ASA images for (key, o) in self.__asaimages.iteritems(): basekey = "ASA.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kqemu", o.kqemu) c.set(basekey + "/kvm", o.kvm) c.set(basekey + "/initrd", o.initrd) c.set(basekey + "/kernel", o.kernel) c.set(basekey + "/kernel_cmdline", o.kernel_cmdline) # IDS images for (key, o) in self.__idsimages.iteritems(): basekey = "IDS.images/" + str(o.id) c.set(basekey + "/name", o.name) c.set(basekey + "/image1", o.image1) c.set(basekey + "/image2", o.image2) c.set(basekey + "/memory", o.memory) c.set(basekey + "/nic_nb", o.nic_nb) c.set(basekey + "/nic", o.nic) c.set(basekey + "/options", o.options) c.set(basekey + "/kqemu", o.kqemu) c.set(basekey + "/kvm", o.kvm) # Libraries id = 0 for (key, o) in self.__libraries.iteritems(): basekey = "Symbol.libraries/" + str(id) c.set(basekey + "/path", o.path) id += 1 # Symbols id = 0 for symbol in SYMBOLS: if not symbol['translated']: basekey = "Symbol.settings/" + str(id) c.set(basekey + "/name", symbol['name']) c.set(basekey + "/type", SYMBOL_TYPES[symbol['object']]) c.set(basekey + "/normal_svg_file", symbol['normal_svg_file']) c.set(basekey + "/selected_svg_file", symbol['select_svg_file']) id += 1 c.sync()