2011-07-18 22:45:47 -04:00
|
|
|
require 'fog/core/collection'
|
2011-08-04 17:21:22 -04:00
|
|
|
require 'fog/rackspace/models/load_balancers/virtual_ip'
|
2011-07-18 22:45:47 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Rackspace
|
2011-08-04 17:21:22 -04:00
|
|
|
class LoadBalancers
|
2011-07-18 22:45:47 -04:00
|
|
|
class VirtualIps < Fog::Collection
|
2011-08-04 17:21:22 -04:00
|
|
|
model Fog::Rackspace::LoadBalancers::VirtualIp
|
2011-07-18 22:45:47 -04:00
|
|
|
|
|
|
|
attr_accessor :load_balancer
|
|
|
|
|
|
|
|
def all
|
|
|
|
data = all_raw
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
#HACK - This method is somewhat hacky since there isn't a way to retrieve a single virtual IP. Hopefully long term a method will
|
|
|
|
# be added that allows a single virtual IP to be returned
|
|
|
|
def get(virtual_ip_id)
|
|
|
|
data = all_raw.select { |virtual_ip| virtual_ip['id'] == virtual_ip_id }.first
|
|
|
|
data && new(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def all_raw
|
2011-07-28 14:37:21 -04:00
|
|
|
requires :load_balancer
|
2012-12-22 18:24:03 -05:00
|
|
|
service.list_virtual_ips(load_balancer.id).body['virtualIps']
|
2011-07-18 22:45:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|