diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py index cc6266adea..0520d0f8b5 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py @@ -1200,7 +1200,7 @@ class NetAppCmodeMultiSVMFileStorageLibrary( 'network_allocations': source_share_server['network_allocations'], 'neutron_subnet_id': - source_share_server['share_network_subnet'].get( + source_share_server['share_network_subnets'][0].get( 'neutron_subnet_id') } @@ -1339,6 +1339,15 @@ class NetAppCmodeMultiSVMFileStorageLibrary( LOG.error(msg) return not_compatible + # Blocking multiple subnets + new_subnets = new_share_network.get('share_network_subnets', []) + old_subnets = old_share_network.get('share_network_subnets', []) + if (len(new_subnets) != 1) or (len(old_subnets) != 1): + msg = _("Cannot perform server migration for share network" + "with multiple subnets.") + LOG.error(msg) + return not_compatible + pools = self._get_pools() # NOTE(dviroel): These clients can only be used for non-tunneling @@ -1468,17 +1477,17 @@ class NetAppCmodeMultiSVMFileStorageLibrary( # Manila haven't made new allocations, we can just get allocation data # from the source share server. if not dest_share_server['network_allocations']: - share_server_to_get_network_info = source_share_server + share_server_network_info = source_share_server else: - share_server_to_get_network_info = dest_share_server + share_server_network_info = dest_share_server # Reuse network information from the source share server in the SVM # Migrate if the there was no share network changes. network_info = { 'network_allocations': - share_server_to_get_network_info['network_allocations'], + share_server_network_info['network_allocations'], 'neutron_subnet_id': - share_server_to_get_network_info['share_network_subnet'].get( + share_server_network_info['share_network_subnets'][0].get( 'neutron_subnet_id') } 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 6868007952..1b527b3a1f 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 @@ -2353,7 +2353,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): 'network_allocations': self.fake_src_share_server['network_allocations'], 'neutron_subnet_id': - self.fake_src_share_server['share_network_subnet'].get( + self.fake_src_share_server['share_network_subnets'][0].get( 'neutron_subnet_id') } self.mock_object(self.library._client, 'list_cluster_nodes', @@ -2400,7 +2400,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): 'network_allocations': self.fake_src_share_server['network_allocations'], 'neutron_subnet_id': - self.fake_src_share_server['share_network_subnet'].get( + self.fake_src_share_server['share_network_subnets'][0].get( 'neutron_subnet_id') } @@ -2689,8 +2689,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): 'network_allocations': server_to_get_network_info['network_allocations'], 'neutron_subnet_id': - server_to_get_network_info['share_network_subnet'][ - 'neutron_subnet_id'] + server_to_get_network_info['share_network_subnets'][0].get( + 'neutron_subnet_id') } mock_list_cluster_nodes = self.mock_object( @@ -2756,8 +2756,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): 'network_allocations': server_to_get_network_info['network_allocations'], 'neutron_subnet_id': - server_to_get_network_info['share_network_subnet'][ - 'neutron_subnet_id'] + server_to_get_network_info['share_network_subnets'][0].get( + 'neutron_subnet_id') } mock_list_cluster_nodes = self.mock_object( diff --git a/manila/tests/share/drivers/netapp/dataontap/fakes.py b/manila/tests/share/drivers/netapp/dataontap/fakes.py index 675f558179..86dddea151 100644 --- a/manila/tests/share/drivers/netapp/dataontap/fakes.py +++ b/manila/tests/share/drivers/netapp/dataontap/fakes.py @@ -575,10 +575,10 @@ SHARE_SERVER = { 'network_allocations': (USER_NETWORK_ALLOCATIONS + ADMIN_NETWORK_ALLOCATIONS), 'host': SERVER_HOST, - 'share_network_subnet': { + 'share_network_subnets': [{ 'neutron_net_id': 'fake_neutron_net_id', 'neutron_subnet_id': 'fake_neutron_subnet_id' - } + }] } SHARE_SERVER_2 = { @@ -590,10 +590,10 @@ SHARE_SERVER_2 = { 'network_allocations': (USER_NETWORK_ALLOCATIONS + ADMIN_NETWORK_ALLOCATIONS), 'host': SERVER_HOST_2, - 'share_network_subnet': { + 'share_network_subnets': [{ 'neutron_net_id': 'fake_neutron_net_id_2', 'neutron_subnet_id': 'fake_neutron_subnet_id_2' - } + }] } VSERVER_INFO = { @@ -1784,7 +1784,7 @@ SHARE_NETWORK = { 'name': 'fake_name', 'description': 'fake_description', 'security_services': [CIFS_SECURITY_SERVICE], - 'subnets': [SHARE_NETWORK_SUBNET], + 'share_network_subnets': [SHARE_NETWORK_SUBNET], } SHARE_TYPE_2 = copy.deepcopy(SHARE_TYPE) diff --git a/releasenotes/notes/fix-netApp-drivers-share-server-migration-is-failing-eee991ccbab4cd5a.yaml b/releasenotes/notes/fix-netApp-drivers-share-server-migration-is-failing-eee991ccbab4cd5a.yaml new file mode 100644 index 0000000000..cfb18fc3ed --- /dev/null +++ b/releasenotes/notes/fix-netApp-drivers-share-server-migration-is-failing-eee991ccbab4cd5a.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Netapp driver: Fix Netapp share server migration with multiple subnets. + For more details please refer to + `launchpad bug #2018300 `