mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
You only need either the size or the snapshot_id.
This commit is contained in:
parent
59fc86a57c
commit
4acd979a9e
2 changed files with 25 additions and 2 deletions
|
@ -39,11 +39,18 @@ module Fog
|
|||
|
||||
def create_volume(availability_zone, size, snapshot_id = nil)
|
||||
response = Excon::Response.new
|
||||
if availability_zone && size
|
||||
if snapshot_id && !self.data[:snapshots][snapshot_id]
|
||||
if availability_zone && (size || snapshot_id)
|
||||
snapshot = self.data[:snapshots][snapshot_id]
|
||||
if snapshot_id && !snapshot
|
||||
raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' does not exist.")
|
||||
end
|
||||
|
||||
if snapshot && size && size != snapshot['volumeSize']
|
||||
raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' with the specified size of '#{size}' does not exist.")
|
||||
elsif snapshot && !size
|
||||
size = snapshot['volumeSize']
|
||||
end
|
||||
|
||||
response.status = 200
|
||||
volume_id = Fog::AWS::Mock.volume_id
|
||||
data = {
|
||||
|
|
|
@ -46,6 +46,22 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
|||
data
|
||||
end
|
||||
|
||||
tests('#create_volume from snapshot').formats(@volume_format) do
|
||||
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1)
|
||||
snapshot = Fog::Compute[:aws].create_snapshot(volume.identity).body
|
||||
data = Fog::Compute[:aws].create_volume(@server.availability_zone, nil, snapshot['snapshotId']).body
|
||||
@volume_id = data['volumeId']
|
||||
data
|
||||
end
|
||||
|
||||
tests('#create_volume from snapshot with size').formats(@volume_format) do
|
||||
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1)
|
||||
snapshot = Fog::Compute[:aws].create_snapshot(volume.identity).body
|
||||
data = Fog::Compute[:aws].create_volume(@server.availability_zone, 1, snapshot['snapshotId']).body
|
||||
@volume_id = data['volumeId']
|
||||
data
|
||||
end
|
||||
|
||||
Fog::Compute[:aws].volumes.get(@volume_id).wait_for { ready? }
|
||||
|
||||
tests('#describe_volumes').formats(@volumes_format) do
|
||||
|
|
Loading…
Add table
Reference in a new issue