1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/ibm/storage.rb
Paul Thornthwaite a72433d2f8 Remove duplicate requires from services
Following work on reorganising the requires, there was an inconsistent
approach to where service wrappers are required. (Fog::Compute...)

Since they should be standardised and shared across providers (although
they really aren't yet) they have been moved to `fog-core` gem.

Each provider has their own `lib/fog/{provider}/core` files that is
required by each of their services. These files should all require
`fog/core` which already required most or these.

So this removes the extra cases to concentrate them in core.
2014-02-13 17:44:48 +00:00

81 lines
1.7 KiB
Ruby

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