1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/hp/requests/lb/create_load_balancer.rb

43 lines
1.1 KiB
Ruby

module Fog
module HP
class LB
class Real
def create_load_balancer(name, nodes, options={})
data = {
"name" => name,
"nodes" => nodes
}
options = Hash[options.map{ |k, v| [k.to_s, v] }]
data['port'] = options['port'] if options['port']
data['protocol'] = options['protocol'] if options['protocol']
data['algorithm'] = options['algorithm'] if options['algorithm']
unless options['virtualIps'].nil?
unless options['virtualIps'].empty?
data['virtualIps'] = []
for vip in options['virtualIps']
data['virtualIps'] << vip
end
end
end
response = request(
:body => Fog::JSON.encode(data),
:expects => 202,
:method => 'POST',
:path => "loadbalancers"
)
response
end
end
class Mock
def create_load_balancer(name, nodes, options={})
response = Excon::Response.new
response
end
end
end
end
end