Permalink
Browse files

use auto unregister to destroy server

  • Loading branch information...
lirazsiri committed Aug 3, 2011
1 parent 3747053 commit 3e775559e0ea9329d1cad471f3d8bb67e07a95b4
Showing with 2 additions and 27 deletions.
  1. +2 −27 cloudtask/_hub.py
View
@@ -73,32 +73,7 @@ def destroy(self, *addresses):
for server in retry(hub.servers.get, refresh_cache=True)
if server.ipaddress in addresses ]
- addresses = dict([ (server.instanceid, server.ipaddress)
- for server in destroyable ])
-
for server in destroyable:
- retry(server.destroy)
-
- destroyable_ids = set([ server.instanceid for server in destroyable ])
-
- time.sleep(self.wait_first)
-
- addresses_destroyed = []
- while True:
- servers = [ server
- for server in retry(hub.servers.get, refresh_cache=True)
- if server.instanceid in destroyable_ids ]
-
- done = True
- for server in servers:
- if server.status == 'terminated':
- retry(server.unregister)
- addresses_destroyed.append(addresses[server.instanceid])
-
- else:
- done = False
+ retry(server.destroy, auto_unregister=True)
- if done:
- return addresses_destroyed
- else:
- time.sleep(self.wait_status)
+ return [ server.ipaddress for server in destroyable ]

0 comments on commit 3e77555

Please sign in to comment.