mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #1139 from ninefold/ninefold
Ninefold - added all load balancer commands for Ninefold
This commit is contained in:
commit
7599b703f3
10 changed files with 212 additions and 0 deletions
|
@ -60,6 +60,14 @@ module Fog
|
||||||
request :create_ip_forwarding_rule
|
request :create_ip_forwarding_rule
|
||||||
request :delete_ip_forwarding_rule
|
request :delete_ip_forwarding_rule
|
||||||
request :list_ip_forwarding_rules
|
request :list_ip_forwarding_rules
|
||||||
|
# Load Balancers
|
||||||
|
request :create_load_balancer_rule
|
||||||
|
request :delete_load_balancer_rule
|
||||||
|
request :remove_from_load_balancer_rule
|
||||||
|
request :assign_to_load_balancer_rule
|
||||||
|
request :list_load_balancer_rules
|
||||||
|
request :list_load_balancer_rule_instances
|
||||||
|
request :update_load_balancer_rule
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ninefold
|
||||||
|
class Real
|
||||||
|
def assign_to_load_balancer_rule(options={})
|
||||||
|
request 'assignToLoadBalancerRule', options, :expects => [200], :response_prefix => 'assigntoloadbalancerruleresponse', :response_type => Hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ninefold
|
||||||
|
class Real
|
||||||
|
def create_load_balancer_rule(options={})
|
||||||
|
request 'createLoadBalancerRule', options, :expects => [200], :response_prefix => 'createloadbalancerruleresponse', :response_type => Hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ninefold
|
||||||
|
class Real
|
||||||
|
def delete_load_balancer_rule(options={})
|
||||||
|
request 'deleteLoadBalancerRule', options, :expects => [200], :response_prefix => 'deleteloadbalancerruleresponse', :response_type => Hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,15 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ninefold
|
||||||
|
class Real
|
||||||
|
def list_load_balancer_rule_instances(options={})
|
||||||
|
request 'listLoadBalancerRuleInstances', options, :expects => [200], :response_prefix => 'listloadbalancerruleinstancesresponse', :response_type => Hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ninefold
|
||||||
|
class Real
|
||||||
|
def list_load_balancer_rules(options={})
|
||||||
|
request 'listLoadBalancerRules', options, :expects => [200], :response_prefix => 'listloadbalancerrulesresponse', :response_type => Hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ninefold
|
||||||
|
class Real
|
||||||
|
def remove_from_load_balancer_rule(options={})
|
||||||
|
request 'removeFromLoadBalancerRule', options, :expects => [200], :response_prefix => 'removefromloadbalancerruleresponse', :response_type => Hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ninefold
|
||||||
|
class Real
|
||||||
|
def update_load_balancer_rule(options={})
|
||||||
|
request 'updateLoadBalancerRule', options, :expects => [200], :response_prefix => 'updateloadbalancerruleresponse', :response_type => Hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -312,6 +312,59 @@ class Ninefold
|
||||||
}
|
}
|
||||||
FORWARDING_RULES = [FORWARDING_RULE]
|
FORWARDING_RULES = [FORWARDING_RULE]
|
||||||
end
|
end
|
||||||
|
module LoadBalancers
|
||||||
|
CREATE_LOAD_BALANCER_RULE_RESPONSE = {
|
||||||
|
"id"=>Integer,
|
||||||
|
"account"=>String,
|
||||||
|
"algorithm"=>String,
|
||||||
|
"cidrlist"=>String,
|
||||||
|
"domain"=>String,
|
||||||
|
"domainid"=>Integer,
|
||||||
|
"name"=>String,
|
||||||
|
"privateport"=>String,
|
||||||
|
"publicip"=>String,
|
||||||
|
"publicipid"=>Integer,
|
||||||
|
"publicport"=>String,
|
||||||
|
"state"=>String,
|
||||||
|
"zoneid"=>Integer
|
||||||
|
}
|
||||||
|
ASSIGN_LOAD_BALANCER_RULE_RESPONSE = {
|
||||||
|
"success"=>Fog::Boolean
|
||||||
|
}
|
||||||
|
LIST_LOAD_BALANCER_RULES_RESPONSE = {
|
||||||
|
"id"=>Integer,
|
||||||
|
"name"=>String,
|
||||||
|
"publicipid"=>Integer,
|
||||||
|
"publicip"=>String,
|
||||||
|
"publicport"=>String,
|
||||||
|
"privateport"=>String,
|
||||||
|
"algorithm"=>String,
|
||||||
|
"cidrlist"=>String,
|
||||||
|
"account"=>String,
|
||||||
|
"domainid"=>Integer,
|
||||||
|
"domain"=>String,
|
||||||
|
"state"=>String,
|
||||||
|
"zoneid"=>Integer
|
||||||
|
}
|
||||||
|
UPDATE_LOAD_BALANCER_RULE_RESPONSE = {
|
||||||
|
"id"=>Integer,
|
||||||
|
"name"=>String,
|
||||||
|
"publicipid"=>Integer,
|
||||||
|
"publicip"=>String,
|
||||||
|
"publicport"=>String,
|
||||||
|
"privateport"=>String,
|
||||||
|
"algorithm"=>String,
|
||||||
|
"cidrlist"=>String,
|
||||||
|
"account"=>String,
|
||||||
|
"domainid"=>Integer,
|
||||||
|
"domain"=>String,
|
||||||
|
"state"=>String,
|
||||||
|
"zoneid"=>Integer
|
||||||
|
}
|
||||||
|
REMOVE_FROM_LOAD_BALANCER_RULE_RESPONSE = {
|
||||||
|
"success"=>Fog::Boolean
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
60
tests/ninefold/requests/compute/load_balancer_tests.rb
Normal file
60
tests/ninefold/requests/compute/load_balancer_tests.rb
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
Shindo.tests('Fog::Compute[:ninefold] | load balancers', ['ninefold']) do
|
||||||
|
|
||||||
|
# NOTE: all of these tests require you to have a vm built with a public IP address.
|
||||||
|
tests('success') do
|
||||||
|
|
||||||
|
before do
|
||||||
|
@compute = Fog::Compute[:ninefold]
|
||||||
|
@public_ip_id = @compute.list_public_ip_addresses.first['id']
|
||||||
|
@server_id = @compute.servers.all.first.id
|
||||||
|
@create_load_balancer = @compute.create_load_balancer_rule(:algorithm => 'roundrobin', :name => 'test',
|
||||||
|
:privateport => 1000, :publicport => 2000,
|
||||||
|
:publicipid => @public_ip_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
delete = @compute.delete_load_balancer_rule id: @create_load_balancer['id']
|
||||||
|
Ninefold::Compute::TestSupport.wait_for_job(delete['jobid'])
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#create_load_balancer_rule()").formats(Ninefold::Compute::Formats::LoadBalancers::CREATE_LOAD_BALANCER_RULE_RESPONSE) do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
result = Ninefold::Compute::TestSupport.wait_for_job(@create_load_balancer['jobid'])
|
||||||
|
result['jobresult']['loadbalancer']
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#assign_to_load_balancer_rule()").formats(Ninefold::Compute::Formats::LoadBalancers::ASSIGN_LOAD_BALANCER_RULE_RESPONSE) do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
assign_load_balancer = @compute.assign_to_load_balancer_rule id: @create_load_balancer['id'], virtualmachineids: @server_id
|
||||||
|
result = Ninefold::Compute::TestSupport.wait_for_job(assign_load_balancer['jobid'])
|
||||||
|
result['jobresult']
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#list_to_load_balancer_rules()").formats(Ninefold::Compute::Formats::LoadBalancers::LIST_LOAD_BALANCER_RULES_RESPONSE) do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
list_load_balancer_rules = @compute.list_load_balancer_rules
|
||||||
|
list_load_balancer_rules['loadbalancerrule'].first
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#update_to_load_balancer_rule()").formats(Ninefold::Compute::Formats::LoadBalancers::UPDATE_LOAD_BALANCER_RULE_RESPONSE) do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
update_load_balancer = @compute.update_load_balancer_rule id: @create_load_balancer['id'], algorithm: 'source'
|
||||||
|
result = Ninefold::Compute::TestSupport.wait_for_job(update_load_balancer['jobid'])
|
||||||
|
result['jobresult']['loadbalancer']
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('with assigned to load balancer rule') do
|
||||||
|
before do
|
||||||
|
assign_load_balancer = @compute.assign_to_load_balancer_rule id: @create_load_balancer['id'], virtualmachineids: @server_id
|
||||||
|
result = Ninefold::Compute::TestSupport.wait_for_job(assign_load_balancer['jobid'])
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#remove_from_load_balancer_rule()").formats(Ninefold::Compute::Formats::LoadBalancers::REMOVE_FROM_LOAD_BALANCER_RULE_RESPONSE) do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
remove = @compute.remove_from_load_balancer_rule id: @create_load_balancer['id'], virtualmachineids: @server_id
|
||||||
|
result = Ninefold::Compute::TestSupport.wait_for_job(remove['jobid'])
|
||||||
|
result['jobresult']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue