mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[hp|lb] Add HP provider models for Load Balancer along with tests.
This commit is contained in:
parent
b2536868fe
commit
cc25048e48
28 changed files with 301 additions and 158 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'] = [{
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
15
tests/hp/models/lb/algorithms_tests.rb
Normal file
15
tests/hp/models/lb/algorithms_tests.rb
Normal file
|
@ -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
|
9
tests/hp/models/lb/load_balancer_node_tests.rb
Normal file
9
tests/hp/models/lb/load_balancer_node_tests.rb
Normal file
|
@ -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
|
27
tests/hp/models/lb/load_balancer_nodes_tests.rb
Normal file
27
tests/hp/models/lb/load_balancer_nodes_tests.rb
Normal file
|
@ -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
|
6
tests/hp/models/lb/load_balancer_tests.rb
Normal file
6
tests/hp/models/lb/load_balancer_tests.rb
Normal file
|
@ -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
|
22
tests/hp/models/lb/load_balancer_virtual_ips_tests.rb
Normal file
22
tests/hp/models/lb/load_balancer_virtual_ips_tests.rb
Normal file
|
@ -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
|
22
tests/hp/models/lb/load_balancers_tests.rb
Normal file
22
tests/hp/models/lb/load_balancers_tests.rb
Normal file
|
@ -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
|
15
tests/hp/models/lb/protocols_tests.rb
Normal file
15
tests/hp/models/lb/protocols_tests.rb
Normal file
|
@ -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
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue