| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
"""Mock Api response for Unit tests of CIFS server module on Unity""" |
| 6 |
|
| 7 |
from __future__ import (absolute_import, division, print_function) |
| 8 |
|
| 9 |
__metaclass__ = type |
| 10 |
|
| 11 |
|
| 12 |
class MockCIFSServerApi: |
| 13 |
CIFS_SERVER_MODULE_ARGS = { |
| 14 |
'nas_server_id': None, |
| 15 |
'nas_server_name': None, |
| 16 |
'netbios_name': None, |
| 17 |
'workgroup': None, |
| 18 |
'local_password': None, |
| 19 |
'domain': None, |
| 20 |
'domain_username': None, |
| 21 |
'domain_password': None, |
| 22 |
'cifs_server_id': None, |
| 23 |
'cifs_server_name': None, |
| 24 |
'interfaces': None, |
| 25 |
'unjoin_cifs_server_account': None, |
| 26 |
'state': None |
| 27 |
} |
| 28 |
|
| 29 |
@staticmethod |
| 30 |
def get_cifs_server_details_method_response(): |
| 31 |
return { |
| 32 |
"description": None, |
| 33 |
"domain": "xxx.xxx.xxx.xxx", |
| 34 |
"existed": True, |
| 35 |
"file_interfaces": { |
| 36 |
"UnityFileInterfaceList": [ |
| 37 |
{ |
| 38 |
"UnityFileInterface": { |
| 39 |
"hash": 8791477905949, |
| 40 |
"id": "if_43" |
| 41 |
} |
| 42 |
} |
| 43 |
] |
| 44 |
}, |
| 45 |
"hash": 8791478461637, |
| 46 |
"health": { |
| 47 |
"UnityHealth": { |
| 48 |
"hash": 8791478461623 |
| 49 |
} |
| 50 |
}, |
| 51 |
"id": "cifs_59", |
| 52 |
"is_standalone": False, |
| 53 |
"last_used_organizational_unit": "ou=Computers,ou=EMC NAS servers", |
| 54 |
"name": "test_cifs_server", |
| 55 |
"nas_server": { |
| 56 |
"UnityNasServer": { |
| 57 |
"hash": 8791478461595, |
| 58 |
"id": "nas_18" |
| 59 |
} |
| 60 |
}, |
| 61 |
"netbios_name": "TEST_CIFS_SERVER", |
| 62 |
"smb_multi_channel_supported": True, |
| 63 |
"smb_protocol_versions": [ |
| 64 |
"1.0", |
| 65 |
"2.0", |
| 66 |
"2.1", |
| 67 |
"3.0" |
| 68 |
], |
| 69 |
"smbca_supported": True, |
| 70 |
"workgroup": None |
| 71 |
} |
| 72 |
|
| 73 |
@staticmethod |
| 74 |
def get_cifs_server_details_method_netbios_response(): |
| 75 |
return { |
| 76 |
"UnityCifsServerList": [{ |
| 77 |
"UnityCifsServer": { |
| 78 |
"existed": True, |
| 79 |
"file_interfaces": { |
| 80 |
"UnityFileInterfaceList": [{ |
| 81 |
"UnityFileInterface": { |
| 82 |
"hash": -9223363293222387298, |
| 83 |
"id": "if_43" |
| 84 |
} |
| 85 |
}] |
| 86 |
}, |
| 87 |
"hash": 8743632213638, |
| 88 |
"health": { |
| 89 |
"UnityHealth": { |
| 90 |
"hash": -9223363293222562209 |
| 91 |
} |
| 92 |
}, |
| 93 |
"id": "cifs_60", |
| 94 |
"is_standalone": True, |
| 95 |
"nas_server": { |
| 96 |
"UnityNasServer": { |
| 97 |
"hash": -9223363293221242245, |
| 98 |
"id": "nas_18" |
| 99 |
} |
| 100 |
}, |
| 101 |
"netbios_name": "ANSIBLE_CIFS", |
| 102 |
"smb_multi_channel_supported": True, |
| 103 |
"smb_protocol_versions": ["1.0", "2.0", "2.1", "3.0"], |
| 104 |
"smbca_supported": True, |
| 105 |
"workgroup": "ANSIBLE" |
| 106 |
} |
| 107 |
}] |
| 108 |
} |
| 109 |
|
| 110 |
@staticmethod |
| 111 |
def create_cifs_server_without_nas(): |
| 112 |
return "Please provide nas server id/name to create CIFS server." |
| 113 |
|
| 114 |
@staticmethod |
| 115 |
def invalid_credentials(): |
| 116 |
return "Incorrect username or password provided." |
| 117 |
|
| 118 |
@staticmethod |
| 119 |
def modify_error_msg(): |
| 120 |
return "Modification is not supported through Ansible module" |
| 121 |
|
| 122 |
@staticmethod |
| 123 |
def get_nas_server_details(): |
| 124 |
return { |
| 125 |
"UnityNasServer": { |
| 126 |
"cifs_server": { |
| 127 |
"UnityCifsServerList": [{ |
| 128 |
"UnityCifsServer": { |
| 129 |
"hash": 8734183189936, |
| 130 |
"id": "cifs_60" |
| 131 |
} |
| 132 |
}] |
| 133 |
}, |
| 134 |
"current_sp": { |
| 135 |
"UnityStorageProcessor": { |
| 136 |
"hash": 8734188780762, |
| 137 |
"id": "spa" |
| 138 |
} |
| 139 |
}, |
| 140 |
"current_unix_directory_service": "NasServerUnixDirectoryServiceEnum.NONE", |
| 141 |
"existed": True, |
| 142 |
"file_dns_server": { |
| 143 |
"UnityFileDnsServer": { |
| 144 |
"hash": 8734183189782, |
| 145 |
"id": "dns_11" |
| 146 |
} |
| 147 |
}, |
| 148 |
"file_interface": { |
| 149 |
"UnityFileInterfaceList": [{ |
| 150 |
"UnityFileInterface": { |
| 151 |
"hash": -9223363302671584431, |
| 152 |
"id": "if_43" |
| 153 |
} |
| 154 |
}] |
| 155 |
}, |
| 156 |
"hash": -9223363302671053452, |
| 157 |
"health": { |
| 158 |
"UnityHealth": { |
| 159 |
"hash": 8734182402245 |
| 160 |
} |
| 161 |
}, |
| 162 |
"home_sp": { |
| 163 |
"UnityStorageProcessor": { |
| 164 |
"hash": -9223363302671594510, |
| 165 |
"id": "spa" |
| 166 |
} |
| 167 |
}, |
| 168 |
"id": "nas_18", |
| 169 |
"is_backup_only": False, |
| 170 |
"is_multi_protocol_enabled": False, |
| 171 |
"is_packet_reflect_enabled": False, |
| 172 |
"is_replication_destination": False, |
| 173 |
"is_replication_enabled": False, |
| 174 |
"name": "test_nas1", |
| 175 |
"pool": { |
| 176 |
"UnityPool": { |
| 177 |
"hash": -9223363302672128291, |
| 178 |
"id": "pool_7" |
| 179 |
} |
| 180 |
}, |
| 181 |
"preferred_interface_settings": { |
| 182 |
"UnityPreferredInterfaceSettings": { |
| 183 |
"hash": -9223363302671585904, |
| 184 |
"id": "preferred_if_16" |
| 185 |
} |
| 186 |
}, |
| 187 |
"replication_type": "ReplicationTypeEnum.NONE", |
| 188 |
"size_allocated": 2952790016, |
| 189 |
"virus_checker": { |
| 190 |
"UnityVirusChecker": { |
| 191 |
"hash": 8734183191465, |
| 192 |
"id": "cava_18" |
| 193 |
} |
| 194 |
} |
| 195 |
} |
| 196 |
} |