本文整理汇总了Python中paasta_tools.cli.utils.PaastaCheckMessages类的典型用法代码示例。如果您正苦于以下问题:Python PaastaCheckMessages类的具体用法?Python PaastaCheckMessages怎么用?Python PaastaCheckMessages使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PaastaCheckMessages类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: git_repo_check
def git_repo_check(service):
git_url = get_git_url(service)
cmd = 'git ls-remote %s' % git_url
returncode, _ = _run(cmd, timeout=5)
if returncode == 0:
print PaastaCheckMessages.GIT_REPO_FOUND
else:
print PaastaCheckMessages.git_repo_missing(git_url)
示例2: service_dir_check
def service_dir_check(service, soa_dir):
"""Check whether directory service exists in /nail/etc/services
:param service: string of service name we wish to inspect
"""
try:
validate_service_name(service, soa_dir)
print PaastaCheckMessages.service_dir_found(service, soa_dir)
except NoSuchService:
print PaastaCheckMessages.service_dir_missing(service, soa_dir)
示例3: sensu_check
def sensu_check(service, service_path, soa_dir):
"""Check whether monitoring.yaml exists in service directory,
and that the team name is declared.
:param service: name of service currently being examined
:param service_path: path to loction of monitoring.yaml file"""
if is_file_in_dir('monitoring.yaml', service_path):
print PaastaCheckMessages.SENSU_MONITORING_FOUND
team = get_team(service=service, overrides={}, soa_dir=soa_dir)
if team is None:
print PaastaCheckMessages.SENSU_TEAM_MISSING
else:
print PaastaCheckMessages.sensu_team_found(team)
else:
print PaastaCheckMessages.SENSU_MONITORING_MISSING
示例4: smartstack_check
def smartstack_check(service, service_path):
"""Check whether smartstack.yaml exists in service directory, and the proxy
ports are declared. Print appropriate message depending on outcome.
:param service: name of service currently being examined
:param service_path: path to loction of smartstack.yaml file"""
if is_file_in_dir('smartstack.yaml', service_path):
print PaastaCheckMessages.SMARTSTACK_YAML_FOUND
instances = get_all_namespaces_for_service(service)
if len(instances) > 0:
for namespace, config in get_all_namespaces_for_service(service, full_name=False):
if 'proxy_port' in config:
print PaastaCheckMessages.smartstack_port_found(
namespace, config.get('proxy_port'))
else:
print PaastaCheckMessages.SMARTSTACK_PORT_MISSING
else:
print PaastaCheckMessages.SMARTSTACK_PORT_MISSING
示例5: test_check_service_dir_check_pass
def test_check_service_dir_check_pass(mock_stdout, mock_validate_service_name):
mock_validate_service_name.return_value = None
service = 'fake_service'
expected_output = \
"%s\n" % PaastaCheckMessages.service_dir_found(service)
service_dir_check(service)
output = mock_stdout.getvalue()
assert output == expected_output
示例6: test_check_service_dir_check_fail
def test_check_service_dir_check_fail(mock_stdout, mock_validate_service_name):
service = 'fake_service'
mock_validate_service_name.side_effect = NoSuchService(service)
expected_output = "%s\n" \
% PaastaCheckMessages.service_dir_missing(service)
service_dir_check(service)
output = mock_stdout.getvalue()
assert output == expected_output
示例7: test_check_sensu_check_pass
def test_check_sensu_check_pass(mock_stdout, mock_get_team,
mock_is_file_in_dir):
# monitoring.yaml exists and team is found
mock_is_file_in_dir.return_value = "/fake/path"
team = 'team-service-infra'
mock_get_team.return_value = team
expected_output = "%s\n%s\n" % (PaastaCheckMessages.SENSU_MONITORING_FOUND,
PaastaCheckMessages.sensu_team_found(team))
sensu_check('fake_service', 'path')
output = mock_stdout.getvalue()
assert output == expected_output
mock_get_team.assert_called_once_with(service='fake_service', overrides={})
示例8: test_check_smartstack_check_pass
def test_check_smartstack_check_pass(mock_stdout, mock_is_file_in_dir,
mock_read_service_info):
# smartstack.yaml exists and port is found
mock_is_file_in_dir.return_value = True
port = 80
instance = 'main'
smartstack_dict = {
'smartstack': {
instance: {
'proxy_port': port
}
}
}
mock_read_service_info.return_value = smartstack_dict
expected_output = "%s\n%s\n" \
% (PaastaCheckMessages.SMARTSTACK_YAML_FOUND,
PaastaCheckMessages.smartstack_port_found(
instance, port))
smartstack_check('fake_service', 'path')
output = mock_stdout.getvalue()
assert output == expected_output