mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[hp|block_storage_v2] Add details to the volumes and snapshots collection. Add new helper methods for corresponding statuses. Add collection tests for volumes and snapshots.
This commit is contained in:
parent
d1d4d9eca9
commit
ee796dfa2f
5 changed files with 37 additions and 5 deletions
|
@ -17,8 +17,13 @@ module Fog
|
|||
end
|
||||
|
||||
def all(filters = filters)
|
||||
details = filters.delete(:details)
|
||||
self.filters = filters
|
||||
data = service.list_snapshots(filters).body['snapshots']
|
||||
if details
|
||||
data = service.list_snapshots_detail(filters).body['snapshots']
|
||||
else
|
||||
data = service.list_snapshots(filters).body['snapshots']
|
||||
end
|
||||
load(data)
|
||||
end
|
||||
|
||||
|
|
|
@ -22,19 +22,18 @@ module Fog
|
|||
attribute :bootable
|
||||
attribute :image_metadata, :aliases => 'volume_image_metadata'
|
||||
|
||||
#attr_reader :server_id
|
||||
#attr_reader :device
|
||||
|
||||
def initialize(attributes = {})
|
||||
# assign these attributes first to prevent race condition with new_record?
|
||||
self.image_id = attributes.delete(:image_id)
|
||||
super
|
||||
end
|
||||
|
||||
# a volume can be attached to only one server at a time
|
||||
def device
|
||||
attachments[0]['device'] if has_attachments?
|
||||
end
|
||||
|
||||
# a volume can be attached to only one server at a time
|
||||
def server_id
|
||||
attachments[0]['serverId'] if has_attachments?
|
||||
end
|
||||
|
@ -58,6 +57,14 @@ module Fog
|
|||
end
|
||||
alias :attached? :in_use?
|
||||
|
||||
def backing_up?
|
||||
self.status == 'backing-up'
|
||||
end
|
||||
|
||||
def restoring?
|
||||
self.status == 'restoring-backup'
|
||||
end
|
||||
|
||||
def ready?
|
||||
self.status == 'available'
|
||||
end
|
||||
|
|
|
@ -17,8 +17,13 @@ module Fog
|
|||
end
|
||||
|
||||
def all(filters = filters)
|
||||
details = filters.delete(:details)
|
||||
self.filters = filters
|
||||
data = service.list_volumes(filters).body['volumes']
|
||||
if details
|
||||
data = service.list_volumes_detail(filters).body['volumes']
|
||||
else
|
||||
data = service.list_volumes(filters).body['volumes']
|
||||
end
|
||||
load(data)
|
||||
end
|
||||
|
||||
|
|
10
tests/hp/models/block_storage_v2/snapshots_tests.rb
Normal file
10
tests/hp/models/block_storage_v2/snapshots_tests.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
Shindo.tests("HP::BlockStorageV2 | snapshots collection", ['hp', 'v2', 'block_storage', 'snapshots']) do
|
||||
|
||||
@volume = HP[:block_storage_v2].volumes.create(:name => 'testsnap2vol', :size => 1)
|
||||
@volume.wait_for { ready? } unless Fog.mocking?
|
||||
|
||||
collection_tests(HP[:block_storage_v2].snapshots, {:name => 'fogsnap2tests', :description => 'fogsnaptests-desc', :volume_id => @volume.id}, true)
|
||||
|
||||
@volume.destroy
|
||||
|
||||
end
|
5
tests/hp/models/block_storage_v2/volumes_tests.rb
Normal file
5
tests/hp/models/block_storage_v2/volumes_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests("HP::BlockStorage | volumes collection", ['hp', 'v2', 'block_storage', 'volumes']) do
|
||||
|
||||
collection_tests(HP[:block_storage_v2].volumes, {:name => 'fogvol2tests', :description => 'fogvol2tests-desc', :size => 1}, true)
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue