@@ -45,23 +45,23 @@ def stop(self, aws_tags: List[Dict]) -> None:
4545 """
4646 tag_key = aws_tags [0 ]["Key" ]
4747 tag_value = "" .join (aws_tags [0 ]["Values" ])
48- asg_list = self .list_groups (tag_key , tag_value )
49- instance_list = self .list_instances (asg_list )
48+ asg_name_list = self .list_groups (tag_key , tag_value )
49+ instance_id_list = self .list_instances (asg_name_list )
5050
51- for asg_name in asg_list :
51+ for asg_name in asg_name_list :
5252 try :
5353 self .asg .suspend_processes (AutoScalingGroupName = asg_name )
5454 print ("Suspend autoscaling group {0}" .format (asg_name ))
5555 except ClientError as exc :
5656 ec2_exception ("instance" , asg_name , exc )
5757
5858 # Stop autoscaling instance
59- for ec2_instance in instance_list :
59+ for instance_id in instance_id_list :
6060 try :
61- self .ec2 .stop_instances (InstanceIds = [ec2_instance ])
62- print ("Stop autoscaling instances {0}" .format (ec2_instance ))
61+ self .ec2 .stop_instances (InstanceIds = [instance_id ])
62+ print ("Stop autoscaling instances {0}" .format (instance_id ))
6363 except ClientError as exc :
64- ec2_exception ("autoscaling group" , ec2_instance , exc )
64+ ec2_exception ("autoscaling group" , instance_id , exc )
6565
6666 def start (self , aws_tags : List [Dict ]) -> None :
6767 """Aws autoscaling resume function.
@@ -83,23 +83,23 @@ def start(self, aws_tags: List[Dict]) -> None:
8383 """
8484 tag_key = aws_tags [0 ]["Key" ]
8585 tag_value = "" .join (aws_tags [0 ]["Values" ])
86- asg_list = self .list_groups (tag_key , tag_value )
87- instance_list = self .list_instances (asg_list )
86+ asg_name_list = self .list_groups (tag_key , tag_value )
87+ instance_id_list = self .list_instances (asg_name_list )
8888 instance_running_ids = []
8989
9090 # Start autoscaling instance
91- for ec2_instance in instance_list :
91+ for instance_id in instance_id_list :
9292 try :
93- self .ec2 .start_instances (InstanceIds = [ec2_instance ])
94- print ("Start autoscaling instances {0}" .format (ec2_instance ))
93+ self .ec2 .start_instances (InstanceIds = [instance_id ])
94+ print ("Start autoscaling instances {0}" .format (instance_id ))
9595 except ClientError as exc :
96- ec2_exception ("instance" , ec2_instance , exc )
96+ ec2_exception ("instance" , instance_id , exc )
9797 else :
98- instance_running_ids .append (ec2_instance )
98+ instance_running_ids .append (instance_id )
9999
100100 self .waiter .instance_running (instance_ids = instance_running_ids )
101101
102- for asg_name in asg_list :
102+ for asg_name in asg_name_list :
103103 try :
104104 self .asg .resume_processes (AutoScalingGroupName = asg_name )
105105 print ("Resume autoscaling group {0}" .format (asg_name ))
@@ -117,36 +117,36 @@ def list_groups(self, tag_key: str, tag_value: str) -> List[str]:
117117 :param str tag_value:
118118 Aws tag value to use for filter resources
119119
120- :return list asg_list :
120+ :return list asg_name_list :
121121 The names of the Auto Scaling groups
122122 """
123- asg_list = []
123+ asg_name_list = []
124124 paginator = self .asg .get_paginator ("describe_auto_scaling_groups" )
125125
126126 for page in paginator .paginate ():
127127 for group in page ["AutoScalingGroups" ]:
128128 for tag in group ["Tags" ]:
129129 if tag ["Key" ] == tag_key and tag ["Value" ] == tag_value :
130- asg_list .append (group ["AutoScalingGroupName" ])
131- return asg_list
130+ asg_name_list .append (group ["AutoScalingGroupName" ])
131+ return asg_name_list
132132
133- def list_instances (self , asg_list : List [str ]) -> Iterator [str ]:
133+ def list_instances (self , asg_name_list : List [str ]) -> Iterator [str ]:
134134 """Aws autoscaling instance list function.
135135
136136 List name of all instances in the autoscaling groups
137137 and return it in list.
138138
139- :param list asg_list :
139+ :param list asg_name_list :
140140 The names of the Auto Scaling groups.
141141
142142 :yield Iterator[str]:
143143 The names of the instances in Auto Scaling groups.
144144 """
145- if not asg_list :
145+ if not asg_name_list :
146146 return iter ([])
147147 paginator = self .asg .get_paginator ("describe_auto_scaling_groups" )
148148
149- for page in paginator .paginate (AutoScalingGroupNames = asg_list ):
149+ for page in paginator .paginate (AutoScalingGroupNames = asg_name_list ):
150150 for scalinggroup in page ["AutoScalingGroups" ]:
151151 for instance in scalinggroup ["Instances" ]:
152152 yield instance ["InstanceId" ]
0 commit comments