Don't get ports info from unavailable neutron service
In shade.meta._get_supplemental_addresses() Neutron API was called to get ports list even if cloud.has_service('neutron') returned False. Now it's done only if Neutron service is available. Change-Id: I30ff7a8d049ef0bac025ac21185deb50760144cf Closes-Bug: https://storyboard.openstack.org/?#!/story/2001011
This commit is contained in:
parent
be92751781
commit
f7b1eb5c60
|
@ -344,7 +344,8 @@ def _get_supplemental_addresses(cloud, server):
|
|||
try:
|
||||
# Don't bother doing this before the server is active, it's a waste
|
||||
# of an API call while polling for a server to come up
|
||||
if cloud._has_floating_ips() and server['status'] == 'ACTIVE':
|
||||
if (cloud.has_service('network') and cloud._has_floating_ips() and
|
||||
server['status'] == 'ACTIVE'):
|
||||
for port in cloud.search_ports(
|
||||
filters=dict(device_id=server['id'])):
|
||||
for fip in cloud.search_floating_ips(
|
||||
|
|
|
@ -300,17 +300,19 @@ class TestMeta(base.RequestsMockTestCase):
|
|||
PRIVATE_V4, meta.get_server_private_ip(srv, self.cloud))
|
||||
self.assert_calls()
|
||||
|
||||
@mock.patch.object(shade.OpenStackCloud, 'has_service')
|
||||
@mock.patch.object(shade.OpenStackCloud, 'get_volumes')
|
||||
@mock.patch.object(shade.OpenStackCloud, 'get_image_name')
|
||||
@mock.patch.object(shade.OpenStackCloud, 'get_flavor_name')
|
||||
def test_get_server_private_ip_devstack(
|
||||
self,
|
||||
mock_get_flavor_name, mock_get_image_name,
|
||||
mock_get_volumes):
|
||||
mock_get_volumes, mock_has_service):
|
||||
|
||||
mock_get_image_name.return_value = 'cirros-0.3.4-x86_64-uec'
|
||||
mock_get_flavor_name.return_value = 'm1.tiny'
|
||||
mock_get_volumes.return_value = []
|
||||
mock_has_service.return_value = True
|
||||
|
||||
self.register_uris([
|
||||
dict(method='GET',
|
||||
|
@ -461,16 +463,18 @@ class TestMeta(base.RequestsMockTestCase):
|
|||
self.assertEqual(PRIVATE_V4, srv['private_v4'])
|
||||
self.assert_calls()
|
||||
|
||||
@mock.patch.object(shade.OpenStackCloud, 'has_service')
|
||||
@mock.patch.object(shade.OpenStackCloud, 'get_volumes')
|
||||
@mock.patch.object(shade.OpenStackCloud, 'get_image_name')
|
||||
@mock.patch.object(shade.OpenStackCloud, 'get_flavor_name')
|
||||
def test_get_server_cloud_missing_fips(
|
||||
self,
|
||||
mock_get_flavor_name, mock_get_image_name,
|
||||
mock_get_volumes):
|
||||
mock_get_volumes, mock_has_service):
|
||||
mock_get_image_name.return_value = 'cirros-0.3.4-x86_64-uec'
|
||||
mock_get_flavor_name.return_value = 'm1.tiny'
|
||||
mock_get_volumes.return_value = []
|
||||
mock_has_service.return_value = True
|
||||
|
||||
self.register_uris([
|
||||
dict(method='GET',
|
||||
|
|
Loading…
Reference in New Issue