Module: Fog::Rackspace

Extended by:
Provider
Defined in:
lib/fog/rackspace.rb,
lib/fog/rackspace/load_balancers.rb,
lib/fog/rackspace/models/load_balancers/node.rb,
lib/fog/rackspace/models/load_balancers/nodes.rb,
lib/fog/rackspace/models/load_balancers/virtual_ip.rb,
lib/fog/rackspace/requests/load_balancers/get_node.rb,
lib/fog/rackspace/models/load_balancers/access_rule.rb,
lib/fog/rackspace/models/load_balancers/virtual_ips.rb,
lib/fog/rackspace/requests/load_balancers/get_usage.rb,
lib/fog/rackspace/models/load_balancers/access_rules.rb,
lib/fog/rackspace/requests/load_balancers/list_nodes.rb,
lib/fog/rackspace/models/load_balancers/load_balancer.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/models/load_balancers/load_balancers.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/list_load_balancers.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/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

Defined Under Namespace

Modules: Errors Classes: LoadBalancers

Class Method Summary collapse

Methods included from Provider

[], extended, service, services

Class Method Details

.authenticate(options, connection_options = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fog/rackspace.rb', line 51

def self.authenticate(options, connection_options = {})
  rackspace_auth_url = options[:rackspace_auth_url] || "auth.api.rackspacecloud.com"
  url = rackspace_auth_url.match(/^https?:/) ? \
            rackspace_auth_url : 'https://' + rackspace_auth_url
  uri = URI.parse(url)
  connection = Fog::Connection.new(url, false, connection_options)
  @rackspace_api_key  = options[:rackspace_api_key]
  @rackspace_username = options[:rackspace_username]
  response = connection.request({
    :expects  => [200, 204],
    :headers  => {
      'X-Auth-Key'  => @rackspace_api_key,
      'X-Auth-User' => @rackspace_username
    },
    :host     => uri.host,
    :method   => 'GET',
    :path     =>  (uri.path and not uri.path.empty?) ? uri.path : 'v1.0'
  })
  response.headers.reject do |key, value|
    !['X-Server-Management-Url', 'X-Storage-Url', 'X-CDN-Management-Url', 'X-Auth-Token'].include?(key)
  end
end

.escape(str, extra_exclude_chars = '') ⇒ Object

CGI.escape, but without special treatment on spaces



75
76
77
78
79
# File 'lib/fog/rackspace.rb', line 75

def self.escape(str,extra_exclude_chars = '')
  str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do
    '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
  end
end