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
|
class Images < Fog::Collection
|
||||||
|
|
||||||
|
attribute :filters
|
||||||
|
|
||||||
model Fog::Compute::OpenStack::Image
|
model Fog::Compute::OpenStack::Image
|
||||||
|
|
||||||
attribute :server
|
attribute :server
|
||||||
|
|
||||||
def all
|
def initialize(attributes)
|
||||||
data = service.list_images_detail.body['images']
|
self.filters ||= {}
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def all(filters = filters)
|
||||||
|
self.filters = filters
|
||||||
|
data = service.list_images_detail(filters).body['images']
|
||||||
images = load(data)
|
images = load(data)
|
||||||
if server
|
if server
|
||||||
self.replace(self.select {|image| image.server_id == server.id})
|
self.replace(self.select {|image| image.server_id == server.id})
|
||||||
|
|
|
@ -3,11 +3,12 @@ module Fog
|
||||||
class OpenStack
|
class OpenStack
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def list_images_detail
|
def list_images_detail(filters = {})
|
||||||
request(
|
request(
|
||||||
:expects => [200, 203],
|
:expects => [200, 203],
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:path => 'images/detail.json'
|
:path => 'images/detail.json',
|
||||||
|
:query => filters
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ module Fog
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
|
|
||||||
def list_images_detail
|
def list_images_detail(filters = {})
|
||||||
response = Excon::Response.new
|
response = Excon::Response.new
|
||||||
|
|
||||||
images = self.data[:images].values
|
images = self.data[:images].values
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue