MCPcopy
hub / github.com/trailofbits/algo / server_attributes_should_be_changed

Function server_attributes_should_be_changed

library/scaleway_compute.py:560–586  ·  view source on GitHub ↗
(compute_api, target_server, wished_server)

Source from the content-addressed store, hash-verified

558
559
560def 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
589def server_change_attributes(compute_api, target_server, wished_server):

Callers 4

present_strategyFunction · 0.85
running_strategyFunction · 0.85
stop_strategyFunction · 0.85
restart_strategyFunction · 0.85

Calls 1

fail_jsonMethod · 0.80

Tested by

no test coverage detected