(configfile, host, zone, pod)
| 484 | open(fn,"w").write(text) |
| 485 | |
| 486 | def setup_consoleproxy_config(configfile, host, zone, pod): |
| 487 | stderr("Examining Console Proxy configuration") |
| 488 | fn = configfile |
| 489 | text = open(fn).read(-1) |
| 490 | lines = [ s.strip() for s in text.splitlines() ] |
| 491 | confopts = dict([ m.split("=",1) for m in lines if "=" in m and not m.startswith("#") ]) |
| 492 | confposes = dict([ (m.split("=",1)[0],n) for n,m in enumerate(lines) if "=" in m and not m.startswith("#") ]) |
| 493 | |
| 494 | if "guid" not in confopts: |
| 495 | stderr("Generating GUID for this Console Proxy") |
| 496 | confopts['guid'] = uuidgen().stdout.strip() |
| 497 | |
| 498 | if host == None: |
| 499 | try: host = confopts["host"] |
| 500 | except KeyError: host = "localhost" |
| 501 | stderr("Please enter the host name of the management server that this console-proxy will connect to: (just hit ENTER to go with %s)",host) |
| 502 | print("> ", end=' ') |
| 503 | newhost = input().strip() |
| 504 | if newhost: host = newhost |
| 505 | confopts["host"] = host |
| 506 | |
| 507 | stderr("Querying %s for zones and pods",host) |
| 508 | |
| 509 | try: |
| 510 | if zone == None or pod == None: |
| 511 | x = list_zonespods(confopts['host']) |
| 512 | zoneandpod = prompt_for_hostpods(x) |
| 513 | if zoneandpod: |
| 514 | confopts["zone"],confopts["pod"] = zoneandpod |
| 515 | stderr("You selected zone %s pod %s",confopts["zone"],confopts["pod"]) |
| 516 | else: |
| 517 | stderr("Skipped -- using the previous zone %s pod %s",confopts["zone"],confopts["pod"]) |
| 518 | else: |
| 519 | confopts["zone"] = zone |
| 520 | confopts["pod"] = pod |
| 521 | except (urllib.error.URLError,urllib.error.HTTPError) as e: |
| 522 | stderr("Query failed: %s. Defaulting to zone %s pod %s",str(e),confopts["zone"],confopts["pod"]) |
| 523 | |
| 524 | for opt,val in list(confopts.items()): |
| 525 | line = "=".join([opt,val]) |
| 526 | if opt not in confposes: lines.append(line) |
| 527 | else: lines[confposes[opt]] = line |
| 528 | |
| 529 | text = "\n".join(lines) |
| 530 | open(fn,"w").write(text) |
| 531 | |
| 532 | # =========================== DATABASE MIGRATION SUPPORT CODE =================== |
| 533 |
nothing calls this directly
no test coverage detected