2011-07-14 15:20:53 -04:00
|
|
|
require 'fog/core/collection'
|
2011-08-04 17:21:22 -04:00
|
|
|
require 'fog/rackspace/models/load_balancers/node'
|
2011-07-14 15:20:53 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Rackspace
|
2011-08-04 17:21:22 -04:00
|
|
|
class LoadBalancers
|
2011-07-14 15:20:53 -04:00
|
|
|
class Nodes < Fog::Collection
|
2011-08-04 17:21:22 -04:00
|
|
|
model Fog::Rackspace::LoadBalancers::Node
|
2011-07-14 15:20:53 -04:00
|
|
|
|
|
|
|
attr_accessor :load_balancer
|
|
|
|
|
|
|
|
def all
|
2011-07-28 14:37:21 -04:00
|
|
|
requires :load_balancer
|
2011-07-14 15:20:53 -04:00
|
|
|
data = connection.list_nodes(load_balancer.id).body['nodes']
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(node_id)
|
2011-07-28 14:37:21 -04:00
|
|
|
requires :load_balancer
|
2011-07-14 15:20:53 -04:00
|
|
|
if node = connection.get_node(load_balancer.id, node_id).body['node']
|
|
|
|
new(node)
|
|
|
|
end
|
2011-08-04 17:21:22 -04:00
|
|
|
rescue Fog::Rackspace::LoadBalancers::NotFound
|
2011-07-14 15:20:53 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|