Пример #1
0
    def validatePage(self):
        type_index, is_ok = self.field('type').toInt()
        ha_type = unicode(self.ha_type.itemData(type_index).toString())

        if QHAObject.getInstance().cfg.ha_type == SECONDARY and ha_type == ENOHA:
            #SECONDARY -> ENOHA is forbidden
            #when PRIMARY, this wizard is not even displayed
            QMessageBox.warning(self,
                tr('Invalid configuration'),
                tr(
                    "In order to fully deconfigure high availability, you "
                    "need to restore this appliance to factory defaults."
                )
                )
            return False

        if ha_type != ENOHA:
            net_cfg = QNetObject.getInstance().netcfg
            iface = self.interface.getInterface()
            iface_id = net_cfg.getHardLabel(iface)
            iface_name = iface.system_name
        else:
            iface_id = None
            iface_name = None
        config = HAConf(ha_type=ha_type, interface_id=iface_id, interface_name=iface_name)
        msg = config.isValidWithMsg()
        if msg is None:
            self.config = config
        else:
            QMessageBox.warning(self, tr('Invalid configuration'), msg[0] % msg[1:])
        if msg is not None:
            return False

        if ha_type != PENDING_PRIMARY:
            return True

        user_valid = QMessageBox.question(
                self,
                tr("Configuring primary appliance. Are you sure?"),
                "<div>%s<br/>%s<br/>%s<br/>%s</div>" % (
                    tr(
                        "After this configuration step, <b>you will not be able to "
                        "change the hostname anymore.</b>"
                      ),
                    tr(
                        "Abort now, or reject the saved configuration if you "
                        "need to change the hostname."
                      ),
                    tr("The hostname is currently <i><b>'%(HOSTNAME)s'</b></i>"
                      ) % {'HOSTNAME': QHostnameObject.getInstance().cfg.hostname},
                    tr("Do you want to continue?"),
                    ),
                QMessageBox.Yes | QMessageBox.Abort
                )

        return user_valid == QMessageBox.Yes
Пример #2
0
    def backend_values(self):
        init_qnetobject()
        serialized_ha_conf = {
            'DATASTRUCTURE_VERSION': 3,
            "ha_type": "PRIMARY",
            "interface_id": "eth0",
            #"interface_id": "268435455",
            "interface_name": "eth0",
            "primary_hostname": "primary",

        }
        QHAObject.getInstance().cfg = HAConf.deserialize(serialized_ha_conf)
        return {
        #('ha', "getState"): ['NOT_REGISTERED', 0, '']
        ('ha', "getState"): ['PRIMARY', 0, '']
    }