Sha256: ec496728d316704a6ab7e7a0fcf94bbec2743f11d6226e641f9819623aa6076f

Contents?: true

Size: 1.65 KB

Versions: 43

Compression:

Stored size: 1.65 KB

Contents

require 'fog/ibm/core'

module Fog
  module Storage
    class IBM < Fog::Service
      requires :ibm_username, :ibm_password
      recognizes :location

      model_path 'fog/ibm/models/storage'

      model :offering
      collection :offerings
      model :volume
      collection :volumes

      request_path 'fog/ibm/requests/storage'

      request :list_offerings

      request :list_volumes
      request :create_volume
      request :delete_volume
      request :get_volume

      class Real
        def initialize(options={})
          @connection = Fog::IBM::Connection.new(options[:ibm_username], options[:ibm_password])
        end

        private

        def request(options)
          begin
            @connection.request(options)
          rescue Excon::Errors::HTTPStatusError => error
            raise case error
            when Excon::Errors::NotFound
              Fog::Storage::IBM::NotFound.slurp(error)
            else
              error
            end
          end
        end
      end

      class Mock
        def self.data
          @data ||= Hash.new do |hash, key|
            hash[key] = {
              :volumes      => {},
            }
          end
        end

        def self.reset
          @data = nil
        end

        def data
          self.class.data[@ibm_username]
        end

        def reset_data
          self.class.data.delete(@ibm_username)
          @data = self.class.data[@ibm_username]
        end

        def initialize(options={})
          @ibm_username = options[:ibm_username]
          @ibm_password = options[:ibm_password]
          @data = self.class.data[@ibm_username]
        end
      end
    end
  end
end

Version data entries

43 entries across 41 versions & 6 rubygems

Version Path
fog-2.3.0 lib/fog/ibm/storage.rb
fog-ifeel-2.2.0 lib/fog/ibm/storage.rb
fog-2.2.0 lib/fog/ibm/storage.rb
fog-2.1.0 lib/fog/ibm/storage.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/ibm/storage.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/ibm/storage.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/ibm/storage.rb
fog-1.42.1 lib/fog/ibm/storage.rb
fog-2.0.0 lib/fog/ibm/storage.rb
fog-1.42.0 lib/fog/ibm/storage.rb
fog-1.41.0 lib/fog/ibm/storage.rb
fog-1.40.0 lib/fog/ibm/storage.rb
fog-1.39.0 lib/fog/ibm/storage.rb
fog-1.38.0 lib/fog/ibm/storage.rb
fog-1.37.0 lib/fog/ibm/storage.rb
fog-1.36.0 lib/fog/ibm/storage.rb
fog-1.35.0 lib/fog/ibm/storage.rb
fog-2.0.0.pre.0 lib/fog/ibm/storage.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/ibm/storage.rb
fog-1.34.0 lib/fog/ibm/storage.rb