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

make the updates for version and virtual ip

This commit is contained in:
howete 2013-05-22 08:03:55 -06:00 committed by Rupak Ganguly
parent 2eeb7055e0
commit d2c3cbeff7
7 changed files with 66 additions and 12 deletions

View file

@ -24,9 +24,9 @@ module Fog
model :protocol
collection :protocols
model :version
model :versions
collection :versions
model :virtual_ip
model :virtual_ips
collection :virtual_ips
request_path 'fog/hp/requests/lb'
request :create_load_balancer
@ -43,6 +43,7 @@ module Fog
request :list_load_balancers
request :list_protocols
request :list_versions
request :list_load_balancer_virtual_ips
request :update_load_balancer
request :update_load_balancer_node

View file

@ -7,9 +7,7 @@ module Fog
identity :id
attribute :status
attribute :updated_at, :alias => "updated"
end
end
end
end
end

View file

@ -8,7 +8,8 @@ module Fog
model Fog::HP::LB::Version
def all
data = service.list_versions.body['versions']
data = service.list_versions.body['version']
data = [data] unless data.kind_of? Array
load(data)
end

View file

@ -4,15 +4,13 @@ module Fog
module HP
class LB
class VirtualIp < Fog::Model
identity :id
attribute :address
attribute :ip_version, :alias => "ipVersion"
attribute :type
attribute :load_balancer_id
end
end
end
end
end

View file

@ -8,8 +8,9 @@ module Fog
model Fog::HP::LB::VirtualIp
def all
data = service.list_virtual_ips.body['virtual_ips']
data = service.list_load_balancer_virtual_ips(@attributes[:load_balancer_id]).body['virtualIps']
load(data)
self.each{ |x| x.load_balancer_id = @attributes[:load_balancer_id] }
end
def get(record_id)

View file

@ -0,0 +1,55 @@
module Fog
module HP
class LB
class Real
def list_load_balancer_virtual_ips(load_balancer_id)
response = request(
:expects => 200,
:method => 'GET',
:path => "loadbalancers/#{load_balancer_id}/virtualips"
)
response
end
end
class Mock
def list_load_balancer_virtual_ips(load_balancer_id)
response = Excon::Response.new
if lb = find_load_balancer(load_balancer_id)
response.status = 200
response.body = {
"virtualIps" => [
{
"id" => "1410",
"address" => "101.1.1.1",
"type" => "PUBLIC",
"ipVersion" => "IPV4"
},
{
"id" => "1236",
"address" => "101.1.1.2",
"type" => "PUBLIC",
"ipVersion" => "IPV4"
},
{
"id" => "2815",
"address" => "101.1.1.3",
"type" => "PUBLIC",
"ipVersion" => "IPV4"
},
]
}
else
raise Fog::HP::LB::NotFound
end
response
end
def find_load_balancer(record_id)
list_load_balancers.body['loadBalancers'].detect { |_| _['id'] == record_id }
end
end
end
end
end

View file

@ -28,4 +28,4 @@ module Fog
end
end
end
end
end