MCPcopy Create free account
hub / github.com/apache/cloudstack / prompt_for_hostpods

Function prompt_for_hostpods

python/lib/cloud_utils.py:382–408  ·  view source on GitHub ↗

Ask user to select one from those zonespods Returns (zone,pod) or None if the user made the default selection.

(zonespods)

Source from the content-addressed store, hash-verified

380 return x
381
382def prompt_for_hostpods(zonespods):
383 """Ask user to select one from those zonespods
384 Returns (zone,pod) or None if the user made the default selection."""
385 while True:
386 stderr("Type the number of the zone and pod combination this host belongs to (hit ENTER to skip this step)")
387 print(" N) ZONE, POD")
388 print("================")
389 for n,(z,p) in enumerate(zonespods):
390 print("%3d) %s, %s"%(n,z,p))
391 print("================")
392 print("> ", end=' ')
393 zoneandpod = input().strip()
394
395 if not zoneandpod:
396 # we go with default, do not touch anything, just break
397 return None
398
399 try:
400 # if parsing fails as an int, just vomit and retry
401 zoneandpod = int(zoneandpod)
402 if zoneandpod >= len(zonespods) or zoneandpod < 0: raise ValueError("%s out of bounds"%zoneandpod)
403 except ValueError as e:
404 stderr(str(e))
405 continue # re-ask
406
407 # oh yeah, the int represents an valid zone and pod index in the array
408 return zonespods[zoneandpod]
409
410# this configures the agent
411

Callers 2

setup_agent_configFunction · 0.85

Calls 2

stderrFunction · 0.85
intFunction · 0.85

Tested by

no test coverage detected