Skip to content

Commit

Permalink
added support for creating volumes from snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
natea committed Mar 3, 2010
1 parent 17d584b commit 6266363
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion mr/awsome/__init__.py
Expand Up @@ -63,6 +63,15 @@ def massage_instance_volumes(self, value):
volumes.append((volume[0], volume[1]))
return tuple(volumes)

def massage_instance_snapshots(self, value):
snapshots = []
for line in value.split('\n'):
snapshot = line.split()
if not len(snapshot):
continue
snapshots.append((snapshot[0], int(snapshot[1]), snapshot[2], snapshot[3]))
return tuple(snapshots)

def massage_securitygroup_connections(self, value):
connections = []
for line in value.split('\n'):
Expand Down Expand Up @@ -296,7 +305,16 @@ def start(self, overrides={}):
if volume.attachment_state() == 'attached':
continue
log.info("Attaching storage (%s on %s)" % (volume_id, device))
self.conn.attach_volume(volume_id, instance.id, device)
self.conn.attach_volume(volume_id, instance.id, device)

for snapshot_id, size, zone, device in self.config.get('snapshots', []):
log.info("Creating volume from snapshot: %s" % snapshot_id)
volume = self.conn.create_volume(size, zone, snapshot_id)
if volume.attachment_state() == 'attached':
continue
log.info("Attaching storage (%s on %s)" % (volume.id, device))
self.conn.attach_volume(volume.id, instance.id, device)

return instance

def init_ssh_key(self, user=None):
Expand Down

0 comments on commit 6266363

Please sign in to comment.