本文整理汇总了Python中barman.config.Config.get_server方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get_server方法的具体用法?Python Config.get_server怎么用?Python Config.get_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类barman.config.Config
的用法示例。
在下文中一共展示了Config.get_server方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_config
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import get_server [as 别名]
def test_config(self):
fp = StringIO(TEST_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
expected = dict(config=c)
expected.update(TEST_CONFIG_MAIN)
assert main.__dict__ == expected
web = c.get_server('web')
expected = dict(config=c)
expected.update(TEST_CONFIG_WEB)
assert web.__dict__ == expected
示例2: test_config
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import get_server [as 别名]
def test_config(self):
"""
Test for a basic configuration object construction
"""
fp = StringIO(TEST_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({
'config': main.config,
'compression': 'gzip',
'last_backup_maximum_age': timedelta(1),
'last_backup_minimum_size': 1048576,
'last_wal_maximum_age': timedelta(hours=1),
'retention_policy': 'redundancy 3',
'reuse_backup': 'link',
'description': 'Main PostgreSQL Database',
'ssh_command': 'ssh -c arcfour -p 22 [email protected]',
'wal_retention_policy': 'base',
'custom_compression_filter': 'bzip2 -c -9',
'wals_directory': 'wals',
'custom_decompression_filter': 'bzip2 -c -d'
})
assert main.__dict__ == expected
web = c.get_server('web')
# create the expected dictionary
expected = build_config_dictionary({
'config': web.config,
'backup_directory': '/some/barman/home/web',
'basebackups_directory': '/some/barman/home/web/base',
'compression': None,
'conninfo': 'host=web01 user=postgres port=5432',
'description': 'Web applications database',
'incoming_wals_directory': '/some/barman/home/web/incoming',
'name': 'web',
'reuse_backup': None,
'retention_policy': 'redundancy 2',
'wals_directory': '/some/barman/home/web/wals',
'wal_retention_policy': 'base',
'last_backup_maximum_age': timedelta(1),
'last_backup_minimum_size': 1048576,
'last_wal_maximum_age': timedelta(hours=1),
'ssh_command': 'ssh -I ~/.ssh/web01_rsa -c arcfour '
'-p 22 [email protected]',
'streaming_conninfo': 'host=web01 user=postgres port=5432',
'streaming_wals_directory': '/some/barman/home/web/streaming',
'errors_directory': '/some/barman/home/web/errors',
})
assert web.__dict__ == expected
示例3: test_interpolation
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import get_server [as 别名]
def test_interpolation(self):
fp = StringIO(MINIMAL_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
expected = dict(config=c)
expected.update(MINIMAL_CONFIG_MAIN)
assert main.__dict__ == expected
示例4: test_interpolation
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import get_server [as 别名]
def test_interpolation(self):
self.maxDiff = None
fp = StringIO(MINIMAL_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
expected = dict(config=c)
expected.update(MINIMAL_CONFIG_MAIN)
self.assertEqual(main.__dict__,expected)
示例5: test_interpolation
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import get_server [as 别名]
def test_interpolation(self):
self.maxDiff = None
fp = StringIO(MINIMAL_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
self.assertEqual(main.__dict__,
dict(MINIMAL_CONFIG_MAIN.items() +
[('config',c)]))
示例6: test_quotes
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import get_server [as 别名]
def test_quotes(self):
"""
Test quotes management during configuration parsing
"""
fp = StringIO(MINIMAL_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
assert main.description == ' Text with quotes '
assert main.ssh_command == 'ssh -c "arcfour" ' \
'-p 22 [email protected]'
示例7: test_interpolation
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import get_server [as 别名]
def test_interpolation(self):
"""
Basic interpolation test
"""
fp = StringIO(MINIMAL_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({'config': main.config})
assert main.__dict__ == expected
示例8: main
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import get_server [as 别名]
def main():
parser = argparse.ArgumentParser(description="Barman plugin for NRPE.")
parser.add_argument("-s", "--server", dest="server",
help="server to check")
parser.add_argument('-w', '--warning', type=int, dest="warning",
metavar="W", help="warning threshold.")
parser.add_argument('-c', '--critical', type=int, dest="critical",
metavar="C", help="critical threshold.")
parser.add_argument('-u' '--user', dest='user', metavar='U',
help="user needed to run this script. If the "
"current user is not this one, the script will try " +
"to rerun itself using sudo.")
subparsers = parser.add_subparsers()
for key, value in ACTIONS.items():
(action, help) = value
subparser = subparsers.add_parser(key, help=help)
subparser.set_defaults(action=action)
parser.error = unknown
args = parser.parse_args()
user = pwd.getpwuid(os.getuid())[0]
if args.user and user != args.user:
import subprocess
retval = subprocess.call(["/usr/bin/sudo", "-u", args.user] + sys.argv)
raise SystemExit(retval)
from barman.config import Config
from barman.server import Server
config = Config()
config.load_configuration_files_directory()
server = Server(config.get_server(args.server))
try:
args.action(server, args)
except KeyError:
unknown("The action %s does not exist." % args.action)
示例9: test_quotes
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import get_server [as 别名]
def test_quotes(self):
fp = StringIO(MINIMAL_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
assert main.description == ' Text with quotes '
assert main.ssh_command == 'ssh -c "arcfour" -p 22 [email protected]'