33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
import argparse
|
|
from tabulate import tabulate
|
|
from ..models import StackStatus
|
|
|
|
def get_credential_parser():
|
|
credentialparser = argparse.ArgumentParser(
|
|
prog="login",
|
|
description="Subparser for login credentials provided by CI"
|
|
)
|
|
credentialparser.add_argument("--username", action="store", type=str, required=True)
|
|
credentialparser.add_argument("--password", action="store", type=str, required=True)
|
|
return credentialparser
|
|
|
|
def stack_formatter(stacks):
|
|
if not stacks["ok"]:
|
|
raise RuntimeError("Stack GET didn't work")
|
|
|
|
table, headers = [], ["Stackname", "Status"]
|
|
for key, val in stacks["stackList"].items():
|
|
table.append([key, StackStatus(val['status']).name])
|
|
|
|
print(tabulate(table, headers=headers, tablefmt="github"), "\n")
|
|
|
|
def status_formatter(status):
|
|
print(f"Is Stack Ok? {'Yes' if status['ok'] else 'No'}")
|
|
headers = ["Container", "Status"]
|
|
table = [[k, v] for k, v in status["serviceStatusList"].items()]
|
|
print(tabulate(table, headers=headers, tablefmt="github"), "\n")
|
|
|
|
def generic_formatter(status):
|
|
print(f"Is Ok? {'Yes' if status['ok'] else 'No'}")
|
|
print(f"Stack status: {status['msg']}")
|