(compute_api, target_server, wished_server)
| 558 | |
| 559 | |
| 560 | def server_attributes_should_be_changed(compute_api, target_server, wished_server): |
| 561 | compute_api.module.debug("Checking if server attributes should be changed") |
| 562 | compute_api.module.debug("Current Server: %s" % target_server) |
| 563 | compute_api.module.debug("Wished Server: %s" % wished_server) |
| 564 | debug_dict = dict( |
| 565 | (x, (target_server[x], wished_server[x])) |
| 566 | for x in PATCH_MUTABLE_SERVER_ATTRIBUTES |
| 567 | if x in target_server and x in wished_server |
| 568 | ) |
| 569 | compute_api.module.debug("Debug dict %s" % debug_dict) |
| 570 | try: |
| 571 | for key in PATCH_MUTABLE_SERVER_ATTRIBUTES: |
| 572 | if key in target_server and key in wished_server: |
| 573 | # When you are working with dict, only ID matter as we ask user to put only the resource ID in the playbook |
| 574 | if ( |
| 575 | isinstance(target_server[key], dict) |
| 576 | and wished_server[key] |
| 577 | and "id" in target_server[key].keys() |
| 578 | and target_server[key]["id"] != wished_server[key] |
| 579 | ): |
| 580 | return True |
| 581 | # Handling other structure compare simply the two objects content |
| 582 | elif not isinstance(target_server[key], dict) and target_server[key] != wished_server[key]: |
| 583 | return True |
| 584 | return False |
| 585 | except AttributeError: |
| 586 | compute_api.module.fail_json(msg="Error while checking if attributes should be changed") |
| 587 | |
| 588 | |
| 589 | def server_change_attributes(compute_api, target_server, wished_server): |
no test coverage detected