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

Function wait_to_complete_state_transition

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

Source from the content-addressed store, hash-verified

199
200
201def wait_to_complete_state_transition(compute_api, server):
202 wait = compute_api.module.params["wait"]
203 if not wait:
204 return
205 wait_timeout = compute_api.module.params["wait_timeout"]
206 wait_sleep_time = compute_api.module.params["wait_sleep_time"]
207
208 start = datetime.datetime.utcnow()
209 end = start + datetime.timedelta(seconds=wait_timeout)
210 while datetime.datetime.utcnow() < end:
211 compute_api.module.debug("We are going to wait for the server to finish its transition")
212 if fetch_state(compute_api, server) not in SCALEWAY_TRANSITIONS_STATES:
213 compute_api.module.debug("It seems that the server is not in transition anymore.")
214 compute_api.module.debug("Server in state: %s" % fetch_state(compute_api, server))
215 break
216 time.sleep(wait_sleep_time)
217 else:
218 compute_api.module.fail_json(msg="Server takes too long to finish its transition")
219
220
221def public_ip_payload(compute_api, public_ip):

Callers 7

create_serverFunction · 0.85
perform_actionFunction · 0.85
remove_serverFunction · 0.85
absent_strategyFunction · 0.85
stop_strategyFunction · 0.85
restart_strategyFunction · 0.85
server_change_attributesFunction · 0.85

Calls 2

fetch_stateFunction · 0.85
fail_jsonMethod · 0.80

Tested by

no test coverage detected