mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Support filters in images collection
This commit is contained in:
parent
c716044ed3
commit
e662dbddcd
2 changed files with 13 additions and 4 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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue