1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #1029 from frodenas/server_filters

[openstack|compute] Add filters to list servers details
This commit is contained in:
Wesley Beary 2012-07-09 08:12:23 -07:00
commit 2c100b9064
2 changed files with 13 additions and 4 deletions

View file

@ -7,10 +7,18 @@ module Fog
class Servers < Fog::Collection class Servers < Fog::Collection
attribute :filters
model Fog::Compute::OpenStack::Server model Fog::Compute::OpenStack::Server
def all def initialize(attributes)
data = connection.list_servers_detail.body['servers'] self.filters ||= {}
super
end
def all(filters = filters)
self.filters = filters
data = connection.list_servers_detail(filters).body['servers']
load(data) load(data)
end end

View file

@ -3,9 +3,10 @@ module Fog
class OpenStack class OpenStack
class Real class Real
def list_servers_detail(options = {}) # Available filters: name, status, image, flavor, changes_since, reservation_id
def list_servers_detail(filters = {})
params = Hash.new params = Hash.new
params['all_tenants'] = 'True' if options[:all_tenants] filters[:all_tenants] ? params['all_tenants'] = 'True' : params = filters
request( request(
:expects => [200, 203], :expects => [200, 203],