Sha256: 42c73c6c2123c2378029c97b2889d2f2416bc7a2b5a202841dca7de06651ebe0

Contents?: true

Size: 859 Bytes

Versions: 30

Compression:

Stored size: 859 Bytes

Contents

require 'fog/core'
require 'fog/json'
require 'uri'

module Fog
  module Cloudstack
    extend Fog::Provider

    service(: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.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

    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

30 entries across 30 versions & 4 rubygems

Version Path
fog-1.38.0 lib/fog/cloudstack/core.rb
fog-1.37.0 lib/fog/cloudstack/core.rb
fog-1.36.0 lib/fog/cloudstack/core.rb
fog-1.35.0 lib/fog/cloudstack/core.rb
fog-2.0.0.pre.0 lib/fog/cloudstack/core.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/cloudstack/core.rb
fog-1.34.0 lib/fog/cloudstack/core.rb
fog-1.33.0 lib/fog/cloudstack/core.rb
fog-1.32.0 lib/fog/cloudstack/core.rb
fog-1.31.0 lib/fog/cloudstack/core.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/cloudstack/core.rb
fog-1.30.0 lib/fog/cloudstack/core.rb
fog-1.29.0 lib/fog/cloudstack/core.rb
fog-1.28.0 lib/fog/cloudstack/core.rb
fog-1.27.0 lib/fog/cloudstack/core.rb
fog-1.26.0 lib/fog/cloudstack/core.rb
fog-1.25.0 lib/fog/cloudstack/core.rb
nsidc-fog-1.24.1 lib/fog/cloudstack/core.rb
fog-1.24.0 lib/fog/cloudstack/core.rb
ns-fog-1.22.11 lib/fog/cloudstack/core.rb