Debian Codegraph @

ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_volume_api.py

raw symbols SCIP
1 # Copyright: (c) 2024, Dell Technologies
2
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 """
6 Mock Api response for Unit tests of volume module on Dell Technologies (Dell) PowerFlex
7 """
8
9 from __future__ import (absolute_import, division, print_function)
10 from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_storagepool_api import MockStoragePoolApi
11
12 __metaclass__ = type
13
14
15 class MockVolumeApi:
16 VOLUME_COMMON_ARGS = {
17 "hostname": "**.***.**.***",
18 "vol_name": None,
19 "vol_id": None,
20 "vol_type": None,
21 "compression_type": None,
22 "storage_pool_name": None,
23 "storage_pool_id": None,
24 "protection_domain_name": None,
25 "protection_domain_id": None,
26 "snapshot_policy_name": None,
27 "snapshot_policy_id": None,
28 "auto_snap_remove_type": None,
29 "use_rmcache": None,
30 "size": None,
31 "cap_unit": None,
32 "vol_new_name": None,
33 "sdc": {},
34 "sdc_state": None,
35 "delete_snapshots": None,
36 "state": None
37 }
38
39 VOLUME_GET_LIST = [
40 {
41 'storagePoolId': 'test_pool_id_1',
42 'dataLayout': 'MediumGranularity',
43 'vtreeId': 'vtree_id_1',
44 'sizeInKb': 8388608,
45 'snplIdOfAutoSnapshot': None,
46 'volumeType': 'ThinProvisioned',
47 'consistencyGroupId': None,
48 'ancestorVolumeId': None,
49 'notGenuineSnapshot': False,
50 'accessModeLimit': 'ReadWrite',
51 'secureSnapshotExpTime': 0,
52 'useRmcache': False,
53 'managedBy': 'ScaleIO',
54 'lockedAutoSnapshot': False,
55 'lockedAutoSnapshotMarkedForRemoval': False,
56 'autoSnapshotGroupId': None,
57 'compressionMethod': 'Invalid',
58 'pairIds': None,
59 'timeStampIsAccurate': False,
60 'mappedSdcInfo': None,
61 'originalExpiryTime': 0,
62 'retentionLevels': [
63 ],
64 'snplIdOfSourceVolume': "snplIdOfSourceVolume",
65 'snapshotPolicyId': 'snapshotPolicyId',
66 'snapshotPolicyName': 'snapshotPolicyName',
67 'volumeReplicationState': 'UnmarkedForReplication',
68 'replicationJournalVolume': False,
69 'replicationTimeStamp': 0,
70 'creationTime': 1655878090,
71 'name': 'testing',
72 'id': 'test_id_1'
73 }
74 ]
75
76 VOLUME_STORAGEPOOL_DETAILS = MockStoragePoolApi.STORAGE_POOL_GET_LIST[0]
77
78 VOLUME_PD_DETAILS = {
79 'rebalanceNetworkThrottlingEnabled': False,
80 'vtreeMigrationNetworkThrottlingEnabled': False,
81 'overallIoNetworkThrottlingEnabled': False,
82 'rfcacheEnabled': True,
83 'rfcacheAccpId': None,
84 'rebuildNetworkThrottlingEnabled': False,
85 'sdrSdsConnectivityInfo': {
86 'clientServerConnStatus': 'CLIENT_SERVER_CONN_STATUS_ALL_CONNECTED',
87 'disconnectedClientId': None,
88 'disconnectedClientName': None,
89 'disconnectedServerId': None,
90 'disconnectedServerName': None,
91 'disconnectedServerIp': None
92 },
93 'protectionDomainState': 'Active',
94 'rebuildNetworkThrottlingInKbps': None,
95 'rebalanceNetworkThrottlingInKbps': None,
96 'overallIoNetworkThrottlingInKbps': None,
97 'vtreeMigrationNetworkThrottlingInKbps': None,
98 'sdsDecoupledCounterParameters': {
99 'shortWindow': {
100 'threshold': 300,
101 'windowSizeInSec': 60
102 },
103 'mediumWindow': {
104 'threshold': 500,
105 'windowSizeInSec': 3600
106 },
107 'longWindow': {
108 'threshold': 700,
109 'windowSizeInSec': 86400
110 }
111 },
112 'sdsConfigurationFailureCounterParameters': {
113 'shortWindow': {
114 'threshold': 300,
115 'windowSizeInSec': 60
116 },
117 'mediumWindow': {
118 'threshold': 500,
119 'windowSizeInSec': 3600
120 },
121 'longWindow': {
122 'threshold': 700,
123 'windowSizeInSec': 86400
124 }
125 },
126 'mdmSdsNetworkDisconnectionsCounterParameters': {
127 'shortWindow': {
128 'threshold': 300,
129 'windowSizeInSec': 60
130 },
131 'mediumWindow': {
132 'threshold': 500,
133 'windowSizeInSec': 3600
134 },
135 'longWindow': {
136 'threshold': 700,
137 'windowSizeInSec': 86400
138 }
139 },
140 'sdsSdsNetworkDisconnectionsCounterParameters': {
141 'shortWindow': {
142 'threshold': 300,
143 'windowSizeInSec': 60
144 },
145 'mediumWindow': {
146 'threshold': 500,
147 'windowSizeInSec': 3600
148 },
149 'longWindow': {
150 'threshold': 700,
151 'windowSizeInSec': 86400
152 }
153 },
154 'rfcacheOpertionalMode': 'WriteMiss',
155 'rfcachePageSizeKb': 64,
156 'rfcacheMaxIoSizeKb': 128,
157 'sdsReceiveBufferAllocationFailuresCounterParameters': {
158 'shortWindow': {
159 'threshold': 20000,
160 'windowSizeInSec': 60
161 },
162 'mediumWindow': {
163 'threshold': 200000,
164 'windowSizeInSec': 3600
165 },
166 'longWindow': {
167 'threshold': 2000000,
168 'windowSizeInSec': 86400
169 }
170 },
171 'fglDefaultNumConcurrentWrites': 1000,
172 'fglMetadataCacheEnabled': False,
173 'fglDefaultMetadataCacheSize': 0,
174 'protectedMaintenanceModeNetworkThrottlingEnabled': False,
175 'protectedMaintenanceModeNetworkThrottlingInKbps': None,
176 'rplCapAlertLevel': 'normal',
177 'systemId': 'syst_id_1',
178 'name': 'domain1',
179 'id': '4eeb304600000000',
180 }
181
182 VOLUME_STATISTICS = {
183 'backgroundScanFixedReadErrorCount': 0,
184 'pendingMovingOutBckRebuildJobs': 0,
185 'degradedHealthyCapacityInKb': 0,
186 'activeMovingOutFwdRebuildJobs': 0,
187 'bckRebuildWriteBwc': {
188 'numSeconds': 0,
189 'totalWeightInKb': 0,
190 'numOccured': 0
191 },
192 'netFglUncompressedDataSizeInKb': 0,
193 'primaryReadFromDevBwc': {
194 'numSeconds': 0,
195 'totalWeightInKb': 0,
196 'numOccured': 0
197 },
198 'BackgroundScannedInMB': 3209584,
199 'volumeIds': [
200 '456ad22e00000003'
201 ],
202 'maxUserDataCapacityInKb': 761204736,
203 'persistentChecksumBuilderProgress': 100.0,
204 'rfcacheReadsSkippedAlignedSizeTooLarge': 0,
205 'pendingMovingInRebalanceJobs': 0,
206 'rfcacheWritesSkippedHeavyLoad': 0,
207 'unusedCapacityInKb': 761204736,
208 'userDataSdcReadLatency': {
209 'numSeconds': 0,
210 'totalWeightInKb': 0,
211 'numOccured': 0
212 },
213 'totalReadBwc': {
214 'numSeconds': 0,
215 'totalWeightInKb': 0,
216 'numOccured': 0
217 },
218 'numOfDeviceAtFaultRebuilds': 0,
219 'totalWriteBwc': {
220 'numSeconds': 0,
221 'totalWeightInKb': 0,
222 'numOccured': 0
223 },
224 'persistentChecksumCapacityInKb': 414720,
225 'rmPendingAllocatedInKb': 0,
226 'numOfVolumes': 1,
227 'rfcacheIosOutstanding': 0,
228 'capacityAvailableForVolumeAllocationInKb': 377487360,
229 'numOfMappedToAllVolumes': 0,
230 'netThinUserDataCapacityInKb': 0,
231 'backgroundScanFixedCompareErrorCount': 0,
232 'volMigrationWriteBwc': {
233 'numSeconds': 0,
234 'totalWeightInKb': 0,
235 'numOccured': 0
236 },
237 'thinAndSnapshotRatio': 'Infinity',
238 'fglUserDataCapacityInKb': 0,
239 'pendingMovingInEnterProtectedMaintenanceModeJobs': 0,
240 'activeMovingInNormRebuildJobs': 0,
241 'aggregateCompressionLevel': 'Uncompressed',
242 'targetOtherLatency': {
243 'numSeconds': 0,
244 'totalWeightInKb': 0,
245 'numOccured': 0
246 },
247 'netUserDataCapacityInKb': 0,
248 'pendingMovingOutExitProtectedMaintenanceModeJobs': 0,
249 'overallUsageRatio': 'Infinity',
250 'volMigrationReadBwc': {
251 'numSeconds': 0,
252 'totalWeightInKb': 0,
253 'numOccured': 0
254 },
255 'netCapacityInUseNoOverheadInKb': 0,
256 'pendingMovingInBckRebuildJobs': 0,
257 'rfcacheReadsSkippedInternalError': 0,
258 'activeBckRebuildCapacityInKb': 0,
259 'rebalanceCapacityInKb': 0,
260 'pendingMovingInExitProtectedMaintenanceModeJobs': 0,
261 'rfcacheReadsSkippedLowResources': 0,
262 'rplJournalCapAllowed': 0,
263 'thinCapacityInUseInKb': 0,
264 'userDataSdcTrimLatency': {
265 'numSeconds': 0,
266 'totalWeightInKb': 0,
267 'numOccured': 0
268 },
269 'activeMovingInEnterProtectedMaintenanceModeJobs': 0,
270 'rfcacheWritesSkippedInternalError': 0,
271 'netUserDataCapacityNoTrimInKb': 0,
272 'rfcacheWritesSkippedCacheMiss': 0,
273 'degradedFailedCapacityInKb': 0,
274 'activeNormRebuildCapacityInKb': 0,
275 'fglSparesInKb': 0,
276 'snapCapacityInUseInKb': 0,
277 'numOfMigratingVolumes': 0,
278 'compressionRatio': 0.0,
279 'rfcacheWriteMiss': 0,
280 'primaryReadFromRmcacheBwc': {
281 'numSeconds': 0,
282 'totalWeightInKb': 0,
283 'numOccured': 0
284 },
285 'migratingVtreeIds': [
286 ],
287 'numOfVtrees': 1,
288 'userDataCapacityNoTrimInKb': 0,
289 'rfacheReadHit': 0,
290 'compressedDataCompressionRatio': 0.0,
291 'rplUsedJournalCap': 0,
292 'pendingMovingCapacityInKb': 0,
293 'numOfSnapshots': 0,
294 'pendingFwdRebuildCapacityInKb': 0,
295 'tempCapacityInKb': 0,
296 'totalFglMigrationSizeInKb': 0,
297 'normRebuildCapacityInKb': 0,
298 'logWrittenBlocksInKb': 0,
299 'primaryWriteBwc': {
300 'numSeconds': 0,
301 'totalWeightInKb': 0,
302 'numOccured': 0
303 },
304 'numOfThickBaseVolumes': 0,
305 'enterProtectedMaintenanceModeReadBwc': {
306 'numSeconds': 0,
307 'totalWeightInKb': 0,
308 'numOccured': 0
309 },
310 'activeRebalanceCapacityInKb': 0,
311 'numOfReplicationJournalVolumes': 0,
312 'rfcacheReadsSkippedLockIos': 0,
313 'unreachableUnusedCapacityInKb': 0,
314 'netProvisionedAddressesInKb': 0,
315 'trimmedUserDataCapacityInKb': 0,
316 'provisionedAddressesInKb': 0,
317 'numOfVolumesInDeletion': 0,
318 'pendingMovingOutFwdRebuildJobs': 0,
319 'maxCapacityInKb': 845783040,
320 'rmPendingThickInKb': 0,
321 'protectedCapacityInKb': 0,
322 'secondaryWriteBwc': {
323 'numSeconds': 0,
324 'totalWeightInKb': 0,
325 'numOccured': 0
326 },
327 'normRebuildReadBwc': {
328 'numSeconds': 0,
329 'totalWeightInKb': 0,
330 'numOccured': 0
331 },
332 'thinCapacityAllocatedInKb': 16777216,
333 'netFglUserDataCapacityInKb': 0,
334 'metadataOverheadInKb': 0,
335 'thinCapacityAllocatedInKm': 16777216,
336 'rebalanceWriteBwc': {
337 'numSeconds': 0,
338 'totalWeightInKb': 0,
339 'numOccured': 0
340 },
341 'primaryVacInKb': 8388608,
342 'deviceIds': [
343 'bbd7580800030001',
344 'bbd4580a00040001',
345 'bbd5580b00050001'
346 ],
347 'netSnapshotCapacityInKb': 0,
348 'secondaryVacInKb': 8388608,
349 'numOfDevices': 3,
350 'rplTotalJournalCap': 0,
351 'failedCapacityInKb': 0,
352 'netMetadataOverheadInKb': 0,
353 'activeMovingOutBckRebuildJobs': 0,
354 'rfcacheReadsFromCache': 0,
355 'activeMovingOutEnterProtectedMaintenanceModeJobs': 0,
356 'enterProtectedMaintenanceModeCapacityInKb': 0,
357 'pendingMovingInNormRebuildJobs': 0,
358 'failedVacInKb': 0,
359 'primaryReadBwc': {
360 'numSeconds': 0,
361 'totalWeightInKb': 0,
362 'numOccured': 0
363 },
364 'fglUncompressedDataSizeInKb': 0,
365 'fglCompressedDataSizeInKb': 0,
366 'pendingRebalanceCapacityInKb': 0,
367 'rfcacheAvgReadTime': 0,
368 'semiProtectedCapacityInKb': 0,
369 'pendingMovingOutEnterProtectedMaintenanceModeJobs': 0,
370 'mgUserDdataCcapacityInKb': 0,
371 'snapshotCapacityInKb': 0,
372 'netMgUserDataCapacityInKb': 0,
373 'fwdRebuildReadBwc': {
374 'numSeconds': 0,
375 'totalWeightInKb': 0,
376 'numOccured': 0
377 },
378 'rfcacheWritesReceived': 0,
379 'netUnusedCapacityInKb': 380602368,
380 'thinUserDataCapacityInKb': 0,
381 'protectedVacInKb': 16777216,
382 'activeMovingRebalanceJobs': 0,
383 'bckRebuildCapacityInKb': 0,
384 'activeMovingInFwdRebuildJobs': 0,
385 'netTrimmedUserDataCapacityInKb': 0,
386 'pendingMovingRebalanceJobs': 0,
387 'numOfMarkedVolumesForReplication': 0,
388 'degradedHealthyVacInKb': 0,
389 'semiProtectedVacInKb': 0,
390 'userDataReadBwc': {
391 'numSeconds': 0,
392 'totalWeightInKb': 0,
393 'numOccured': 0
394 },
395 'pendingBckRebuildCapacityInKb': 0,
396 'capacityLimitInKb': 845783040,
397 'vtreeIds': [
398 '32b13de900000003'
399 ],
400 'activeMovingCapacityInKb': 0,
401 'targetWriteLatency': {
402 'numSeconds': 0,
403 'totalWeightInKb': 0,
404 'numOccured': 0
405 },
406 'pendingExitProtectedMaintenanceModeCapacityInKb': 0,
407 'rfcacheIosSkipped': 0,
408 'userDataWriteBwc': {
409 'numSeconds': 0,
410 'totalWeightInKb': 0,
411 'numOccured': 0
412 },
413 'inMaintenanceVacInKb': 0,
414 'exitProtectedMaintenanceModeReadBwc': {
415 'numSeconds': 0,
416 'totalWeightInKb': 0,
417 'numOccured': 0
418 },
419 'netFglSparesInKb': 0,
420 'rfcacheReadsSkipped': 0,
421 'activeExitProtectedMaintenanceModeCapacityInKb': 0,
422 'activeMovingOutExitProtectedMaintenanceModeJobs': 0,
423 'numOfUnmappedVolumes': 1,
424 'tempCapacityVacInKb': 0,
425 'volumeAddressSpaceInKb': 8388608,
426 'currentFglMigrationSizeInKb': 0,
427 'rfcacheWritesSkippedMaxIoSize': 0,
428 'netMaxUserDataCapacityInKb': 380602368,
429 'numOfMigratingVtrees': 0,
430 'atRestCapacityInKb': 0,
431 'rfacheWriteHit': 0,
432 'bckRebuildReadBwc': {
433 'numSeconds': 0,
434 'totalWeightInKb': 0,
435 'numOccured': 0
436 },
437 'rfcacheSourceDeviceWrites': 0,
438 'spareCapacityInKb': 84578304,
439 'enterProtectedMaintenanceModeWriteBwc': {
440 'numSeconds': 0,
441 'totalWeightInKb': 0,
442 'numOccured': 0
443 },
444 'rfcacheIoErrors': 0,
445 'inaccessibleCapacityInKb': 0,
446 'normRebuildWriteBwc': {
447 'numSeconds': 0,
448 'totalWeightInKb': 0,
449 'numOccured': 0
450 },
451 'capacityInUseInKb': 0,
452 'rebalanceReadBwc': {
453 'numSeconds': 0,
454 'totalWeightInKb': 0,
455 'numOccured': 0
456 },
457 'rfcacheReadsSkippedMaxIoSize': 0,
458 'activeMovingInExitProtectedMaintenanceModeJobs': 0,
459 'secondaryReadFromDevBwc': {
460 'numSeconds': 0,
461 'totalWeightInKb': 0,
462 'numOccured': 0
463 },
464 'secondaryReadBwc': {
465 'numSeconds': 0,
466 'totalWeightInKb': 0,
467 'numOccured': 0
468 },
469 'rfcacheWritesSkippedStuckIo': 0,
470 'secondaryReadFromRmcacheBwc': {
471 'numSeconds': 0,
472 'totalWeightInKb': 0,
473 'numOccured': 0
474 },
475 'inMaintenanceCapacityInKb': 0,
476 'exposedCapacityInKb': 0,
477 'netFglCompressedDataSizeInKb': 0,
478 'userDataSdcWriteLatency': {
479 'numSeconds': 0,
480 'totalWeightInKb': 0,
481 'numOccured': 0
482 },
483 'inUseVacInKb': 16777216,
484 'fwdRebuildCapacityInKb': 0,
485 'thickCapacityInUseInKb': 0,
486 'backgroundScanReadErrorCount': 0,
487 'activeMovingInRebalanceJobs': 0,
488 'migratingVolumeIds': [
489 ],
490 'rfcacheWritesSkippedLowResources': 0,
491 'capacityInUseNoOverheadInKb': 0,
492 'exitProtectedMaintenanceModeWriteBwc': {
493 'numSeconds': 0,
494 'totalWeightInKb': 0,
495 'numOccured': 0
496 },
497 'rfcacheSkippedUnlinedWrite': 0,
498 'netCapacityInUseInKb': 0,
499 'numOfOutgoingMigrations': 0,
500 'rfcacheAvgWriteTime': 0,
501 'pendingNormRebuildCapacityInKb': 0,
502 'pendingMovingOutNormrebuildJobs': 0,
503 'rfcacheSourceDeviceReads': 0,
504 'rfcacheReadsPending': 0,
505 'volumeAllocationLimitInKb': 3791650816,
506 'rfcacheReadsSkippedHeavyLoad': 0,
507 'fwdRebuildWriteBwc': {
508 'numSeconds': 0,
509 'totalWeightInKb': 0,
510 'numOccured': 0
511 },
512 'rfcacheReadMiss': 0,
513 'targetReadLatency': {
514 'numSeconds': 0,
515 'totalWeightInKb': 0,
516 'numOccured': 0
517 },
518 'userDataCapacityInKb': 0,
519 'activeMovingInBckRebuildJobs': 0,
520 'movingCapacityInKb': 0,
521 'activeEnterProtectedMaintenanceModeCapacityInKb': 0,
522 'backgroundScanCompareErrorCount': 0,
523 'pendingMovingInFwdRebuildJobs': 0,
524 'rfcacheReadsReceived': 0,
525 'spSdsIds': [
526 'abdfe71b00030001',
527 'abdce71d00040001',
528 'abdde71e00050001'
529 ],
530 'pendingEnterProtectedMaintenanceModeCapacityInKb': 0,
531 'vtreeAddresSpaceInKb': 8388608,
532 'snapCapacityInUseOccupiedInKb': 0,
533 'activeFwdRebuildCapacityInKb': 0,
534 'rfcacheReadsSkippedStuckIo': 0,
535 'activeMovingOutNormRebuildJobs': 0,
536 'rfcacheWritePending': 0,
537 'numOfThinBaseVolumes': 1,
538 'degradedFailedVacInKb': 0,
539 'userDataTrimBwc': {
540 'numSeconds': 0,
541 'totalWeightInKb': 0,
542 'numOccured': 0
543 },
544 'numOfIncomingVtreeMigrations': 0
545 }
546
547 SDC_RESPONSE = [
548 {
549 'id': 'abdfe71b00030001',
550 }
551 ]
552
553 SDC_RESPONSE_EMPTY = []
554
555 GET_STORAGE_POOL = {
556 'dataLayout': 'MediumGranularity'
557 }
558
559 GET_STORAGE_POOL_FINE = {
560 'dataLayout': 'FineGranularity',
561 }
562
563 PROTECTION_DETAILS = [{"pd_id": "pd_id", "pd_name": "pd_name"}]
564
565 GET_ID = {"id": "e0d8f6c900000000"}
566 PROTECTION_DETAILS_MULTI = [
567 {"pd_id": "pd_id", "pd_name": "pd_name"},
568 {"pd_id": "pd_id", "pd_name": "pd_name"},
569 ]
570
571 RESPONSE_EXEC_DICT = {
572 'get_details': "Failed to get the volume test_id_1 with error ",
573 'get_sds': "Failed to get the SDC sdc_name with error ",
574 'create_vol_name': "Please provide valid volume name.",
575 'create_vol_size': "Size is a mandatory parameter",
576 'create_vol_ctype': "compression_type for volume can only be",
577 'create_vol_exc': "Create volume vol_name operation failed with error",
578 'modify_access': "Modify access mode of SDC operation failed",
579 'modify_limits': "Modify bandwidth/iops limits of SDC",
580 'delete_volume': "Delete volume vol_id operation failed with",
581 'val_params_err1': "sdc_id, sdc_ip and sdc_name are mutually exclusive",
582 'val_params_err2': "cap_unit can be specified along with size only",
583 'val_params_err3': "To remove/detach snapshot policy, please provide",
584 'val_params_err4': "delete_snapshots can be specified only when the state",
585 'modify_volume_exp': "Failed to update the volume",
586 'to_modify_err1': "To remove/detach a snapshot policy, provide the ",
587 'snap_pol_id_err': "Entered snapshot policy id does not ",
588 'snap_pol_name_err': "Entered snapshot policy name does not ",
589 'pd_id_err': "Entered protection domain id does not ",
590 'pool_id_err': "Entered storage pool id does ",
591 'pd_name_err': "Entered protection domain name does ",
592 'pool_name_err': "Entered storage pool name does ",
593 'get_pd_exception': "Failed to get the protection domain ",
594 'get_sp_exception': "Failed to get the snapshot policy ",
595 'get_spool_error1': "More than one storage pool found with",
596 'get_spool_error2': "Failed to get the storage pool",
597 'map_vol_exception': "Mapping volume name to SDC sdc_id1 failed with error",
598 'unmap': "Unmap SDC sdc_id from volume vol_id failed with error",
599 'perform_error1': "vol_new_name parameter is not supported during creation of a volume"
600 }
601
602 @staticmethod
603 def get_exception_response(response_type):
604 return MockVolumeApi.RESPONSE_EXEC_DICT.get(response_type, "")