Skip to content

Commit 0c0c5bf

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "[NetApp] Enabling total_volumes capability support" into stable/2025.1
2 parents aaa7fa4 + b1a0af2 commit 0c0c5bf

13 files changed

Lines changed: 144 additions & 8 deletions

cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_cmode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,6 +3480,7 @@ def test_get_lun_sizes_by_volume(self):
34803480
'query': {
34813481
'lun-info': {
34823482
'volume': fake.NETAPP_VOLUME,
3483+
'vserver': fake_client.VSERVER_NAME
34833484
}
34843485
},
34853486
'desired-attributes': {

cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_cmode_rest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ def test_get_lun_sizes_by_volume(self):
800800
volume_name = fake_client.VOLUME_NAME
801801
query = {
802802
'location.volume.name': volume_name,
803+
'svm.name': fake_client.VSERVER_NAME,
803804
'fields': 'space.size,name'
804805
}
805806
response = fake_client.LUN_GET_ITER_REST
@@ -823,8 +824,10 @@ def test_get_lun_sizes_by_volume(self):
823824

824825
def test_get_lun_sizes_by_volume_no_records(self):
825826
volume_name = fake_client.VOLUME_NAME
827+
vserver = fake_client.VSERVER_NAME
826828
query = {
827829
'location.volume.name': volume_name,
830+
'svm.name': vserver,
828831
'fields': 'space.size,name'
829832
}
830833
response = fake_client.NO_RECORDS_RESPONSE_REST
@@ -4022,6 +4025,7 @@ def test_get_namespace_sizes_by_volume(self):
40224025

40234026
fake_query = {
40244027
'location.volume.name': 'fake_volume',
4028+
'svm.name': fake_client.VSERVER_NAME,
40254029
'fields': 'space.size,name'
40264030
}
40274031

@@ -4049,6 +4053,7 @@ def test_get_namespace_sizes_by_volume_no_response(self):
40494053

40504054
fake_query = {
40514055
'location.volume.name': 'fake_volume',
4056+
'svm.name': fake_client.VSERVER_NAME,
40524057
'fields': 'space.size,name'
40534058
}
40544059

cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ def test_get_pool_stats(self, replication_backends, cluster_credentials,
499499
'replication_enabled': False,
500500
'online_extend_support': True,
501501
'netapp_is_flexgroup': 'false',
502+
'total_volumes': 2,
502503
}]
503504
if report_provisioned_capacity:
504505
expected[0].update({'provisioned_capacity_gb': 5.0})

cinder/tests/unit/volume/drivers/netapp/dataontap/test_nvme_library.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ def test_get_pool_stats(self, cluster_credentials,
617617
'netapp_disk_type': 'SSD',
618618
'online_extend_support': False,
619619
'netapp_is_flexgroup': 'false',
620+
'total_volumes': 2,
620621
}]
621622
if report_provisioned_capacity:
622623
expected[0].update({'provisioned_capacity_gb': 5.0})

cinder/tests/unit/volume/drivers/netapp/dataontap/utils/fakes.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,37 @@
110110
},
111111
}
112112

113+
SSC_VOLUME_COUNT_INFO = {
114+
'volume1': {
115+
'total_volumes': 3,
116+
},
117+
'volume2': {
118+
'total_volumes': 2,
119+
},
120+
}
121+
122+
SSC_LUNS_BY_SIZES = [
123+
{
124+
'path': '/vol/volume-ae947c9b-2392-4956-b373-aaac4521f37e',
125+
'size': 5368709120.0
126+
},
127+
{
128+
'path': '/vol/snapshot-527eedad-a431-483d-b0ca-18995dd65b66',
129+
'size': 1073741824.0
130+
}
131+
]
132+
133+
SSC_NAMESPACES_BY_SIZES = [
134+
{
135+
'path': '/vol/namespace-ae947c9b-2392-4956-b373-aaac4521f37e',
136+
'size': 5379821234.0
137+
},
138+
{
139+
'path': '/vol/namespace-527eedad-a431-483d-b0ca-18995dd65b66',
140+
'size': 4673741874.0
141+
}
142+
]
143+
113144
SSC_MIRROR_INFO = {
114145
'volume1': {
115146
'netapp_mirrored': 'false',

cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_capabilities.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def setUp(self):
3838
self.ssc_library = capabilities.CapabilitiesLibrary(
3939
'iSCSI', fake.SSC_VSERVER, self.zapi_client, self.configuration)
4040
self.ssc_library.ssc = fake.SSC
41+
self.ssc_library_nvme = capabilities.CapabilitiesLibrary(
42+
'NVMe', fake.SSC_VSERVER, self.zapi_client, self.configuration)
4143

4244
def get_config_cmode(self):
4345
config = na_fakes.create_configuration_cmode()
@@ -88,7 +90,8 @@ def test_is_qos_min_supported_not_found(self):
8890

8991
self.assertFalse(result)
9092

91-
def test_update_ssc(self):
93+
@ddt.data('nfs', 'iscsi')
94+
def test_update_ssc(self, protocol):
9295

9396
mock_get_ssc_flexvol_info = self.mock_object(
9497
self.ssc_library, '_get_ssc_flexvol_info',
@@ -114,13 +117,29 @@ def test_update_ssc(self):
114117
self.ssc_library, '_get_ssc_qos_min_info',
115118
side_effect=[fake.SSC_QOS_MIN_INFO['volume1'],
116119
fake.SSC_QOS_MIN_INFO['volume2']])
120+
if protocol != 'nfs':
121+
mock_get_ssc_volume_count_info = self.mock_object(
122+
self.ssc_library, '_get_ssc_volume_count_info',
123+
side_effect=[fake.SSC_QOS_MIN_INFO['volume1'],
124+
fake.SSC_QOS_MIN_INFO['volume2']])
125+
else:
126+
mock_get_ssc_volume_count_info = self.mock_object(
127+
self.ssc_library, '_get_ssc_volume_count_info',
128+
side_effect=None)
117129

118130
ordered_ssc = collections.OrderedDict()
119131
ordered_ssc['volume1'] = fake.SSC_VOLUME_MAP['volume1']
120132
ordered_ssc['volume2'] = fake.SSC_VOLUME_MAP['volume2']
121133

122134
result = self.ssc_library.update_ssc(ordered_ssc)
123135

136+
if protocol != 'nfs':
137+
mock_get_ssc_volume_count_info.assert_has_calls([
138+
mock.call('volume1'), mock.call('volume2')])
139+
else:
140+
self.ssc_library._get_ssc_volume_count_info(fake.SSC_VOLUMES[0]).\
141+
assert_not_called()
142+
124143
self.assertIsNone(result)
125144
self.assertEqual(fake.SSC, self.ssc_library.ssc)
126145
mock_get_ssc_flexvol_info.assert_has_calls([
@@ -543,6 +562,35 @@ def test_get_ssc_qos_min_info_flexgroup(self, qos_min_support):
543562
self.zapi_client.is_qos_min_supported.assert_called_once_with(False,
544563
'node')
545564

565+
@ddt.data('iscsi', 'fc', 'nvme')
566+
def test_get_ssc_volume_count_info(self, protocol):
567+
568+
self.ssc_library = self.ssc_library_nvme if protocol == 'nvme' else \
569+
self.ssc_library
570+
571+
self.mock_object(self.ssc_library.zapi_client,
572+
'get_namespace_sizes_by_volume',
573+
return_value=fake.SSC_NAMESPACES_BY_SIZES)
574+
575+
self.mock_object(self.ssc_library.zapi_client,
576+
'get_lun_sizes_by_volume',
577+
return_value=fake.SSC_LUNS_BY_SIZES)
578+
579+
result = self.ssc_library._get_ssc_volume_count_info(
580+
fake_client.VOLUME_NAMES[0])
581+
582+
expected = {'total_volumes': 2}
583+
self.assertEqual(expected, result)
584+
585+
if protocol != 'nvme':
586+
self.zapi_client.get_lun_sizes_by_volume.\
587+
assert_called_once_with(fake_client.VOLUME_NAMES[0])
588+
self.zapi_client.get_namespace_sizes_by_volume.assert_not_called()
589+
else:
590+
self.zapi_client.get_namespace_sizes_by_volume.\
591+
assert_called_once_with(fake_client.VOLUME_NAMES[0])
592+
self.zapi_client.get_lun_sizes_by_volume.assert_not_called()
593+
546594
@ddt.data(True, False)
547595
def test_is_flexgroup(self, is_fg):
548596
pool_name = 'fake_pool'

cinder/volume/drivers/netapp/dataontap/block_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class NetAppBlockStorageLibrary(
8787
'xen', 'hyper_v']
8888
DEFAULT_LUN_OS = 'linux'
8989
DEFAULT_HOST_TYPE = 'linux'
90-
DEFAULT_FILTER_FUNCTION = 'capabilities.utilization < 70'
90+
DEFAULT_FILTER_FUNCTION = ('capabilities.utilization < 70 and '
91+
'capabilities.total_volumes < 1024')
9192
DEFAULT_GOODNESS_FUNCTION = '100 - capabilities.utilization'
9293

9394
def __init__(self, driver_name, driver_protocol, **kwargs):

cinder/volume/drivers/netapp/dataontap/block_cmode.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,10 @@ def _get_pool_stats(self, filter_function=None, goodness_function=None):
338338
size_available_gb = capacity['size-available'] / units.Gi
339339
pool['free_capacity_gb'] = na_utils.round_down(size_available_gb)
340340

341+
luns = self.zapi_client.get_lun_sizes_by_volume(
342+
ssc_vol_name)
343+
pool['total_volumes'] = len(luns)
341344
if self.configuration.netapp_driver_reports_provisioned_capacity:
342-
luns = self.zapi_client.get_lun_sizes_by_volume(
343-
ssc_vol_name)
344345
provisioned_cap = 0
345346
for lun in luns:
346347
lun_name = lun['path'].split('/')[-1]

cinder/volume/drivers/netapp/dataontap/client/client_cmode.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,8 @@ def get_lun_sizes_by_volume(self, volume_name):
441441
api_args = {
442442
'query': {
443443
'lun-info': {
444-
'volume': volume_name
444+
'volume': volume_name,
445+
'vserver': self.vserver
445446
}
446447
},
447448
'desired-attributes': {

cinder/volume/drivers/netapp/dataontap/client/client_cmode_rest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ def get_lun_sizes_by_volume(self, volume_name):
770770

771771
query = {
772772
'location.volume.name': volume_name,
773+
'svm.name': self.vserver,
773774
'fields': 'space.size,name'
774775
}
775776

@@ -2772,6 +2773,7 @@ def get_namespace_sizes_by_volume(self, volume_name):
27722773

27732774
query = {
27742775
'location.volume.name': volume_name,
2776+
'svm.name': self.vserver,
27752777
'fields': 'space.size,name'
27762778
}
27772779
response = self.send_request('/storage/namespaces', 'get', query=query)

0 commit comments

Comments
 (0)