Debian Codegraph @

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

raw symbols SCIP
1 # Copyright: (c) 2023, Dell Technologies
2
3 # Apache License version 2.0 (see MODULE-LICENSE or http: //www.apache.org/licenses/LICENSE-2.0.txt)
4
5 """Mock Api response for Unit tests of volume module on Unity"""
6
7 from __future__ import absolute_import, division, print_function
8
9 __metaclass__ = type
10
11
12 class MockVolumeApi:
13
14 VOLUME_MODULE_ARGS = {
15 'unispherehost': '**.***.**.***',
16 'port': '123',
17 'vol_name': None,
18 'vol_id': None,
19 'description': None,
20 'pool_name': None,
21 'pool_id': None,
22 'size': None,
23 'cap_unit': None,
24 'is_thin': None,
25 'compression': None,
26 'advanced_dedup': None,
27 'sp': None,
28 'io_limit_policy': None,
29 'snap_schedule': None,
30 'host_name': None,
31 'host_id': None,
32 'hosts': {},
33 'hlu': None,
34 'mapping_state': None,
35 'new_vol_name': None,
36 'tiering_policy': None,
37 'state': None,
38 }
39
40 pool = {
41 'alert_threshold': 60,
42 'creation_time': '2021-10-18 12:51:27+00:00',
43 'description': 'A2Z',
44 'existed': True,
45 'harvest_state': 'UsageHarvestStateEnum.IDLE',
46 'hash': 8778647453970,
47 'health': {'UnityHealth': {'hash': 8778647453730}},
48 'id': 'pool_3',
49 'is_all_flash': True,
50 'is_empty': False,
51 'is_fast_cache_enabled': False,
52 'is_harvest_enabled': True,
53 'is_snap_harvest_enabled': True,
54 'metadata_size_subscribed': 646124142592,
55 'metadata_size_used': 357287591936,
56 'name': 'Extreme_Perf_tier',
57 'object_id': 12884901892,
58 'pool_fast_vp': {'UnityPoolFastVp': {'hash': 8778647539688}},
59 'pool_space_harvest_high_threshold': 95.0,
60 'pool_space_harvest_low_threshold': 70.5,
61 'pool_type': 'StoragePoolTypeEnum.TRADITIONAL',
62 'raid_type': 'RaidTypeEnum.RAID5',
63 'size_free': 1174673555456,
64 'size_subscribed': 8703230820352,
65 'size_total': 3141768577024,
66 'size_used': 1802576257024,
67 'snap_size_subscribed': 290195193856,
68 'snap_size_used': 43098112,
69 'snap_space_harvest_high_threshold': 20.5,
70 'snap_space_harvest_low_threshold': 1.0,
71 'tiers': {'UnityPoolTierList': [{'UnityPoolTier': {'hash': 8778647538737}},
72 {'UnityPoolTier': {'hash': 8778647538749}},
73 {'UnityPoolTier': {'hash': 8778647526797}}]},
74 }
75
76 @staticmethod
77 def create_volume_response(response_type):
78 if response_type == 'api':
79 return {'volume_details': {
80 'current_node': 'NodeEnum.SPB',
81 'data_reduction_percent': 0,
82 'data_reduction_ratio': 1.0,
83 'data_reduction_size_saved': 0,
84 'default_node': 'NodeEnum.SPB',
85 'description': None,
86 'effective_io_limit_max_iops': None,
87 'effective_io_limit_max_kbps': None,
88 'existed': True,
89 'family_base_lun': {'UnityLun': {}},
90 'family_clone_count': 0,
91 'hash': 8769317548849,
92 'health': {'UnityHealth': {}},
93 'host_access': [],
94 'id': 'sv_214551',
95 'io_limit_policy': True,
96 'is_advanced_dedup_enabled': True,
97 'is_compression_enabled': True,
98 'is_data_reduction_enabled': True,
99 'is_replication_destination': False,
100 'is_snap_schedule_paused': False,
101 'is_thin_clone': False,
102 'is_thin_enabled': True,
103 'metadata_size': 3758096384,
104 'metadata_size_allocated': 3221225472,
105 'name': 'Atest',
106 'per_tier_size_used': [3489660928, 0, 0],
107 'pool': {'id': 'pool_3', 'name': 'Extreme_Perf_tier'},
108 'size_allocated': 0,
109 'size_total': 2147483648,
110 'size_total_with_unit': '2.0 GB',
111 'size_used': None,
112 'snap_count': 0,
113 'snap_schedule': None,
114 'snap_wwn': '60:06:01:60:5C:F0:50:00:F6:42:70:38:7A:90:40:FF',
115 'snaps_size': 0,
116 'snaps_size_allocated': 0,
117 'storage_resource': {'UnityStorageResource': {}},
118 'tiering_policy': 'TieringPolicyEnum.AUTOTIER_HIGH',
119 'type': 'LUNTypeEnum.STANDALONE',
120 'wwn': '60:06:01:60:5C:F0:50:00:41:25:EA:63:94:92:92:AE',
121 }}
122 else:
123 return 'Create volume operation Atest failed with error'
124
125 @staticmethod
126 def modify_volume_response(response_type):
127 if response_type == 'api':
128 return {'volume_details': {
129 'current_node': 'NodeEnum.SPB',
130 'data_reduction_percent': 0,
131 'data_reduction_ratio': 1.0,
132 'data_reduction_size_saved': 0,
133 'default_node': 'NodeEnum.SPB',
134 'description': None,
135 'effective_io_limit_max_iops': None,
136 'effective_io_limit_max_kbps': None,
137 'existed': True,
138 'family_base_lun': {'UnityLun': {}},
139 'family_clone_count': 0,
140 'hash': 8769317548849,
141 'health': {'UnityHealth': {}},
142 'host_access': [],
143 'id': 'sv_214551',
144 'io_limit_policy': None,
145 'is_advanced_dedup_enabled': False,
146 'is_compression_enabled': True,
147 'is_data_reduction_enabled': True,
148 'is_replication_destination': False,
149 'is_snap_schedule_paused': False,
150 'is_thin_clone': False,
151 'is_thin_enabled': True,
152 'metadata_size': 3758096384,
153 'metadata_size_allocated': 3221225472,
154 'name': 'Atest',
155 'per_tier_size_used': [3489660928, 0, 0],
156 'pool': {'id': 'pool_3', 'name': 'Extreme_Perf_tier'},
157 'size_allocated': 0,
158 'size_total': 2147483648,
159 'size_total_with_unit': '2.0 GB',
160 'size_used': None,
161 'snap_count': 0,
162 'snap_schedule': None,
163 'snap_wwn': '60:06:01:60:5C:F0:50:00:F6:42:70:38:7A:90:40:FF',
164 'snaps_size': 0,
165 'snaps_size_allocated': 0,
166 'storage_resource': {'UnityStorageResource': {}},
167 'tiering_policy': 'TieringPolicyEnum.AUTOTIER_HIGH',
168 'type': 'LUNTypeEnum.STANDALONE',
169 'wwn': '60:06:01:60:5C:F0:50:00:41:25:EA:63:94:92:92:AE',
170 }}
171 else:
172 return 'Failed to modify the volume Atest with error'