mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
updated save method in Fog::Rackspace::BlockStorage::Volume and Fog::Rackspace::BlockStorage::Snapshot to skip creating cloud reources if identity was already set Fixes #1402
This commit is contained in:
parent
c2d8fffc37
commit
1efffe5d85
4 changed files with 32 additions and 17 deletions
|
@ -26,6 +26,7 @@ module Fog
|
|||
|
||||
def save(force = false)
|
||||
requires :volume_id
|
||||
return true if identity
|
||||
data = connection.create_snapshot(volume_id, {
|
||||
:display_name => display_name,
|
||||
:display_description => display_description,
|
||||
|
|
|
@ -37,6 +37,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :size
|
||||
return true if identity
|
||||
data = connection.create_volume(size, {
|
||||
:display_name => display_name,
|
||||
:display_description => display_description,
|
||||
|
|
|
@ -3,6 +3,7 @@ Shindo.tests('Fog::Rackspace::BlockStorage | snapshot', ['rackspace']) do
|
|||
pending if Fog.mocking?
|
||||
|
||||
service = Fog::Rackspace::BlockStorage.new
|
||||
begin
|
||||
volume = service.volumes.create({
|
||||
:display_name => "fog_#{Time.now.to_i.to_s}",
|
||||
:size => 100
|
||||
|
@ -13,8 +14,14 @@ Shindo.tests('Fog::Rackspace::BlockStorage | snapshot', ['rackspace']) do
|
|||
options = { :display_name => "fog_#{Time.now.to_i.to_s}", :volume_id => volume.id }
|
||||
model_tests(service.snapshots, options, false) do
|
||||
@instance.wait_for { ready? }
|
||||
|
||||
tests('double save').returns(true) do
|
||||
@instance.save
|
||||
end
|
||||
end
|
||||
|
||||
volume.wait_for { snapshots.empty? }
|
||||
volume.destroy
|
||||
ensure
|
||||
volume.destroy if volume
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,11 @@ Shindo.tests('Fog::Rackspace::BlockStorage | volume', ['rackspace']) do
|
|||
options = { :display_name => "fog_#{Time.now.to_i.to_s}", :size => 100 }
|
||||
|
||||
model_tests(service.volumes, options, false) do
|
||||
@instance.wait_for { ready? }
|
||||
@instance.wait_for(timeout=1200) { ready? }
|
||||
|
||||
tests('double save').returns(true) do
|
||||
@instance.save
|
||||
end
|
||||
|
||||
tests('#attached?').succeeds do
|
||||
@instance.state = 'in-use'
|
||||
|
@ -14,12 +18,14 @@ Shindo.tests('Fog::Rackspace::BlockStorage | volume', ['rackspace']) do
|
|||
end
|
||||
|
||||
tests('#snapshots').succeeds do
|
||||
begin
|
||||
snapshot = service.snapshots.create({ :volume_id => @instance.id })
|
||||
snapshot.wait_for { ready? }
|
||||
snapshot.wait_for(timeout = 1200) { ready? }
|
||||
|
||||
returns(true) { @instance.snapshots.first.id == snapshot.id }
|
||||
|
||||
snapshot.destroy
|
||||
ensure
|
||||
snapshot.destroy if snapshot
|
||||
end
|
||||
end
|
||||
|
||||
@instance.wait_for { snapshots.empty? }
|
||||
|
|
Loading…
Add table
Reference in a new issue