diff --git a/src/bosh_openstack_cpi/lib/cloud/openstack/openstack.rb b/src/bosh_openstack_cpi/lib/cloud/openstack/openstack.rb index 53f36581..09f88fdc 100644 --- a/src/bosh_openstack_cpi/lib/cloud/openstack/openstack.rb +++ b/src/bosh_openstack_cpi/lib/cloud/openstack/openstack.rb @@ -128,7 +128,7 @@ def network end rescue Excon::Errors::SocketError => e cloud_error(socket_error_msg + "#{e.message}") - rescue Bosh::Common::RetryCountExceeded, Excon::Errors::ClientError, Excon::Errors::ServerError => e + rescue Bosh::Common::RetryCountExceeded, Excon::Errors::ClientError, Excon::Errors::ServerError, Fog::Errors::NotFound => e cloud_error("Unable to connect to the OpenStack Network Service API: #{e.message}. Check task debug log for details.") end end @@ -136,11 +136,6 @@ def network @network end - def metadata - - end - - private def openstack_params(options) diff --git a/src/bosh_openstack_cpi/spec/unit/openstack_spec.rb b/src/bosh_openstack_cpi/spec/unit/openstack_spec.rb index 985d3c96..e8508d73 100644 --- a/src/bosh_openstack_cpi/spec/unit/openstack_spec.rb +++ b/src/bosh_openstack_cpi/spec/unit/openstack_spec.rb @@ -60,6 +60,17 @@ end end + context 'when the service is not available' do + describe 'Network' do + it 'raises a CloudError exception if cannot connect to the service API' do + allow(Fog::Network).to receive(:new).and_raise(Fog::Errors::NotFound, 'Not found message') + expect { + Bosh::OpenStackCloud::Openstack.new(openstack_options).network + }.to raise_error(Bosh::Clouds::CloudError, + 'Unable to connect to the OpenStack Network Service API: Not found message. Check task debug log for details.') + end + end + end [ {clazz: Fog::Compute, name: 'Compute', method_name: :compute}, {clazz: Fog::Image::OpenStack::V2, name: 'Image', method_name: :image},