def JUNOS_images(self): """ Load JunOS images settings from config file """ # Loading JunOS image conf basegroup = "JUNOS.images" c = ConfDB() c.beginGroup(basegroup) childGroups = c.childGroups() c.endGroup() for id in childGroups: cgroup = basegroup + '/' + id conf = junosImageConf() conf.id = int(id) conf.name = c.get(cgroup + "/name", unicode('')) conf.filename = c.get(cgroup + "/filename", unicode('')) conf.memory = int(c.get(cgroup + "/memory", 128)) conf.nic_nb = int(c.get(cgroup + "/nic_nb", 6)) conf.usermod = c.value(cgroup + "/usermod", QtCore.QVariant(False)).toBool() conf.nic = str(c.get(cgroup + "/nic", 'e1000')) conf.options = str(c.get(cgroup + "/options", '')) conf.kvm = c.value(cgroup + "/kvm", QtCore.QVariant(False)).toBool() conf.monitor = c.value(cgroup + "/monitor", QtCore.QVariant(False)).toBool() globals.GApp.junosimages[conf.name] = conf if conf.id >= globals.GApp.junosimages_ids: globals.GApp.junosimages_ids = conf.id + 1
def JUNOS_images(self): """ Load JunOS images settings from config file """ # Loading JunOS image conf basegroup = "JUNOS.images" c = ConfDB() c.beginGroup(basegroup) childGroups = c.childGroups() c.endGroup() for id in childGroups: cgroup = basegroup + '/' + id conf = junosImageConf() conf.id = int(id) conf.name = c.get(cgroup + "/name", unicode('')) conf.filename = c.get(cgroup + "/filename", unicode('')) conf.memory = int(c.get(cgroup + "/memory", 128)) conf.nic_nb = int(c.get(cgroup + "/nic_nb", 6)) conf.nic = str(c.get(cgroup + "/nic", 'e1000')) conf.options = str(c.get(cgroup + "/options", '')) conf.kqemu = c.value(cgroup + "/kqemu", QtCore.QVariant(False)).toBool() conf.kvm = c.value(cgroup + "/kvm", QtCore.QVariant(False)).toBool() globals.GApp.junosimages[conf.name] = conf if conf.id >= globals.GApp.junosimages_ids: globals.GApp.junosimages_ids = conf.id + 1
def slotSaveJunOSImage(self): """ Add/Save JunOS Image in the list of JunOS images """ name = unicode(self.NameJunOSImage.text()) image = unicode(self.JunOSImage.text()) if not name or not image: QtGui.QMessageBox.critical(globals.preferencesWindow, translate("Page_PreferencesQemu", "JunOS router"), translate("Page_PreferencesQemu", "Identifier and binary image must be set!")) return if globals.GApp.junosimages.has_key(name): # update an already existing JunOS image item_to_update = self.treeWidgetJunOSImages.findItems(name, QtCore.Qt.MatchFixedString)[0] item_to_update.setText(1, image) else: # else create a new entry item = QtGui.QTreeWidgetItem(self.treeWidgetJunOSImages) # image name column item.setText(0, name) # image path column item.setText(1, image) # save settings if globals.GApp.junosimages.has_key(name): conf = globals.GApp.junosimages[name] else: conf = junosImageConf() conf.id = globals.GApp.junosimages_ids globals.GApp.junosimages_ids += 1 conf.name = name conf.filename = image conf.memory = self.JunOSMemory.value() conf.nic_nb = self.JunOSNICNb.value() conf.nic = str(self.JunOSNIC.currentText()) conf.options = str(self.JunOSOptions.text()) if self.JunOScheckBoxKqemu.checkState() == QtCore.Qt.Checked: conf.kqemu = True else: conf.kqemu = False if self.JunOScheckBoxKVM.checkState() == QtCore.Qt.Checked: conf.kvm = True else: conf.kvm = False globals.GApp.junosimages[name] = conf self.treeWidgetJunOSImages.resizeColumnToContents(0) QtGui.QMessageBox.information(globals.preferencesWindow, translate("Page_PreferencesQemu", "Save"), translate("Page_PreferencesQemu", "JunOS settings have been saved"))