Module: Fog::Softlayer

Extended by:
Provider
Defined in:
lib/fog/softlayer/core.rb,
lib/fog/softlayer/version.rb,
lib/fog/softlayer/compute/shared.rb

Defined Under Namespace

Modules: Compute, Slapi

Constant Summary collapse

SL_API_URL =
'api.softlayer.com/rest/v3'
SL_STORAGE_AUTH_URL =
'objectstorage.softlayer.net/auth/v1.0'
VERSION =
"0.3.15"

Class Method Summary collapse

Class Method Details

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

CGI.escape, but without special treatment on spaces



123
124
125
126
127
# File 'lib/fog/softlayer/core.rb', line 123

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

.mock_account_idObject



106
107
108
# File 'lib/fog/softlayer/core.rb', line 106

def self.
  Fog.mocking? and  ||= Fog::Mock.random_numbers(7)
end

.mock_global_identifierObject



114
115
116
# File 'lib/fog/softlayer/core.rb', line 114

def self.mock_global_identifier
  Fog::UUID.uuid
end

.mock_vm_idObject



110
111
112
# File 'lib/fog/softlayer/core.rb', line 110

def self.mock_vm_id
  Fog::Mock.random_numbers(7)
end

.stringify_keys(obj) ⇒ Object



129
130
131
132
133
# File 'lib/fog/softlayer/core.rb', line 129

def self.stringify_keys(obj)
  return obj.inject({}){|memo,(k,v)| memo[k.to_s] =  stringify_keys(v); memo} if obj.is_a? Hash
  return obj.inject([]){|memo,v    | memo         << stringify_keys(v); memo} if obj.is_a? Array
  obj
end

.valid_request?(required, passed) ⇒ Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/fog/softlayer/core.rb', line 118

def self.valid_request?(required, passed)
  required.all? {|k| k = k.to_sym; passed.key?(k) and !passed[k].nil?}
end