diff --git a/lib/fog/hp/dns.rb b/lib/fog/hp/dns.rb index ba265bda5..4368c5c37 100644 --- a/lib/fog/hp/dns.rb +++ b/lib/fog/hp/dns.rb @@ -107,13 +107,14 @@ module Fog def request(params, parse_json = true, &block) begin response = @connection.request(params.merge!({ - :headers => { - 'Content-Type' => 'application/json', - 'X-Auth-Token' => @auth_token - }.merge!(params[:headers] || {}), - :host => @host, - :path => "#{@path}/#{params[:path]}", - }), &block) + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'X-Auth-Token' => @auth_token + }.merge!(params[:headers] || {}), + :host => @host, + :path => "#{@path}/#{params[:path]}", + }), &block) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound diff --git a/lib/fog/hp/lb.rb b/lib/fog/hp/lb.rb index 922f91aec..584866c39 100644 --- a/lib/fog/hp/lb.rb +++ b/lib/fog/hp/lb.rb @@ -14,16 +14,12 @@ module Fog model_path 'fog/hp/models/lb' model :algorithm collection :algorithms - model :limit - collection :limits model :load_balancer collection :load_balancers model :node collection :nodes model :protocol collection :protocols - model :version - collection :versions model :virtual_ip collection :virtual_ips @@ -148,6 +144,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/hp/models/lb/algorithm.rb b/lib/fog/hp/models/lb/algorithm.rb index ca8b49065..c7ba60fea 100644 --- a/lib/fog/hp/models/lb/algorithm.rb +++ b/lib/fog/hp/models/lb/algorithm.rb @@ -5,6 +5,19 @@ module Fog class LB class Algorithm < Fog::Model identity :name + + def destroy + raise Fog::HP::LB::NotFound.new('Operation not allowed.') + end + + def create(params) + raise Fog::HP::LB::NotFound.new('Operation not allowed.') + end + + def save + raise Fog::HP::LB::NotFound.new('Operation not allowed.') + end + end end end diff --git a/lib/fog/hp/models/lb/algorithms.rb b/lib/fog/hp/models/lb/algorithms.rb index f0821215e..6a97a2c18 100644 --- a/lib/fog/hp/models/lb/algorithms.rb +++ b/lib/fog/hp/models/lb/algorithms.rb @@ -12,9 +12,10 @@ module Fog load(data) end - def get(record_id) - record = service.get_algorithm_details(record_id).body['algorithm'] - new(record) + def get(name) + data = service.list_algorithms.body['algorithms'] + algorithm = data.detect {|algo| algo['name'] == name} + new(algorithm) rescue Fog::HP::LB::NotFound nil end diff --git a/lib/fog/hp/models/lb/limit.rb b/lib/fog/hp/models/lb/limit.rb deleted file mode 100644 index 1469ae6a7..000000000 --- a/lib/fog/hp/models/lb/limit.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'fog/core/model' - -module Fog - module HP - class LB - class Limit < Fog::Model - - identity :id - attribute :max_load_balancer_name_length, :aliases => 'maxLoadBalancerNameLength' - attribute :max_load_balancers, :aliases => 'maxLoadBalancers' - attribute :max_nodes_per_load_balancer, :aliases => 'maxNodesPerLoadBalancer' - attribute :max_vips_per_load_balancer, :aliases => 'maxVIPsPerLoadBalancer' - - end - end - end -end \ No newline at end of file diff --git a/lib/fog/hp/models/lb/limits.rb b/lib/fog/hp/models/lb/limits.rb deleted file mode 100644 index bf26d76f9..000000000 --- a/lib/fog/hp/models/lb/limits.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'fog/core/collection' -require 'fog/hp/models/lb/limit' - -module Fog - module HP - class LB - class Limits < Fog::Collection - model Fog::HP::LB::Limit - - #{ - # "limits" : { - # "absolute" : { - # "values" : { - # "maxLoadBalancerNameLength" : 128, - # "maxLoadBalancers" : 20, - # "maxNodesPerLoadBalancer" : 5, - # "maxVIPsPerLoadBalancer" : 1 - #} - #} - #} - #} - def all - data = service.list_limits.body['limits']['absolute']['values'] - load([data]) - end - end - end - end -end diff --git a/lib/fog/hp/models/lb/load_balancer.rb b/lib/fog/hp/models/lb/load_balancer.rb index efc02cf1c..cc641415c 100644 --- a/lib/fog/hp/models/lb/load_balancer.rb +++ b/lib/fog/hp/models/lb/load_balancer.rb @@ -5,15 +5,18 @@ module Fog class LB class LoadBalancer < Fog::Model - identity :id + identity :id + attribute :name attribute :protocol attribute :port attribute :algorithm attribute :status + attribute :status_description, :aliases => 'statusDescription' attribute :nodes - attribute :virtualIps - attribute :created_at, :aliases => 'created' + attribute :virtual_ips, :aliases => 'virtualIps' + attribute :node_count, :aliases => 'nodeCount' + attribute :created_at, :aliases => 'created' attribute :updated_at , :aliases => 'updated' def destroy @@ -30,19 +33,50 @@ module Fog identity ? update : create end + def nodes + @nodes ||= begin + Fog::HP::LB::Nodes.new({ + :service => service, + :load_balancer => self + }) + end + end + + def nodes=(new_nodes=[]) + nodes.load(new_nodes) + end + private def create - merge_attributes(service.create_load_balancer(name, nodes, attributes).body) + requires :name, :nodes + + options = {} + options['virtualIps'] = virtual_ips if virtual_ips + options['port'] = port if port + options['protocol'] = protocol if protocol + options['algorithm'] = algorithm if algorithm + merge_attributes(service.create_load_balancer(name, nodes_to_hash, options).body) true end def update requires :id - merge_attributes(service.update_load_balancer(id, attributes).body) + + options = {} + options['name'] = name if name + options['algorithm'] = algorithm if algorithm + service.update_load_balancer(id, options).body true end + def nodes_to_hash + if nodes + nodes.collect do |node| + { 'address' => node.address, 'port' => node.port, 'condition' => node.condition } + end + end + end end end end diff --git a/lib/fog/hp/models/lb/load_balancers.rb b/lib/fog/hp/models/lb/load_balancers.rb index 5ed8d7456..490e1e825 100644 --- a/lib/fog/hp/models/lb/load_balancers.rb +++ b/lib/fog/hp/models/lb/load_balancers.rb @@ -12,9 +12,10 @@ module Fog load(data) end - def get(record_id) - record = service.get_load_balancer_details(record_id).body['load_balancer'] - new(record) + def get(lb_id) + ### Inconsistent API - does not return a 'loadBalancer' + lb = service.get_load_balancer(lb_id).body + new(lb) rescue Fog::HP::LB::NotFound nil end diff --git a/lib/fog/hp/models/lb/node.rb b/lib/fog/hp/models/lb/node.rb index 46dff502b..a6d480061 100644 --- a/lib/fog/hp/models/lb/node.rb +++ b/lib/fog/hp/models/lb/node.rb @@ -5,22 +5,21 @@ module Fog class LB class Node < Fog::Model - identity :id + identity :id + attribute :address attribute :port attribute :condition attribute :status - attribute :load_balancer_id def destroy - requires :id - requires :load_balancer_id - service.delete_load_balancer_node(load_balancer_id, id) + requires :id, :load_balancer + service.delete_load_balancer_node(load_balancer.id, id) true end def ready? - self.status == 'ACTIVE' + self.status == 'ONLINE' end def save @@ -29,16 +28,22 @@ module Fog private + def load_balancer + collection.load_balancer + end + def create - requires :load_balancer_id - merge_attributes(service.create_load_balancer_node(load_balancer_id, {'nodes' => [attributes]}).body) + requires :load_balancer, :address, :port + options = {} + options['condition'] = condition if condition + data = service.create_load_balancer_node(load_balancer.id, address, port, options) + merge_attributes(data.body['nodes'][0]) true end def update - requires :id - requires :load_balancer_id - service.update_load_balancer_node(load_balancer_id, id, attributes[:condition]) + requires :id, :load_balancer, :condition + service.update_load_balancer_node(load_balancer.id, id, condition) true end diff --git a/lib/fog/hp/models/lb/nodes.rb b/lib/fog/hp/models/lb/nodes.rb index c56a87c18..443e83aa4 100644 --- a/lib/fog/hp/models/lb/nodes.rb +++ b/lib/fog/hp/models/lb/nodes.rb @@ -5,17 +5,21 @@ module Fog module HP class LB class Nodes < Fog::Collection + model Fog::HP::LB::Node + attr_accessor :load_balancer + def all - data = service.list_load_balancer_nodes(@attributes[:load_balancer_id]).body['nodes'] + requires :load_balancer + data = service.list_load_balancer_nodes(load_balancer.id).body['nodes'] load(data) - self.each{ |x| x.load_balancer_id = @attributes[:load_balancer_id] } end - def get(record_id) - record = service.get_load_balancer_node(@attributes[:load_balancer_id], record_id).body['node'] - new(record) + def get(node_id) + requires :load_balancer + node = service.get_load_balancer_node(load_balancer.id, node_id).body + new(node) rescue Fog::HP::LB::NotFound nil end diff --git a/lib/fog/hp/models/lb/protocol.rb b/lib/fog/hp/models/lb/protocol.rb index 6cb3584f3..2ff0bdb21 100644 --- a/lib/fog/hp/models/lb/protocol.rb +++ b/lib/fog/hp/models/lb/protocol.rb @@ -6,6 +6,19 @@ module Fog class Protocol < Fog::Model identity :name attribute :port + + def destroy + raise Fog::HP::LB::NotFound.new('Operation not allowed.') + end + + def create(params) + raise Fog::HP::LB::NotFound.new('Operation not allowed.') + end + + def save + raise Fog::HP::LB::NotFound.new('Operation not allowed.') + end + end end end diff --git a/lib/fog/hp/models/lb/protocols.rb b/lib/fog/hp/models/lb/protocols.rb index bdea3a986..dbb94a348 100644 --- a/lib/fog/hp/models/lb/protocols.rb +++ b/lib/fog/hp/models/lb/protocols.rb @@ -12,9 +12,10 @@ module Fog load(data) end - def get(record_id) - record = service.get_protocol_details(record_id).body['protocol'] - new(record) + def get(name) + data = service.list_protocols.body['protocols'] + protocol = data.detect {|p| p['name'] == name} + new(protocol) rescue Fog::HP::LB::NotFound nil end diff --git a/lib/fog/hp/models/lb/version.rb b/lib/fog/hp/models/lb/version.rb deleted file mode 100644 index a90434372..000000000 --- a/lib/fog/hp/models/lb/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'fog/core/model' - -module Fog - module HP - class LB - class Version < Fog::Model - identity :id - attribute :status - attribute :updated - end - end - end -end diff --git a/lib/fog/hp/models/lb/versions.rb b/lib/fog/hp/models/lb/versions.rb deleted file mode 100644 index bd4522786..000000000 --- a/lib/fog/hp/models/lb/versions.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'fog/core/collection' -require 'fog/hp/models/lb/version' - -module Fog - module HP - class LB - class Versions < Fog::Collection - model Fog::HP::LB::Version - - def all - data = service.list_versions.body['versions'] - data = [data] unless data.kind_of? Array - load(data) - end - - def get(record_id) - record = service.get_versions(record_id).body['versions'] - new(record) - rescue Fog::HP::LB::NotFound - nil - end - - end - end - end -end diff --git a/lib/fog/hp/models/lb/virtual_ip.rb b/lib/fog/hp/models/lb/virtual_ip.rb index 8a228aeca..f52b1a9a1 100644 --- a/lib/fog/hp/models/lb/virtual_ip.rb +++ b/lib/fog/hp/models/lb/virtual_ip.rb @@ -7,9 +7,27 @@ module Fog identity :id attribute :address - attribute :ip_version, :alias => "ipVersion" + attribute :ip_version, :alias => 'ipVersion' attribute :type - attribute :load_balancer_id + + def destroy + raise Fog::HP::LB::NotFound.new('Operation not allowed.') + end + + def create(params) + raise Fog::HP::LB::NotFound.new('Operation not allowed.') + end + + def save + raise Fog::HP::LB::NotFound.new('Operation not allowed.') + end + + private + + def load_balancer + collection.load_balancer + end + end end end diff --git a/lib/fog/hp/models/lb/virtual_ips.rb b/lib/fog/hp/models/lb/virtual_ips.rb index cf03fde86..95d84e31d 100644 --- a/lib/fog/hp/models/lb/virtual_ips.rb +++ b/lib/fog/hp/models/lb/virtual_ips.rb @@ -5,17 +5,24 @@ module Fog module HP class LB class VirtualIps < Fog::Collection + model Fog::HP::LB::VirtualIp + attr_accessor :load_balancer + def all - data = service.list_load_balancer_virtual_ips(@attributes[:load_balancer_id]).body['virtualIps'] + requires :load_balancer + + data = service.list_load_balancer_virtual_ips(load_balancer.id).body['virtualIps'] load(data) - self.each{ |x| x.load_balancer_id = @attributes[:load_balancer_id] } end - def get(record_id) - record = service.get_virtual_ip_details(record_id).body['virtual_ip'] - new(record) + def get(vip_id) + requires :load_balancer + + data = service.list_load_balancer_virtual_ips(load_balancer.id).body['virtualIps'] + vip = data.detect {|vip| vip['id'].to_s == vip_id} + new(vip) rescue Fog::HP::LB::NotFound nil end diff --git a/lib/fog/hp/requests/lb/create_load_balancer.rb b/lib/fog/hp/requests/lb/create_load_balancer.rb index 439a09b3b..1743a442c 100644 --- a/lib/fog/hp/requests/lb/create_load_balancer.rb +++ b/lib/fog/hp/requests/lb/create_load_balancer.rb @@ -13,6 +13,11 @@ module Fog # * 'port'<~String> - Port for the load balancer, defaults to '80' # * 'protocol'<~String> - Protocol for the load balancer, defaults to 'HTTP' # * 'algorithm'<~String> - Algorithm for the load balancer, defaults to 'ROUND_ROBIN' + # * 'virtualIps'<~ArrayOfHash> - Virtual IPs for the load balancer + # * 'id'<~String> - UUId for the virtual IP + # * 'address'<~String> - Address for the virtual IP + # * 'type'<~String> - Type for the virtual IP + # * 'ipVersion'<~String> - IP Version for the virtual IP # # ==== Returns # * response<~Excon::Response>: @@ -28,6 +33,11 @@ module Fog # * 'nodes'<~ArrayOfHash> - Nodes for the load balancer # * 'address'<~String> - Address for the node # * 'port'<~String> - Port for the node + # * 'virtualIps'<~ArrayOfHash> - Virtual IPs for the load balancer + # * 'id'<~String> - UUId for the virtual IP + # * 'address'<~String> - Address for the virtual IP + # * 'type'<~String> - Type for the virtual IP + # * 'ipVersion'<~String> - IP Version for the virtual IP class Real def create_load_balancer(name, nodes, options={}) ### Inconsistent behavior. Should be passing in as a 'loadbalancer' => {'name', 'nodes'} @@ -79,7 +89,7 @@ module Fog 'updated' => '2012-01-01T13:32:20Z', 'nodes' => nodes } - if options['virtualIps'] + if (!options['virtualIps'].nil? && !options['virtualIps'].empty?) data['virtualIps'] = options['virtualIps'] else data['virtualIps'] = [{ diff --git a/lib/fog/hp/requests/lb/create_load_balancer_node.rb b/lib/fog/hp/requests/lb/create_load_balancer_node.rb index 2db80b133..316c4c778 100644 --- a/lib/fog/hp/requests/lb/create_load_balancer_node.rb +++ b/lib/fog/hp/requests/lb/create_load_balancer_node.rb @@ -6,10 +6,10 @@ module Fog # # ==== Parameters # * 'load_balancer_id'<~String> - UUId of load balancer to create node for - # * 'nodes'<~ArrayOfHash> - Nodes for the load balancer - # * 'address'<~String> - Address for the node - # * 'port'<~String> - Port for the node + # * 'address'<~String> - Address for the node + # * 'port'<~String> - Port for the node # * options<~Hash>: + # * 'condition'<~String> - Condition for the node. Valid values are ['ENABLED', 'DISABLED'] # # ==== Returns # * response<~Excon::Response>: @@ -18,14 +18,23 @@ module Fog # * 'id'<~String> - UUID of the node # * 'address'<~String> - Address for the node # * 'port'<~String> - Port for the node - # * 'condition'<~String> - Condition for the node + # * 'condition'<~String> - Condition for the node. Valid values are ['ENABLED', 'DISABLED'] # * 'status'<~String> - Status for the node class Real - def create_load_balancer_node(load_balancer_id, nodes, options={}) + def create_load_balancer_node(load_balancer_id, address, port, options={}) data = { - 'nodes' => nodes + 'nodes' => [ + { + 'address' => address, + 'port' => port + } + ] } - response = request( + if options['condition'] + data['nodes'][0]['condition'] = options['condition'] + end + + request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', @@ -35,17 +44,16 @@ module Fog end end class Mock - def create_load_balancer_node(load_balancer_id, nodes, options={}) - ### Call: {"nodes" => [{"address" => "15.185.1.1", "port" => "80"}]} + def create_load_balancer_node(load_balancer_id, address, port, options={}) response = Excon::Response.new if get_load_balancer(load_balancer_id) response.status = 202 data = { 'id' => Fog::HP::Mock.uuid.to_s, - 'address' => nodes[0]['address'], - 'port' => nodes[0]['port'], - 'condition' => 'ENABLED', + 'address' => address, + 'port' => port, + 'condition' => options['condition'] || 'ENABLED', 'status' => 'ONLINE' } diff --git a/lib/fog/hp/requests/lb/get_load_balancer_node.rb b/lib/fog/hp/requests/lb/get_load_balancer_node.rb index 8ec498f29..d207a31b3 100644 --- a/lib/fog/hp/requests/lb/get_load_balancer_node.rb +++ b/lib/fog/hp/requests/lb/get_load_balancer_node.rb @@ -45,7 +45,7 @@ module Fog def find_node(load_balancer_id, node_id) nodes = list_load_balancer_nodes(load_balancer_id).body['nodes'] - nodes.select {|n| n['id'] == node_id} + nodes.detect {|n| n['id'] == node_id} end end diff --git a/tests/hp/models/lb/algorithms_tests.rb b/tests/hp/models/lb/algorithms_tests.rb new file mode 100644 index 000000000..f5e32ba18 --- /dev/null +++ b/tests/hp/models/lb/algorithms_tests.rb @@ -0,0 +1,15 @@ +Shindo.tests('HP::LB | algorithms collection', ['hp', 'lb', 'algorithms']) do + + tests('success') do + + tests('#all').succeeds do + HP[:lb].algorithms + end + + tests('#get("ROUND_ROBIN")').succeeds do + HP[:lb].algorithms.get("ROUND_ROBIN") + end + + end + +end \ No newline at end of file diff --git a/tests/hp/models/lb/load_balancer_node_tests.rb b/tests/hp/models/lb/load_balancer_node_tests.rb new file mode 100644 index 000000000..704423dad --- /dev/null +++ b/tests/hp/models/lb/load_balancer_node_tests.rb @@ -0,0 +1,9 @@ +Shindo.tests('HP::LB | load balancer node model', ['hp', 'lb', 'node']) do + + attributes = {:name => 'fog-lb', :nodes => [{'address' => '15.185.1.1', 'port' => '80'}]} + @lb = HP[:lb].load_balancers.create(attributes) + + attributes = {:address => '15.185.1.1', :port => '80'} + model_tests(@lb.nodes, attributes, true) + +end \ No newline at end of file diff --git a/tests/hp/models/lb/load_balancer_nodes_tests.rb b/tests/hp/models/lb/load_balancer_nodes_tests.rb new file mode 100644 index 000000000..46f8f60af --- /dev/null +++ b/tests/hp/models/lb/load_balancer_nodes_tests.rb @@ -0,0 +1,27 @@ +Shindo.tests('HP::LB | load balancer nodes collection', ['hp', 'lb', 'node']) do + + attributes = {:name => 'fog-lb', :nodes => [{'address' => '15.185.1.1', 'port' => '80'}]} + @lb = HP[:lb].load_balancers.create(attributes) + + attributes = {:address => '15.185.1.1', :port => '80'} + collection_tests(@lb.nodes, attributes, true) + + tests('success') do + + attributes = {:address => '15.185.1.1', :port => '80'} + @node = @lb.nodes.create(attributes) + + tests('#all').succeeds do + @lb.nodes.all + end + + tests("#get(#{@node.id})").succeeds do + @lb.nodes.get(@node.id) + end + + @node.destroy + end + + @lb.destroy + +end \ No newline at end of file diff --git a/tests/hp/models/lb/load_balancer_tests.rb b/tests/hp/models/lb/load_balancer_tests.rb new file mode 100644 index 000000000..b24161b11 --- /dev/null +++ b/tests/hp/models/lb/load_balancer_tests.rb @@ -0,0 +1,6 @@ +Shindo.tests('HP::LB | load balancer model', ['hp', 'lb', 'load_balancer']) do + + attributes = {:name => 'fog-lb', :nodes => [{'address' => '15.185.1.1', 'port' => '80'}]} + model_tests(HP[:lb].load_balancers, attributes, true) + +end \ No newline at end of file diff --git a/tests/hp/models/lb/load_balancer_virtual_ips_tests.rb b/tests/hp/models/lb/load_balancer_virtual_ips_tests.rb new file mode 100644 index 000000000..f1d0d5847 --- /dev/null +++ b/tests/hp/models/lb/load_balancer_virtual_ips_tests.rb @@ -0,0 +1,22 @@ +Shindo.tests('HP::LB | load balancer virtual ips collection', ['hp', 'lb', 'virtual_ip']) do + + attributes = {:name => 'fog-lb', :nodes => [{'address' => '15.185.1.1', 'port' => '80'}]} + @lb = HP[:lb].load_balancers.create(attributes) + + tests('success') do + + @vip = HP[:lb].virtual_ips(:load_balancer => @lb).all.first + + tests('#all').succeeds do + HP[:lb].virtual_ips(:load_balancer => @lb).all + end + + tests("#get(#{@vip.id})").succeeds do + HP[:lb].virtual_ips(:load_balancer => @lb).get(@vip.id) + end + + end + + @lb.destroy + +end \ No newline at end of file diff --git a/tests/hp/models/lb/load_balancers_tests.rb b/tests/hp/models/lb/load_balancers_tests.rb new file mode 100644 index 000000000..ee53622ed --- /dev/null +++ b/tests/hp/models/lb/load_balancers_tests.rb @@ -0,0 +1,22 @@ +Shindo.tests('HP::LB | load balancer collection', ['hp', 'lb', 'load_balancer']) do + + attributes = {:name => 'fog-lb', :nodes => [{'address' => '15.185.1.1', 'port' => '80'}]} + collection_tests(HP[:lb].load_balancers, attributes, true) + + tests('success') do + + attributes = {:name => 'fog-lb', :nodes => [{'address' => '15.185.1.1', 'port' => '80'}]} + @lb = HP[:lb].load_balancers.create(attributes) + + tests('#all').succeeds do + HP[:lb].load_balancers.all + end + + tests("#get(#{@lb.id})").succeeds do + HP[:lb].load_balancers.get(@lb.id) + end + + @lb.destroy + end + +end \ No newline at end of file diff --git a/tests/hp/models/lb/protocols_tests.rb b/tests/hp/models/lb/protocols_tests.rb new file mode 100644 index 000000000..13035c862 --- /dev/null +++ b/tests/hp/models/lb/protocols_tests.rb @@ -0,0 +1,15 @@ +Shindo.tests('HP::LB | protocol collection', ['hp', 'lb', 'protocol']) do + + tests('success') do + + tests('#all').succeeds do + HP[:lb].protocols + end + + tests('#get("HTTP")').succeeds do + HP[:lb].protocols.get('HTTP') + end + + end + +end \ No newline at end of file diff --git a/tests/hp/requests/lb/load_balancer_nodes_tests.rb b/tests/hp/requests/lb/load_balancer_nodes_tests.rb index a7da7d10c..b7efd473e 100644 --- a/tests/hp/requests/lb/load_balancer_nodes_tests.rb +++ b/tests/hp/requests/lb/load_balancer_nodes_tests.rb @@ -1,4 +1,4 @@ -Shindo.tests("HP::LB | load balancer nodes", ['hp', 'lb', 'nodes']) do +Shindo.tests('HP::LB | load balancer nodes', ['hp', 'lb', 'nodes']) do @node_format = { 'id' => String, 'address' => String, @@ -7,14 +7,13 @@ Shindo.tests("HP::LB | load balancer nodes", ['hp', 'lb', 'nodes']) do 'status' => String } - tests('success') do - @nodes = [{'address' => '15.185.2.2', 'port' => '88'}] + tests('successs') do data = HP[:lb].create_load_balancer('rg-fog-lb2', [{'address' => '15.185.1.1', 'port' => '80'}]).body @lb_id = data['id'] - tests("#create_load_balancer_node(#{@lb_id}, #{@nodes})").formats({'nodes' => [@node_format]}) do - data = HP[:lb].create_load_balancer_node(@lb_id, @nodes).body - @lb_node_id = data['id'] + tests("#create_load_balancer_node(#{@lb_id}, '15.185.2.2', '88')").formats({'nodes' => [@node_format]}) do + data = HP[:lb].create_load_balancer_node(@lb_id, '15.185.2.2', '88').body + @lb_node_id = data['nodes'][0]['id'] data end @@ -22,13 +21,13 @@ Shindo.tests("HP::LB | load balancer nodes", ['hp', 'lb', 'nodes']) do HP[:lb].list_load_balancer_nodes(@lb_id).body end - tests("#get_load_balancer_node(#{@lb_id}, #{@lb_node_id})").formats([@node_format]) do + tests("#get_load_balancer_node(#{@lb_id}, #{@lb_node_id})").formats(@node_format) do HP[:lb].get_load_balancer_node(@lb_id, @lb_node_id).body end - #tests("#update_load_balancer_node(#{@lb_id}, #{@lb_node_id}, 'DISABLED')").succeeds do - # HP[:lb].update_load_balancer_node(@lb_id, @lb_node_id, 'DISABLED') - #end + tests("#update_load_balancer_node(#{@lb_id}, #{@lb_node_id}, 'DISABLED')").succeeds do + HP[:lb].update_load_balancer_node(@lb_id, @lb_node_id, 'DISABLED') + end tests("#delete_load_balancer_node(#{@lb_id}, #{@lb_node_id})").succeeds do HP[:lb].delete_load_balancer_node(@lb_id, @lb_node_id) diff --git a/tests/hp/requests/lb/load_balancer_tests.rb b/tests/hp/requests/lb/load_balancer_tests.rb index 74d8c0567..8e1aec9b6 100644 --- a/tests/hp/requests/lb/load_balancer_tests.rb +++ b/tests/hp/requests/lb/load_balancer_tests.rb @@ -1,4 +1,4 @@ -Shindo.tests("HP::LB | load balancers requests", ['hp', 'lb', 'load_balancers']) do +Shindo.tests("HP::LB | load balancers requests", ['hp', 'lb', 'load_balancer']) do @lb_format = { 'id' => String, 'name' => String,