diff --git a/lib/fog/rackspace/models/block_storage/volume.rb b/lib/fog/rackspace/models/block_storage/volume.rb index 61dbf3aff..4d3a6abc8 100644 --- a/lib/fog/rackspace/models/block_storage/volume.rb +++ b/lib/fog/rackspace/models/block_storage/volume.rb @@ -34,6 +34,11 @@ module Fog def snapshots connection.snapshots.select { |s| s.volume_id == identity } end + + def create_snapshot(options={}) + requires :identity + connection.snapshots.create(options.merge(:volume_id => identity)) + end def save requires :size diff --git a/tests/rackspace/models/block_storage/volume_tests.rb b/tests/rackspace/models/block_storage/volume_tests.rb index f39ca4812..327a3387b 100644 --- a/tests/rackspace/models/block_storage/volume_tests.rb +++ b/tests/rackspace/models/block_storage/volume_tests.rb @@ -14,12 +14,14 @@ Shindo.tests('Fog::Rackspace::BlockStorage | volume', ['rackspace']) do end tests('#snapshots').succeeds do - snapshot = service.snapshots.create({ :volume_id => @instance.id }) - snapshot.wait_for { ready? } + begin + snapshot = @instance.create_snapshot + snapshot.wait_for(timeout=1200) { ready? } - returns(true) { @instance.snapshots.first.id == snapshot.id } - - snapshot.destroy + returns(true) { @instance.snapshots.first.id == snapshot.id } + ensure + snapshot.destroy + end end @instance.wait_for { snapshots.empty? }