Module: Fog::Rackspace

Extended by:
Provider
Defined in:
lib/fog/rackspace.rb,
lib/fog/rackspace/errors.rb,
lib/fog/rackspace/service.rb,
lib/fog/rackspace/identity.rb,
lib/fog/rackspace/databases.rb,
lib/fog/rackspace/mock_data.rb,
lib/fog/rackspace/block_storage.rb,
lib/fog/rackspace/load_balancers.rb,
lib/fog/rackspace/models/identity/role.rb,
lib/fog/rackspace/models/identity/user.rb,
lib/fog/rackspace/models/databases/user.rb,
lib/fog/rackspace/models/identity/roles.rb,
lib/fog/rackspace/models/identity/users.rb,
lib/fog/rackspace/models/databases/users.rb,
lib/fog/rackspace/models/identity/tenant.rb,
lib/fog/rackspace/models/databases/flavor.rb,
lib/fog/rackspace/models/identity/tenants.rb,
lib/fog/rackspace/models/databases/flavors.rb,
lib/fog/rackspace/models/databases/database.rb,
lib/fog/rackspace/models/databases/instance.rb,
lib/fog/rackspace/models/databases/databases.rb,
lib/fog/rackspace/models/databases/instances.rb,
lib/fog/rackspace/models/identity/credential.rb,
lib/fog/rackspace/models/load_balancers/node.rb,
lib/fog/rackspace/models/block_storage/volume.rb,
lib/fog/rackspace/models/identity/credentials.rb,
lib/fog/rackspace/models/load_balancers/nodes.rb,
lib/fog/rackspace/models/block_storage/volumes.rb,
lib/fog/rackspace/requests/identity/list_users.rb,
lib/fog/rackspace/models/block_storage/snapshot.rb,
lib/fog/rackspace/requests/databases/get_flavor.rb,
lib/fog/rackspace/requests/databases/list_users.rb,
lib/fog/rackspace/requests/identity/create_user.rb,
lib/fog/rackspace/requests/identity/delete_user.rb,
lib/fog/rackspace/requests/identity/update_user.rb,
lib/fog/rackspace/models/block_storage/snapshots.rb,
lib/fog/rackspace/requests/databases/create_user.rb,
lib/fog/rackspace/requests/databases/delete_user.rb,
lib/fog/rackspace/requests/identity/create_token.rb,
lib/fog/rackspace/requests/identity/list_tenants.rb,
lib/fog/rackspace/models/identity/service_catalog.rb,
lib/fog/rackspace/requests/databases/get_instance.rb,
lib/fog/rackspace/requests/databases/list_flavors.rb,
lib/fog/rackspace/models/block_storage/volume_type.rb,
lib/fog/rackspace/models/load_balancers/virtual_ip.rb,
lib/fog/rackspace/requests/identity/get_user_by_id.rb,
lib/fog/rackspace/requests/load_balancers/get_node.rb,
lib/fog/rackspace/models/block_storage/volume_types.rb,
lib/fog/rackspace/models/load_balancers/access_rule.rb,
lib/fog/rackspace/models/load_balancers/virtual_ips.rb,
lib/fog/rackspace/requests/block_storage/get_volume.rb,
lib/fog/rackspace/requests/databases/list_databases.rb,
lib/fog/rackspace/requests/databases/list_instances.rb,
lib/fog/rackspace/requests/identity/list_user_roles.rb,
lib/fog/rackspace/requests/load_balancers/get_usage.rb,
lib/fog/rackspace/models/load_balancers/access_rules.rb,
lib/fog/rackspace/requests/databases/check_root_user.rb,
lib/fog/rackspace/requests/databases/create_database.rb,
lib/fog/rackspace/requests/databases/create_instance.rb,
lib/fog/rackspace/requests/databases/delete_database.rb,
lib/fog/rackspace/requests/databases/delete_instance.rb,
lib/fog/rackspace/requests/databases/resize_instance.rb,
lib/fog/rackspace/requests/identity/get_user_by_name.rb,
lib/fog/rackspace/requests/identity/list_credentials.rb,
lib/fog/rackspace/requests/load_balancers/list_nodes.rb,
lib/fog/rackspace/models/load_balancers/load_balancer.rb,
lib/fog/rackspace/requests/block_storage/get_snapshot.rb,
lib/fog/rackspace/requests/block_storage/list_volumes.rb,
lib/fog/rackspace/requests/databases/enable_root_user.rb,
lib/fog/rackspace/requests/databases/restart_instance.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/block_storage/create_volume.rb,
lib/fog/rackspace/requests/block_storage/delete_volume.rb,
lib/fog/rackspace/requests/load_balancers/delete_nodes.rb,
lib/fog/rackspace/requests/block_storage/list_snapshots.rb,
lib/fog/rackspace/requests/block_storage/create_snapshot.rb,
lib/fog/rackspace/requests/block_storage/delete_snapshot.rb,
lib/fog/rackspace/requests/block_storage/get_volume_type.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/block_storage/list_volume_types.rb,
lib/fog/rackspace/requests/load_balancers/list_virtual_ips.rb,
lib/fog/rackspace/requests/databases/resize_instance_volume.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

Defined Under Namespace

Modules: Errors, MockData Classes: BlockStorage, Databases, Identity, LoadBalancers, Service

Constant Summary collapse

US_AUTH_ENDPOINT =
'https://identity.api.rackspacecloud.com/v2.0'
UK_AUTH_ENDPOINT =
'https://lon.identity.api.rackspacecloud.com/v2.0'

Class Method Summary collapse

Methods included from Provider

[], extended, service, services

Class Method Details

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



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/fog/rackspace.rb', line 75

def self.authenticate(options, connection_options = {})
  rackspace_auth_url = options[:rackspace_auth_url]
  rackspace_auth_url ||= options[:rackspace_endpoint] == Fog::Compute::RackspaceV2::LON_ENDPOINT ? "lon.auth.api.rackspacecloud.com" : "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



107
108
109
110
111
# File 'lib/fog/rackspace.rb', line 107

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

.normalize_url(endpoint) ⇒ Object



99
100
101
102
103
104
# File 'lib/fog/rackspace.rb', line 99

def self.normalize_url(endpoint)
  return nil unless endpoint
  str = endpoint.chomp " "
  str = str.chomp "/"
  str.downcase
end