Check NetApp SnapRestore license for pools

Added check to validate SnapRestore license for
NetApp ONTAP pools before setting revert_to_snapshot_support
to true/false for the respective pool.
This was always set to True before.

Change-Id: I4750d28c8acfe6d68a91e129e767c6e8607e6a75
Closes-Bug: #1678524
This commit is contained in:
Naresh Kumar Gunjalli 2019-01-21 11:36:44 -05:00
parent 1ac6370943
commit f333b88e25
3 changed files with 38 additions and 1 deletions

View File

@ -252,6 +252,14 @@ class NetAppCmodeFileStorageLibrary(object):
else:
return self._client.get_vserver_aggregate_capacities(aggregates)
@na_utils.trace
def _check_snaprestore_license(self):
"""Check if snaprestore license is enabled."""
if not self._licenses:
self._licenses = self._client.get_licenses()
return 'snaprestore' in self._licenses
@na_utils.trace
def _get_aggregate_node(self, aggregate_name):
"""Get home node for the specified aggregate, or None."""
@ -323,6 +331,8 @@ class NetAppCmodeFileStorageLibrary(object):
netapp_flexvol_encryption = self._cluster_info.get(
'nve_support', False)
revert_to_snapshot_support = self._check_snaprestore_license()
for aggr_name in sorted(aggregates):
reserved_percentage = self.configuration.reserved_share_percentage
@ -352,7 +362,7 @@ class NetAppCmodeFileStorageLibrary(object):
'thin_provisioning': [True, False],
'snapshot_support': True,
'create_share_from_snapshot_support': True,
'revert_to_snapshot_support': True,
'revert_to_snapshot_support': revert_to_snapshot_support,
}
# Add storage service catalog data.

View File

@ -329,6 +329,22 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
assert_called_once_with(fake.AGGREGATES))
self.assertDictEqual(fake.AGGREGATE_CAPACITIES, result)
def test_check_snaprestore_license_notfound(self):
licenses = list(fake.LICENSES)
licenses.remove('snaprestore')
self.mock_object(self.client,
'get_licenses',
mock.Mock(return_value=licenses))
result = self.library._check_snaprestore_license()
self.assertIs(False, result)
def test_check_snaprestore_license_found(self):
self.mock_object(self.client,
'get_licenses',
mock.Mock(return_value=fake.LICENSES))
result = self.library._check_snaprestore_license()
self.assertIs(True, result)
def test_get_aggregate_node_cluster_creds(self):
self.library._have_cluster_creds = True
@ -433,6 +449,9 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
self.library._ssc_stats = fake.SSC_INFO
self.library._perf_library.get_node_utilization_for_pool = (
mock.Mock(side_effect=[30.0, 42.0]))
self.mock_object(self.library,
'_check_snaprestore_license',
mock.Mock(return_value=True))
result = self.library._get_pools(filter_function='filter',
goodness_function='goodness')
@ -449,6 +468,9 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
self.library._ssc_stats = fake.SSC_INFO_VSERVER_CREDS
self.library._perf_library.get_node_utilization_for_pool = (
mock.Mock(side_effect=[50.0, 50.0]))
self.mock_object(self.library,
'_check_snaprestore_license',
mock.Mock(return_value=True))
result = self.library._get_pools()

View File

@ -0,0 +1,5 @@
---
fixes:
- The NetApp ONTAP driver is now fixed to set
revert_to_snapshot_support to True or False
depending upon SnapRestore License.