mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add a get_snapshot_details request method, a corresponding mock, and add support for it in the block storage provider.
This commit is contained in:
parent
553648727e
commit
2ce3f962c7
2 changed files with 55 additions and 0 deletions
|
@ -20,6 +20,7 @@ module Fog
|
||||||
|
|
||||||
request :create_snapshot
|
request :create_snapshot
|
||||||
request :list_snapshots
|
request :list_snapshots
|
||||||
|
request :get_snapshot_details
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
|
|
||||||
|
|
54
lib/fog/hp/requests/block_storage/get_snapshot_details.rb
Normal file
54
lib/fog/hp/requests/block_storage/get_snapshot_details.rb
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
module Fog
|
||||||
|
module BlockStorage
|
||||||
|
class HP
|
||||||
|
class Real
|
||||||
|
|
||||||
|
# Get details for existing block storage snapshot
|
||||||
|
#
|
||||||
|
# ==== Parameters
|
||||||
|
# * snapshot_id<~Integer> - Id of the snapshot to get
|
||||||
|
#
|
||||||
|
# ==== Returns
|
||||||
|
# * response<~Excon::Response>:
|
||||||
|
# * body<~Hash>:
|
||||||
|
# * snapshot<~Hash>:
|
||||||
|
# * 'id'<~Integer>: - Id for the snapshot
|
||||||
|
# * 'displayName'<~String>: - Name of the snapshot
|
||||||
|
# * 'displayDescription'<~String>: - Description of the snapshot
|
||||||
|
# * 'size'<~Integer>: - Size in GB for the snapshot
|
||||||
|
# * 'status'<~String>: - Status of the snapshot i.e. "available"
|
||||||
|
# * 'volumeId'<~Integer>: - Id of the volume from which the snapshot was created
|
||||||
|
# * 'createdAt'<~String>: - Timestamp in UTC when volume was created
|
||||||
|
|
||||||
|
def get_snapshot_details(snapshot_id)
|
||||||
|
response = request(
|
||||||
|
:expects => 200,
|
||||||
|
:method => 'GET',
|
||||||
|
:path => "os-snapshots/#{snapshot_id}"
|
||||||
|
)
|
||||||
|
response
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock # :nodoc:all
|
||||||
|
|
||||||
|
def get_snapshot_details(snapshot_id)
|
||||||
|
unless snapshot_id
|
||||||
|
raise ArgumentError.new('snapshot_id is required')
|
||||||
|
end
|
||||||
|
response = Excon::Response.new
|
||||||
|
if snapshot = self.data[:snapshots][snapshot_id]
|
||||||
|
response.status = 200
|
||||||
|
response.body = { 'snapshot' => snapshot }
|
||||||
|
response
|
||||||
|
else
|
||||||
|
raise Fog::BlockStorage::HP::NotFound
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue