Module: Fog::Cloudstack

Extended by:
Provider
Defined in:
lib/fog/cloudstack.rb

Constant Summary collapse

DIGEST =
OpenSSL::Digest::Digest.new('sha1')

Class Method Summary collapse

Methods included from Provider

[], extended, service, services

Class Method Details

.escape(string) ⇒ Object



13
14
15
16
17
# File 'lib/fog/cloudstack.rb', line 13

def self.escape(string)
  string = CGI::escape(string)
  string = string.gsub("+","%20")
  string
end

.signed_params(key, params) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/fog/cloudstack.rb', line 19

def self.signed_params(key,params)
  query = params.to_a.sort.collect{|c| "#{c[0]}=#{escape(c[1].to_s)}"}.join('&').downcase
  
  signed_string = Base64.encode64(OpenSSL::HMAC.digest(DIGEST,key,query)).strip
  
  signed_string
end