Class: Fog::Rackspace::LoadBalancers::Real

Inherits:
Service
  • Object
show all
Includes:
Shared
Defined in:
lib/fog/rackspace/load_balancers.rb,
lib/fog/rackspace/requests/load_balancers/get_node.rb,
lib/fog/rackspace/requests/load_balancers/get_stats.rb,
lib/fog/rackspace/requests/load_balancers/get_usage.rb,
lib/fog/rackspace/requests/load_balancers/list_nodes.rb,
lib/fog/rackspace/requests/load_balancers/create_node.rb,
lib/fog/rackspace/requests/load_balancers/delete_node.rb,
lib/fog/rackspace/requests/load_balancers/get_monitor.rb,
lib/fog/rackspace/requests/load_balancers/set_monitor.rb,
lib/fog/rackspace/requests/load_balancers/update_node.rb,
lib/fog/rackspace/requests/load_balancers/delete_nodes.rb,
lib/fog/rackspace/requests/load_balancers/get_error_page.rb,
lib/fog/rackspace/requests/load_balancers/list_protocols.rb,
lib/fog/rackspace/requests/load_balancers/remove_monitor.rb,
lib/fog/rackspace/requests/load_balancers/set_error_page.rb,
lib/fog/rackspace/requests/load_balancers/list_algorithms.rb,
lib/fog/rackspace/requests/load_balancers/list_virtual_ips.rb,
lib/fog/rackspace/requests/load_balancers/create_virtual_ip.rb,
lib/fog/rackspace/requests/load_balancers/delete_virtual_ip.rb,
lib/fog/rackspace/requests/load_balancers/get_load_balancer.rb,
lib/fog/rackspace/requests/load_balancers/list_access_rules.rb,
lib/fog/rackspace/requests/load_balancers/remove_error_page.rb,
lib/fog/rackspace/requests/load_balancers/create_access_rule.rb,
lib/fog/rackspace/requests/load_balancers/delete_access_rule.rb,
lib/fog/rackspace/requests/load_balancers/get_content_caching.rb,
lib/fog/rackspace/requests/load_balancers/get_ssl_termination.rb,
lib/fog/rackspace/requests/load_balancers/list_load_balancers.rb,
lib/fog/rackspace/requests/load_balancers/set_content_caching.rb,
lib/fog/rackspace/requests/load_balancers/set_ssl_termination.rb,
lib/fog/rackspace/requests/load_balancers/create_load_balancer.rb,
lib/fog/rackspace/requests/load_balancers/delete_load_balancer.rb,
lib/fog/rackspace/requests/load_balancers/update_load_balancer.rb,
lib/fog/rackspace/requests/load_balancers/get_connection_logging.rb,
lib/fog/rackspace/requests/load_balancers/remove_ssl_termination.rb,
lib/fog/rackspace/requests/load_balancers/set_connection_logging.rb,
lib/fog/rackspace/requests/load_balancers/delete_all_access_rules.rb,
lib/fog/rackspace/requests/load_balancers/get_load_balancer_usage.rb,
lib/fog/rackspace/requests/load_balancers/get_session_persistence.rb,
lib/fog/rackspace/requests/load_balancers/set_session_persistence.rb,
lib/fog/rackspace/requests/load_balancers/get_connection_throttling.rb,
lib/fog/rackspace/requests/load_balancers/set_connection_throttling.rb,
lib/fog/rackspace/requests/load_balancers/remove_session_persistence.rb,
lib/fog/rackspace/requests/load_balancers/remove_connection_throttling.rb

Instance Method Summary collapse

Methods included from Shared

#algorithms, #protocols, #usage

Methods inherited from Service

#request_without_retry, #service_net?

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/fog/rackspace/load_balancers.rb', line 105

def initialize(options={})
  @rackspace_api_key = options[:rackspace_api_key]
  @rackspace_username = options[:rackspace_username]
  @rackspace_auth_url = options[:rackspace_auth_url]
  @rackspace_must_reauthenticate = false
  @connection_options     = options[:connection_options] || {}

  setup_custom_endpoint(options)

  authenticate

  deprecation_warnings(options)

  @persistent = options[:persistent] || false
  @connection = Fog::Core::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end

Instance Method Details

#authenticate(options = {}) ⇒ Object



134
135
136
137
138
139
140
141
# File 'lib/fog/rackspace/load_balancers.rb', line 134

def authenticate(options={})
  super({
    :rackspace_api_key => @rackspace_api_key,
    :rackspace_username => @rackspace_username,
    :rackspace_auth_url => @rackspace_auth_url,
    :connection_options => @connection_options
  })
end

#create_access_rule(load_balancer_id, address, type) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/rackspace/requests/load_balancers/create_access_rule.rb', line 5

def create_access_rule(load_balancer_id, address, type)
  #TODO - This can actually support adding multiple access rules.
  data = {
    'accessList' => [
      {
        'address' => address,
        'type' => type
      }
  ]}
  request(
    :body     => Fog::JSON.encode(data),
    :expects  => [200, 202],
    :method   => 'POST',
    :path     => "loadbalancers/#{load_balancer_id}/accesslist"
  )
end

#create_load_balancer(name, protocol, port = nil, virtual_ips = [{'type' => 'PUBLIC'}], nodes = nil, options = {}) ⇒ Object

Issue an asynchronous request to create a new Load Balancer.

Parameters:

  • name (String)

    human-friendly identifier for the balancer that will be shown in the web UI.

  • protocol (String)

    well-known protocol describing the traffic to be load balanced.

  • port (Integer) (defaults to: nil)

    port for the balancer to listen on and balance to.

  • virtual_ips (Array<Hash>) (defaults to: [{'type' => 'PUBLIC'}])

    description of the kind of IP address to bind to, or id of the existing virtual IP from another balancer. Examples: ‘{ ’type’ => ‘PUBLIC’ }‘, `{ ’type’ => ‘PRIVATE’ }‘, `{ ’id’ => 1234 }‘

  • nodes (Array<Hash>) (defaults to: nil)

    collection of

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/rackspace/requests/load_balancers/create_load_balancer.rb', line 22

def create_load_balancer(name, protocol, port = nil, virtual_ips = [{'type' => 'PUBLIC'}], nodes = nil, options = {})
  lb_data = {
    'name' => name,
    'protocol' => protocol,
    'virtualIps' => virtual_ips
  }

  lb_data['nodes'] = nodes if nodes && !nodes.empty?
  lb_data['port'] = port if port
  lb_data['algorithm'] = options[:algorithm] if options.key? :algorithm
  lb_data['timeout'] = options[:timeout] if options.key? :timeout
  lb_data['httpsRedirect'] = options[:https_redirect] if options.key? :https_redirect

  data = { 'loadBalancer' => lb_data }

  request(
    :body     => Fog::JSON.encode(data),
    :expects  => 202,
    :method   => 'POST',
    :path     => 'loadbalancers.json'
  )
end

#create_node(load_balancer_id, address, port, condition, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/rackspace/requests/load_balancers/create_node.rb', line 5

def create_node(load_balancer_id, address, port, condition, options = {})
  data = {
    'nodes' => [
      {
        'address' => address,
        'port' => port,
        'condition' => condition
      }
  ]}
  if options.key?(:weight)
    data['nodes'][0]['weight'] = options[:weight]
  end
  if options.key? :type
    data['node']['type'] = options[:type]
  end
  request(
    :body     => Fog::JSON.encode(data),
    :expects  => [200, 202],
    :method   => 'POST',
    :path     => "loadbalancers/#{load_balancer_id}/nodes.json"
  )
end

#create_virtual_ip(load_balancer_id, type) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/rackspace/requests/load_balancers/create_virtual_ip.rb', line 5

def create_virtual_ip(load_balancer_id, type)
  data = {
    'type' => type,
    'ipVersion' => 'IPV6'
  }
  request(
    :body     => Fog::JSON.encode(data),
    :expects  => [200, 202],
    :method   => 'POST',
    :path     => "loadbalancers/#{load_balancer_id}/virtualips.json"
  )
end

#delete_access_rule(load_balancer_id, access_rule_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/delete_access_rule.rb', line 5

def delete_access_rule(load_balancer_id, access_rule_id)
  request(
    :expects => [200, 202],
    :path => "loadbalancers/#{load_balancer_id}/accesslist/#{access_rule_id}",
    :method => 'DELETE'
  )
end

#delete_all_access_rules(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/delete_all_access_rules.rb', line 5

def delete_all_access_rules(load_balancer_id)
  request(
    :expects => [200, 202],
    :path => "loadbalancers/#{load_balancer_id}/accesslist",
    :method => 'DELETE'
  )
end

#delete_load_balancer(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/delete_load_balancer.rb', line 5

def delete_load_balancer(load_balancer_id)
  request(
    :expects => 202,
    :path => "loadbalancers/#{load_balancer_id}.json",
    :method => 'DELETE'
  )
end

#delete_node(load_balancer_id, node_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/delete_node.rb', line 5

def delete_node(load_balancer_id, node_id)
  request(
    :expects => [200, 202],
    :path => "loadbalancers/#{load_balancer_id}/nodes/#{node_id}",
    :method => 'DELETE'
  )
end

#delete_nodes(load_balancer_id, *node_ids) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/load_balancers/delete_nodes.rb', line 5

def delete_nodes(load_balancer_id, *node_ids)
  query_string = node_ids.map { |node_id| "id=#{node_id}" }.join('&')
  request(
    :expects => [200, 202],
    :path => "loadbalancers/#{load_balancer_id}/nodes?#{query_string}",
    :method => 'DELETE'
  )
end

#delete_virtual_ip(load_balancer_id, virtual_ip_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/delete_virtual_ip.rb', line 5

def delete_virtual_ip(load_balancer_id, virtual_ip_id)
  request(
    :expects => [200, 202],
    :path => "loadbalancers/#{load_balancer_id}/virtualips/#{virtual_ip_id}",
    :method => 'DELETE'
  )
end

#endpoint_uri(service_endpoint_url = nil) ⇒ Object



151
152
153
# File 'lib/fog/rackspace/load_balancers.rb', line 151

def endpoint_uri(service_endpoint_url=nil)
  @uri = super(@rackspace_endpoint || service_endpoint_url, :rackspace_load_balancers_url)
end

#get_connection_logging(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_connection_logging.rb', line 5

def get_connection_logging(load_balancer_id)
 request(
   :expects => 200,
   :path => "loadbalancers/#{load_balancer_id}/connectionlogging",
   :method => 'GET'
 )
end

#get_connection_throttling(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_connection_throttling.rb', line 5

def get_connection_throttling(load_balancer_id)
 request(
   :expects => 200,
   :path => "loadbalancers/#{load_balancer_id}/connectionthrottle",
   :method => 'GET'
 )
end

#get_content_caching(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_content_caching.rb', line 5

def get_content_caching(load_balancer_id)
 request(
   :expects => 200,
   :path => "loadbalancers/#{load_balancer_id}/contentcaching",
   :method => 'GET'
 )
end

#get_error_page(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_error_page.rb', line 5

def get_error_page(load_balancer_id)
 request(
   :expects => 200,
   :path => "loadbalancers/#{load_balancer_id}/errorpage",
   :method => 'GET'
 )
end

#get_load_balancer(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_load_balancer.rb', line 5

def get_load_balancer(load_balancer_id)
 request(
   :expects => 200,
   :path => "loadbalancers/#{load_balancer_id}.json",
   :method => 'GET'
 )
end

#get_load_balancer_usage(load_balancer_id, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/rackspace/requests/load_balancers/get_load_balancer_usage.rb', line 5

def get_load_balancer_usage(load_balancer_id, options = {})
 #TODO - Didn't implement usage/current.  Not sure if it is needed
 if options.key? :start_time and options.key? :end_time
   query = "?startTime=#{options[:start_time]}&endTime=#{options[:end_time]}"
 else
   query = ''
 end
 request(
   :expects => 200,
   :path => "loadbalancers/#{load_balancer_id}/usage#{query}",
   :method => 'GET'
 )
end

#get_monitor(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_monitor.rb', line 5

def get_monitor(load_balancer_id)
 request(
   :expects => 200,
   :path => "loadbalancers/#{load_balancer_id}/healthmonitor",
   :method => 'GET'
 )
end

#get_node(load_balancer_id, node_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_node.rb', line 5

def get_node(load_balancer_id, node_id)
 request(
   :expects => 200,
   :path => "loadbalancers/#{load_balancer_id}/nodes/#{node_id}.json",
   :method => 'GET'
 )
end

#get_session_persistence(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_session_persistence.rb', line 5

def get_session_persistence(load_balancer_id)
 request(
   :expects => 200,
   :path => "loadbalancers/#{load_balancer_id}/sessionpersistence",
   :method => 'GET'
 )
end

#get_ssl_termination(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_ssl_termination.rb', line 5

def get_ssl_termination(load_balancer_id)
 request(
   :expects => [200],
   :path => "loadbalancers/#{load_balancer_id}/ssltermination",
   :method => 'GET'
 )
end

#get_stats(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/get_stats.rb', line 5

def get_stats(load_balancer_id)
  request(
      :expects => 200,
      :path => "loadbalancers/#{load_balancer_id}/stats",
      :method => 'GET'
  )
end

#get_usage(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/rackspace/requests/load_balancers/get_usage.rb', line 5

def get_usage(options = {})
 if options.key? :start_time and options.key? :end_time
   query = "?startTime=#{options[:start_time]}&endTime=#{options[:end_time]}"
 else
   query = ''
 end
 request(
   :expects => 200,
   :path => "loadbalancers/usage#{query}",
   :method => 'GET'
 )
end

#list_access_rules(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/list_access_rules.rb', line 5

def list_access_rules(load_balancer_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "loadbalancers/#{load_balancer_id}/accesslist"
  )
end

#list_algorithmsObject



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/list_algorithms.rb', line 5

def list_algorithms
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'loadbalancers/algorithms'
  )
end

#list_load_balancers(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/rackspace/requests/load_balancers/list_load_balancers.rb', line 5

def list_load_balancers(options = {})
  if options.key? :node_address
    query_string = "?nodeaddress=#{options[:node_address]}"
  else
    query_string = ''
  end

  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "loadbalancers.json?#{query_string}"
  )
end

#list_nodes(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/list_nodes.rb', line 5

def list_nodes(load_balancer_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "loadbalancers/#{load_balancer_id}/nodes.json"
  )
end

#list_protocolsObject



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/list_protocols.rb', line 5

def list_protocols
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'loadbalancers/protocols'
  )
end

#list_virtual_ips(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/list_virtual_ips.rb', line 5

def list_virtual_ips(load_balancer_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "loadbalancers/#{load_balancer_id}/virtualips.json"
  )
end

#regionObject



147
148
149
# File 'lib/fog/rackspace/load_balancers.rb', line 147

def region
  @rackspace_region
end

#remove_connection_throttling(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/remove_connection_throttling.rb', line 5

def remove_connection_throttling(load_balancer_id)
 request(
   :expects => [200, 202],
   :path => "loadbalancers/#{load_balancer_id}/connectionthrottle",
   :method => 'DELETE'
 )
end

#remove_error_page(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/remove_error_page.rb', line 5

def remove_error_page(load_balancer_id)
 request(
   :expects => [200, 202],
   :path => "loadbalancers/#{load_balancer_id}/errorpage",
   :method => 'DELETE'
 )
end

#remove_monitor(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/remove_monitor.rb', line 5

def remove_monitor(load_balancer_id)
 request(
   :expects => [200, 202],
   :path => "loadbalancers/#{load_balancer_id}/healthmonitor",
   :method => 'DELETE'
 )
end

#remove_session_persistence(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/remove_session_persistence.rb', line 5

def remove_session_persistence(load_balancer_id)
 request(
   :expects => [200, 202],
   :path => "loadbalancers/#{load_balancer_id}/sessionpersistence",
   :method => 'DELETE'
 )
end

#remove_ssl_termination(load_balancer_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/load_balancers/remove_ssl_termination.rb', line 5

def remove_ssl_termination(load_balancer_id)
 request(
   :expects => [200, 202],
   :path => "loadbalancers/#{load_balancer_id}/ssltermination",
   :method => 'DELETE'
 )
end

#request(params, parse_json = true) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
# File 'lib/fog/rackspace/load_balancers.rb', line 122

def request(params, parse_json = true)
  super
rescue Excon::Errors::NotFound => error
  raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error
  raise BadRequest.slurp(error, self)
rescue Excon::Errors::InternalServerError => error
  raise InternalServerError.slurp(error, self)
rescue Excon::Errors::HTTPStatusError => error
  raise ServiceError.slurp(error, self)
end

#service_nameObject



143
144
145
# File 'lib/fog/rackspace/load_balancers.rb', line 143

def service_name
  :cloudLoadBalancers
end

#set_connection_logging(load_balancer_id, value) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/rackspace/requests/load_balancers/set_connection_logging.rb', line 5

def set_connection_logging(load_balancer_id, value)
 data = {
   'connectionLogging' => {
     'enabled' => value.to_s
   }
 }
 request(
   :body     => Fog::JSON.encode(data),
   :expects  => [200, 202],
   :path     => "loadbalancers/#{load_balancer_id}/connectionlogging",
   :method   => 'PUT'
 )
end

#set_connection_throttling(load_balancer_id, max_connections, min_connections, max_connection_rate, rate_interval) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/rackspace/requests/load_balancers/set_connection_throttling.rb', line 5

def set_connection_throttling(load_balancer_id, max_connections, min_connections, max_connection_rate, rate_interval)
 data = {
   'maxConnections' => max_connections,
   'minConnections' => min_connections,
   'maxConnectionRate' => max_connection_rate,
   'rateInterval' => rate_interval
 }
 request(
   :body     => Fog::JSON.encode(data),
   :expects  => [200, 202],
   :path     => "loadbalancers/#{load_balancer_id}/connectionthrottle",
   :method   => 'PUT'
 )
end

#set_content_caching(load_balancer_id, value) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/rackspace/requests/load_balancers/set_content_caching.rb', line 5

def set_content_caching(load_balancer_id, value)
 data = {
   'contentCaching' => {
     'enabled' => value.to_s
   }
 }
 request(
   :body     => Fog::JSON.encode(data),
   :expects  => [200, 202],
   :path     => "loadbalancers/#{load_balancer_id}/contentcaching",
   :method   => 'PUT'
 )
end

#set_error_page(load_balancer_id, content) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/rackspace/requests/load_balancers/set_error_page.rb', line 5

def set_error_page(load_balancer_id, content)
 data = {
   'errorpage' => {
     'content' => content
   }
 }
 request(
   :body     => Fog::JSON.encode(data),
   :expects  => [200, 202],
   :path     => "loadbalancers/#{load_balancer_id}/errorpage",
   :method   => 'PUT'
 )
end

#set_monitor(load_balancer_id, type, delay, timeout, attempsBeforeDeactivation, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/rackspace/requests/load_balancers/set_monitor.rb', line 5

def set_monitor(load_balancer_id, type, delay, timeout, attempsBeforeDeactivation, options = {})
 data = {
   'type' => type,
   'delay' => delay,
   'timeout' => timeout,
   'attemptsBeforeDeactivation' => attempsBeforeDeactivation
 }
 if options.key? :path
   data['path'] = options[:path]
 end
 if options.key? :body_regex
   data['bodyRegex'] = options[:body_regex]
 end
 if options.key? :status_regex
   data['statusRegex'] = options[:status_regex]
 end
 request(
   :body     => Fog::JSON.encode(data),
   :expects  => [200, 202],
   :path     => "loadbalancers/#{load_balancer_id}/healthmonitor",
   :method   => 'PUT'
 )
end

#set_session_persistence(load_balancer_id, persistence_type) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/rackspace/requests/load_balancers/set_session_persistence.rb', line 5

def set_session_persistence(load_balancer_id, persistence_type)
 data = {
   'sessionPersistence' => {
     'persistenceType' => persistence_type
   }
 }
 request(
   :body     => Fog::JSON.encode(data),
   :expects  => [200, 202],
   :path     => "loadbalancers/#{load_balancer_id}/sessionpersistence",
   :method   => 'PUT'
 )
end

#set_ssl_termination(load_balancer_id, securePort, privatekey, certificate, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/rackspace/requests/load_balancers/set_ssl_termination.rb', line 5

def set_ssl_termination(load_balancer_id, securePort, privatekey, certificate, options = {})
 data = {
   :securePort => securePort,
   :privatekey => privatekey,
   :certificate => certificate
 }

 if options.key? :intermediate_certificate
   data['intermediateCertificate'] = options[:intermediate_certificate]
 end
 if options.key? :enabled
   data['enabled'] = options[:enabled]
 end
 if options.key? :secure_traffic_only
   data['secureTrafficOnly'] = options[:secure_traffic_only]
 end
 request(
   :body     => Fog::JSON.encode(data),
   :expects => [200, 202],
   :path => "loadbalancers/#{load_balancer_id}/ssltermination",
   :method => 'PUT'
 )
end

#update_load_balancer(load_balancer_id, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/rackspace/requests/load_balancers/update_load_balancer.rb', line 5

def update_load_balancer(load_balancer_id, options = {})
  data = {
    'loadBalancer' => {
      'name' => options[:name],
      'port' => options[:port],
      'protocol' => options[:protocol],
      'algorithm' => options[:algorithm],
      'timeout' => options[:timeout],
      'httpsRedirect' => options[:https_redirect]
    }
  }
  request(
    :body     => Fog::JSON.encode(data),
    :expects  => 202,
    :method   => 'PUT',
    :path     => "loadbalancers/#{load_balancer_id}.json"
  )
end

#update_node(load_balancer_id, node_id, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/rackspace/requests/load_balancers/update_node.rb', line 5

def update_node(load_balancer_id, node_id, options = {})
  data = {
    'node' => {}
  }
  if options.key? :weight
    data['node']['weight'] = options[:weight]
  end
  if options.key? :condition
    data['node']['condition'] = options[:condition]
  end
  if options.key? :type
    data['node']['type'] = options[:type]
  end
  #TODO - Do anything if no valid options are passed in?
  request(
    :body     => Fog::JSON.encode(data),
    :expects  => [200, 202],
    :method   => 'PUT',
    :path     => "loadbalancers/#{load_balancer_id}/nodes/#{node_id}.json"
  )
end