lib/rubber/cloud/aws.rb in axtro-rubber-1.0.2.6 vs lib/rubber/cloud/aws.rb in axtro-rubber-1.0.2.7
- old
+ new
@@ -163,11 +163,16 @@
def destroy_static_ip(ip)
response = @ec2.release_address(:public_ip => ip)
return response.return == "true"
end
- def create_volume(size, zone, snapshot_id = nil)
- response = @ec2.create_volume(:size => size.to_s, :availability_zone => zone, :snapshot_id => snapshot_id)
+ def create_volume(size, zone, base_volume_id = nil)
+ snapshot = {}
+ if base_volume_id
+ base_snapshots = @ec2.describe_snapshots["snapshotSet"]["item"].select{|s|s["volumeId"] == base_volume_id}
+ snapshot = base_snapshots.sort{|a,b| b["startTime"] <=> a["startTime"]}.first
+ end
+ response = @ec2.create_volume(:size => size.to_s, :availability_zone => zone, :snapshot_id => snapshot["snapshotId"])
return response.volumeId
end
def attach_volume(volume_id, instance_id, device)
response = @ec2.attach_volume(:volume_id => volume_id, :instance_id => instance_id, :device => device)