From b213a25c44c0d49edefaa17d3a4de7a88c3c2de0 Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Wed, 4 Jan 2017 09:35:19 -0500 Subject: [PATCH] Remove NovaNetworkPlugin Nova network was deprecated in Newton and is no longer supported for regular deployments in Ocata [1]. Complete the removal of nova network support from manila begun in [2] by removing support for ''nova_net_id`` in the share networks API, by removing the corresponding column from the share networks DB model, and by removing the nova network plugins themselves. Unit tests for share network api views were refactored to remove redundancy while extending coverage to the new microversion introduced with this patch and maintaining full coverage of earlier microversions. APIImpact DocImpact UpgradeImpact Partially-implements: bp remove-nova-net-plugin [1] http://docs.openstack.org/releasenotes/nova/unreleased.html [2] I846b760fa7c01f7f86768399a2bfad9ced7e57cd Change-Id: I8b9a559fbea61979f01737ed1dc272276c4f1269 --- api-ref/source/parameters.yaml | 27 +- ...network-add-security-service-response.json | 1 - .../share-network-create-response.json | 1 - ...work-remove-security-service-response.json | 1 - .../samples/share-network-show-response.json | 1 - .../share-network-update-response.json | 1 - ...share-networks-list-detailed-response.json | 3 - api-ref/source/share-networks.inc | 12 +- manila/api/openstack/api_version_request.py | 4 +- .../openstack/rest_api_version_history.rst | 5 + manila/api/v1/router.py | 2 +- manila/api/v2/router.py | 2 +- manila/api/{v1 => v2}/share_networks.py | 27 +- manila/api/views/share_networks.py | 7 +- ...0_remove_nova_net_id_column_from_share_.py | 36 ++ manila/db/sqlalchemy/models.py | 1 - .../network/neutron/neutron_network_plugin.py | 4 - manila/network/nova_network_plugin.py | 228 ------------ manila/network/standalone_network_plugin.py | 2 +- manila/opts.py | 2 - manila/share/manager.py | 1 - .../api/{v1 => v2}/test_share_networks.py | 28 +- manila/tests/api/views/test_share_networks.py | 243 +++++-------- .../alembic/migrations_data_checks.py | 35 ++ .../network/neutron/test_neutron_plugin.py | 32 -- .../tests/network/test_nova_network_plugin.py | 343 ------------------ .../share/drivers/huawei/test_huawei_nas.py | 1 - .../cluster_mode/test_lib_multi_svm.py | 11 - manila/tests/share/test_manager.py | 2 - manila_tempest_tests/config.py | 2 +- .../tests/api/test_share_networks_negative.py | 1 - ...nova-network-support-f5bcb8b2fcd38581.yaml | 5 + 32 files changed, 223 insertions(+), 848 deletions(-) rename manila/api/{v1 => v2}/share_networks.py (93%) create mode 100644 manila/db/migrations/alembic/versions/95e3cf760840_remove_nova_net_id_column_from_share_.py delete mode 100644 manila/network/nova_network_plugin.py rename manila/tests/api/{v1 => v2}/test_share_networks.py (96%) delete mode 100644 manila/tests/network/test_nova_network_plugin.py create mode 100644 releasenotes/notes/remove-nova-network-support-f5bcb8b2fcd38581.yaml diff --git a/api-ref/source/parameters.yaml b/api-ref/source/parameters.yaml index 51d4543b22..abdc35c713 100644 --- a/api-ref/source/parameters.yaml +++ b/api-ref/source/parameters.yaml @@ -1951,9 +1951,9 @@ neutron_net_id: type: string neutron_net_id_1: description: | - The UUID of the neutron network to set up for - share servers. You can set up either a neutron network and subnet - or a nova network. + The UUID of a neutron network when setting up a share network + with neutron. Specify both a neutron network and a neutron + subnet that belongs to that neutron network. in: body required: false type: string @@ -1965,10 +1965,9 @@ neutron_subnet_id: type: string neutron_subnet_id_1: description: | - The UUID of the neutron subnet to set up for - share servers. This subnet must be part of the neutron network. - You can set up either a neutron network and subnet or a nova - network. + The UUID of the neutron subnet when setting up a share network + with neutron. Specify both a neutron network and a neutron + subnet that belongs to that neutron network. in: body required: false type: string @@ -1996,20 +1995,6 @@ notify: in: body required: true type: string -nova_net_id: - description: | - The nova network ID. - in: body - required: true - type: string -nova_net_id_1: - description: | - The UUID of the nova network to set up for share - servers. You can set up either a neutron network and subnet or a - nova network. - in: body - required: false - type: string os-force_delete: description: | The ``force_delete`` object. diff --git a/api-ref/source/samples/share-network-add-security-service-response.json b/api-ref/source/samples/share-network-add-security-service-response.json index 32c13657a3..acc0d336c2 100644 --- a/api-ref/source/samples/share-network-add-security-service-response.json +++ b/api-ref/source/samples/share-network-add-security-service-response.json @@ -8,7 +8,6 @@ "id": "d8ae6799-2567-4a89-aafb-fa4424350d2b", "neutron_net_id": null, "ip_version": null, - "nova_net_id": "998b42ee-2cee-4d36-8b95-67b5ca1f2109", "cidr": null, "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", "network_type": null, diff --git a/api-ref/source/samples/share-network-create-response.json b/api-ref/source/samples/share-network-create-response.json index 81bdabcf58..84dead1752 100644 --- a/api-ref/source/samples/share-network-create-response.json +++ b/api-ref/source/samples/share-network-create-response.json @@ -8,7 +8,6 @@ "id": "77eb3421-4549-4789-ac39-0d5185d68c29", "neutron_net_id": "998b42ee-2cee-4d36-8b95-67b5ca1f2109", "ip_version": null, - "nova_net_id": null, "cidr": null, "project_id": "e10a683c20da41248cfd5e1ab3d88c62", "network_type": null, diff --git a/api-ref/source/samples/share-network-remove-security-service-response.json b/api-ref/source/samples/share-network-remove-security-service-response.json index 32c13657a3..acc0d336c2 100644 --- a/api-ref/source/samples/share-network-remove-security-service-response.json +++ b/api-ref/source/samples/share-network-remove-security-service-response.json @@ -8,7 +8,6 @@ "id": "d8ae6799-2567-4a89-aafb-fa4424350d2b", "neutron_net_id": null, "ip_version": null, - "nova_net_id": "998b42ee-2cee-4d36-8b95-67b5ca1f2109", "cidr": null, "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", "network_type": null, diff --git a/api-ref/source/samples/share-network-show-response.json b/api-ref/source/samples/share-network-show-response.json index 5a94c78f75..00d2c93e39 100644 --- a/api-ref/source/samples/share-network-show-response.json +++ b/api-ref/source/samples/share-network-show-response.json @@ -8,7 +8,6 @@ "id": "7f950b52-6141-4a08-bbb5-bb7ffa3ea5fd", "neutron_net_id": "998b42ee-2cee-4d36-8b95-67b5ca1f2109", "ip_version": null, - "nova_net_id": null, "cidr": null, "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", "network_type": null, diff --git a/api-ref/source/samples/share-network-update-response.json b/api-ref/source/samples/share-network-update-response.json index c606f62d8a..75cc817831 100644 --- a/api-ref/source/samples/share-network-update-response.json +++ b/api-ref/source/samples/share-network-update-response.json @@ -8,7 +8,6 @@ "id": "713df749-aac0-4a54-af52-10f6c991e80c", "neutron_net_id": "998b42ee-2cee-4d36-8b95-67b5ca1f2109", "ip_version": "4", - "nova_net_id": null, "cidr": null, "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", "network_type": null, diff --git a/api-ref/source/samples/share-networks-list-detailed-response.json b/api-ref/source/samples/share-networks-list-detailed-response.json index a36cebe89e..53147d752f 100644 --- a/api-ref/source/samples/share-networks-list-detailed-response.json +++ b/api-ref/source/samples/share-networks-list-detailed-response.json @@ -9,7 +9,6 @@ "id": "32763294-e3d4-456a-998d-60047677c2fb", "neutron_net_id": "998b42ee-2cee-4d36-8b95-67b5ca1f2109", "ip_version": null, - "nova_net_id": null, "cidr": null, "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", "network_type": null, @@ -24,7 +23,6 @@ "id": "713df749-aac0-4a54-af52-10f6c991e80c", "neutron_net_id": "998b42ee-2cee-4d36-8b95-67b5ca1f2109", "ip_version": null, - "nova_net_id": null, "cidr": null, "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", "network_type": null, @@ -39,7 +37,6 @@ "id": "fa158a3d-6d9f-4187-9ca5-abbb82646eb2", "neutron_net_id": null, "ip_version": null, - "nova_net_id": null, "cidr": null, "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", "network_type": null, diff --git a/api-ref/source/share-networks.inc b/api-ref/source/share-networks.inc index 99fa266dcc..8a1cd810ee 100644 --- a/api-ref/source/share-networks.inc +++ b/api-ref/source/share-networks.inc @@ -12,12 +12,11 @@ access the share. You can create, update, view, and delete a share network. -When you create a share network, you can specify only one type of -network: +When you create a share network, you may optionally specify an associated +neutron network and subnetwork: - Neutron network. Specify a network ID and subnet ID. -- Nova network. Specify a network ID. For more information about supported plug-ins for share networks, see `Manila Network Plugins = + api_version.APIVersionRequest('2.18')) + mtu_support = (api_version.APIVersionRequest(microversion) >= + api_version.APIVersionRequest('2.20')) + nova_net_support = (api_version.APIVersionRequest(microversion) < + api_version.APIVersionRequest('2.26')) + req = fakes.HTTPRequest.blank('/share-networks', version=microversion) + expected_keys = { 'id', 'name', 'project_id', 'created_at', 'updated_at', - 'neutron_net_id', 'neutron_subnet_id', 'nova_net_id', - 'network_type', 'segmentation_id', 'cidr', 'ip_version', - 'gateway', 'description') - - result = self.builder.build_share_network(req, sn) + 'neutron_net_id', 'neutron_subnet_id', 'network_type', + 'segmentation_id', 'cidr', 'ip_version', 'description'} + if gateway_support: + expected_keys.add('gateway') + if mtu_support: + expected_keys.add('mtu') + if nova_net_support: + expected_keys.add('nova_net_id') + result = self.builder.build_share_network(req, share_network_data) self.assertEqual(1, len(result)) self.assertIn('share_network', result) - self.assertEqual(sn['id'], result['share_network']['id']) - self.assertEqual(sn['name'], result['share_network']['name']) - self.assertEqual(len(expected_keys), len(result['share_network'])) - for key in expected_keys: - self.assertIn(key, result['share_network']) - - @ddt.data( - [], - [dict(id='fake_id', - name='fake_name', - project_id='fake_project_id', - created_at='fake_created_at', - updated_at='fake_updated_at', - neutron_net_id='fake_neutron_net_id', - neutron_subnet_id='fake_neutron_subnet_id', - nova_net_id='fake_nova_net_id', - network_type='fake_network_type', - segmentation_id='fake_segmentation_id', - cidr='fake_cidr', - ip_version='fake_ip_version', - gateway='fake_gateway', - description='fake_description'), - dict(id='fake_id2', name='fake_name2')], - ) - def test_build_share_networks_with_details_v_2_18(self, share_networks): - req = fakes.HTTPRequest.blank('/share-networks', version="2.18") - expected = [] - for share_network in share_networks: - expected.append(dict( - id=share_network.get('id'), - name=share_network.get('name'), - project_id=share_network.get('project_id'), - created_at=share_network.get('created_at'), - updated_at=share_network.get('updated_at'), - neutron_net_id=share_network.get('neutron_net_id'), - neutron_subnet_id=share_network.get('neutron_subnet_id'), - nova_net_id=share_network.get('nova_net_id'), - network_type=share_network.get('network_type'), - segmentation_id=share_network.get('segmentation_id'), - cidr=share_network.get('cidr'), - ip_version=share_network.get('ip_version'), - gateway=share_network.get('gateway'), - description=share_network.get('description'))) - expected = {'share_networks': expected} - - result = self.builder.build_share_networks( - req, share_networks, True) - - self.assertEqual(expected, result) - - @ddt.data( - [], - [{'id': 'foo', 'name': 'bar'}], - [{'id': 'id1', 'name': 'name1'}, {'id': 'id2', 'name': 'name2'}], - [{'id': 'id1', 'name': 'name1'}, - {'id': 'id2', 'name': 'name2', 'fake': 'I should not be returned'}], - ) - def test_build_share_networks_without_details_v_2_18(self, - share_networks): - req = fakes.HTTPRequest.blank('/share-networks', version="2.18") - expected = [] - for share_network in share_networks: - expected.append(dict( - id=share_network.get('id'), name=share_network.get('name'))) - expected = {'share_networks': expected} - - result = self.builder.build_share_networks( - req, share_networks, False) - - self.assertEqual(expected, result) - - @ddt.data( - {'id': 'fake_sn_id', 'name': 'fake_sn_name'}, - {'id': 'fake_sn_id', 'name': 'fake_sn_name', 'fake_extra_key': 'foo'}, - ) - def test_build_share_network_v_2_20(self, sn): - req = fakes.HTTPRequest.blank('/share-networks', version="2.20") - expected_keys = ( - 'id', 'name', 'project_id', 'created_at', 'updated_at', - 'neutron_net_id', 'neutron_subnet_id', 'nova_net_id', - 'network_type', 'segmentation_id', 'cidr', 'ip_version', - 'gateway', 'description', 'mtu') - - result = self.builder.build_share_network(req, sn) - - self.assertEqual(1, len(result)) - self.assertIn('share_network', result) - self.assertEqual(sn['id'], result['share_network']['id']) - self.assertEqual(sn['name'], result['share_network']['name']) - self.assertEqual(len(expected_keys), len(result['share_network'])) + self.assertEqual(share_network_data['id'], + result['share_network']['id']) + self.assertEqual(share_network_data['name'], + result['share_network']['name']) + self.assertEqual(len(expected_keys), + len(result['share_network'])) for key in expected_keys: self.assertIn(key, result['share_network']) for key in result['share_network']: self.assertIn(key, expected_keys) - @ddt.data( - [], [{ - 'id': 'fake_id', - 'name': 'fake_name', - 'project_id': 'fake_project_id', - 'created_at': 'fake_created_at', - 'updated_at': 'fake_updated_at', - 'neutron_net_id': 'fake_neutron_net_id', - 'neutron_subnet_id': 'fake_neutron_subnet_id', - 'nova_net_id': 'fake_nova_net_id', - 'network_type': 'fake_network_type', - 'segmentation_id': 'fake_segmentation_id', - 'cidr': 'fake_cidr', - 'ip_version': 'fake_ip_version', - 'gateway': 'fake_gateway', - 'description': 'fake_description', - 'mtu': 1509 - }, - { - 'id': 'fake_id2', - 'name': 'fake_name2' - }], + @ddt.data(*itertools.product( + [ + [], + [{'id': 'fake_id', + 'name': 'fake_name', + 'project_id': 'fake_project_id', + 'created_at': 'fake_created_at', + 'updated_at': 'fake_updated_at', + 'neutron_net_id': 'fake_neutron_net_id', + 'neutron_subnet_id': 'fake_neutron_subnet_id', + 'network_type': 'fake_network_type', + 'segmentation_id': 'fake_segmentation_id', + 'cidr': 'fake_cidr', + 'ip_version': 'fake_ip_version', + 'description': 'fake_description'}, + {'id': 'fake_id2', + 'name': 'fake_name2'}], + ], + set(["1.0", "2.0", "2.18", "2.20", "2.25", "2.26", + api_version._MAX_API_VERSION])) ) - def test_build_share_networks_with_details_v_2_20(self, share_networks): - req = fakes.HTTPRequest.blank('/share-networks', version="2.20") - expected = [] + @ddt.unpack + def test_build_share_networks_with_details(self, share_networks, + microversion): + gateway_support = (api_version.APIVersionRequest(microversion) >= + api_version.APIVersionRequest('2.18')) + mtu_support = (api_version.APIVersionRequest(microversion) >= + api_version.APIVersionRequest('2.20')) + nova_net_support = (api_version.APIVersionRequest(microversion) < + api_version.APIVersionRequest('2.26')) + req = fakes.HTTPRequest.blank('/share-networks', version=microversion) + expected_networks_list = [] for share_network in share_networks: - expected.append({ + expected_data = { 'id': share_network.get('id'), 'name': share_network.get('name'), 'project_id': share_network.get('project_id'), @@ -176,32 +116,45 @@ class ViewBuilderTestCase(test.TestCase): 'updated_at': share_network.get('updated_at'), 'neutron_net_id': share_network.get('neutron_net_id'), 'neutron_subnet_id': share_network.get('neutron_subnet_id'), - 'nova_net_id': share_network.get('nova_net_id'), 'network_type': share_network.get('network_type'), 'segmentation_id': share_network.get('segmentation_id'), 'cidr': share_network.get('cidr'), 'ip_version': share_network.get('ip_version'), - 'gateway': share_network.get('gateway'), 'description': share_network.get('description'), - 'mtu': share_network.get('mtu'), - }) - expected = {'share_networks': expected} + } + if gateway_support: + share_network.update({'gateway': 'fake_gateway'}) + expected_data.update({'gateway': share_network.get('gateway')}) + if mtu_support: + share_network.update({'mtu': 1509}) + expected_data.update({'mtu': share_network.get('mtu')}) + if nova_net_support: + share_network.update({'nova_net_id': 'fake_nova_net_id'}) + expected_data.update({'nova_net_id': None}) + expected_networks_list.append(expected_data) + expected = {'share_networks': expected_networks_list} - result = self.builder.build_share_networks( - req, share_networks, True) + result = self.builder.build_share_networks(req, share_networks, + is_detail=True) self.assertEqual(expected, result) - @ddt.data( - [], - [{'id': 'foo', 'name': 'bar'}], - [{'id': 'id1', 'name': 'name1'}, {'id': 'id2', 'name': 'name2'}], - [{'id': 'id1', 'name': 'name1'}, - {'id': 'id2', 'name': 'name2', 'fake': 'I should not be returned'}], + @ddt.data(*itertools.product( + [ + [], + [{'id': 'foo', 'name': 'bar'}], + [{'id': 'id1', 'name': 'name1'}, {'id': 'id2', 'name': 'name2'}], + [{'id': 'id1', 'name': 'name1'}, + {'id': 'id2', 'name': 'name2', + 'fake': 'I should not be returned'}] + ], + set(["1.0", "2.0", "2.18", "2.20", "2.25", "2.26", + api_version._MAX_API_VERSION])) ) - def test_build_share_networks_without_details_v_2_20(self, - share_networks): - req = fakes.HTTPRequest.blank('/share-networks', version="2.20") + @ddt.unpack + def test_build_share_networks_without_details(self, share_networks, + microversion): + req = fakes.HTTPRequest.blank('/share-networks', version=microversion) expected = [] for share_network in share_networks: expected.append({ @@ -210,7 +163,7 @@ class ViewBuilderTestCase(test.TestCase): }) expected = {'share_networks': expected} - result = self.builder.build_share_networks( - req, share_networks, False) + result = self.builder.build_share_networks(req, share_networks, + is_detail=False) self.assertEqual(expected, result) diff --git a/manila/tests/db/migrations/alembic/migrations_data_checks.py b/manila/tests/db/migrations/alembic/migrations_data_checks.py index 4891ebe63b..742e32cc0f 100644 --- a/manila/tests/db/migrations/alembic/migrations_data_checks.py +++ b/manila/tests/db/migrations/alembic/migrations_data_checks.py @@ -1331,3 +1331,38 @@ class CreateFromSnapshotExtraSpecAndShareColumn(BaseMigrationChecks): if x['spec_key'] == self.expected_attr and x['share_type_id'] == share_type_id] self.test_case.assertEqual(0, len(new_extra_spec)) + + +@map_to_migration('95e3cf760840') +class RemoveNovaNetIdColumnFromShareNetworks(BaseMigrationChecks): + table_name = 'share_networks' + nova_net_column_name = 'nova_net_id' + + def setup_upgrade_data(self, engine): + user_id = 'user_id' + project_id = 'project_id' + nova_net_id = 'foo_nova_net_id' + + share_network_data = { + 'id': 'foo_share_network_id_3', + 'user_id': user_id, + 'project_id': project_id, + 'nova_net_id': nova_net_id, + } + sn_table = utils.load_table(self.table_name, engine) + engine.execute(sn_table.insert(share_network_data)) + + def check_upgrade(self, engine, data): + sn_table = utils.load_table(self.table_name, engine) + rows = engine.execute(sn_table.select()) + self.test_case.assertGreater(rows.rowcount, 0) + for row in rows: + self.test_case.assertFalse(hasattr(row, self.nova_net_column_name)) + + def check_downgrade(self, engine): + sn_table = utils.load_table(self.table_name, engine) + rows = engine.execute(sn_table.select()) + self.test_case.assertGreater(rows.rowcount, 0) + for row in rows: + self.test_case.assertTrue(hasattr(row, self.nova_net_column_name)) + self.test_case.assertIsNone(row[self.nova_net_column_name]) diff --git a/manila/tests/network/neutron/test_neutron_plugin.py b/manila/tests/network/neutron/test_neutron_plugin.py index e994a9ddbb..a0db5d1f3b 100644 --- a/manila/tests/network/neutron/test_neutron_plugin.py +++ b/manila/tests/network/neutron/test_neutron_plugin.py @@ -612,22 +612,6 @@ class NeutronSingleNetworkPluginTest(test.TestCase): self.context, share_network) self.assertFalse(instance.db.share_network_update.called) - def test___update_share_network_net_data_nova_net_id_present(self): - instance = self._get_neutron_network_plugin_instance() - share_network = { - 'id': 'fake_share_network_id', - 'nova_net_id': 'foo', - } - self.mock_object( - instance.db, 'share_network_update', - mock.Mock(return_value=share_network)) - - self.assertRaises( - exception.NetworkBadConfigurationException, - instance._update_share_network_net_data, - self.context, share_network) - self.assertFalse(instance.db.share_network_update.called) - def test_allocate_network(self): self.mock_object(plugin.NeutronNetworkPlugin, 'allocate_network') plugin.NeutronNetworkPlugin.allocate_network.return_value = [ @@ -1196,22 +1180,6 @@ class NeutronBindSingleNetworkPluginTest(test.TestCase): self.context, share_network) self.assertFalse(instance.db.share_network_update.called) - def test___update_share_network_net_data_nova_net_id_present(self): - instance = self._get_neutron_single_network_plugin_instance() - share_network = { - 'id': 'fake_share_network_id', - 'nova_net_id': 'foo', - } - self.mock_object( - instance.db, 'share_network_update', - mock.Mock(return_value=share_network)) - - self.assertRaises( - exception.NetworkBadConfigurationException, - instance._update_share_network_net_data, - self.context, share_network) - self.assertFalse(instance.db.share_network_update.called) - def test_wait_for_bind(self): self.mock_object(self.bind_plugin.neutron_api, 'show_port') self.bind_plugin.neutron_api.show_port.return_value = fake_neutron_port diff --git a/manila/tests/network/test_nova_network_plugin.py b/manila/tests/network/test_nova_network_plugin.py deleted file mode 100644 index aa433cec9a..0000000000 --- a/manila/tests/network/test_nova_network_plugin.py +++ /dev/null @@ -1,343 +0,0 @@ -# Copyright 2015 Mirantis, Inc. -# All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import ddt -import mock - -from manila import context -from manila import exception -from manila.network import nova_network_plugin as plugin -from manila import test -from manila.tests import utils as test_utils - - -@ddt.ddt -class NovaNetworkPluginTest(test.TestCase): - - def setUp(self): - super(NovaNetworkPluginTest, self).setUp() - self.fake_context = context.RequestContext( - user_id='fake user', project_id='fake project', is_admin=False) - self.instance = plugin.NovaNetworkPlugin() - self.share_server = dict(id='fake_share_server_id') - self.share_network = dict( - id='fake_sn_id', nova_net_id='fake_nova_net_id') - - def test_allocate_network_get_zero(self): - share_network = 'fake_share_network' - - allocations = self.instance.allocate_network( - self.fake_context, self.share_server, share_network, count=0) - - self.assertEqual([], allocations) - self.assertTrue(hasattr(self.instance, 'label')) - self.assertEqual('user', self.instance.label) - - @ddt.data('flat', 'vlan') - def test_allocate_network_get_one(self, net_type): - def fake_get_ip_from_db(context, ip_addr): - return [] if ip_addr != '20.0.0.7' else ['fake not empty list'] - - def fake_fixed_ip_get(context, ip_addr): - if ip_addr == '20.0.0.8': - return dict(host='foo', hostname='bar') - return dict(host=None, hostname=None) - - share_network = dict(id='fake_sn_id', nova_net_id='fake_nova_net_id') - nova_net = dict( - cidr='20.0.0.0/24', cidr_v6=None, - gateway='20.0.0.1', gateway_v6=None, - dhcp_server='20.0.0.2', broadcast='20.0.0.255', - vpn_private_address='20.0.0.3', vpn_public_address='20.0.0.4', - dns1='20.0.0.5', dns2='20.0.0.6', vlan=None, mtu=1509) - if net_type == 'vlan': - nova_net['vlan'] = 100 - self.mock_object(self.instance.nova_api, 'fixed_ip_reserve') - self.mock_object( - self.instance.nova_api, 'fixed_ip_get', - mock.Mock(side_effect=fake_fixed_ip_get)) - self.mock_object( - self.instance.nova_api, 'network_get', - mock.Mock(return_value=nova_net)) - self.mock_object(self.instance.db, 'share_network_update') - self.mock_object( - self.instance.db, 'network_allocations_get_by_ip_address', - mock.Mock(side_effect=fake_get_ip_from_db)) - expected_ip_address = '20.0.0.9' - - allocations = self.instance.allocate_network( - self.fake_context, self.share_server, share_network) - - self.assertEqual(1, len(allocations)) - self.assertEqual( - self.share_server['id'], allocations[0]['share_server_id']) - self.assertEqual(expected_ip_address, allocations[0]['ip_address']) - self.instance.nova_api.network_get.assert_called_once_with( - self.instance.admin_context, share_network['nova_net_id']) - self.instance.nova_api.fixed_ip_reserve.assert_called_once_with( - self.instance.admin_context, expected_ip_address) - self.instance.db.share_network_update.assert_called_once_with( - self.fake_context, share_network['id'], - dict(cidr=nova_net['cidr'], gateway=nova_net['gateway'], - ip_version=4, segmentation_id=nova_net['vlan'], - network_type=net_type, mtu=1509)) - self.instance.db.network_allocations_get_by_ip_address.\ - assert_has_calls([ - mock.call(self.fake_context, '20.0.0.7'), - mock.call(self.fake_context, '20.0.0.8'), - mock.call(self.fake_context, '20.0.0.9')]) - self.instance.nova_api.fixed_ip_get.assert_has_calls([ - mock.call(self.instance.admin_context, '20.0.0.8'), - mock.call(self.instance.admin_context, '20.0.0.9')]) - - @ddt.data('flat', 'vlan') - def test_allocate_network_get_two(self, net_type): - def fake_get_ip_from_db(context, ip_addr): - return [] if ip_addr != '20.0.0.7' else ['fake not empty list'] - - def fake_fixed_ip_get(context, ip_addr): - if ip_addr == '20.0.0.8': - return dict(host='foo', hostname='bar') - return dict(host=None, hostname=None) - - nova_net = dict( - cidr='20.0.0.0/24', cidr_v6=None, - gateway='20.0.0.1', gateway_v6=None, - dhcp_server='20.0.0.254', broadcast='20.0.0.255', - vpn_private_address='20.0.0.3', vpn_public_address='20.0.0.4', - dns1='20.0.0.5', dns2='20.0.0.6', vlan=None, mtu=1509) - if net_type == 'vlan': - nova_net['vlan'] = 100 - self.mock_object(self.instance.nova_api, 'fixed_ip_reserve') - self.mock_object( - self.instance.nova_api, 'fixed_ip_get', - mock.Mock(side_effect=fake_fixed_ip_get)) - self.mock_object( - self.instance.nova_api, 'network_get', - mock.Mock(return_value=nova_net)) - self.mock_object(self.instance.db, 'share_network_update') - self.mock_object( - self.instance.db, 'network_allocations_get_by_ip_address', - mock.Mock(side_effect=fake_get_ip_from_db)) - expected_ip_address1 = '20.0.0.2' - expected_ip_address2 = '20.0.0.9' - - allocations = self.instance.allocate_network( - self.fake_context, self.share_server, self.share_network, count=2) - - self.assertEqual(2, len(allocations)) - for allocation in allocations: - self.assertEqual( - self.share_server['id'], allocation['share_server_id']) - self.assertEqual(expected_ip_address1, allocations[0]['ip_address']) - self.assertEqual(expected_ip_address2, allocations[1]['ip_address']) - self.instance.nova_api.network_get.assert_called_once_with( - self.instance.admin_context, self.share_network['nova_net_id']) - self.instance.nova_api.fixed_ip_reserve.assert_has_calls([ - mock.call(self.instance.admin_context, expected_ip_address1), - mock.call(self.instance.admin_context, expected_ip_address2)]) - self.instance.db.share_network_update.assert_called_once_with( - self.fake_context, self.share_network['id'], - dict(cidr=nova_net['cidr'], gateway=nova_net['gateway'], - ip_version=4, segmentation_id=nova_net['vlan'], - network_type=net_type, mtu=1509)) - self.instance.db.network_allocations_get_by_ip_address.\ - assert_has_calls([ - mock.call(self.fake_context, '20.0.0.2'), - mock.call(self.fake_context, '20.0.0.7'), - mock.call(self.fake_context, '20.0.0.8'), - mock.call(self.fake_context, '20.0.0.9')]) - self.instance.nova_api.fixed_ip_get.assert_has_calls([ - mock.call(self.instance.admin_context, '20.0.0.2'), - mock.call(self.instance.admin_context, '20.0.0.8'), - mock.call(self.instance.admin_context, '20.0.0.9')]) - - def test_allocate_network_nova_net_id_no_available_ips_left(self): - nova_net = dict( - id='fake_net_id', cidr='20.0.0.0/24', cidr_v6=None, - gateway='20.0.0.1', gateway_v6=None, - dhcp_server='20.0.0.2', broadcast='20.0.0.255', - vpn_private_address='20.0.0.3', vpn_public_address='20.0.0.4', - dns1='20.0.0.5', dns2='20.0.0.6', vlan=100, mtu=1509) - self.mock_object( - self.instance.nova_api, 'network_get', - mock.Mock(return_value=nova_net)) - self.mock_object(self.instance.db, 'share_network_update') - self.mock_object( - self.instance.db, 'network_allocations_get_by_ip_address', - mock.Mock(return_value=['fake not empty list'])) - - self.assertRaises( - exception.NetworkBadConfigurationException, - self.instance.allocate_network, - self.fake_context, self.share_server, self.share_network) - - self.instance.nova_api.network_get.assert_called_once_with( - self.instance.admin_context, self.share_network['nova_net_id']) - self.instance.db.share_network_update.assert_called_once_with( - self.fake_context, self.share_network['id'], - dict(cidr=nova_net['cidr'], gateway=nova_net['gateway'], - ip_version=4, segmentation_id=nova_net['vlan'], - network_type='vlan', mtu=1509)) - self.assertEqual( - 248, - self.instance.db.network_allocations_get_by_ip_address.call_count) - - @ddt.data(dict(), dict(nova_net_id=None)) - def test_allocate_network_nova_net_id_is_not_provided(self, share_network): - self.assertRaises( - exception.NetworkException, - self.instance.allocate_network, - self.fake_context, self.share_server, share_network) - - def test_deallocate_network(self): - fake_alloc = dict(id='fake_alloc_id', ip_address='fake_ip_address') - self.mock_object(self.instance.nova_api, 'fixed_ip_unreserve') - self.mock_object(self.instance.db, 'network_allocation_delete') - self.mock_object( - self.instance.db, 'network_allocations_get_for_share_server', - mock.Mock(return_value=[fake_alloc])) - - self.instance.deallocate_network( - self.fake_context, self.share_server['id']) - - self.instance.db.network_allocations_get_for_share_server.\ - assert_called_once_with( - self.fake_context, self.share_server['id']) - self.instance.db.network_allocation_delete.assert_called_once_with( - self.fake_context, fake_alloc['id']) - self.instance.nova_api.fixed_ip_unreserve.assert_called_once_with( - self.instance.admin_context, fake_alloc['ip_address']) - - -@ddt.ddt -class NovaSingleNetworkPluginTest(test.TestCase): - - def setUp(self): - super(NovaSingleNetworkPluginTest, self).setUp() - self.share_server = dict(id='fake_share_server_id') - self.context = context.RequestContext( - user_id='fake user', project_id='fake project', is_admin=False) - - def _get_instance(self, label=None): - nova_net_id = 'fake_nova_net_id' - config_data = dict( - DEFAULT=dict(nova_single_network_plugin_net_id=nova_net_id)) - with test_utils.create_temp_config_with_opts(config_data): - return plugin.NovaSingleNetworkPlugin(label=label) - - def test_init_valid(self): - nova_net_id = 'fake_nova_net_id' - config_data = dict( - DEFAULT=dict(nova_single_network_plugin_net_id=nova_net_id)) - with test_utils.create_temp_config_with_opts(config_data): - instance = plugin.NovaSingleNetworkPlugin() - self.assertEqual(nova_net_id, instance.net_id) - - @ddt.data(dict(), dict(net='')) - def test_init_invalid(self, data): - config_data = dict(DEFAULT=data) - with test_utils.create_temp_config_with_opts(config_data): - self.assertRaises( - exception.NetworkBadConfigurationException, - plugin.NovaSingleNetworkPlugin) - - def test_allocate_network_net_is_not_set_in_share_network(self): - instance = self._get_instance() - share_network = dict(id='fake_share_network') - updated_share_network = dict(id='fake_updated_share_network') - allocations = ['foo', 'bar'] - self.mock_object( - instance.db, 'share_network_update', - mock.Mock(return_value=updated_share_network)) - self.mock_object( - instance, '_allocate_network', mock.Mock(return_value=allocations)) - - result = instance.allocate_network( - self.context, self.share_server, share_network, count=2) - - self.assertEqual(allocations, result) - instance.db.share_network_update.assert_called_once_with( - self.context, share_network['id'], - dict(nova_net_id='fake_nova_net_id')) - instance._allocate_network.assert_called_once_with( - self.context, self.share_server, updated_share_network, count=2) - - def test_allocate_network_net_is_set_in_share_network(self): - instance = self._get_instance() - share_network = dict( - id='fake_share_network', nova_net_id='fake_nova_net_id') - allocations = ['foo', 'bar'] - self.mock_object(instance.db, 'share_network_update') - self.mock_object( - instance, '_allocate_network', mock.Mock(return_value=allocations)) - - result = instance.allocate_network( - self.context, self.share_server, share_network, count=2) - - self.assertEqual(allocations, result) - instance.db.share_network_update.assert_has_calls([]) - instance._allocate_network.assert_called_once_with( - self.context, self.share_server, share_network, count=2) - - def test_allocate_network_with_admin_label(self): - instance = self._get_instance(label='admin') - allocations = ['foo', 'bar'] - self.mock_object(instance.db, 'share_network_update') - self.mock_object( - instance, '_allocate_network', mock.Mock(return_value=allocations)) - fake_share_network = {'nova_net_id': 'fake_nova_net_id'} - - result = instance.allocate_network( - self.context, self.share_server, fake_share_network, count=2) - - self.assertTrue(hasattr(instance, 'label')) - self.assertEqual('admin', instance.label) - self.assertEqual(allocations, result) - instance.db.share_network_update.assert_has_calls([]) - instance._allocate_network.assert_called_once_with( - self.context, self.share_server, fake_share_network, count=2) - - def test_allocate_network_different_nova_net_id_is_set(self): - instance = self._get_instance() - share_network = dict( - id='fake_share_network', nova_net_id='foobar') - self.mock_object(instance.db, 'share_network_update') - self.mock_object(instance, '_allocate_network') - - self.assertRaises( - exception.NetworkBadConfigurationException, - instance.allocate_network, - self.context, self.share_server, share_network, count=3) - - instance.db.share_network_update.assert_has_calls([]) - instance._allocate_network.assert_has_calls([]) - - @ddt.data( - dict(id='foo', neutron_net_id='bar'), - dict(id='foo', neutron_subnet_id='quuz'), - dict(id='foo', neutron_net_id='bar', neutron_subnet_id='quuz')) - def test_allocate_network_neutron_data_exist(self, sn): - instance = self._get_instance() - self.mock_object(instance.db, 'share_network_update') - self.mock_object(instance, '_allocate_network') - - self.assertRaises( - exception.NetworkBadConfigurationException, - instance.allocate_network, - self.context, self.share_server, sn, count=3) - - instance.db.share_network_update.assert_has_calls([]) - instance._allocate_network.assert_has_calls([]) diff --git a/manila/tests/share/drivers/huawei/test_huawei_nas.py b/manila/tests/share/drivers/huawei/test_huawei_nas.py index 73a5118a71..44f2354495 100644 --- a/manila/tests/share/drivers/huawei/test_huawei_nas.py +++ b/manila/tests/share/drivers/huawei/test_huawei_nas.py @@ -1187,7 +1187,6 @@ class HuaweiShareDriverTestCase(test.TestCase): 'cidr': '111.111.111.0/24', 'neutron_net_id': 'fake_neutron_net_id', 'neutron_subnet_id': 'fake_neutron_subnet_id', - 'nova_net_id': '', 'security_services': '', 'network_allocations': self.fake_network_allocations, 'network_type': 'vlan', diff --git a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py index b59883f70b..7cf69c322a 100644 --- a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py +++ b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py @@ -420,17 +420,6 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): self.assertEqual('Default', result) - def test_create_ipspace_not_neutron(self): - - self.library._client.features.IPSPACES = True - network_info = copy.deepcopy(fake.NETWORK_INFO) - network_info['neutron_subnet_id'] = None - network_info['nova_net_id'] = 'fake_nova_net_id' - - result = self.library._create_ipspace(network_info) - - self.assertEqual('Default', result) - def test_create_ipspace_already_present(self): self.library._client.features.IPSPACES = True diff --git a/manila/tests/share/test_manager.py b/manila/tests/share/test_manager.py index 9d542b4ef5..54c4c04d97 100644 --- a/manila/tests/share/test_manager.py +++ b/manila/tests/share/test_manager.py @@ -2796,7 +2796,6 @@ class ShareManagerTestCase(test.TestCase): cidr='fake_cidr', neutron_net_id='fake_neutron_net_id', neutron_subnet_id='fake_neutron_subnet_id', - nova_net_id='fake_nova_net_id', security_services='fake_security_services', network_type='fake_network_type') expected = dict( @@ -2805,7 +2804,6 @@ class ShareManagerTestCase(test.TestCase): cidr=fake_share_network['cidr'], neutron_net_id=fake_share_network['neutron_net_id'], neutron_subnet_id=fake_share_network['neutron_subnet_id'], - nova_net_id=fake_share_network['nova_net_id'], security_services=fake_share_network['security_services'], network_allocations=( fake_network_allocations_get_for_share_server()), diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py index 1cd553edc2..aebe1254d6 100644 --- a/manila_tempest_tests/config.py +++ b/manila_tempest_tests/config.py @@ -30,7 +30,7 @@ ShareGroup = [ help="The minimum api microversion is configured to be the " "value of the minimum microversion supported by Manila."), cfg.StrOpt("max_api_microversion", - default="2.25", + default="2.26", help="The maximum api microversion is configured to be the " "value of the latest microversion supported by Manila."), cfg.StrOpt("region", diff --git a/manila_tempest_tests/tests/api/test_share_networks_negative.py b/manila_tempest_tests/tests/api/test_share_networks_negative.py index 4c40857d6a..0ec9407eae 100644 --- a/manila_tempest_tests/tests/api/test_share_networks_negative.py +++ b/manila_tempest_tests/tests/api/test_share_networks_negative.py @@ -118,7 +118,6 @@ class ShareNetworksNegativeTest(base.BaseSharesTest): new_sn = self.create_share_network( neutron_net_id=share_network['neutron_net_id'], neutron_subnet_id=share_network['neutron_subnet_id'], - nova_net_id=share_network['nova_net_id'], cleanup_in_class=False) # Create share with share network diff --git a/releasenotes/notes/remove-nova-network-support-f5bcb8b2fcd38581.yaml b/releasenotes/notes/remove-nova-network-support-f5bcb8b2fcd38581.yaml new file mode 100644 index 0000000000..0cc3cb8a91 --- /dev/null +++ b/releasenotes/notes/remove-nova-network-support-f5bcb8b2fcd38581.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - Removed support for ``nova_net_id`` in share_networks API and in the + ShareNetwork DB model. Also removed the nova network plugins themselves + and corresponding manila.conf options.