本文整理汇总了Python中paasta_tools.cli.utils.PaastaCheckMessages.smartstack_port_found方法的典型用法代码示例。如果您正苦于以下问题:Python PaastaCheckMessages.smartstack_port_found方法的具体用法?Python PaastaCheckMessages.smartstack_port_found怎么用?Python PaastaCheckMessages.smartstack_port_found使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paasta_tools.cli.utils.PaastaCheckMessages
的用法示例。
在下文中一共展示了PaastaCheckMessages.smartstack_port_found方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: smartstack_check
# 需要导入模块: from paasta_tools.cli.utils import PaastaCheckMessages [as 别名]
# 或者: from paasta_tools.cli.utils.PaastaCheckMessages import smartstack_port_found [as 别名]
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
示例2: test_check_smartstack_check_pass
# 需要导入模块: from paasta_tools.cli.utils import PaastaCheckMessages [as 别名]
# 或者: from paasta_tools.cli.utils.PaastaCheckMessages import smartstack_port_found [as 别名]
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