Skip to content

Commit 2d67ec2

Browse files
author
Joel Barciauskas
committed
Fixes to update-image and migrate-instances
1 parent fd1da12 commit 2d67ec2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

bin/asadmin

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def delete_lc(autoscale, name):
136136
print "Launch configuration %s deleted" % name
137137
return list_lc(autoscale)
138138

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):
140140
""" Get the current launch config,
141141
Update its name and image id
142142
Re-create it as a new launch config
@@ -153,16 +153,17 @@ def update_image(autoscale, name, lc_name, image_id, migrate_instances=False):
153153
g.launch_config_name = l.name
154154
g.update()
155155

156-
if(migrate_instances):
156+
if(is_migrate_instances):
157157
migrate_instances(autoscale, name)
158-
return get(autoscale, name)
158+
else:
159+
return get(autoscale, name)
159160

160161
def migrate_instances(autoscale, name):
161162
""" Shut down instances of the old image type one by one
162163
and let the ASG start up instances with the new image """
163164
g = get_group(autoscale, name)
164165

165-
old_instances = i.instances
166+
old_instances = g.instances
166167
ec2 = boto.connect_ec2()
167168
for old_instance in old_instances:
168169
print "Terminating instance " + old_instance.instance_id
@@ -176,16 +177,15 @@ def migrate_instances(autoscale, name):
176177
if(old_instance.instance_id == new_instance.instance_id):
177178
hasOldInstance = True
178179
print "Waiting for old instance to shut down..."
179-
time.sleep(20)
180180
break
181181
elif(new_instance.lifecycle_state != 'InService'):
182182
instancesReady = False
183183
print "Waiting for instances to be ready...."
184-
time.sleep(20)
185184
break
186185
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)
189189
return get(autoscale, name)
190190

191191
if __name__ == "__main__":

0 commit comments

Comments
 (0)