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


Python ConfigurationManager.has_system_override方法代码示例

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


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

示例1: PgSqlApp

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

#.........这里部分代码省略.........
        #
        # Make the rules readable only by the Postgres service.
        #
        # NOTE: The order of entries is important.
        # The first failure to authenticate stops the lookup.
        # That is why the 'local' connections validate first.
        # The OrderedDict is necessary to guarantee the iteration order.
        local_admins = ','.join([self.default_superuser_name, self.ADMIN_USER])
        remote_admins = self.ADMIN_USER
        access_rules = OrderedDict(
            [('local', [['all', local_admins, None, 'trust'],
                        ['replication', local_admins, None, 'trust'],
                        ['all', 'all', None, 'md5']]),
             ('host', [['all', local_admins, '127.0.0.1/32', 'trust'],
                       ['all', local_admins, '::1/128', 'trust'],
                       ['all', local_admins, 'localhost', 'trust'],
                       ['all', remote_admins, '0.0.0.0/0', 'reject'],
                       ['all', remote_admins, '::/0', 'reject'],
                       ['all', 'all', '0.0.0.0/0', 'md5'],
                       ['all', 'all', '::/0', 'md5']])
             ])
        operating_system.write_file(self.pgsql_hba_config, access_rules,
                                    PropertiesCodec(
                                        string_mappings={'\t': None}),
                                    as_root=True)
        operating_system.chown(self.pgsql_hba_config,
                               self.pgsql_owner, self.pgsql_owner,
                               as_root=True)
        operating_system.chmod(self.pgsql_hba_config, FileMode.SET_USR_RO,
                               as_root=True)

    def disable_backups(self):
        """Reverse overrides applied by PgBaseBackup strategy"""
        if not self.configuration_manager.has_system_override(
                BACKUP_CFG_OVERRIDE):
            return
        LOG.info("Removing configuration changes for backups")
        self.configuration_manager.remove_system_override(BACKUP_CFG_OVERRIDE)
        self.remove_wal_archive_dir()
        self.restart()

    def enable_backups(self):
        """Apply necessary changes to config to enable WAL-based backups
        if we are using the PgBaseBackup strategy
        """
        LOG.info("Checking if we need to apply changes to WAL config")
        if 'PgBaseBackup' not in self.backup_strategy:
            return
        if self.configuration_manager.has_system_override(BACKUP_CFG_OVERRIDE):
            return

        LOG.info("Applying changes to WAL config for use by base backups")
        arch_cmd = "'test ! -f {wal_arch}/%f && cp %p {wal_arch}/%f'".format(
            wal_arch=self.wal_archive_location
        )
        opts = {
            # FIXME(atomic77) These spaces after the options are needed until
            # DBAAS-949 is fixed
            'wal_level ': 'hot_standby',
            'archive_mode ': 'on',
            'max_wal_senders': 8,
            # 'checkpoint_segments ': 8,
            'wal_keep_segments': 8,
            'archive_command': arch_cmd
        }
        if self.pg_version[1] in ('9.4', '9.5'):
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:70,代码来源:service.py


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