2011-08-02 11:58:18 -04:00
|
|
|
require 'fog/core'
|
2011-09-07 10:00:25 -04:00
|
|
|
require 'uri'
|
2011-08-02 11:58:18 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Cloudstack
|
|
|
|
|
|
|
|
extend Fog::Provider
|
|
|
|
|
2011-11-10 12:40:44 -05:00
|
|
|
service(:compute, 'cloudstack/compute','Compute')
|
2012-03-08 10:27:50 -05:00
|
|
|
|
2012-03-08 10:30:03 -05:00
|
|
|
@@digest = OpenSSL::Digest::Digest.new('sha1')
|
2012-03-08 10:27:50 -05:00
|
|
|
|
2011-08-02 11:58:18 -04:00
|
|
|
def self.escape(string)
|
2011-09-07 10:00:25 -04:00
|
|
|
string = CGI::escape(string)
|
|
|
|
string = string.gsub("+","%20")
|
|
|
|
string
|
2011-08-02 11:58:18 -04:00
|
|
|
end
|
2012-03-08 10:27:50 -05:00
|
|
|
|
2011-08-02 11:58:18 -04:00
|
|
|
def self.signed_params(key,params)
|
2011-08-02 14:46:21 -04:00
|
|
|
query = params.to_a.sort.collect{|c| "#{c[0]}=#{escape(c[1].to_s)}"}.join('&').downcase
|
2012-03-08 10:27:50 -05:00
|
|
|
|
2012-03-08 10:30:03 -05:00
|
|
|
signed_string = Base64.encode64(OpenSSL::HMAC.digest(@@digest,key,query)).strip
|
2012-03-08 10:27:50 -05:00
|
|
|
|
2011-08-02 11:58:18 -04:00
|
|
|
signed_string
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|