From b1d2217a7caa85c5725f40ec6f9c2316bde9eed2 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 1 Sep 2017 09:48:02 +0100 Subject: [PATCH] Assume neutron auto_allocate extension's enabled No recent neutron deployment should ever have the 'auto_allocate' extension missing in its list of extensions. It appears like this has been the case since at least Mitaka [1]. This simplifies code slightly and allows us to remove a few now-unnecessary tests. [1] https://github.com/openstack/neutron/blob/mitaka-eol/neutron/plugins/common/constants.py#L41-L47 Change-Id: Ia420eac4471cdafecfe1ad3d411c494545046c92 --- nova/network/neutronv2/api.py | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index 8b393073..0ecfbcdc 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -1033,12 +1033,6 @@ class API(base_api.NetworkAPI): self.extensions.clear() self.extensions = {ext['name']: ext for ext in extensions_list} - def _has_auto_allocate_extension(self, context, refresh_cache=False, - neutron=None): - if refresh_cache or not self.extensions: - self._refresh_neutron_extensions_cache(context, neutron=neutron) - return constants.AUTO_ALLOCATE_TOPO_EXT in self.extensions - def _has_multi_provider_extension(self, context, neutron=None): self._refresh_neutron_extensions_cache(context, neutron=neutron) return constants.MULTI_NET_EXT in self.extensions @@ -1527,23 +1521,17 @@ class API(base_api.NetworkAPI): :returns: True if it's possible to auto-allocate networks, False otherwise. """ - # check that the auto-allocated-topology extension is available - if self._has_auto_allocate_extension(context, neutron=neutron): - # run the dry-run validation, which will raise a 409 if not ready - try: - neutron.validate_auto_allocated_topology_requirements( - context.project_id) - LOG.debug('Network auto-allocation is available for project ' - '%s', context.project_id) - except neutron_client_exc.Conflict as ex: - LOG.debug('Unable to auto-allocate networks. %s', - six.text_type(ex)) - else: - return True - else: - LOG.debug('Unable to auto-allocate networks. The neutron ' - 'auto-allocated-topology extension is not available.') - return False + # run the dry-run validation, which will raise a 409 if not ready + try: + neutron.validate_auto_allocated_topology_requirements( + context.project_id) + LOG.debug('Network auto-allocation is available for project ' + '%s', context.project_id) + return True + except neutron_client_exc.Conflict as ex: + LOG.debug('Unable to auto-allocate networks. %s', + six.text_type(ex)) + return False def _auto_allocate_network(self, instance, neutron): """Automatically allocates a network for the given project.