mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #1843 from cloudbau/image_filters
Support filters in images collection
This commit is contained in:
commit
a2e2f1cc61
2 changed files with 14 additions and 5 deletions
|
@ -7,12 +7,20 @@ module Fog
|
|||
|
||||
class Images < Fog::Collection
|
||||
|
||||
attribute :filters
|
||||
|
||||
model Fog::Compute::OpenStack::Image
|
||||
|
||||
attribute :server
|
||||
|
||||
def all
|
||||
data = service.list_images_detail.body['images']
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = service.list_images_detail(filters).body['images']
|
||||
images = load(data)
|
||||
if server
|
||||
self.replace(self.select {|image| image.server_id == server.id})
|
||||
|
|
|
@ -3,11 +3,12 @@ module Fog
|
|||
class OpenStack
|
||||
class Real
|
||||
|
||||
def list_images_detail
|
||||
def list_images_detail(filters = {})
|
||||
request(
|
||||
:expects => [200, 203],
|
||||
:method => 'GET',
|
||||
:path => 'images/detail.json'
|
||||
:path => 'images/detail.json',
|
||||
:query => filters
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -15,7 +16,7 @@ module Fog
|
|||
|
||||
class Mock
|
||||
|
||||
def list_images_detail
|
||||
def list_images_detail(filters = {})
|
||||
response = Excon::Response.new
|
||||
|
||||
images = self.data[:images].values
|
||||
|
|
Loading…
Add table
Reference in a new issue