INNER CODE UNIT · Python
choose
LINBIT/linstor-server · scripts/linstor-controller-ha-setup.py:460
def choose(prompt, options):
"""Interactive numbered picker; falls back to a clear error when there is
no TTY (e.g. the script is being piped) so automation can pass the
--storage-pool option instead."""
for i, opt in enumerate(options, 1):
print(" " + str(i) + ") " + opt)
try:
reply = input(prompt + " [1-" + str(len(options)) + "] ").strip()
except EOFError:
die("multiple storage pools and no TTY to choose — pass "
"--storage-pool NAME")
if reply.isdigit() and 1 <= int(reply) <= len(options):
return options[int(reply) - 1]
die("invalid selection: " + reply)
def resolve_storage_pool(requested):
"""Discover the storage pool from the live cluster. A single (non-diskless)