Commit cb316f51 authored by Nazrul Kamaruddin's avatar Nazrul Kamaruddin

Cleaned up and abstracted routine into generic functions.

parent 6d7e6634
......@@ -72,7 +72,6 @@ class ASG():
logging.error("No EC2 instances found.")
return new_asg
logging.error("Please specify a target group.")
......@@ -94,7 +93,6 @@ class ASG():
new_color = None
a = name.split('-')
color = a[-1]
# Determine the "new" auto scaling group name
if color == 'blue':
new_color = 'green'
......@@ -152,15 +150,6 @@ class ASG():"Saving to file: {}".format(filename))
return open(filename, "w").write("{}\n".format(output))
def instance_state(self, instance):
ec2_client = aws_client.create_client('ec2', self.region, self.role_arn)
instance_states = ec2_client.describe_instance_status(IncludeAllInstances=True, InstanceIds=[instance])
while 'InstanceStatuses' not in instance_states:
instance_states = ec2_client.describe_instance_status(InstanceIds=[instance])
return instance_states['InstanceStatuses'][0]['InstanceState']['Name']
def get_lt_name(self, asg):
asg_client = aws_client.create_client('autoscaling', self.region, self.role_arn)
lt_info = asg_client.describe_auto_scaling_groups(AutoScalingGroupNames=[asg])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment