| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
"""Unit Tests for MDM cluster module on PowerFlex""" |
| 6 |
|
| 7 |
from __future__ import (absolute_import, division, print_function) |
| 8 |
|
| 9 |
__metaclass__ = type |
| 10 |
|
| 11 |
import pytest |
| 12 |
from mock.mock import MagicMock |
| 13 |
from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_mdm_cluster_api import MockMdmClusterApi |
| 14 |
from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_sdk_response \ |
| 15 |
import MockSDKResponse |
| 16 |
from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_api_exception \ |
| 17 |
import MockApiException |
| 18 |
from ansible_collections.dellemc.powerflex.plugins.module_utils.storage.dell \ |
| 19 |
import utils |
| 20 |
|
| 21 |
utils.get_logger = MagicMock() |
| 22 |
utils.get_powerflex_gateway_host_connection = MagicMock() |
| 23 |
utils.PowerFlexClient = MagicMock() |
| 24 |
from ansible.module_utils import basic |
| 25 |
basic.AnsibleModule = MagicMock() |
| 26 |
from ansible_collections.dellemc.powerflex.plugins.modules.mdm_cluster import PowerFlexMdmCluster |
| 27 |
|
| 28 |
|
| 29 |
class TestPowerflexMDMCluster(): |
| 30 |
|
| 31 |
get_module_args = MockMdmClusterApi.MDM_CLUSTER_COMMON_ARGS |
| 32 |
add_mdm_ip = "xx.3x.xx.xx" |
| 33 |
|
| 34 |
@pytest.fixture |
| 35 |
def mdm_cluster_module_mock(self, mocker): |
| 36 |
mocker.patch(MockMdmClusterApi.MODULE_UTILS_PATH + '.PowerFlexClient', new=MockApiException) |
| 37 |
mdm_cluster_module_mock = PowerFlexMdmCluster() |
| 38 |
mdm_cluster_module_mock.module.check_mode = False |
| 39 |
return mdm_cluster_module_mock |
| 40 |
|
| 41 |
def test_get_mdm_cluster(self, mdm_cluster_module_mock): |
| 42 |
self.get_module_args.update({ |
| 43 |
"state": "present" |
| 44 |
}) |
| 45 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 46 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 47 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 48 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 49 |
) |
| 50 |
mdm_cluster_module_mock.perform_module_operation() |
| 51 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details.assert_called() |
| 52 |
|
| 53 |
def test_get_mdm_cluster_with_exception(self, mdm_cluster_module_mock): |
| 54 |
self.get_module_args.update({ |
| 55 |
"state": "present" |
| 56 |
}) |
| 57 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 58 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 59 |
side_effect=utils.PowerFlexClient |
| 60 |
) |
| 61 |
mdm_cluster_module_mock.perform_module_operation() |
| 62 |
assert MockMdmClusterApi.get_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 63 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details.assert_called() |
| 64 |
|
| 65 |
def test_rename_mdm(self, mdm_cluster_module_mock): |
| 66 |
self.get_module_args.update({ |
| 67 |
"mdm_name": MockMdmClusterApi.MDM_NAME, |
| 68 |
"mdm_new_name": "mdm_node_renamed", |
| 69 |
"state": "present" |
| 70 |
}) |
| 71 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 72 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 73 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 74 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 75 |
) |
| 76 |
mdm_cluster_module_mock.powerflex_conn.system.rename_mdm = MagicMock() |
| 77 |
mdm_cluster_module_mock.perform_module_operation() |
| 78 |
mdm_cluster_module_mock.powerflex_conn.system.rename_mdm.assert_called() |
| 79 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 80 |
|
| 81 |
def test_rename_mdm_exception(self, mdm_cluster_module_mock): |
| 82 |
self.get_module_args.update({ |
| 83 |
"mdm_name": MockMdmClusterApi.MDM_NAME, |
| 84 |
"mdm_new_name": "mdm_node_renamed", |
| 85 |
"state": "present" |
| 86 |
}) |
| 87 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 88 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 89 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 90 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 91 |
) |
| 92 |
mdm_cluster_module_mock.powerflex_conn.system.rename_mdm = MagicMock( |
| 93 |
side_effect=utils.PowerFlexClient |
| 94 |
) |
| 95 |
mdm_cluster_module_mock.perform_module_operation() |
| 96 |
mdm_cluster_module_mock.powerflex_conn.system.rename_mdm.assert_called() |
| 97 |
assert MockMdmClusterApi.rename_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 98 |
|
| 99 |
def test_set_performance_profile_mdm_cluster(self, mdm_cluster_module_mock): |
| 100 |
self.get_module_args.update({ |
| 101 |
"performance_profile": "Compact", |
| 102 |
"state": "present" |
| 103 |
}) |
| 104 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 105 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 106 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 107 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 108 |
) |
| 109 |
mdm_cluster_module_mock.powerflex_conn.system.set_cluster_mdm_performance_profile = MagicMock() |
| 110 |
mdm_cluster_module_mock.perform_module_operation() |
| 111 |
mdm_cluster_module_mock.powerflex_conn.system.set_cluster_mdm_performance_profile.assert_called() |
| 112 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 113 |
|
| 114 |
def test_set_performance_profile_mdm_cluster_exception(self, mdm_cluster_module_mock): |
| 115 |
self.get_module_args.update({ |
| 116 |
"performance_profile": "Compact", |
| 117 |
"state": "present" |
| 118 |
}) |
| 119 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 120 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 121 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 122 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 123 |
) |
| 124 |
mdm_cluster_module_mock.powerflex_conn.system.set_cluster_mdm_performance_profile = MagicMock( |
| 125 |
side_effect=utils.PowerFlexClient |
| 126 |
) |
| 127 |
mdm_cluster_module_mock.perform_module_operation() |
| 128 |
mdm_cluster_module_mock.powerflex_conn.system.set_cluster_mdm_performance_profile.assert_called() |
| 129 |
assert MockMdmClusterApi.perf_profile_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 130 |
|
| 131 |
def test_set_virtual_ip_interface_mdm(self, mdm_cluster_module_mock): |
| 132 |
self.get_module_args.update({ |
| 133 |
"mdm_id": MockMdmClusterApi.MDM_ID, |
| 134 |
"virtual_ip_interfaces": ["ens11"], |
| 135 |
"state": "present" |
| 136 |
}) |
| 137 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 138 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 139 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 140 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 141 |
) |
| 142 |
mdm_cluster_module_mock.powerflex_conn.system.modify_virtual_ip_interface = MagicMock() |
| 143 |
mdm_cluster_module_mock.perform_module_operation() |
| 144 |
mdm_cluster_module_mock.powerflex_conn.system.modify_virtual_ip_interface.assert_called() |
| 145 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 146 |
|
| 147 |
def test_set_virtual_ip_interface_mdm_exception(self, mdm_cluster_module_mock): |
| 148 |
self.get_module_args.update({ |
| 149 |
"mdm_id": MockMdmClusterApi.MDM_ID, |
| 150 |
"virtual_ip_interfaces": ["ens11"], |
| 151 |
"state": "present" |
| 152 |
}) |
| 153 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 154 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 155 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 156 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 157 |
) |
| 158 |
mdm_cluster_module_mock.powerflex_conn.system.modify_virtual_ip_interface = MagicMock( |
| 159 |
side_effect=utils.PowerFlexClient |
| 160 |
) |
| 161 |
mdm_cluster_module_mock.perform_module_operation() |
| 162 |
mdm_cluster_module_mock.powerflex_conn.system.modify_virtual_ip_interface.assert_called() |
| 163 |
assert MockMdmClusterApi.virtual_ip_interface_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 164 |
|
| 165 |
def test_set_virtual_ip_interface_mdm_idempotency(self, mdm_cluster_module_mock): |
| 166 |
self.get_module_args.update({ |
| 167 |
"mdm_id": MockMdmClusterApi.MDM_ID, |
| 168 |
"virtual_ip_interfaces": ["ens1"], |
| 169 |
"state": "present" |
| 170 |
}) |
| 171 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 172 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 173 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 174 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 175 |
) |
| 176 |
mdm_cluster_module_mock.perform_module_operation() |
| 177 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is False |
| 178 |
|
| 179 |
def test_remove_standby_mdm(self, mdm_cluster_module_mock): |
| 180 |
self.get_module_args.update({ |
| 181 |
"mdm_id": MockMdmClusterApi.STB_TB_MDM_ID, |
| 182 |
"state": "absent" |
| 183 |
}) |
| 184 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 185 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 186 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 187 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 188 |
) |
| 189 |
mdm_cluster_module_mock.powerflex_conn.system.remove_standby_mdm = MagicMock() |
| 190 |
mdm_cluster_module_mock.perform_module_operation() |
| 191 |
mdm_cluster_module_mock.powerflex_conn.system.remove_standby_mdm.assert_called() |
| 192 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 193 |
|
| 194 |
def test_remove_standby_mdm_idempotency(self, mdm_cluster_module_mock): |
| 195 |
self.get_module_args.update({ |
| 196 |
"mdm_name": "non_existing_node", |
| 197 |
"state": "absent" |
| 198 |
}) |
| 199 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 200 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 201 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 202 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 203 |
) |
| 204 |
mdm_cluster_module_mock.perform_module_operation() |
| 205 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is False |
| 206 |
|
| 207 |
def test_remove_standby_mdm_exception(self, mdm_cluster_module_mock): |
| 208 |
self.get_module_args.update({ |
| 209 |
"mdm_id": MockMdmClusterApi.STB_TB_MDM_ID, |
| 210 |
"state": "absent" |
| 211 |
}) |
| 212 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 213 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 214 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 215 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 216 |
) |
| 217 |
mdm_cluster_module_mock.powerflex_conn.system.remove_standby_mdm = MagicMock( |
| 218 |
side_effect=utils.PowerFlexClient |
| 219 |
) |
| 220 |
mdm_cluster_module_mock.perform_module_operation() |
| 221 |
mdm_cluster_module_mock.powerflex_conn.system.remove_standby_mdm.assert_called() |
| 222 |
assert MockMdmClusterApi.remove_mdm_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 223 |
|
| 224 |
def test_add_standby_mdm(self, mdm_cluster_module_mock): |
| 225 |
self.get_module_args.update({ |
| 226 |
"mdm_name": "standby_node", |
| 227 |
"standby_mdm": { |
| 228 |
"mdm_ips": [self.add_mdm_ip], |
| 229 |
"role": "Manager", |
| 230 |
"port": 9011, |
| 231 |
"management_ips": [self.add_mdm_ip], |
| 232 |
"virtual_interfaces": ["ens1"], |
| 233 |
"allow_multiple_ips": True |
| 234 |
}, |
| 235 |
"state": "present" |
| 236 |
}) |
| 237 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 238 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 239 |
return_value=MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS |
| 240 |
) |
| 241 |
mdm_cluster_module_mock.powerflex_conn.system.add_standby_mdm = MagicMock() |
| 242 |
mdm_cluster_module_mock.perform_module_operation() |
| 243 |
mdm_cluster_module_mock.powerflex_conn.system.add_standby_mdm.assert_called() |
| 244 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 245 |
|
| 246 |
def test_add_standby_mdm_idempotency(self, mdm_cluster_module_mock): |
| 247 |
self.get_module_args.update({ |
| 248 |
"mdm_name": MockMdmClusterApi.MDM_NAME, |
| 249 |
"standby_mdm": { |
| 250 |
"mdm_ips": ["10.x.z.z"], |
| 251 |
"role": "TieBreaker", |
| 252 |
"port": 9011 |
| 253 |
}, |
| 254 |
"state": "present" |
| 255 |
}) |
| 256 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 257 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 258 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 259 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 260 |
) |
| 261 |
mdm_cluster_module_mock.perform_module_operation() |
| 262 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is False |
| 263 |
|
| 264 |
def test_add_standby_mdm_exception(self, mdm_cluster_module_mock): |
| 265 |
self.get_module_args.update({ |
| 266 |
"mdm_name": "standby_node", |
| 267 |
"standby_mdm": { |
| 268 |
"mdm_ips": [self.add_mdm_ip], |
| 269 |
"role": "Manager", |
| 270 |
"port": 9011, |
| 271 |
"management_ips": [self.add_mdm_ip], |
| 272 |
"virtual_interfaces": ["ens1"], |
| 273 |
"allow_multiple_ips": True |
| 274 |
}, |
| 275 |
"state": "present" |
| 276 |
}) |
| 277 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 278 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 279 |
return_value=MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS |
| 280 |
) |
| 281 |
mdm_cluster_module_mock.powerflex_conn.system.add_standby_mdm = MagicMock( |
| 282 |
side_effect=utils.PowerFlexClient |
| 283 |
) |
| 284 |
mdm_cluster_module_mock.perform_module_operation() |
| 285 |
mdm_cluster_module_mock.powerflex_conn.system.add_standby_mdm.assert_called() |
| 286 |
assert MockMdmClusterApi.add_mdm_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 287 |
|
| 288 |
def test_change_mdm_cluster_owner(self, mdm_cluster_module_mock): |
| 289 |
self.get_module_args.update({ |
| 290 |
"mdm_name": "sample_mdm1", |
| 291 |
"is_primary": True, |
| 292 |
"state": "present" |
| 293 |
}) |
| 294 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 295 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 296 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 297 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 298 |
) |
| 299 |
mdm_cluster_module_mock.powerflex_conn.system.change_mdm_ownership = MagicMock() |
| 300 |
mdm_cluster_module_mock.perform_module_operation() |
| 301 |
mdm_cluster_module_mock.powerflex_conn.system.change_mdm_ownership.assert_called() |
| 302 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 303 |
|
| 304 |
def test_change_mdm_cluster_owner_idempotency(self, mdm_cluster_module_mock): |
| 305 |
self.get_module_args.update({ |
| 306 |
"mdm_id": "5908d328581d1400", |
| 307 |
"is_primary": True, |
| 308 |
"state": "present" |
| 309 |
}) |
| 310 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 311 |
mdm_cluster_resp = MockSDKResponse( |
| 312 |
MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 313 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 314 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 315 |
) |
| 316 |
mdm_cluster_module_mock.perform_module_operation() |
| 317 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is False |
| 318 |
|
| 319 |
def test_change_mdm_cluster_owner_execption(self, mdm_cluster_module_mock): |
| 320 |
self.get_module_args.update({ |
| 321 |
"mdm_name": "sample_mdm1", |
| 322 |
"is_primary": True, |
| 323 |
"state": "present" |
| 324 |
}) |
| 325 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 326 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 327 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 328 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 329 |
) |
| 330 |
mdm_cluster_module_mock.powerflex_conn.system.change_mdm_ownership = MagicMock( |
| 331 |
side_effect=utils.PowerFlexClient |
| 332 |
) |
| 333 |
mdm_cluster_module_mock.perform_module_operation() |
| 334 |
mdm_cluster_module_mock.powerflex_conn.system.change_mdm_ownership.assert_called() |
| 335 |
assert MockMdmClusterApi.owner_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 336 |
|
| 337 |
def test_expand_mdm_cluster_mode(self, mdm_cluster_module_mock): |
| 338 |
self.get_module_args.update({ |
| 339 |
"cluster_mode": "FiveNodes", |
| 340 |
"mdm": [ |
| 341 |
{ |
| 342 |
"mdm_name": MockMdmClusterApi.MDM_NAME_STB_MGR, |
| 343 |
"mdm_id": None, |
| 344 |
"mdm_type": "Secondary" |
| 345 |
}, |
| 346 |
{ |
| 347 |
"mdm_id": MockMdmClusterApi.STB_TB_MDM_ID, |
| 348 |
"mdm_name": None, |
| 349 |
"mdm_type": "TieBreaker" |
| 350 |
} |
| 351 |
], |
| 352 |
"mdm_state": "present-in-cluster", |
| 353 |
"state": "present" |
| 354 |
}) |
| 355 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 356 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 357 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 358 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 359 |
) |
| 360 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode = MagicMock() |
| 361 |
mdm_cluster_module_mock.perform_module_operation() |
| 362 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode.assert_called() |
| 363 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 364 |
|
| 365 |
def test_reduce_mdm_cluster_mode_idempotency(self, mdm_cluster_module_mock): |
| 366 |
self.get_module_args.update({ |
| 367 |
"cluster_mode": "ThreeNodes", |
| 368 |
"mdm": [ |
| 369 |
{ |
| 370 |
"mdm_name": None, |
| 371 |
"mdm_id": MockMdmClusterApi.STB_MGR_MDM_ID, |
| 372 |
"mdm_type": "Secondary" |
| 373 |
}, |
| 374 |
{ |
| 375 |
"mdm_id": None, |
| 376 |
"mdm_name": MockMdmClusterApi.MDM_NAME, |
| 377 |
"mdm_type": "TieBreaker" |
| 378 |
} |
| 379 |
], |
| 380 |
"mdm_state": "absent-in-cluster", |
| 381 |
"state": "present" |
| 382 |
}) |
| 383 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 384 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 385 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 386 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 387 |
) |
| 388 |
mdm_cluster_module_mock.perform_module_operation() |
| 389 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is False |
| 390 |
|
| 391 |
def test_expand_mdm_cluster_mode_exception(self, mdm_cluster_module_mock): |
| 392 |
self.get_module_args.update({ |
| 393 |
"cluster_mode": "FiveNodes", |
| 394 |
"mdm": [ |
| 395 |
{ |
| 396 |
"mdm_name": MockMdmClusterApi.MDM_NAME_STB_MGR, |
| 397 |
"mdm_id": None, |
| 398 |
"mdm_type": "Secondary" |
| 399 |
}, |
| 400 |
{ |
| 401 |
"mdm_id": MockMdmClusterApi.STB_TB_MDM_ID, |
| 402 |
"mdm_name": None, |
| 403 |
"mdm_type": "TieBreaker" |
| 404 |
} |
| 405 |
], |
| 406 |
"mdm_state": "present-in-cluster", |
| 407 |
"state": "present" |
| 408 |
}) |
| 409 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 410 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 411 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 412 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 413 |
) |
| 414 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode = MagicMock( |
| 415 |
side_effect=utils.PowerFlexClient |
| 416 |
) |
| 417 |
mdm_cluster_module_mock.perform_module_operation() |
| 418 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode.assert_called() |
| 419 |
assert MockMdmClusterApi.switch_mode_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 420 |
|
| 421 |
def test_reduce_mdm_cluster_mode(self, mdm_cluster_module_mock): |
| 422 |
self.get_module_args.update({ |
| 423 |
"cluster_mode": "ThreeNodes", |
| 424 |
"mdm": [ |
| 425 |
{ |
| 426 |
"mdm_name": None, |
| 427 |
"mdm_id": MockMdmClusterApi.STB_MGR_MDM_ID, |
| 428 |
"mdm_type": "Secondary" |
| 429 |
}, |
| 430 |
{ |
| 431 |
"mdm_id": None, |
| 432 |
"mdm_name": MockMdmClusterApi.MDM_NAME, |
| 433 |
"mdm_type": "TieBreaker" |
| 434 |
} |
| 435 |
], |
| 436 |
"mdm_state": "absent-in-cluster", |
| 437 |
"state": "present" |
| 438 |
}) |
| 439 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 440 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.FIVE_MDM_CLUSTER_DETAILS) |
| 441 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 442 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 443 |
) |
| 444 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode = MagicMock() |
| 445 |
mdm_cluster_module_mock.perform_module_operation() |
| 446 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode.assert_called() |
| 447 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 448 |
|
| 449 |
def test_clear_virtual_ip_interface_mdm(self, mdm_cluster_module_mock): |
| 450 |
self.get_module_args.update({ |
| 451 |
"mdm_id": MockMdmClusterApi.STB_MGR_MDM_ID, |
| 452 |
"clear_interfaces": True, |
| 453 |
"state": "present" |
| 454 |
}) |
| 455 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 456 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 457 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 458 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 459 |
) |
| 460 |
mdm_cluster_module_mock.powerflex_conn.system.modify_virtual_ip_interface = MagicMock() |
| 461 |
mdm_cluster_module_mock.perform_module_operation() |
| 462 |
mdm_cluster_module_mock.powerflex_conn.system.modify_virtual_ip_interface.assert_called() |
| 463 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 464 |
|
| 465 |
def test_clear_virtual_ip_interface_mdm_idempotency(self, mdm_cluster_module_mock): |
| 466 |
self.get_module_args.update({ |
| 467 |
"mdm_name": "sample_mdm11", |
| 468 |
"clear_interfaces": True, |
| 469 |
"state": "present" |
| 470 |
}) |
| 471 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 472 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.FIVE_MDM_CLUSTER_DETAILS) |
| 473 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 474 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 475 |
) |
| 476 |
mdm_cluster_module_mock.perform_module_operation() |
| 477 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is False |
| 478 |
|
| 479 |
def test_get_system_id_exception(self, mdm_cluster_module_mock): |
| 480 |
self.get_module_args.update({ |
| 481 |
"state": "present" |
| 482 |
}) |
| 483 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 484 |
mdm_cluster_module_mock.powerflex_conn.system.get = MagicMock( |
| 485 |
side_effect=utils.PowerFlexClient |
| 486 |
) |
| 487 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 488 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 489 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 490 |
) |
| 491 |
mdm_cluster_module_mock.perform_module_operation() |
| 492 |
assert MockMdmClusterApi.system_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 493 |
|
| 494 |
def test_remove_mdm_cluster_owner_none(self, mdm_cluster_module_mock): |
| 495 |
self.get_module_args.update({ |
| 496 |
"state": "absent" |
| 497 |
}) |
| 498 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 499 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 500 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 501 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 502 |
) |
| 503 |
mdm_cluster_module_mock.perform_module_operation() |
| 504 |
assert MockMdmClusterApi.remove_mdm_no_id_name_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 505 |
|
| 506 |
def test_expand_cluster_without_standby(self, mdm_cluster_module_mock): |
| 507 |
self.get_module_args.update({ |
| 508 |
"cluster_mode": "FiveNodes", |
| 509 |
"mdm": [ |
| 510 |
{ |
| 511 |
"mdm_name": None, |
| 512 |
"mdm_id": None, |
| 513 |
"mdm_type": "Secondary" |
| 514 |
}, |
| 515 |
{ |
| 516 |
"mdm_id": None, |
| 517 |
"mdm_name": None, |
| 518 |
"mdm_type": "TieBreaker" |
| 519 |
} |
| 520 |
], |
| 521 |
"mdm_state": "present-in-cluster", |
| 522 |
"state": "present" |
| 523 |
}) |
| 524 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 525 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS_2) |
| 526 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 527 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 528 |
) |
| 529 |
mdm_cluster_module_mock.perform_module_operation() |
| 530 |
assert MockMdmClusterApi.without_standby_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 531 |
|
| 532 |
def test_get_system_exception(self, mdm_cluster_module_mock): |
| 533 |
self.get_module_args.update({ |
| 534 |
"state": "present" |
| 535 |
}) |
| 536 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 537 |
system_resp = MockSDKResponse(MockMdmClusterApi.PARTIAL_SYSTEM_DETAILS_1) |
| 538 |
mdm_cluster_module_mock.powerflex_conn.system.get = MagicMock( |
| 539 |
return_value=system_resp.__dict__['data'] |
| 540 |
) |
| 541 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 542 |
return_value={} |
| 543 |
) |
| 544 |
mdm_cluster_module_mock.perform_module_operation() |
| 545 |
assert MockMdmClusterApi.no_cluster_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 546 |
|
| 547 |
def test_clear_virtual_ip_interface_mdm_id_none(self, mdm_cluster_module_mock): |
| 548 |
self.get_module_args.update({ |
| 549 |
"mdm_id": None, |
| 550 |
"clear_interfaces": True, |
| 551 |
"state": "present" |
| 552 |
}) |
| 553 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 554 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 555 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 556 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 557 |
) |
| 558 |
mdm_cluster_module_mock.is_mdm_name_id_exists = MagicMock( |
| 559 |
return_value=MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS['master'] |
| 560 |
) |
| 561 |
mdm_cluster_module_mock.perform_module_operation() |
| 562 |
assert MockMdmClusterApi.id_none_interface_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 563 |
|
| 564 |
def test_rename_mdm_id_none(self, mdm_cluster_module_mock): |
| 565 |
self.get_module_args.update({ |
| 566 |
"mdm_id": None, |
| 567 |
"mdm_new_name": "new_node", |
| 568 |
"state": "present" |
| 569 |
}) |
| 570 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 571 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 572 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 573 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 574 |
) |
| 575 |
mdm_cluster_module_mock.is_mdm_name_id_exists = MagicMock( |
| 576 |
return_value=MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS['master'] |
| 577 |
) |
| 578 |
mdm_cluster_module_mock.perform_module_operation() |
| 579 |
assert MockMdmClusterApi.id_none_rename_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 580 |
|
| 581 |
def test_change_owner_id_none(self, mdm_cluster_module_mock): |
| 582 |
self.get_module_args.update({ |
| 583 |
"mdm_id": None, |
| 584 |
"is_primary": True, |
| 585 |
"state": "present" |
| 586 |
}) |
| 587 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 588 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 589 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 590 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 591 |
) |
| 592 |
mdm_cluster_module_mock.is_mdm_name_id_exists = MagicMock( |
| 593 |
return_value=MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS['master'] |
| 594 |
) |
| 595 |
mdm_cluster_module_mock.perform_module_operation() |
| 596 |
assert MockMdmClusterApi.id_none_change_owner_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 597 |
|
| 598 |
def test_get_multiple_system_exception(self, mdm_cluster_module_mock): |
| 599 |
self.get_module_args.update({ |
| 600 |
"state": "present" |
| 601 |
}) |
| 602 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 603 |
system_resp = MockSDKResponse(MockMdmClusterApi.PARTIAL_SYSTEM_DETAILS) |
| 604 |
mdm_cluster_module_mock.powerflex_conn.system.get = MagicMock( |
| 605 |
return_value=system_resp.__dict__['data'] |
| 606 |
) |
| 607 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 608 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 609 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 610 |
) |
| 611 |
mdm_cluster_module_mock.perform_module_operation() |
| 612 |
assert MockMdmClusterApi.multiple_system_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 613 |
|
| 614 |
def test_add_standby_mdm_new_name_exception(self, mdm_cluster_module_mock): |
| 615 |
self.get_module_args.update({ |
| 616 |
"mdm_name": "standby_node", |
| 617 |
"standby_mdm": { |
| 618 |
"mdm_ips": [self.add_mdm_ip], |
| 619 |
"role": "Manager", |
| 620 |
"port": 9011, |
| 621 |
"management_ips": [self.add_mdm_ip], |
| 622 |
"virtual_interfaces": ["ens1"], |
| 623 |
"allow_multiple_ips": True |
| 624 |
}, |
| 625 |
"mdm_new_name": "new_node", |
| 626 |
"state": "present" |
| 627 |
}) |
| 628 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 629 |
mdm_cluster_module_mock.get_mdm_cluster_details = MagicMock( |
| 630 |
return_value=MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS |
| 631 |
) |
| 632 |
mdm_cluster_module_mock.is_mdm_name_id_exists = MagicMock( |
| 633 |
return_value=MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS['master'] |
| 634 |
) |
| 635 |
mdm_cluster_module_mock.perform_module_operation() |
| 636 |
assert MockMdmClusterApi.new_name_add_mdm_failed_response() in mdm_cluster_module_mock.module.fail_json.call_args[1]['msg'] |
| 637 |
|
| 638 |
def test_change_cluster_mode(self, mdm_cluster_module_mock): |
| 639 |
self.get_module_args.update({ |
| 640 |
"cluster_mode": "FiveNodes", |
| 641 |
"mdm": [ |
| 642 |
{ |
| 643 |
"mdm_name": MockMdmClusterApi.MDM_NAME_STB_MGR, |
| 644 |
"mdm_id": None, |
| 645 |
"mdm_type": "Secondary" |
| 646 |
}, |
| 647 |
{ |
| 648 |
"mdm_id": MockMdmClusterApi.STB_TB_MDM_ID, |
| 649 |
"mdm_name": None, |
| 650 |
"mdm_type": "TieBreaker" |
| 651 |
} |
| 652 |
], |
| 653 |
"mdm_state": "absent-in-cluster", |
| 654 |
"state": "present" |
| 655 |
}) |
| 656 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 657 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 658 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 659 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 660 |
) |
| 661 |
mdm_cluster_module_mock.validate_parameters = MagicMock(return_value=None) |
| 662 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode = MagicMock() |
| 663 |
mdm_cluster_module_mock.perform_module_operation() |
| 664 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 665 |
|
| 666 |
def test_change_cluster_mode_with_name(self, mdm_cluster_module_mock): |
| 667 |
self.get_module_args.update({ |
| 668 |
"cluster_mode": "FiveNodes", |
| 669 |
"mdm": [ |
| 670 |
{ |
| 671 |
"mdm_name": MockMdmClusterApi.MDM_NAME_STB_MGR, |
| 672 |
"mdm_id": MockMdmClusterApi.MDM_ID, |
| 673 |
"mdm_type": "Secondary" |
| 674 |
}, |
| 675 |
{ |
| 676 |
"mdm_id": MockMdmClusterApi.STB_TB_MDM_ID, |
| 677 |
"mdm_name": MockMdmClusterApi.MDM_NAME, |
| 678 |
"mdm_type": "TieBreaker" |
| 679 |
} |
| 680 |
], |
| 681 |
"mdm_state": "absent-in-cluster", |
| 682 |
"state": "present" |
| 683 |
}) |
| 684 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 685 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 686 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 687 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 688 |
) |
| 689 |
mdm_cluster_module_mock.validate_parameters = MagicMock(return_value=None) |
| 690 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode = MagicMock() |
| 691 |
mdm_cluster_module_mock.perform_module_operation() |
| 692 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 693 |
|
| 694 |
def test_cluster_reduce_mode_absent(self, mdm_cluster_module_mock): |
| 695 |
self.get_module_args.update({ |
| 696 |
"cluster_mode": "FiveNodes", |
| 697 |
"mdm": [ |
| 698 |
{ |
| 699 |
"mdm_name": MockMdmClusterApi.MDM_NAME_STB_MGR, |
| 700 |
"mdm_id": None, |
| 701 |
"mdm_type": "Secondary" |
| 702 |
}, |
| 703 |
{ |
| 704 |
"mdm_id": None, |
| 705 |
"mdm_name": MockMdmClusterApi.MDM_NAME, |
| 706 |
"mdm_type": "TieBreaker" |
| 707 |
} |
| 708 |
], |
| 709 |
"mdm_state": "absent-in-cluster", |
| 710 |
"state": "present" |
| 711 |
}) |
| 712 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 713 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 714 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 715 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 716 |
) |
| 717 |
mdm_cluster_module_mock.is_mdm_name_id_exists = MagicMock(return_value=None) |
| 718 |
mdm_cluster_module_mock.validate_parameters = MagicMock(return_value=None) |
| 719 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode = MagicMock() |
| 720 |
mdm_cluster_module_mock.perform_module_operation() |
| 721 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 722 |
|
| 723 |
def test_cluster_expand_list_tb(self, mdm_cluster_module_mock): |
| 724 |
self.get_module_args.update({ |
| 725 |
"cluster_mode": "FiveNodes", |
| 726 |
"mdm": [ |
| 727 |
{ |
| 728 |
"mdm_name": MockMdmClusterApi.MDM_NAME_STB_MGR, |
| 729 |
"mdm_id": None, |
| 730 |
"mdm_type": "Secondary" |
| 731 |
}, |
| 732 |
{ |
| 733 |
"mdm_id": None, |
| 734 |
"mdm_name": MockMdmClusterApi.MDM_NAME, |
| 735 |
"mdm_type": "TieBreaker" |
| 736 |
} |
| 737 |
], |
| 738 |
"mdm_state": "present-in-cluster", |
| 739 |
"state": "present" |
| 740 |
}) |
| 741 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 742 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 743 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 744 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 745 |
) |
| 746 |
mdm_cluster_module_mock.validate_parameters = MagicMock(return_value=None) |
| 747 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode = MagicMock() |
| 748 |
mdm_cluster_module_mock.perform_module_operation() |
| 749 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |
| 750 |
|
| 751 |
def test_cluster_expand_list_tb_mdm_none(self, mdm_cluster_module_mock): |
| 752 |
self.get_module_args.update({ |
| 753 |
"cluster_mode": "FiveNodes", |
| 754 |
"mdm": [ |
| 755 |
{ |
| 756 |
"mdm_name": MockMdmClusterApi.MDM_NAME_STB_MGR, |
| 757 |
"mdm_id": None, |
| 758 |
"mdm_type": "Secondary" |
| 759 |
}, |
| 760 |
{ |
| 761 |
"mdm_id": None, |
| 762 |
"mdm_name": MockMdmClusterApi.MDM_NAME, |
| 763 |
"mdm_type": "TieBreaker" |
| 764 |
} |
| 765 |
], |
| 766 |
"mdm_state": "present-in-cluster", |
| 767 |
"state": "present" |
| 768 |
}) |
| 769 |
mdm_cluster_module_mock.module.params = self.get_module_args |
| 770 |
mdm_cluster_resp = MockSDKResponse(MockMdmClusterApi.THREE_MDM_CLUSTER_DETAILS) |
| 771 |
mdm_cluster_module_mock.powerflex_conn.system.get_mdm_cluster_details = MagicMock( |
| 772 |
return_value=mdm_cluster_resp.__dict__['data'] |
| 773 |
) |
| 774 |
mdm_cluster_module_mock.is_mdm_name_id_exists = MagicMock(return_value=None) |
| 775 |
mdm_cluster_module_mock.validate_parameters = MagicMock(return_value=None) |
| 776 |
mdm_cluster_module_mock.powerflex_conn.system.switch_cluster_mode = MagicMock() |
| 777 |
mdm_cluster_module_mock.perform_module_operation() |
| 778 |
assert mdm_cluster_module_mock.module.exit_json.call_args[1]['changed'] is True |