Module: Fog::Cloudstack
- Extended by:
- Provider
- Defined in:
- lib/fog/cloudstack/core.rb
Constant Summary collapse
- @@digest =
OpenSSL::Digest.new('sha1')
Class Method Summary collapse
- .escape(string) ⇒ Object
- .ip_address ⇒ Object
- .mac_address ⇒ Object
- .signed_params(key, params) ⇒ Object
- .uuid ⇒ Object
Class Method Details
.escape(string) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/fog/cloudstack/core.rb', line 13 def self.escape(string) string = CGI::escape(string) string = string.gsub("+","%20") # Escaped asterisk will cause malformed request string = string.gsub("%2A","*") string end |
.ip_address ⇒ Object
33 34 35 |
# File 'lib/fog/cloudstack/core.rb', line 33 def self.ip_address 4.times.map{ Fog::Mock.random_numbers(3) }.join(".") end |
.mac_address ⇒ Object
37 38 39 |
# File 'lib/fog/cloudstack/core.rb', line 37 def self.mac_address 6.times.map{ Fog::Mock.random_numbers(2) }.join(":") end |
.signed_params(key, params) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/fog/cloudstack/core.rb', line 21 def self.signed_params(key,params) query = params.map{|k,v| [k.to_s, v]}.sort.map{|c| "#{c[0]}=#{escape(c[1].to_s)}"}.join('&').downcase signed_string = Base64.encode64(OpenSSL::HMAC.digest(@@digest,key,query)).strip signed_string end |
.uuid ⇒ Object
29 30 31 |
# File 'lib/fog/cloudstack/core.rb', line 29 def self.uuid [8,4,4,4,12].map{|i| Fog::Mock.random_hex(i)}.join("-") end |