Example #1
0
    def ASA_images(self):
        """ Load ASA images settings from config file
        """

        # Loading ASA image conf
        basegroup = "ASA.images"
        c = ConfDB()
        c.beginGroup(basegroup)
        childGroups = c.childGroups()
        c.endGroup()

        for id in childGroups:

            cgroup = basegroup + '/' + id
            
            conf = asaImageConf()
            conf.id = int(id)
            conf.name = c.get(cgroup + "/name", unicode(''))
            conf.memory = int(c.get(cgroup + "/memory", 256))
            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()
            conf.initrd = c.get(cgroup + "/initrd", unicode(''))
            conf.kernel = c.get(cgroup + "/kernel", unicode(''))
            conf.kernel_cmdline = c.get(cgroup + "/kernel_cmdline", unicode(''))
            globals.GApp.asaimages[conf.name] = conf

            if conf.id >= globals.GApp.asaimages_ids:
                globals.GApp.asaimages_ids = conf.id + 1
Example #2
0
    def slotSaveASAImage(self):
        """ Add/Save ASA Image in the list of ASA images
        """

        name = unicode(self.NameASAImage.text())
        initrd = unicode(self.ASAInitrd.text())
        kernel = unicode(self.ASAKernel.text())
        
        if not name or not initrd or not kernel:
            QtGui.QMessageBox.critical(globals.preferencesWindow, translate("Page_PreferencesQemu", "ASA firewall"), 
                                       translate("Page_PreferencesQemu", "Identifier, initrd and kernel must be set!"))
            return

        if globals.GApp.asaimages.has_key(name):
            # update an already existing ASA initrd + kernel
            item_to_update = self.treeWidgetASAImages.findItems(name, QtCore.Qt.MatchFixedString)[0]
            item_to_update.setText(1, initrd)
            item_to_update.setText(2, kernel)
        else:
            # else create a new entry
            item = QtGui.QTreeWidgetItem(self.treeWidgetASAImages)
            # image name column
            item.setText(0, name)
            # initrd path column
            item.setText(1, initrd)
            # kernel path column
            item.setText(2, kernel)
            
        # save settings
        if globals.GApp.asaimages.has_key(name):
            conf = globals.GApp.asaimages[name]
        else:
            conf = asaImageConf()

        conf.id = globals.GApp.asaimages_ids
        globals.GApp.asaimages_ids += 1
        conf.name = name
        conf.initrd = initrd
        conf.kernel = kernel
        conf.kernel_cmdline = unicode(self.ASAKernelCmdLine.text())
        conf.memory = self.ASAMemory.value()
        conf.nic_nb = self.ASANICNb.value()
        conf.nic = str(self.ASANIC.currentText())
        conf.options = str(self.ASAOptions.text())
        
        if self.ASAcheckBoxKqemu.checkState() == QtCore.Qt.Checked:
            conf.kqemu = True
        else:
            conf.kqemu  = False
        if self.ASAcheckBoxKVM.checkState() == QtCore.Qt.Checked:
            conf.kvm = True
        else:
            conf.kvm  = False

        globals.GApp.asaimages[name] = conf
        self.treeWidgetASAImages.resizeColumnToContents(0)
        QtGui.QMessageBox.information(globals.preferencesWindow, translate("Page_PreferencesQemu", "Save"),  translate("Page_PreferencesQemu", "ASA settings have been saved"))
Example #3
0
    def ASA_images(self):
        """ Load ASA images settings from config file
        """

        # Loading ASA image conf
        basegroup = "ASA.images"
        c = ConfDB()
        c.beginGroup(basegroup)
        childGroups = c.childGroups()
        c.endGroup()

        for id in childGroups:

            cgroup = basegroup + '/' + id

            conf = asaImageConf()
            conf.id = int(id)
            conf.name = c.get(cgroup + "/name", unicode(''))
            conf.memory = int(c.get(cgroup + "/memory", 256))
            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()
            conf.initrd = c.get(cgroup + "/initrd", unicode(''))
            conf.kernel = c.get(cgroup + "/kernel", unicode(''))
            conf.kernel_cmdline = c.get(cgroup + "/kernel_cmdline",
                                        unicode(''))
            globals.GApp.asaimages[conf.name] = conf

            if conf.id >= globals.GApp.asaimages_ids:
                globals.GApp.asaimages_ids = conf.id + 1