Sha256: a270a81d13f6d03064837b6285dc9a4f8008f77f0f33a0f7fefa2884f444a618

Contents?: true

Size: 867 Bytes

Versions: 14

Compression:

Stored size: 867 Bytes

Contents

require 'fog/core'
require 'uri'

module Fog
  module Cloudstack

    extend Fog::Provider

    service(:compute, 'cloudstack/compute','Compute')

    @@digest  = OpenSSL::Digest.new('sha1')

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

    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

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

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

    def self.mac_address
      6.times.map{ Fog::Mock.random_numbers(2) }.join(":")
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
fog-maestrodev-1.19.0.20140212012611 lib/fog/cloudstack.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/cloudstack.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/cloudstack.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/cloudstack.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/cloudstack.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/cloudstack.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/cloudstack.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/cloudstack.rb
fog-1.19.0 lib/fog/cloudstack.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/cloudstack.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/cloudstack.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/cloudstack.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/cloudstack.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/cloudstack.rb