Debian Codegraph @

ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_info_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 info 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 from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_volume_api import MockVolumeApi
12 from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_replication_consistency_group_api \
13 import MockReplicationConsistencyGroupApi
14 from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_replication_pair_api \
15 import MockReplicationPairApi
16 from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_snapshot_policy_api \
17 import MockSnapshotPolicyApi
18 from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_fault_set_api import MockFaultSetApi
19
20
21 __metaclass__ = type
22
23
24 class MockInfoApi:
25 MODULE_UTILS_PATH = "ansible_collections.dellemc.powerflex.plugins.module_utils.storage.dell.utils"
26 INFO_COMMON_ARGS = {
27 "hostname": "**.***.**.***",
28 "gather_subset": [],
29 "filters": None
30 }
31
32 DUMMY_IP = 'xx.xx.xx.xx'
33 INFO_ARRAY_DETAILS = [
34 {
35 'systemVersionName': 'DellEMC PowerFlex Version',
36 'perfProfile': 'Compact',
37 'authenticationMethod': 'Native',
38 'capacityAlertHighThresholdPercent': 80,
39 'capacityAlertCriticalThresholdPercent': 90,
40 'upgradeState': 'NoUpgrade',
41 'remoteReadOnlyLimitState': False,
42 'mdmManagementPort': 6611,
43 'mdmExternalPort': 7611,
44 'sdcMdmNetworkDisconnectionsCounterParameters': {
45 'shortWindow': {
46 'threshold': 300,
47 'windowSizeInSec': 60
48 },
49 'mediumWindow': {
50 'threshold': 500,
51 'windowSizeInSec': 3600
52 },
53 'longWindow': {
54 'threshold': 700,
55 'windowSizeInSec': 86400
56 }
57 },
58 'sdcSdsNetworkDisconnectionsCounterParameters': {
59 'shortWindow': {
60 'threshold': 800,
61 'windowSizeInSec': 60
62 },
63 'mediumWindow': {
64 'threshold': 4000,
65 'windowSizeInSec': 3600
66 },
67 'longWindow': {
68 'threshold': 20000,
69 'windowSizeInSec': 86400
70 }
71 },
72 'sdcMemoryAllocationFailuresCounterParameters': {
73 'shortWindow': {
74 'threshold': 300,
75 'windowSizeInSec': 60
76 },
77 'mediumWindow': {
78 'threshold': 500,
79 'windowSizeInSec': 3600
80 },
81 'longWindow': {
82 'threshold': 700,
83 'windowSizeInSec': 86400
84 }
85 },
86 'sdcSocketAllocationFailuresCounterParameters': {
87 'shortWindow': {
88 'threshold': 300,
89 'windowSizeInSec': 60
90 },
91 'mediumWindow': {
92 'threshold': 500,
93 'windowSizeInSec': 3600
94 },
95 'longWindow': {
96 'threshold': 700,
97 'windowSizeInSec': 86400
98 }
99 },
100 'sdcLongOperationsCounterParameters': {
101 'shortWindow': {
102 'threshold': 10000,
103 'windowSizeInSec': 60
104 },
105 'mediumWindow': {
106 'threshold': 100000,
107 'windowSizeInSec': 3600
108 },
109 'longWindow': {
110 'threshold': 1000000,
111 'windowSizeInSec': 86400
112 }
113 },
114 'cliPasswordAllowed': True,
115 'managementClientSecureCommunicationEnabled': True,
116 'tlsVersion': 'TLSv1.2',
117 'showGuid': True,
118 'defragmentationEnabled': True,
119 'mdmSecurityPolicy': 'None',
120 'mdmCluster': {
121 'clusterState': 'ClusteredNormal',
122 'clusterMode': 'ThreeNodes',
123 'slaves': [
124 {
125 'managementIPs': [
126 DUMMY_IP
127 ],
128 'ips': [
129 DUMMY_IP
130 ],
131 'versionInfo': '',
132 'virtualInterfaces': [
133 ''
134 ],
135 'opensslVersion': 'OpenSSL 26 Jan 2017',
136 'role': 'Manager',
137 'status': 'Normal',
138 'name': 'test_node1_MDM',
139 'id': 'test_id_1',
140 'port': 0000
141 }
142 ],
143 'goodNodesNum': 3,
144 'master': {
145 'managementIPs': [
146 DUMMY_IP
147 ],
148 'ips': [
149 DUMMY_IP
150 ],
151 'versionInfo': 'R3_6.0.0',
152 'virtualInterfaces': [
153 'ens192'
154 ],
155 'opensslVersion': 'OpenSSL26 Jan 2017',
156 'role': 'Manager',
157 'status': 'Normal',
158 'name': 'test_node_0',
159 'id': 'test_id_2',
160 'port': 0000
161 },
162 'tieBreakers': [
163 {
164 'managementIPs': [
165 DUMMY_IP
166 ],
167 'ips': [
168 DUMMY_IP
169 ],
170 'versionInfo': '',
171 'opensslVersion': 'N/A',
172 'role': 'TieBreaker',
173 'status': 'Normal',
174 'id': 'test_id_3',
175 'port': 0000
176 }
177 ],
178 'goodReplicasNum': 2,
179 'id': ''
180 },
181 'sdcSdsConnectivityInfo': {
182 'clientServerConnectivityStatus': 'AllConnected',
183 'disconnectedClientId': None,
184 'disconnectedClientName': None,
185 'disconnectedServerId': None,
186 'disconnectedServerName': None,
187 'disconnectedServerIp': None
188 },
189 'addressSpaceUsage': 'Normal',
190 'lastUpgradeTime': 0,
191 'sdcSdrConnectivityInfo': {
192 'clientServerConnectivityStatus': 'AllConnected',
193 'disconnectedClientId': None,
194 'disconnectedClientName': None,
195 'disconnectedServerId': None,
196 'disconnectedServerName': None,
197 'disconnectedServerIp': None
198 },
199 'sdrSdsConnectivityInfo': {
200 'clientServerConnectivityStatus': 'AllConnected',
201 'disconnectedClientId': None,
202 'disconnectedClientName': None,
203 'disconnectedServerId': None,
204 'disconnectedServerName': None,
205 'disconnectedServerIp': None
206 },
207 'isInitialLicense': False,
208 'capacityTimeLeftInDays': '253',
209 'swid': 'abcdXXX',
210 'installId': 'id_111',
211 'restrictedSdcModeEnabled': False,
212 'restrictedSdcMode': 'None',
213 'enterpriseFeaturesEnabled': True,
214 'daysInstalled': 112,
215 'maxCapacityInGb': '5120',
216 'id': 'id_222'
217 }
218 ]
219
220 INFO_VOLUME_GET_LIST = MockVolumeApi.VOLUME_GET_LIST
221
222 INFO_VOLUME_STATISTICS = {
223 'test_vol_id_1': MockVolumeApi.VOLUME_STATISTICS
224 }
225
226 INFO_SNAPSHOT_POLICY_GET_LIST = MockSnapshotPolicyApi.SNAPSHOT_POLICY_GET_LIST
227
228 INFO_SNAPSHOT_POLICY_STATISTICS = {
229 'test_snap_pol_id_1': MockSnapshotPolicyApi.SNAPSHOT_POLICY_STATISTICS
230 }
231
232 INFO_STORAGE_POOL_GET_LIST = MockStoragePoolApi.STORAGE_POOL_GET_LIST
233
234 INFO_STORAGE_POOL_STATISTICS = {
235 'test_pool_id_1': MockStoragePoolApi.STORAGE_POOL_STATISTICS
236 }
237
238 RCG_LIST = MockReplicationConsistencyGroupApi.get_rcg_details()
239 PAIR_LIST = MockReplicationPairApi.get_pair_details()
240
241 INFO_GET_FAULT_SET_LIST = MockFaultSetApi.FAULT_SET_GET_LIST
242
243 INFO_SDC_GET_LIST = [
244 {
245 "id": "07335d3d00000006",
246 "name": "sdc_1"
247 },
248 {
249 "id": "07335d3c00000005",
250 "name": "sdc_2"
251 },
252 {
253 "id": "0733844a00000003",
254 "name": "sdc_3"
255 }
256 ]
257
258 INFO_SDC_FILTER_LIST = [
259 {
260 "id": "07335d3d00000006",
261 "name": "sdc_1"
262 }
263 ]
264
265 INFO_SDS_GET_LIST = [
266 {
267 "id": "8f3bb0cc00000002",
268 "name": "node0"
269 },
270 {
271 "id": "8f3bb0ce00000000",
272 "name": "node1"
273 },
274 {
275 "id": "8f3bb15300000001",
276 "name": "node22"
277 }
278 ]
279 INFO_GET_PD_LIST = [
280 {
281 "id": "9300e90900000001",
282 "name": "domain2"
283 },
284 {
285 "id": "9300c1f900000000",
286 "name": "domain1"
287 }
288 ]
289 INFO_GET_DEVICE_LIST = [
290 {
291 "id": "b6efa59900000000",
292 "name": "device230"
293 },
294 {
295 "id": "b6efa5fa00020000",
296 "name": "device_node0"
297 },
298 {
299 "id": "b7f3a60900010000",
300 "name": "device22"
301 }
302 ]
303
304 INFO_NVME_HOST_LIST = [
305 {
306 "id": "fake_host_id_1",
307 "name": "fake_host_name_1",
308 "hostType": "NVMeHost"
309 },
310 {
311 "id": "fake_host_id_2",
312 "hostType": "NVMeHost"
313 }
314 ]
315
316 INFO_NVME_HOST_FILTER_LIST = [
317 {
318 "id": "fake_host_id",
319 "name": "fake_host_name",
320 }
321 ]
322 INFO_GET_SDT_LIST = [
323 {
324 "mdmConnectionState": "Connected",
325 "softwareVersionInfo": "R4_5.2100.0",
326 "name": "sdt-name",
327 "id": "8bddf18c00000001"
328 }
329 ]
330 INFO_GET_SDT_NVME_HOST_LIST = [
331 {
332 "hostType": "NVMeHost",
333 "id": "1040d69e00010001"
334 }
335 ]
336 INFO_GET_SDT_NVME_CONTROLLER_LIST = [
337 {
338 "isConnected": True,
339 "sdtId": "8bddf18c00000001",
340 "hostIp": "172.171.1.17",
341 "hostId": "1040d69e00010001",
342 "controllerId": 1,
343 "sysPortId": 0,
344 "sysPortIp": "172.171.3.21",
345 "subsystem": "Io",
346 "id": "cc00010001000002"
347 }
348 ]
349
350 RESPONSE_EXEC_DICT = {
351 'volume_get_details': "Get volumes list from powerflex array failed with error",
352 'snapshot_policy_get_details': "Get snapshot policies list from powerflex array failed with error ",
353 'sp_get_details': "Get storage pool list from powerflex array failed with error ",
354 'rcg_get_details': "Get replication consistency group list from powerflex array failed with error ",
355 'replication_pair_get_details': "Get replication pair list from powerflex array failed with error ",
356 'fault_set_get_details': "Get fault set list from powerflex array failed with error",
357 'sdc_get_details': "Get SDC list from powerflex array failed with error",
358 'sds_get_details': "Get SDS list from powerflex array failed with error",
359 'pd_get_details': "Get protection domain list from powerflex array failed with error",
360 'device_get_details': "Get device list from powerflex array failed with error",
361 'get_sds_details_filter_invalid': "Filter should have all keys: 'filter_key, filter_operator, filter_value'",
362 'get_sds_details_filter_empty': "Filter keys: '['filter_key', 'filter_operator', 'filter_value']' cannot be None",
363 'invalid_filter_operator_exception': "Given filter operator 'does_not_contain' is not supported.",
364 'api_exception': "Get API details from Powerflex array failed with error",
365 'system_exception': "Get array details from Powerflex array failed with error",
366 'managed_device_get_error': "Get managed devices from PowerFlex Manager failed with error",
367 'service_template_get_error': "Get service templates from PowerFlex Manager failed with error",
368 'deployment_get_error': "Get deployments from PowerFlex Manager failed with error",
369 'firmware_repository_get_error': "Get firmware repository from PowerFlex Manager failed with error",
370 'nvme_host_get_details': "Get NVMe host list from powerflex array failed with error",
371 "sdt_get_error": "Get sdt from PowerFlex Manager failed with error"
372 }
373
374 @staticmethod
375 def get_exception_response(response_type):
376 return MockInfoApi.RESPONSE_EXEC_DICT.get(response_type, "")