當前位置: 首頁>>代碼示例>>Python>>正文


Python plugins.Changeset類代碼示例

本文整理匯總了Python中ovirt.node.plugins.Changeset的典型用法代碼示例。如果您正苦於以下問題:Python Changeset類的具體用法?Python Changeset怎麽用?Python Changeset使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Changeset類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving remote storage page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        txs = utils.Transaction(_("Updating remote storage configuration"))

        iscsi_keys = ["iscsi.initiator_name"]
        if changes.contains_any(iscsi_keys):
            model = defaults.iSCSI()
            args = effective_model.values_for(iscsi_keys)
            args += [None, None, None]  # No target config
            model.update(*args)
            txs += model.transaction()

        nfsv4_keys = ["nfsv4.domain"]
        if changes.contains_any(nfsv4_keys):
            model = defaults.NFSv4()
            args = effective_model.values_for(nfsv4_keys)
            model.update(*args)
            txs += model.transaction()

        scsi_keys = ["scsi.dh_alua"]
        if changes.contains_any(scsi_keys):
            model = defaults.SCSIDhAlua()
            args = effective_model.values_for(scsi_keys)
            model.update(*args)
            txs += model.transaction()

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
開發者ID:Zealsathish,項目名稱:ovirt-node,代碼行數:35,代碼來源:remote_storage_page.py

示例2: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving logging page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        txs = utils.Transaction(_("Updating logging related configuration"))

        # If any logrotate key changed ...
        logrotate_keys = ["logrotate.max_size"]
        if changes.contains_any(logrotate_keys):
            # Get all logrotate values fomr the effective model
            model = defaults.Logrotate()
            # And update the defaults
            model.update(*effective_model.values_for(logrotate_keys))
            txs += model.transaction()

        rsyslog_keys = ["rsyslog.address", "rsyslog.port"]
        if changes.contains_any(rsyslog_keys):
            model = defaults.Syslog()
            model.update(*effective_model.values_for(rsyslog_keys))
            txs += model.transaction()

        netconsole_keys = ["netconsole.address", "netconsole.port"]
        if changes.contains_any(netconsole_keys):
            model = defaults.Netconsole()
            model.update(*effective_model.values_for(netconsole_keys))
            txs += model.transaction()

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
開發者ID:GregSutcliffe,項目名稱:ovirt-node,代碼行數:34,代碼來源:logging_page.py

示例3: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving SNMP page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        snmp_keys = ["snmp.password", "snmp.enabled"]

        txs = utils.Transaction("Updating SNMP configuration")

        if changes.contains_any(snmp_keys):
            is_enabled = effective_model["snmp.enabled"]
            pw = effective_model["snmp.password"]
            if is_enabled and len(pw) == 0:
                txt = "Unable to configure SNMP without a password!"
                self._confirm_dialog = ui.InfoDialog("dialog.confirm",
                                                     "SNMP Error",
                                                     txt)
                return self._confirm_dialog
            else:
                model = snmp_model.SNMP()
                model.update(is_enabled)
                txs += model.transaction(snmp_password=pw)
                progress_dialog = ui.TransactionProgressDialog("dialog.txs",
                                                               txs, self)
                progress_dialog.run()
        return self.ui_content()
開發者ID:Zealsathish,項目名稱:ovirt-node,代碼行數:30,代碼來源:snmp_page.py

示例4: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving security page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        ssh_keys = ["ssh.pwauth", "strongrng.num_bytes", "strongrng.disable_aesni"]

        txs = utils.Transaction("Updating security configuration")

        if changes.contains_any(ssh_keys):
            model = defaults.SSH()
            model.update(*effective_model.values_for(ssh_keys))
            txs += model.transaction()

        if changes.contains_any(["passwd.admin.password"]):
            pw = effective_model["passwd.admin.password"]
            passwd = utils.security.Passwd()

            # Create a custom transaction element, because the password
            # is not handled/saved in the defaults file
            class SetAdminPasswd(utils.Transaction.Element):
                title = "Setting admin password"

                def commit(self):
                    self.logger.debug("Setting admin password.")
                    passwd.set_password("admin", pw)

            txs += [SetAdminPasswd()]

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
開發者ID:oVirt,項目名稱:Node,代碼行數:35,代碼來源:security_page.py

示例5: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving remote storage page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        txs = utils.Transaction("make local storage path")

        iscsi_keys = ["iscsi.initiator_name"]
        if changes.contains_any(iscsi_keys):
            
            args = effective_model.values_for(iscsi_keys)
            #model = defaults.iSCSI()
            txs += [createPath(args[0])]
            #args += [None, None, None]  # No target config
            #model.update(*args)
            #txs += model.transaction()

        #nfsv4_keys = ["nfsv4.domain"]
        #if changes.contains_any(nfsv4_keys):
        #    model = defaults.NFSv4()
        #    args = effective_model.values_for(nfsv4_keys)
        #    model.update(*args)
        #    txs += model.transaction()

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
開發者ID:aiminickwong,項目名稱:ovirt_config,代碼行數:30,代碼來源:remote_storage_page.py

示例6: on_merge

    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """
        self.logger.debug("Saving kdump page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        saved_model = self.model()
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        kdump_keys = ["kdump.type", "kdump.ssh_location", "kdump.ssh_key",
                      "kdump.nfs_location"]

        txs = utils.Transaction(_("Updating kdump related configuration"))

        if changes.contains_any(kdump_keys):
            model = defaults.KDump()
            ktype, sshloc, sshkey, nfsloc = effective_model.values_for(
                kdump_keys)
            if ktype == "nfs":
                model.configure_nfs(nfsloc)
            elif ktype == "ssh":
                if "kdump.ssh_key" in changes:
                    model.configure_ssh(sshloc, sshkey)
                else:
                    model.configure_ssh(sshloc)
            elif ktype == "local":
                model.configure_local()
            else:
                model.configure_disable()
            txs += model.transaction()

        try:
            with self.application.ui.suspended():
                console.reset()
                is_dry = self.application.args.dry
                progress_dialog = console.TransactionProgress(txs, is_dry)
                progress_dialog.run()
                console.writeln("\nPlease press any key to continue")
                console.wait_for_keypress()
        except KeyboardInterrupt:
            def _handler(signum, frame):
                console.writeln("\nWait for configuration to be restored\n")
            with self.application.ui.suspended():
                _original_sigint = signal.getsignal(signal.SIGINT)
                signal.signal(signal.SIGINT, _handler)
                self.restore_config(saved_model)
                signal.signal(signal.SIGINT, _original_sigint)
                return InfoDialog("dialog.restore", "Restored the "
                                  "configuration on keyboard interrupt")
        except Exception as e:
            self.restore_config(saved_model)
            self.logger.exception("Exception while configuring kdump")
            self.application.show(self.ui_content())
            return InfoDialog("dialog.info", "An error occurred", e.message)
        return self.ui_content()
開發者ID:gvsurenderreddy,項目名稱:ovirt-node,代碼行數:60,代碼來源:kdump_page.py

示例7: on_merge

    def on_merge(self, effective_changes):
        self.logger.info("Saving Puppet config")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        puppet_keys = ["puppet.enabled", "puppet.server", "puppet.certname"]
        if changes.contains_any(puppet_keys):
            Puppet().update(*effective_model.values_for(puppet_keys))

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        txs = utils.Transaction("Configuring Puppet")

        if effective_changes.contains_any(["action.register"]):
            self.logger.debug("Connecting to puppet")
            txs += [ActivatePuppet()]

        if len(txs) > 0:
            progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs,
                                                           self)
            progress_dialog.run()

        # Acts like a page reload
        return self.ui_content()
開發者ID:lzap,項目名稱:ovirt-node,代碼行數:26,代碼來源:puppet_page.py

示例8: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving CIM page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        cim_keys = ["cim.password_confirmation", "cim.enabled"]

        txs = utils.Transaction("Updating CIM configuration")

        if changes.contains_any(cim_keys):
            is_enabled = effective_model["cim.enabled"]
            pw = effective_model["cim.password_confirmation"]

            model = cim_model.CIM()
            model.update(is_enabled)
            txs += model.transaction(cim_password=pw)
        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
開發者ID:kobex11,項目名稱:Node-1,代碼行數:22,代碼來源:cim_page.py

示例9: on_merge

    def on_merge(self, effective_changes):
        model = NodeManagement()
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        txs = utils.Transaction("Configuring {engine_name}".format(
            engine_name=config.engine_name))

        if changes.contains_any(["vdsm_cfg.password"]):
            txs += [SetRootPassword(
                password=effective_model["vdsm_cfg.password"]
            )]

        if effective_model["vdsm_cfg.address"]:
            if validate_server(effective_model["vdsm_cfg.address"]):
                self._server, self._port = \
                    effective_model["vdsm_cfg.address"].split(":")
            else:
                self._server = effective_model["vdsm_cfg.address"]
                self._port = config.ENGINE_PORT

            txs += [NodeRegister(self._server, self._port)]

        model.update(mserver=self._server, mport=self._port)

        if len(txs) > 0:
            progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs,
                                                           self)
            progress_dialog.run()

            # VDSM messes with logging, and we just reset it
            log.configure_logging()

        # Acts like a page reload
        return self.ui_content()
開發者ID:oVirt,項目名稱:ovirt-node-plugin-vdsm,代碼行數:39,代碼來源:engine_page.py

示例10: on_merge

    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """
        self.logger.debug("Saving kdump page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        kdump_keys = ["kdump.type", "kdump.ssh_location", "kdump.ssh_key",
                      "kdump.nfs_location"]

        txs = utils.Transaction(_("Updating kdump related configuration"))

        if changes.contains_any(kdump_keys):
            model = defaults.KDump()
            ktype, sshloc, sshkey, nfsloc = effective_model.values_for(
                kdump_keys)
            if ktype == "nfs":
                model.update(nfsloc, None, None, None)
            elif ktype == "ssh":
                if "kdump.ssh_key" in changes:
                    model.update(None, sshloc, sshkey, None)
                else:
                    model.update(None, sshloc, None, None)
            elif ktype == "local":
                model.update(None, None, None, True)
            else:
                model.update(None, None, None, None)
            txs += model.transaction()

        try:
            with self.application.ui.suspended():
                console.reset()
                is_dry = self.application.args.dry
                progress_dialog = console.TransactionProgress(txs, is_dry)
                progress_dialog.run()
                console.writeln("\nPlease press any key to continue")
                console.wait_for_keypress()
        except Exception as e:
            self.logger.exception("Exception while configuring kdump")
            return InfoDialog("dialog.info", _("An error occurred"), e.message)
開發者ID:GregSutcliffe,項目名稱:ovirt-node,代碼行數:46,代碼來源:kdump_page.py

示例11: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving hostname page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        collectd_keys = ["collectd.ip", "collectd.hostname"]

        txs = utils.Transaction("Add Node hostname to the Engine")

        if changes.contains_any(collectd_keys):
            model = defaults.Hostname()
            model.update(*effective_model.values_for(collectd_keys))
            args = effective_model.values_for(collectd_keys)
            txs += [Hostname(args[0],args[1])]
            txs += model.transaction()

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
開發者ID:aiminickwong,項目名稱:ovirt_config,代碼行數:22,代碼來源:hostname_page.py

示例12: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving monitoring page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        collectd_keys = ["collectd.address", "collectd.port"]

        txs = utils.Transaction("Add engine to Windows AD")

        if changes.contains_any(collectd_keys):
            model = defaults.Collectd()
            model.update(*effective_model.values_for(collectd_keys))
            args = effective_model.values_for(collectd_keys)
            txs += [AD(args[0],args[1])]
            txs += model.transaction()

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
開發者ID:aiminickwong,項目名稱:ovirt_config,代碼行數:22,代碼來源:monitoring_page.py

示例13: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving keyboard page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        layout_keys = ["keyboard.layout"]

        txs = utils.Transaction("Updating keyboard related configuration")

        if changes.contains_any(layout_keys):
            model = defaults.Keyboard()
            model.update(*effective_model.values_for(layout_keys))
            txs += model.transaction()

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
開發者ID:ArchipelProject,項目名稱:Node,代碼行數:20,代碼來源:keyboard_page.py

示例14: on_merge

    def on_merge(self, effective_changes):
        """Applies the changes to the plugins model, will do all required logic
        Normally on_merge is called by pushing the SaveButton instance, in this
        case it is called by on_change
        """
        self.logger.debug("Saving kdump page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        kdump_keys = ["kdump.type", "kdump.ssh_location", "kdump.nfs_location"]

        txs = utils.Transaction("Updating kdump related configuration")

        if changes.contains_any(kdump_keys):
            model = defaults.KDump()
            ktype, sshloc, nfsloc = effective_model.values_for(kdump_keys)
            if ktype == "nfs":
                model.update(nfsloc, None, None)
            elif ktype == "ssh":
                model.update(None, sshloc, None)
            elif ktype == "local":
                model.update(None, None, True)
            else:
                model.update(None, None, None)
            txs += model.transaction()

        with self.application.ui.suspended():
            utils.process.call("reset")
            progress_dialog = console.TransactionProgress(txs, self)
            progress_dialog.run()
            console.writeln("\nPlease press any key to continue")
            console.wait_for_keypress()
開發者ID:ArchipelProject,項目名稱:Node,代碼行數:36,代碼來源:kdump_page.py

示例15: on_merge

    def on_merge(self, effective_changes):
        self.logger.debug("Saving SNMP page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        snmp_keys = ["snmp.password_confirmation", "snmp.enabled"]

        txs = utils.Transaction("Updating SNMP configuration")

        if changes.contains_any(snmp_keys):
            values = effective_model.values_for(snmp_keys)
            args = [values[0]]
            if values[1] is False:  # If set to disabled, set password to None
                args[0] = None
            model = snmp_model.SNMP()
            model.update(*args)
            txs += model.transaction()

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
開發者ID:ianjw11,項目名稱:ovirt-node,代碼行數:24,代碼來源:snmp_page.py


注:本文中的ovirt.node.plugins.Changeset類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。