mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add implementation for #list_images_detail service.
This commit is contained in:
parent
f455ce4c62
commit
4a93105f6c
1 changed files with 49 additions and 0 deletions
49
lib/fog/compute/requests/hp/list_images_detail.rb
Normal file
49
lib/fog/compute/requests/hp/list_images_detail.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
module Fog
|
||||
module HP
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
# List all images
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'id'<~Integer> - Id of the image
|
||||
# * 'name'<~String> - Name of the image
|
||||
# * 'updated'<~String> - Last update timestamp for image
|
||||
# * 'created'<~String> - Creation timestamp for image
|
||||
# * 'status'<~String> - Status of image
|
||||
def list_images_detail
|
||||
request(
|
||||
:expects => [200, 203],
|
||||
:method => 'GET',
|
||||
:path => 'images/detail.json'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def list_images_detail
|
||||
response = Excon::Response.new
|
||||
|
||||
images = self.data[:images].values
|
||||
for image in images
|
||||
case image['status']
|
||||
when 'SAVING'
|
||||
if Time.now - self.data[:last_modified][:images][image['id']] >= Fog::Mock.delay
|
||||
image['status'] = 'ACTIVE'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
response.status = [200, 203][rand(1)]
|
||||
response.body = { 'images' => images.map {|image| image.reject {|key, value| !['id', 'name', 'status', 'updated'].include?(key)}} }
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue