本文整理汇总了Python中disco_aws_automation.DiscoAWS.smoketest_once方法的典型用法代码示例。如果您正苦于以下问题:Python DiscoAWS.smoketest_once方法的具体用法?Python DiscoAWS.smoketest_once怎么用?Python DiscoAWS.smoketest_once使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类disco_aws_automation.DiscoAWS
的用法示例。
在下文中一共展示了DiscoAWS.smoketest_once方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import smoketest_once [as 别名]
#.........这里部分代码省略.........
line = u"{0} {1:<30} {2:<15}".format(
instance.id, instance.tags.get("hostclass", "-"),
instance.ip_address or instance_to_private_ip[instance.id])
if args.state or most:
line += u" {0:<10}".format(instance.state)
if args.hostname or most:
line += u" {0:<1}".format("-" if instance.tags.get("hostname") is None else "y")
if args.owner or most:
line += u" {0:<11}".format(instance.tags.get("owner", u"-"))
if args.instance_type or most:
line += u" {0:<10}".format(instance.instance_type)
if args.ami or most:
line += u" {0:<12}".format(instance.image_id)
if args.smoke or most:
line += u" {0:<1}".format("-" if instance.tags.get("smoketest") is None else "y")
if args.ami_age or most:
creation_time = bake.get_ami_creation_time(ami_dict.get(instance.id))
line += u" {0:<4}".format(DiscoBake.time_diff_in_hours(now, creation_time))
if args.uptime or most:
launch_time = dateutil_parser.parse(instance.launch_time)
now_with_tz = now.replace(tzinfo=launch_time.tzinfo) # use a timezone-aware `now`
line += u" {0:<3}".format(DiscoBake.time_diff_in_hours(now_with_tz, launch_time))
if args.private_ip or args.all:
line += u" {0:<16}".format(instance_to_private_ip[instance.id])
if args.availability_zone or args.all:
line += u" {0:<12}".format(instance.placement)
if args.productline or args.all:
productline = instance.tags.get("productline", u"unknown")
line += u" {0:<15}".format(productline if productline != u"unknown" else u"-")
if args.securitygroup or args.all:
line += u" {0:15}".format(instance.groups[0].name)
print(line)
elif args.mode == "terminate":
instances = instances_from_args(aws, args)
terminated_instances = aws.terminate(instances)
print("Terminated: {0}".format(",".join([str(inst) for inst in terminated_instances])))
elif args.mode == "stop":
instances = instances_from_args(aws, args)
stopped_instances = aws.stop(instances)
print("Stopped: {0}".format(",".join([str(inst) for inst in stopped_instances])))
elif args.mode == "exec":
instances = instances_from_args(aws, args)
exit_code = 0
for instance in instances:
_code, _stdout = aws.remotecmd(instance, [args.command], user=args.user, nothrow=True)
sys.stdout.write(_stdout)
exit_code = _code if _code else exit_code
sys.exit(exit_code)
elif args.mode == "exec-ssm":
ssm = DiscoSSM(environment_name)
if args.parameters:
parsed_parameters = parse_ssm_parameters(args.parameters)
else:
parsed_parameters = None
instances = [instance.id for instance in instances_from_args(aws, args)]
if ssm.execute(instances, args.document, parameters=parsed_parameters, comment=args.comment):
sys.exit(0)
else:
sys.exit(1)
elif args.mode == "isready":
instances = instances_from_args(aws, args)
if not instances:
print("No instances found")
ready_count = 0
for instance in instances:
name = "{0} {1}".format(instance.tags.get("hostname"), instance.id)
print("Checking {0}...".format(name))
try:
aws.smoketest_once(instance)
print("...{0} is ready".format(name))
ready_count += 1
except SmokeTestError:
print("..{0} failed smoke test".format(name))
except TimeoutError:
print("...{0} is NOT ready".format(name))
sys.exit(0 if ready_count == len(instances) else 1)
elif args.mode == "tag":
for instance in aws.instances(instance_ids=args.instances):
instance.remove_tag(args.key)
if args.value:
instance.add_tag(args.key, args.value)
elif args.mode == "spinup":
hostclass_dicts = read_pipeline_file(args.pipeline_definition_file)
aws.spinup(hostclass_dicts, stage=args.stage, no_smoke=args.no_smoke, testing=args.testing)
elif args.mode == "spindown":
hostclasses = [line["hostclass"] for line in read_pipeline_file(args.pipeline_definition_file)]
aws.spindown(hostclasses)
elif args.mode == "spindownandup":
hostclass_dicts = read_pipeline_file(args.pipeline_definition_file)
hostclasses = [d["hostclass"] for d in hostclass_dicts]
aws.spindown(hostclasses)
aws.spinup(hostclass_dicts)
elif args.mode == "gethostclassoption":
try:
print(aws.hostclass_option(args.hostclass, args.option))
except NoOptionError:
print("Hostclass %s doesn't have option %s." % (args.hostclass, args.option))
elif args.mode == "promoterunning":
aws.promote_running_instances_to_prod(args.hours * 60 * 60)
示例2: test_smoketest_all_good
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import smoketest_once [as 别名]
def test_smoketest_all_good(self, mock_config, **kwargs):
'''smoketest_once raises TimeoutError if instance is not tagged as smoketested'''
aws = DiscoAWS(config=mock_config, environment_name=TEST_ENV_NAME)
self.instance.tags.get = MagicMock(return_value="100")
self.assertTrue(aws.smoketest_once(self.instance))