@@ -136,7 +136,7 @@ def delete_lc(autoscale, name):
136
136
print "Launch configuration %s deleted" % name
137
137
return list_lc (autoscale )
138
138
139
- def update_image (autoscale , name , lc_name , image_id , migrate_instances = False ):
139
+ def update_image (autoscale , name , lc_name , image_id , is_migrate_instances = False ):
140
140
""" Get the current launch config,
141
141
Update its name and image id
142
142
Re-create it as a new launch config
@@ -153,16 +153,17 @@ def update_image(autoscale, name, lc_name, image_id, migrate_instances=False):
153
153
g .launch_config_name = l .name
154
154
g .update ()
155
155
156
- if (migrate_instances ):
156
+ if (is_migrate_instances ):
157
157
migrate_instances (autoscale , name )
158
- return get (autoscale , name )
158
+ else :
159
+ return get (autoscale , name )
159
160
160
161
def migrate_instances (autoscale , name ):
161
162
""" Shut down instances of the old image type one by one
162
163
and let the ASG start up instances with the new image """
163
164
g = get_group (autoscale , name )
164
165
165
- old_instances = i .instances
166
+ old_instances = g .instances
166
167
ec2 = boto .connect_ec2 ()
167
168
for old_instance in old_instances :
168
169
print "Terminating instance " + old_instance .instance_id
@@ -176,16 +177,15 @@ def migrate_instances(autoscale, name):
176
177
if (old_instance .instance_id == new_instance .instance_id ):
177
178
hasOldInstance = True
178
179
print "Waiting for old instance to shut down..."
179
- time .sleep (20 )
180
180
break
181
181
elif (new_instance .lifecycle_state != 'InService' ):
182
182
instancesReady = False
183
183
print "Waiting for instances to be ready...."
184
- time .sleep (20 )
185
184
break
186
185
if (not hasOldInstance and instancesReady ):
187
- print "Still waiting for old instance to go away and new instance to be ready..."
188
- break
186
+ break
187
+ else :
188
+ time .sleep (20 )
189
189
return get (autoscale , name )
190
190
191
191
if __name__ == "__main__" :
0 commit comments