当前位置: 首页>>代码示例>>Python>>正文


Python Changeset.update方法代码示例

本文整理汇总了Python中ovirt.node.plugins.Changeset.update方法的典型用法代码示例。如果您正苦于以下问题:Python Changeset.update方法的具体用法?Python Changeset.update怎么用?Python Changeset.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ovirt.node.plugins.Changeset的用法示例。


在下文中一共展示了Changeset.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:37,代码来源:security_page.py

示例2: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:32,代码来源:snmp_page.py

示例3: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:62,代码来源:kdump_page.py

示例4: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:36,代码来源:logging_page.py

示例5: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:28,代码来源:puppet_page.py

示例6: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:37,代码来源:remote_storage_page.py

示例7: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:32,代码来源:remote_storage_page.py

示例8: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:48,代码来源:kdump_page.py

示例9: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:22,代码来源:keyboard_page.py

示例10: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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(_("Updating monitoring configuration"))

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

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()
开发者ID:GregSutcliffe,项目名称:ovirt-node,代码行数:22,代码来源:monitoring_page.py

示例11: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:24,代码来源:cim_page.py

示例12: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:41,代码来源:engine_page.py

示例13: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:24,代码来源:hostname_page.py

示例14: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:26,代码来源:snmp_page.py

示例15: on_merge

# 需要导入模块: from ovirt.node.plugins import Changeset [as 别名]
# 或者: from ovirt.node.plugins.Changeset import update [as 别名]
    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,代码行数:38,代码来源:kdump_page.py


注:本文中的ovirt.node.plugins.Changeset.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。