Debian Codegraph @

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

raw symbols SCIP
1 # Copyright: (c) 2022, 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 NFS server module on Unity"""
6
7 from __future__ import (absolute_import, division, print_function)
8
9 __metaclass__ = type
10
11 from ansible_collections.dellemc.unity.tests.unit.plugins.module_utils.mock_sdk_response \
12 import MockSDKObject
13
14
15 class MockNFSServerApi:
16 NFS_SERVER_MODULE_ARGS = {
17 'nas_server_id': None,
18 'nas_server_name': None,
19 'host_name': None,
20 'is_secure_enabled': None,
21 'kerberos_domain_controller_type': None,
22 'kerberos_domain_controller_username': None,
23 'kerberos_domain_controller_password': None,
24 'is_extended_credentials_enabled': None,
25 'nfs_v4_enabled': None,
26 'nfs_server_id': None,
27 'interfaces': None,
28 'remove_spn_from_kerberos': None,
29 'state': None
30 }
31
32 NAS_SERVER_OBJ = MockSDKObject({"id": "nas_10"})
33
34 @staticmethod
35 def get_nfs_server_details_method_response():
36 return {
37 "credentials_cache_ttl": "0:15:00",
38 "existed": True,
39 "file_interfaces": {
40 "UnityFileInterfaceList": [{
41 "UnityFileInterface": {
42 "hash": 1111111111111,
43 "id": "if_3"
44 }
45 }]
46 },
47 "hash": 1111111111111,
48 "id": "nfs_95",
49 "is_extended_credentials_enabled": False,
50 "is_secure_enabled": False,
51 "nas_server": MockNFSServerApi.NAS_SERVER_OBJ,
52 "nfs_v4_enabled": True,
53 'servicee_principal_name': None
54 }
55
56 @staticmethod
57 def get_nfs_server_details():
58 return [MockSDKObject({
59 "credentials_cache_ttl": "0:15:00",
60 "existed": True,
61 "file_interfaces": {
62 "UnityFileInterfaceList": [{
63 "UnityFileInterface": {
64 "hash": 1111111111111,
65 "id": "if_3"
66 }
67 }]
68 },
69 "hash": 1111111111111,
70 "id": "nfs_95",
71 "is_extended_credentials_enabled": False,
72 "is_secure_enabled": False,
73 "nas_server": MockNFSServerApi.NAS_SERVER_OBJ,
74 "nfs_v4_enabled": True,
75 'servicee_principal_name': None})]
76
77 @staticmethod
78 def validate_params_exception():
79 return "Please provide valid value for:"
80
81 @staticmethod
82 def create_nfs_server_without_nas_server_id():
83 return "Please provide nas server id/name to create NFS server."
84
85 @staticmethod
86 def get_nas_server_id_api_exception():
87 return "Failed to get details of NAS server:"
88
89 @staticmethod
90 def create_nfs_server_without_is_secure_enabled():
91 return "For create NFS Server nfs_v4_enabled and is_secure_enabled should be true."
92
93 @staticmethod
94 def create_nfs_server_with_api_exception():
95 return "Failed to create NFS server with on NAS Server"
96
97 @staticmethod
98 def get_nfs_server_api_exception():
99 return "Incorrect username or password provided."
100
101 @staticmethod
102 def get_nfs_server_api_exception_1():
103 return "Failed to get details of NFS Server with error"
104
105 @staticmethod
106 def delete_exception():
107 return "Failed to delete NFS server:"
108
109 @staticmethod
110 def modify_error_msg():
111 return "Modification of NFS Server parameters is not supported through Ansible module"
112
113 @staticmethod
114 def get_nas_server_details():
115 return {
116 "UnityNasServer": {
117 "cifs_server": {
118 "UnityCifsServerList": [{
119 "UnityCifsServer": {
120 "hash": 1111111111111,
121 "id": "cifs_60"
122 }
123 }]
124 },
125 "current_sp": {
126 "UnityStorageProcessor": {
127 "hash": 1111111111111,
128 "id": "spa"
129 }
130 },
131 "current_unix_directory_service": "NasServerUnixDirectoryServiceEnum.NONE",
132 "existed": True,
133 "file_dns_server": {
134 "UnityFileDnsServer": {
135 "hash": 1111111111111,
136 "id": "dns_11"
137 }
138 },
139 "file_interface": {
140 "UnityFileInterfaceList": [{
141 "UnityFileInterface": {
142 "hash": -1111111111111,
143 "id": "if_43"
144 }
145 }]
146 },
147 "hash": -1111111111111,
148 "health": {
149 "UnityHealth": {
150 "hash": 1111111111111
151 }
152 },
153 "home_sp": {
154 "UnityStorageProcessor": {
155 "hash": -1111111111111,
156 "id": "spa"
157 }
158 },
159 "id": "nas_18",
160 "is_backup_only": False,
161 "is_multi_protocol_enabled": False,
162 "is_packet_reflect_enabled": False,
163 "is_replication_destination": False,
164 "is_replication_enabled": False,
165 "name": "test_nas1",
166 "pool": {
167 "UnityPool": {
168 "hash": -1111111111111,
169 "id": "pool_7"
170 }
171 },
172 "preferred_interface_settings": {
173 "UnityPreferredInterfaceSettings": {
174 "hash": -1111111111111,
175 "id": "preferred_if_16"
176 }
177 },
178 "replication_type": "ReplicationTypeEnum.NONE",
179 "size_allocated": 1111111111111,
180 "virus_checker": {
181 "UnityVirusChecker": {
182 "hash": 1111111111111,
183 "id": "cava_18"
184 }
185 }
186 }
187 }
188
189 @staticmethod
190 def get_nas_server_id():
191 return MockSDKObject({
192 "cifs_server": {
193 "UnityCifsServerList": [{
194 "UnityCifsServer": {
195 "hash": 1111111111111,
196 "id": "cifs_34"
197 }
198 }]
199 },
200 "current_sp": {
201 "UnityStorageProcessor": {
202 "hash": 1111111111111,
203 "id": "spb"
204 }
205 },
206 "current_unix_directory_service": "NasServerUnixDirectoryServiceEnum.NIS",
207 "existed": True,
208 "file_dns_server": {
209 "UnityFileDnsServer": {
210 "hash": 1111111111111,
211 "id": "dns_12"
212 }
213 },
214 "file_interface": {
215 "UnityFileInterfaceList": [{
216 "UnityFileInterface": {
217 "hash": 1111111111111,
218 "id": "if_37"
219 }
220 }]
221 },
222 "hash": 1111111111111,
223 "health": {
224 "UnityHealth": {
225 "hash": 1111111111111
226 }
227 },
228 "home_sp": {
229 "UnityStorageProcessor": {
230 "hash": 1111111111111,
231 "id": "spb"
232 }
233 },
234 "id": "nas_10",
235 "is_backup_only": False,
236 "is_multi_protocol_enabled": False,
237 "is_packet_reflect_enabled": False,
238 "is_replication_destination": False,
239 "is_replication_enabled": True,
240 "name": "dummy_nas",
241 "pool": {
242 "UnityPool": {
243 "hash": 1111111111111,
244 "id": "pool_7"
245 }
246 },
247 "preferred_interface_settings": {
248 "UnityPreferredInterfaceSettings": {
249 "hash": 1111111111111,
250 "id": "preferred_if_10"
251 }
252 },
253 "replication_type": "ReplicationTypeEnum.REMOTE",
254 "size_allocated": 1111111111111,
255 "virus_checker": {
256 "UnityVirusChecker": {
257 "hash": 1111111111111,
258 "id": "cava_10"}}})