class Fog::HP::LB::Real
Create a new load balancer
Parameters¶ ↑
-
‘name’<~String> - Name of the load balancer
-
‘nodes’<~ArrayOfHash> -
Nodes
for the load balancer-
‘address’<~String> - Address for the node
-
‘port’<~String> - Port for the node
-
-
options<~Hash>:
-
‘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>:
-
body<~Hash>:
-
‘id’<~String> - UUID of the load balancer
-
‘name’<~String> - Name of the load balancer
-
‘protocol’<~String> -
Protocol
for the load balancer -
‘port’<~String> - Port for the load balancer
-
‘algorithm’<~String> -
Algorithm
for the load balancer -
‘status’<~String> - Status for the load balancer
-
‘created’<~String> - created date time stamp
-
‘updated’<~String> - updated date time stamp
-
‘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
-
-
-
Create a new load balancer node
Parameters¶ ↑
-
‘load_balancer_id’<~String> - UUId of load balancer to create node for
-
‘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>:
-
body<~Hash>:
-
‘nodes’<~Array>:
-
‘id’<~String> - UUID of the node
-
‘address’<~String> - Address for the node
-
‘port’<~String> - Port for the node
-
‘condition’<~String> - Condition for the node. Valid values are [‘ENABLED’, ‘DISABLED’]
-
‘status’<~String> - Status for the node
-
-
-
Delete an existing load balancer
Parameters¶ ↑
-
‘load_balancer_id’<~String> - UUId of load balancer to delete
Delete an existing load balancer node
Parameters¶ ↑
-
‘load_balancer_id’<~String> - UUId of load balancer for the node
-
‘node_id’<~String> - UUId of node to delete
Get details for an existing load balancer
Parameters¶ ↑
-
‘load_balancer_id’<~String> - UUId of the load balancer to get
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘loadBalancers’<~Array>:
-
‘id’<~String> - UUID of the load balancer
-
‘name’<~String> - Name of the load balancer
-
‘protocol’<~String> -
Protocol
for the load balancer -
‘port’<~String> - Port for the load balancer
-
‘algorithm’<~String> -
Algorithm
for the load balancer -
‘status’<~String> - Status for the load balancer
-
‘statusDescription’<~String> - Desc. of Status for the load balancer
-
‘created’<~String> - created date time stamp
-
‘updated’<~String> - updated date time stamp
-
‘nodeCount’<~Integer> -
Nodes
attached to the load balancer -
‘nodes’<~ArrayOfHash> -
Nodes
for the load balancer-
‘id’<~String> - UUId for the node
-
‘address’<~String> - Address for the node
-
‘port’<~String> - Port for the node
-
‘condition’<~String> - Condition for the node e.g. ‘ENABLED’
-
‘status’<~String> - Status for the node e.g. ‘ONLINE’
-
-
‘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
-
-
-
-
List algorithms
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘algorithms’<~Array>:
-
‘name’<~String> - Name of the algorithm
-
-
-
List limits
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘limits’<~Hash>:
-
‘absolute’<~Hash>:
-
‘values’<~Hash>:
-
‘maxLoadBalancerNameLength’<~Integer> - Limit of the name of the load balancer
-
‘maxLoadBalancers’<~Integer> - Limit of the number of the load balancer
-
‘maxVIPsPerLoadBalancer’<~Integer> - Limit of the virtual IPs per load balancer
-
‘maxNodesPerLoadBalancer’<~Integer> - Limit of the nodes per load balancer
-
-
-
-
-
List all load balancer nodes
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘nodes’<~Array>:
Nodes
for the load balancer-
‘id’<~String> - UUId for the node
-
‘address’<~String> - Address for the node
-
‘port’<~String> - Port for the node
-
‘condition’<~String> - Condition for the node e.g. ‘ENABLED’
-
‘status’<~String> - Status for the node e.g. ‘ONLINE’
-
-
-
List virtual IPs for an existing load balancer
Parameters¶ ↑
-
‘load_balancer_id’<~String> - UUId of the load balancer to get virtual IPs for
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘virtualIps’<~Array>:
-
‘id’<~String> - UUId for the virtual IP
-
‘address’<~String> - Address for the virtual IP
-
‘type’<~String> - Type for the virtual IP e.g. ‘PUBLIC’
-
‘ipVersion’<~String> - Version for virtual IP e.g. ‘IPV4’, ‘IPV6’
-
-
-
List all load balancers
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘loadBalancers’<~Array>:
-
‘id’<~String> - UUID of the load balancer
-
‘name’<~String> - Name of the load balancer
-
‘protocol’<~String> -
Protocol
for the load balancer -
‘port’<~String> - Port for the load balancer
-
‘algorithm’<~String> -
Algorithm
for the load balancer -
‘status’<~String> - Status for the load balancer
-
‘created’<~String> - created date time stamp
-
‘updated’<~String> - updated date time stamp
-
‘nodeCount’<~Integer> -
Nodes
attached to the load balancer
-
-
-
List protocols
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘protocols’<~Array>:
-
‘name’<~String> - Name of the protocol
-
‘port’<~String> - Port of the protocol
-
-
-
Update an existing load balancer
Parameters¶ ↑
-
‘load_balancer_id’<~String> - UUId of the load balancer to update
-
options<~Hash>:
-
‘name’<~String> - Name for the load balancer
-
‘algorithm’<~String> -
Algorithm
for the load balancer
-
Update an existing load balancer node
Parameters¶ ↑
-
‘load_balancer_id’<~String> - UUId of the load balancer to update
-
‘node_id’<~String> - UUId of node to update
-
options<~Hash>:
-
‘condition’<~String> - Condition for the node. Valid values are []‘ENABLED’, ‘DISABLED’]
-
Attributes
Public Class Methods
# File lib/fog/hp/lb.rb, line 96 def initialize(options={}) @hp_access_key = options[:hp_access_key] @hp_secret_key = options[:hp_secret_key] @hp_auth_uri = options[:hp_auth_uri] @connection_options = options[:connection_options] || {} ### Set an option to use the style of authentication desired; :v1 or :v2 (default) auth_version = options[:hp_auth_version] || :v2 ### Pass the service name for object storage to the authentication call options[:hp_service_type] ||= "hpext:lbaas" @hp_tenant_id = options[:hp_tenant_id] @hp_avl_zone = options[:hp_avl_zone] ### Make the authentication call if (auth_version == :v2) # Call the control services authentication credentials = Fog::HP.authenticate_v2(options, @connection_options) # the CS service catalog returns the block storage endpoint @hp_block_uri = credentials[:endpoint_url] else # Call the legacy v1.0/v1.1 authentication credentials = Fog::HP.authenticate_v1(options, @connection_options) # the user sends in the block storage endpoint @hp_block_uri = options[:hp_auth_uri] end @auth_token = credentials[:auth_token] @persistent = options[:persistent] || false uri = URI.parse(@hp_block_uri) @host = uri.host @path = uri.path @port = uri.port @scheme = uri.scheme @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end
Public Instance Methods
# File lib/fog/hp/requests/lb/create_load_balancer.rb, line 41 def create_load_balancer(name, nodes, options={}) ### Inconsistent behavior. Should be passing in as a 'loadbalancer' => {'name', 'nodes'} data = { 'name' => name, 'nodes' => nodes } l_options = ['port', 'protocol', 'algorithm'] l_options.select{|o| options[o]}.each do |key| data[key] = options[key] end if options['virtualIps'] data['virtualIps'] = [] for vip in options['virtualIps'] data['virtualIps'] << vip end end response = request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => 'loadbalancers' ) response end
# File lib/fog/hp/requests/lb/create_load_balancer_node.rb, line 23 def create_load_balancer_node(load_balancer_id, address, port, options={}) data = { 'nodes' => [ { 'address' => address, 'port' => port } ] } if options['condition'] data['nodes'][0]['condition'] = options['condition'] end request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => "loadbalancers/#{load_balancer_id}/nodes" ) end
# File lib/fog/hp/requests/lb/delete_load_balancer.rb, line 10 def delete_load_balancer(load_balancer_id) request( :expects => 202, :method => 'DELETE', :path => "loadbalancers/#{load_balancer_id}" ) end
# File lib/fog/hp/requests/lb/delete_load_balancer_node.rb, line 11 def delete_load_balancer_node(load_balancer_id, node_id) request( :expects => 202, :method => 'DELETE', :path => "loadbalancers/#{load_balancer_id}/nodes/#{node_id}" ) end
# File lib/fog/hp/requests/lb/get_load_balancer.rb, line 35 def get_load_balancer(load_balancer_id) request( :expects => 200, :method => 'GET', :path => "loadbalancers/#{load_balancer_id}" ) end
Get details for an existing load balancer node
Parameters¶ ↑
-
‘load_balancer_id’<~String> - UUId of the load balancer to get
-
‘node_id’<~String> - UUId of node to get
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘id’<~String> - UUId for the node
-
‘address’<~String> - Address for the node
-
‘port’<~String> - Port for the node
-
‘condition’<~String> - Condition for the node e.g. ‘ENABLED’
-
‘status’<~String> - Status for the node e.g. ‘ONLINE’
-
-
# File lib/fog/hp/requests/lb/get_load_balancer_node.rb, line 19 def get_load_balancer_node(load_balancer_id, node_id) request( :expects => 200, :method => 'GET', :path => "loadbalancers/#{load_balancer_id}/nodes/#{node_id}" ) end
# File lib/fog/hp/requests/lb/list_algorithms.rb, line 12 def list_algorithms request( :expects => 200, :method => 'GET', :path => 'algorithms' ) end
# File lib/fog/hp/requests/lb/list_limits.rb, line 17 def list_limits request( :expects => 200, :method => 'GET', :path => 'limits' ) end
# File lib/fog/hp/requests/lb/list_load_balancer_nodes.rb, line 16 def list_load_balancer_nodes(load_balancer_id) response = request( :expects => 200, :method => 'GET', :path => "loadbalancers/#{load_balancer_id}/nodes" ) response end
# File lib/fog/hp/requests/lb/list_load_balancer_virtual_ips.rb, line 18 def list_load_balancer_virtual_ips(load_balancer_id) request( :expects => 200, :method => 'GET', :path => "loadbalancers/#{load_balancer_id}/virtualips" ) end
# File lib/fog/hp/requests/lb/list_load_balancers.rb, line 20 def list_load_balancers request( :expects => 200, :method => 'GET', :path => 'loadbalancers' ) end
# File lib/fog/hp/requests/lb/list_protocols.rb, line 13 def list_protocols response = request( :expects => 200, :method => 'GET', :path => 'protocols' ) response end
# File lib/fog/hp/requests/lb/list_versions.rb, line 5 def list_versions request( :expects => 200, :method => 'GET', :path => '' ) end
# File lib/fog/hp/lb.rb, line 133 def reload @connection.reset end
# File lib/fog/hp/lb.rb, line 137 def request(params, parse_json = true, &block) begin response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :path => "#{@path}/#{params[:path]}", }), &block) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::HP::LB::NotFound.slurp(error) else error end end if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json} response.body = Fog::JSON.decode(response.body) end response end
# File lib/fog/hp/requests/lb/update_load_balancer.rb, line 12 def update_load_balancer(load_balancer_id, options={}) data = {} l_options = ['name', 'algorithm'] l_options.select{|o| options[o]}.each do |key| data[key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'PUT', :path => "loadbalancers/#{load_balancer_id}" ) end
# File lib/fog/hp/requests/lb/update_load_balancer_node.rb, line 12 def update_load_balancer_node(load_balancer_id, node_id, condition) data = { 'condition' => condition } request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'PUT', :path => "loadbalancers/#{load_balancer_id}/nodes/#{node_id}" ) end