Remove nova api extension checks

Entire api extension concept has been removed from nova. API bindings
which have been deprecated since Train release are removed with
https://review.opendev.org/#/c/686516/.

Change-Id: Ifd318a54ef01eb500cebbc11e642b3ae62e5fc79
This commit is contained in:
Rabi Mishra 2019-11-06 16:46:51 +05:30
parent 61048ef16b
commit 49a2a1e55a
17 changed files with 19 additions and 104 deletions

View File

@ -82,11 +82,9 @@ class NovaClientPlugin(microversion_mixin.MicroversionMixin,
def _get_args(self, version):
endpoint_type = self._get_client_option(CLIENT_NAME, 'endpoint_type')
extensions = nc.discover_extensions(version)
return {
'session': self.context.keystone_session,
'extensions': extensions,
'endpoint_type': endpoint_type,
'service_type': self.COMPUTE,
'region_name': self._get_region_name(),
@ -829,15 +827,6 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
return True
return False
@os_client.MEMOIZE_EXTENSIONS
def _list_extensions(self):
extensions = self.client().list_extensions.show_all()
return set(extension.alias for extension in extensions)
def has_extension(self, alias):
"""Check if specific extension is present."""
return alias in self._list_extensions()
class NovaBaseConstraint(constraints.BaseCustomConstraint):

View File

@ -41,8 +41,6 @@ class NovaFlavor(resource.Resource):
default_client_name = 'nova'
required_service_extension = 'os-flavor-manage'
entity = 'flavors'
PROPERTIES = (

View File

@ -49,8 +49,6 @@ class NovaFloatingIp(resource.Resource):
)
)
required_service_extension = 'os-floating-ips'
PROPERTIES = (POOL,) = ('pool',)
ATTRIBUTES = (

View File

@ -38,8 +38,6 @@ class HostAggregate(resource.Resource):
entity = 'aggregates'
required_service_extension = 'os-aggregates'
PROPERTIES = (
NAME, AVAILABILITY_ZONE, HOSTS, METADATA
) = (

View File

@ -43,8 +43,6 @@ class KeyPair(resource.Resource):
support_status = support.SupportStatus(version='2014.1')
required_service_extension = 'os-keypairs'
PROPERTIES = (
NAME, SAVE_PRIVATE_KEY, PUBLIC_KEY, KEY_TYPE, USER,
) = (

View File

@ -53,8 +53,6 @@ class NovaQuota(resource.Resource):
entity = 'quotas'
required_service_extension = 'os-quota-sets'
PROPERTIES = (
PROJECT, CORES, FIXED_IPS, FLOATING_IPS, INSTANCES,
INJECTED_FILES, INJECTED_FILE_CONTENT_BYTES, INJECTED_FILE_PATH_BYTES,

View File

@ -33,8 +33,6 @@ class ServerGroup(resource.Resource):
entity = 'server_groups'
required_service_extension = 'os-server-groups'
PROPERTIES = (
NAME, POLICIES
) = (

View File

@ -190,12 +190,6 @@ class ServerNetworkMixin(object):
creating. We need to store information about that ports, so store
their IDs to data with key `external_ports`.
"""
# check if os-attach-interfaces extension is available on this cloud.
# If it's not, then novaclient's interface_list method cannot be used
# to get the list of interfaces.
if not self.client_plugin().has_extension('os-attach-interfaces'):
return
server = self.client().servers.get(self.resource_id)
ifaces = server.interface_list()
external_port_ids = set(iface.port_id for iface in ifaces)

View File

@ -45,27 +45,21 @@ class NovaClientPluginTest(NovaClientPluginTestCase):
def test_create(self):
context = utils.dummy_context()
ext_mock = self.patchobject(nc, 'discover_extensions')
plugin = context.clients.client_plugin('nova')
plugin.max_microversion = '2.53'
client = plugin.client()
ext_mock.assert_called_once_with('2.53')
self.assertIsNotNone(client.servers)
def test_v2_26_create(self):
ctxt = utils.dummy_context()
ext_mock = self.patchobject(nc, 'discover_extensions')
self.patchobject(nc, 'Client', return_value=mock.Mock())
plugin = ctxt.clients.client_plugin('nova')
plugin.max_microversion = '2.53'
plugin.client(version='2.26')
ext_mock.assert_called_once_with('2.26')
def test_v2_26_create_failed(self):
ctxt = utils.dummy_context()
self.patchobject(nc, 'discover_extensions')
plugin = ctxt.clients.client_plugin('nova')
plugin.max_microversion = '2.23'
client_stub = mock.Mock()
@ -654,30 +648,3 @@ class ConsoleUrlsTest(common.HeatTestCase):
self.console_method.side_effect = exc("spam")
self._test_get_console_url_tolerate_exception('spam')
class NovaClientPluginExtensionsTest(NovaClientPluginTestCase):
"""Tests for extensions in novaclient."""
def test_has_no_extensions(self):
self.nova_client.list_extensions.show_all.return_value = []
self.assertFalse(self.nova_plugin.has_extension(
"os-virtual-interfaces"))
def test_has_no_interface_extensions(self):
mock_extension = mock.Mock()
p = mock.PropertyMock(return_value='os-xxxx')
type(mock_extension).alias = p
self.nova_client.list_extensions.show_all.return_value = [
mock_extension]
self.assertFalse(self.nova_plugin.has_extension(
"os-virtual-interfaces"))
def test_has_os_interface_extension(self):
mock_extension = mock.Mock()
p = mock.PropertyMock(return_value='os-virtual-interfaces')
type(mock_extension).alias = p
self.nova_client.list_extensions.show_all.return_value = [
mock_extension]
self.assertTrue(self.nova_plugin.has_extension(
"os-virtual-interfaces"))

View File

@ -363,6 +363,19 @@ class FakeSessionClient(base_client.SessionClient):
'id': 3, 'name': 'm1.large', 'ram': 512, 'disk': 20,
'OS-FLV-EXT-DATA:ephemeral': 30}})
#
# Interfaces
#
def get_servers_5678_os_interface(self, **kw):
return (200, {'interfaceAttachments':
[{"fixed_ips":
[{"ip_address": "10.0.0.1",
"subnet_id": "f8a6e8f8-c2ec-497c-9f23-da9616de54ef"
}],
"port_id": "ce531f90-199f-48c0-816c-13e38010b442"
}]})
#
# Floating ips
#

View File

@ -13,7 +13,6 @@
import mock
from heat.engine.clients.os import nova as novac
from heat.engine import stack
from heat.engine import template
from heat.tests import common
@ -42,8 +41,6 @@ flavor_template = {
class NovaFlavorTest(common.HeatTestCase):
def setUp(self):
super(NovaFlavorTest, self).setUp()
self.patchobject(novac.NovaClientPlugin, 'has_extension',
return_value=True)
self.ctx = utils.dummy_context()
def create_flavor(self, with_name_id=False, is_public=True):

View File

@ -39,9 +39,6 @@ AGGREGATE_TEMPLATE = {
class NovaHostAggregateTest(common.HeatTestCase):
def setUp(self):
super(NovaHostAggregateTest, self).setUp()
self.patchobject(nova.NovaClientPlugin,
'has_extension',
return_value=True)
self.ctx = utils.dummy_context()
self.stack = stack.Stack(

View File

@ -46,8 +46,6 @@ class NovaKeyPairTest(common.HeatTestCase):
self.fake_nova = mock.MagicMock()
self.fake_keypairs = mock.MagicMock()
self.fake_nova.keypairs = self.fake_keypairs
self.patchobject(nova.NovaClientPlugin, 'has_extension',
return_value=True)
self.cp_mock = self.patchobject(nova.NovaClientPlugin, 'client',
return_value=self.fake_nova)

View File

@ -16,7 +16,6 @@ import six
from heat.common import exception
from heat.common import template_format
from heat.engine.clients.os import keystone as k_plugin
from heat.engine.clients.os import nova as n_plugin
from heat.engine import rsrc_defn
from heat.engine import stack as parser
from heat.engine import template
@ -62,8 +61,6 @@ class NovaQuotaTest(common.HeatTestCase):
super(NovaQuotaTest, self).setUp()
self.ctx = utils.dummy_context()
self.patchobject(n_plugin.NovaClientPlugin, 'has_extension',
return_value=True)
self.patchobject(k_plugin.KeystoneClientPlugin, 'get_project_id',
return_value='some_project_id')
tpl = template_format.parse(quota_template)

View File

@ -1349,8 +1349,6 @@ class ServersTest(common.HeatTestCase):
}
}
'''
self.patchobject(nova.NovaClientPlugin, 'has_extension',
return_value=True)
t = template_format.parse(nova_keypair_template)
templ = template.Template(t)
self.patchobject(nova.NovaClientPlugin, 'client',
@ -4947,7 +4945,6 @@ class ServerInternalPortTest(ServersTest):
server.client = mock.Mock()
server.client().servers.get.return_value = Fake()
server.client_plugin = mock.Mock()
server.client_plugin().has_extension.return_value = True
server._data = {"internal_ports": '[{"id": "1122"}]',
"external_ports": '[{"id": "3344"},{"id": "5566"}]'}
@ -5220,28 +5217,3 @@ class ServerInternalPortTest(ServersTest):
mock.call('prev_rsrc', 1122),
mock.call('prev_rsrc', 3344),
mock.call('prev_rsrc', 5566)])
def test_store_external_ports_os_interface_not_installed(self):
t, stack, server = self._return_template_stack_and_rsrc_defn(
'test', tmpl_server_with_network_id)
class Fake(object):
def interface_list(self):
return [iface('1122'),
iface('1122'),
iface('2233'),
iface('3344')]
server.client = mock.Mock()
server.client().servers.get.return_value = Fake()
server.client_plugin = mock.Mock()
server.client_plugin().has_extension.return_value = False
server._data = {"internal_ports": '[{"id": "1122"}]',
"external_ports": '[{"id": "3344"},{"id": "5566"}]'}
iface = collections.namedtuple('iface', ['port_id'])
update_data = self.patchobject(server, '_data_update_ports')
server.store_external_ports()
self.assertEqual(0, update_data.call_count)

View File

@ -16,7 +16,6 @@ import json
import mock
from heat.common import template_format
from heat.engine.clients.os import nova
from heat.engine import scheduler
from heat.tests import common
from heat.tests import utils
@ -44,8 +43,6 @@ class FakeGroup(object):
class NovaServerGroupTest(common.HeatTestCase):
def setUp(self):
super(NovaServerGroupTest, self).setUp()
self.patchobject(nova.NovaClientPlugin, 'has_extension',
return_value=True)
def _init_template(self, sg_template):
template = template_format.parse(json.dumps(sg_template))

View File

@ -0,0 +1,6 @@
---
upgrade:
- |
Nova has removed api extension support and its api bindings.
Heat has now removed support for extensions from nova client
plugin and the resource plugins using it.