INNER CODE UNIT · Python
api_call
LINBIT/linstor-server · scripts/linstor-controller-ha-setup.py:189
def api_call(what, call, *call_args, **call_kwargs):
"""Announce a LINSTOR API call, make it, and fail on any error it reports.
The steps this replaced were `linstor ...` command lines that run() echoed
before running them, so announce these the same way and before the call:
spawning a resource takes a while, and a run that appears to do nothing
meanwhile is not one an operator can follow.
"""
print("+ linstor: " + what, flush=True)
responses = call(*call_args, **call_kwargs)
for response in responses:
if response.is_error():
die(what + " failed: " + response.message)
return responses
def die(msg):
print("ERROR: " + msg, file=sys.stderr)