Exemple #1
0
    def PIX_images(self):
        """ Load PIX images settings from config file
        """

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

        for id in childGroups:

            cgroup = basegroup + '/' + id

            conf = pixImageConf()
            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.key = str(c.get(cgroup + "/key", ''))
            conf.serial = str(c.get(cgroup + "/serial", ''))
            globals.GApp.piximages[conf.name] = conf

            if conf.id >= globals.GApp.piximages_ids:
                globals.GApp.piximages_ids = conf.id + 1
Exemple #2
0
    def PIX_images(self):
        """ Load PIX images settings from config file
        """

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

        for id in childGroups:

            cgroup = basegroup + '/' + id
            
            conf = pixImageConf()
            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.key = str(c.get(cgroup + "/key", ''))
            conf.serial = str(c.get(cgroup + "/serial", ''))
            globals.GApp.piximages[conf.name] = conf
            
            if conf.id >= globals.GApp.piximages_ids:
                globals.GApp.piximages_ids = conf.id + 1
Exemple #3
0
    def slotSavePIXImage(self):
        """ Add/Save PIX Image in the list of PIX images
        """

        name = unicode(self.NamePIXImage.text())
        image = unicode(self.PIXImage.text())
        
        if not name or not image:
            QtGui.QMessageBox.critical(globals.preferencesWindow, translate("Page_PreferencesQemu", "PIX firewall"), 
                                       translate("Page_PreferencesQemu", "Identifier and binary image must be set!"))
            return

        if globals.GApp.piximages.has_key(name):
            # update an already existing PIX image
            item_to_update = self.treeWidgetPIXImages.findItems(name, QtCore.Qt.MatchFixedString)[0]
            item_to_update.setText(1, image)
        else:
            # else create a new entry
            item = QtGui.QTreeWidgetItem(self.treeWidgetPIXImages)
            # image name column
            item.setText(0, name)
            # image path column
            item.setText(1, image)

        # save settings
        if globals.GApp.piximages.has_key(name):
            conf = globals.GApp.piximages[name]
        else:
            conf = pixImageConf()

        conf.id = globals.GApp.piximages_ids
        globals.GApp.piximages_ids += 1
        conf.name = name
        conf.filename = image
        conf.memory = self.PIXMemory.value()
        conf.nic_nb = self.PIXNICNb.value()
        conf.nic = str(self.PIXNIC.currentText())
        conf.options = str(self.PIXOptions.text())
        
        if self.PIXcheckBoxKqemu.checkState() == QtCore.Qt.Checked:
            conf.kqemu = True
        else:
            conf.kqemu  = False
            
        serial = str(self.PIXSerial.text())
        if serial and not re.search(r"""^0x[0-9a-fA-F]{8}$""", serial):
            QtGui.QMessageBox.critical(globals.preferencesWindow, translate("Page_PreferencesQemu", "Serial"), 
                                       translate("Page_PreferencesQemu", "Invalid serial (format required: 0xhhhhhhhh)"))
        else:
            conf.serial = serial

        key = str(self.PIXKey.text())
        if key and not re.search(r"""^(0x[0-9a-fA-F]{8},){3}0x[0-9a-fA-F]{8}$""", key):
            QtGui.QMessageBox.critical(globals.preferencesWindow, translate("Page_PreferencesQemu", "Key"),
                                       translate("Page_PreferencesQemu", "Invalid key (format required: 0xhhhhhhhh,0xhhhhhhhh,0xhhhhhhhh,0xhhhhhhhh)"))
        else:
            conf.key = key

        globals.GApp.piximages[name] = conf
        self.treeWidgetPIXImages.resizeColumnToContents(0)
        QtGui.QMessageBox.information(globals.preferencesWindow, translate("Page_PreferencesQemu", "Save"),  translate("Page_PreferencesQemu", "PIX settings have been saved"))