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

.ip_addressObject



31
32
33
# File 'lib/fog/cloudstack.rb', line 31

def self.ip_address
  4.times.map{ Fog::Mock.random_numbers(3) }.join(".")
end

.mac_addressObject



35
36
37
# File 'lib/fog/cloudstack.rb', line 35

def self.mac_address
  6.times.map{ Fog::Mock.random_numbers(2) }.join(":")
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.map{|k,v| [k.to_s, v]}.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

.uuidObject



27
28
29
# File 'lib/fog/cloudstack.rb', line 27

def self.uuid
  [8,4,4,4,12].map{|i| Fog::Mock.random_hex(i)}.join("-")
end