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


Python ConfigurationManager.refresh_cache方法代码示例

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


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

示例1: PgSqlApp

# 需要导入模块: from trove.guestagent.common.configuration import ConfigurationManager [as 别名]
# 或者: from trove.guestagent.common.configuration.ConfigurationManager import refresh_cache [as 别名]

#.........这里部分代码省略.........
    def is_root_enabled(self, context):
        """Return True if there is a superuser account enabled.
        """
        results = self.build_admin().query(
            pgsql_query.UserQuery.list_root(),
            timeout=30,
        )

        # There should be only one superuser (Trove's administrative account).
        return len(results) > 1 or (results[0][0] != self.ADMIN_USER)

    def enable_root(self, context, root_password=None):
        """Create a superuser user or reset the superuser password.

        The default PostgreSQL administration account is 'postgres'.
        This account always exists and cannot be removed.
        Its attributes and access can however be altered.

        Clients can connect from the localhost or remotely via TCP/IP:

        Local clients (e.g. psql) can connect from a preset *system* account
        called 'postgres'.
        This system account has no password and is *locked* by default,
        so that it can be used by *local* users only.
        It should *never* be enabled (or its password set)!!!
        That would just open up a new attack vector on the system account.

        Remote clients should use a build-in *database* account of the same
        name. It's password can be changed using the "ALTER USER" statement.

        Access to this account is disabled by Trove exposed only once the
        superuser access is requested.
        Trove itself creates its own administrative account.

            {"_name": "postgres", "_password": "<secret>"}
        """
        user = self.build_root_user(root_password)
        self.build_admin().alter_user(
            context, user, None, *PgSqlAdmin.ADMIN_OPTIONS)
        return user.serialize()

    def build_root_user(self, password=None):
        return models.PostgreSQLUser.root(password=password)

    def pg_start_backup(self, backup_label):
        r = self.build_admin().query(
            "SELECT pg_start_backup('%s', true)" % backup_label)
        return r[0][0]

    def pg_xlogfile_name(self, start_segment):
        r = self.build_admin().query(
            "SELECT pg_xlogfile_name('%s')" % start_segment)
        return r[0][0]

    def pg_stop_backup(self):
        r = self.build_admin().query("SELECT pg_stop_backup()")
        return r[0][0]

    def disable_root(self, context):
        """Generate a new random password for the public superuser account.
        Do not disable its access rights. Once enabled the account should
        stay that way.
        """
        self.enable_root(context)

    def enable_root_with_password(self, context, root_password=None):
        return self.enable_root(context, root_password)

    @property
    def wal_archive_location(self):
        return cfg.get_configuration_property('wal_archive_location')

    @property
    def backup_strategy(self):
        return cfg.get_configuration_property('backup_strategy')

    def save_files_pre_upgrade(self, mount_point):
        LOG.debug('Saving files pre-upgrade.')
        mnt_etc_dir = os.path.join(mount_point, 'save_etc')
        if self.OS not in [operating_system.REDHAT, operating_system.ORACLE]:
            # No need to store the config files away for Redhat because
            # they are already stored in the data volume.
            operating_system.remove(mnt_etc_dir, force=True, as_root=True)
            operating_system.copy(self.pgsql_config_dir, mnt_etc_dir,
                                  preserve=True, recursive=True, as_root=True)
        return {'save_etc': mnt_etc_dir}

    def restore_files_post_upgrade(self, upgrade_info):
        LOG.debug('Restoring files post-upgrade.')
        if self.OS not in [operating_system.REDHAT, operating_system.ORACLE]:
            # No need to restore the config files for Redhat because
            # they are already in the data volume.
            operating_system.copy('%s/.' % upgrade_info['save_etc'],
                                  self.pgsql_config_dir,
                                  preserve=True, recursive=True,
                                  force=True, as_root=True)
            operating_system.remove(upgrade_info['save_etc'], force=True,
                                    as_root=True)
        self.configuration_manager.refresh_cache()
        self.status.set_ready()
开发者ID:Tesora,项目名称:tesora-trove,代码行数:104,代码来源:service.py


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