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

Function fetch_state

library/scaleway_compute.py:183–198  ·  view source on GitHub ↗
(compute_api, server)

Source from the content-addressed store, hash-verified

181
182
183def fetch_state(compute_api, server):
184 compute_api.module.debug("fetch_state of server: %s" % server["id"])
185 response = compute_api.get(path="servers/%s" % server["id"])
186
187 if response.status_code == 404:
188 return "absent"
189
190 if not response.ok:
191 msg = "Error during state fetching: (%s) %s" % (response.status_code, response.json)
192 compute_api.module.fail_json(msg=msg)
193
194 try:
195 compute_api.module.debug("Server %s in state: %s" % (server["id"], response.json["server"]["state"]))
196 return response.json["server"]["state"]
197 except KeyError:
198 compute_api.module.fail_json(msg="Could not fetch state in %s" % response.json)
199
200
201def wait_to_complete_state_transition(compute_api, server):

Callers 5

absent_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