From 1a7d624d705e949d9de52c734b8c968f2a1e7300 Mon Sep 17 00:00:00 2001 From: Jan von Loewenstein Date: Tue, 23 Aug 2016 14:29:26 +0200 Subject: [PATCH] Network ID is only checked if neutron is available [#128759741](https://www.pivotaltracker.com/story/show/128759741) Signed-off-by: Beyhan Veli --- .../lib/cloud/openstack/openstack.rb | 7 +------ src/bosh_openstack_cpi/spec/unit/openstack_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) 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},