diff --git a/lib/fog/ibm/compute.rb b/lib/fog/ibm/compute.rb index d113321a9..cb9f6dae4 100644 --- a/lib/fog/ibm/compute.rb +++ b/lib/fog/ibm/compute.rb @@ -89,7 +89,6 @@ module Fog :keys => {}, :locations => populate_locations, :private_keys => {}, - :volumes => {}, :addresses => {} } end diff --git a/lib/fog/ibm/requests/compute/modify_instance.rb b/lib/fog/ibm/requests/compute/modify_instance.rb index 66c859ef8..5511fb2fd 100644 --- a/lib/fog/ibm/requests/compute/modify_instance.rb +++ b/lib/fog/ibm/requests/compute/modify_instance.rb @@ -48,7 +48,7 @@ module Fog response.status = 404 end elsif params['type'] == 'attach' || params['type'] == 'detach' - if (instance_exists?(instance_id) && volume_exists?(volume_id)) + if (instance_exists?(instance_id) && Fog::Storage[:ibm].volume_exists?(volume_id)) # TODO: Update the instance in the data hash, assuming IBM ever gets this feature working properly. response.status = 415 else diff --git a/lib/fog/ibm/storage.rb b/lib/fog/ibm/storage.rb index 9fa4a9d90..92e9ce7f2 100644 --- a/lib/fog/ibm/storage.rb +++ b/lib/fog/ibm/storage.rb @@ -48,8 +48,31 @@ module Fog class Mock - def request(options) - Fog::Mock.not_implemented + 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_user_id] + end + + def reset_data + self.class.data.delete(@ibm_user_id) + @data = self.class.data[@ibm_user_id] + end + + def initialize(options={}) + @ibm_user_id = options[:ibm_user_id] + @ibm_password = options[:ibm_password] + @data = self.class.data[@ibm_user_id] end end diff --git a/tests/ibm/models/storage/volume_tests.rb b/tests/ibm/models/storage/volume_tests.rb index 05f477263..2e2fdfb74 100644 --- a/tests/ibm/models/storage/volume_tests.rb +++ b/tests/ibm/models/storage/volume_tests.rb @@ -1,4 +1,4 @@ -Shindo.tests('Fog::Compute[:ibm] | volume', ['ibm']) do +Shindo.tests('Fog::Storage[:ibm] | volume', ['ibm']) do tests('success') do @@ -10,8 +10,8 @@ Shindo.tests('Fog::Compute[:ibm] | volume', ['ibm']) do @size = "256" @offering_id = "20001208" - tests('Fog::Compute::IBM::Volume.new') do - @volume = Fog::Compute[:ibm].volumes.new( + tests('Fog::Storage::IBM::Volume.new') do + @volume = Fog::Storage[:ibm].volumes.new( :name => @name, :format => @image_id, :location_id => @location_id, @@ -21,36 +21,36 @@ Shindo.tests('Fog::Compute[:ibm] | volume', ['ibm']) do returns(@name) { @volume.name } end - tests('Fog::Compute::IBM::Volume#save') do + tests('Fog::Storage::IBM::Volume#save') do returns(true) { @volume.save } returns(String) { @volume.id.class } @volume_id = @volume.id end - tests("Fog::Compute::IBM::Volume#instance") do + tests("Fog::Storage::IBM::Volume#instance") do returns(nil) { @volume.instance } end - tests("Fog::Compute::IBM::Volume#location") do + tests("Fog::Storage::IBM::Volume#location") do returns(Fog::Compute::IBM::Location) { @volume.location.class } end - tests('Fog::Compute::IBM::Volume#id') do + tests('Fog::Storage::IBM::Volume#id') do returns(@volume_id) { @volume.id } end - tests('Fog::Compute::IBM::Volume#ready?') do + tests('Fog::Storage::IBM::Volume#ready?') do # We do a "get" to advance the state if we are mocked. # TODO: Fix this for real connections - Fog::Compute[:ibm].get_volume(@volume_id) + Fog::Storage[:ibm].get_volume(@volume_id) returns(true) { @volume.ready? } end - tests('Fog::Compute::IBM::Volume#status') do + tests('Fog::Storage::IBM::Volume#status') do returns("Detached") { @volume.status } end - tests('Fog::Compute::IBM::Volume#destroy') do + tests('Fog::Storage::IBM::Volume#destroy') do returns(true) { @volume.destroy } end diff --git a/tests/ibm/requests/compute/volume_tests.rb b/tests/ibm/requests/storage/volume_tests.rb similarity index 94% rename from tests/ibm/requests/compute/volume_tests.rb rename to tests/ibm/requests/storage/volume_tests.rb index 99202b974..35c9b67a3 100644 --- a/tests/ibm/requests/compute/volume_tests.rb +++ b/tests/ibm/requests/storage/volume_tests.rb @@ -1,4 +1,4 @@ -Shindo.tests('Fog::Compute[:ibm] | volume requests', ['ibm']) do +Shindo.tests('Fog::Storage[:ibm] | volume requests', ['ibm']) do @combined_volume_format = { "id" => String, @@ -50,11 +50,11 @@ Shindo.tests('Fog::Compute[:ibm] | volume requests', ['ibm']) do end tests("#list_volumes").formats(@volumes_format) do - Fog::Compute[:ibm].list_volumes.body + Fog::Storage[:ibm].list_volumes.body end tests("#get_volume('#{@volume_id}')").formats(@volume_format) do - Fog::Compute[:ibm].get_volume(@volume_id).body + Fog::Storage[:ibm].get_volume(@volume_id).body end tests("#attach_volume('#{@instance_id}','#{@volume_id}')") do