[NetApp] Fix share server migration

SVM Migration was failing using NetApp driver after changes on share server structure,
since now the share server can have more than one subnet.

This patch fix all the errors related to this change.

Closes-bug: #2018300
Change-Id: I9eae95ff3f66a3497b00ca582491afec58ae6dc3
This commit is contained in:
MatheusAndrade777 2023-05-02 13:26:35 +00:00
parent 15b4b39eb5
commit a934499834
4 changed files with 31 additions and 16 deletions

View File

@ -1200,7 +1200,7 @@ class NetAppCmodeMultiSVMFileStorageLibrary(
'network_allocations': 'network_allocations':
source_share_server['network_allocations'], source_share_server['network_allocations'],
'neutron_subnet_id': 'neutron_subnet_id':
source_share_server['share_network_subnet'].get( source_share_server['share_network_subnets'][0].get(
'neutron_subnet_id') 'neutron_subnet_id')
} }
@ -1339,6 +1339,15 @@ class NetAppCmodeMultiSVMFileStorageLibrary(
LOG.error(msg) LOG.error(msg)
return not_compatible 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() pools = self._get_pools()
# NOTE(dviroel): These clients can only be used for non-tunneling # 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 # Manila haven't made new allocations, we can just get allocation data
# from the source share server. # from the source share server.
if not dest_share_server['network_allocations']: if not dest_share_server['network_allocations']:
share_server_to_get_network_info = source_share_server share_server_network_info = source_share_server
else: 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 # Reuse network information from the source share server in the SVM
# Migrate if the there was no share network changes. # Migrate if the there was no share network changes.
network_info = { network_info = {
'network_allocations': 'network_allocations':
share_server_to_get_network_info['network_allocations'], share_server_network_info['network_allocations'],
'neutron_subnet_id': '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') 'neutron_subnet_id')
} }

View File

@ -2353,7 +2353,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'network_allocations': 'network_allocations':
self.fake_src_share_server['network_allocations'], self.fake_src_share_server['network_allocations'],
'neutron_subnet_id': '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') 'neutron_subnet_id')
} }
self.mock_object(self.library._client, 'list_cluster_nodes', self.mock_object(self.library._client, 'list_cluster_nodes',
@ -2400,7 +2400,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'network_allocations': 'network_allocations':
self.fake_src_share_server['network_allocations'], self.fake_src_share_server['network_allocations'],
'neutron_subnet_id': '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') 'neutron_subnet_id')
} }
@ -2689,8 +2689,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'network_allocations': 'network_allocations':
server_to_get_network_info['network_allocations'], server_to_get_network_info['network_allocations'],
'neutron_subnet_id': 'neutron_subnet_id':
server_to_get_network_info['share_network_subnet'][ server_to_get_network_info['share_network_subnets'][0].get(
'neutron_subnet_id'] 'neutron_subnet_id')
} }
mock_list_cluster_nodes = self.mock_object( mock_list_cluster_nodes = self.mock_object(
@ -2756,8 +2756,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
'network_allocations': 'network_allocations':
server_to_get_network_info['network_allocations'], server_to_get_network_info['network_allocations'],
'neutron_subnet_id': 'neutron_subnet_id':
server_to_get_network_info['share_network_subnet'][ server_to_get_network_info['share_network_subnets'][0].get(
'neutron_subnet_id'] 'neutron_subnet_id')
} }
mock_list_cluster_nodes = self.mock_object( mock_list_cluster_nodes = self.mock_object(

View File

@ -574,10 +574,10 @@ SHARE_SERVER = {
'network_allocations': (USER_NETWORK_ALLOCATIONS + 'network_allocations': (USER_NETWORK_ALLOCATIONS +
ADMIN_NETWORK_ALLOCATIONS), ADMIN_NETWORK_ALLOCATIONS),
'host': SERVER_HOST, 'host': SERVER_HOST,
'share_network_subnet': { 'share_network_subnets': [{
'neutron_net_id': 'fake_neutron_net_id', 'neutron_net_id': 'fake_neutron_net_id',
'neutron_subnet_id': 'fake_neutron_subnet_id' 'neutron_subnet_id': 'fake_neutron_subnet_id'
} }]
} }
SHARE_SERVER_2 = { SHARE_SERVER_2 = {
@ -589,10 +589,10 @@ SHARE_SERVER_2 = {
'network_allocations': (USER_NETWORK_ALLOCATIONS + 'network_allocations': (USER_NETWORK_ALLOCATIONS +
ADMIN_NETWORK_ALLOCATIONS), ADMIN_NETWORK_ALLOCATIONS),
'host': SERVER_HOST_2, 'host': SERVER_HOST_2,
'share_network_subnet': { 'share_network_subnets': [{
'neutron_net_id': 'fake_neutron_net_id_2', 'neutron_net_id': 'fake_neutron_net_id_2',
'neutron_subnet_id': 'fake_neutron_subnet_id_2' 'neutron_subnet_id': 'fake_neutron_subnet_id_2'
} }]
} }
VSERVER_INFO = { VSERVER_INFO = {
@ -1783,7 +1783,7 @@ SHARE_NETWORK = {
'name': 'fake_name', 'name': 'fake_name',
'description': 'fake_description', 'description': 'fake_description',
'security_services': [CIFS_SECURITY_SERVICE], 'security_services': [CIFS_SECURITY_SERVICE],
'subnets': [SHARE_NETWORK_SUBNET], 'share_network_subnets': [SHARE_NETWORK_SUBNET],
} }
SHARE_TYPE_2 = copy.deepcopy(SHARE_TYPE) SHARE_TYPE_2 = copy.deepcopy(SHARE_TYPE)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Netapp driver: Fix Netapp share server migration with multiple subnets.
For more details please refer to
`launchpad bug #2018300 <https://bugs.launchpad.net/manila/+bug/2018300>`