migration command added, OTP creds can be read from environment variables, json output is now formated nicely

This commit is contained in:
ahmadbilalkhalid 2019-08-12 17:56:19 +05:00
commit 61d1633599
5 changed files with 59 additions and 33 deletions

View file

@ -3,7 +3,7 @@ import json
import requests
from decouple import config
from .helper import OTPCredentials
from .helper import OTPCredentials, load_dump_pretty
@click.group()
@ -12,9 +12,9 @@ def host():
@host.command("add")
@click.option("--name", required=True)
@click.option("--realm", required=True)
@click.option("--seed", required=True)
@click.option("--name", envvar="OTP_NAME", required=True)
@click.option("--realm", envvar="OTP_REALM", required=True)
@click.option("--seed", envvar="OTP_SEED", required=True)
@click.option("--specs", required=True)
@click.option("--hostname", required=True)
def add_host(name, realm, seed, specs, hostname):
@ -26,5 +26,10 @@ def add_host(name, realm, seed, specs, hostname):
"hostname": hostname,
}
r = requests.post(f"{config('UCLOUD_API_SERVER')}/host/create", json=data)
print(load_dump_pretty(r.content))
print(json.loads(r.content))
@host.command("list")
def list_host():
r = requests.get(f"{config('UCLOUD_API_SERVER')}/host/list")
print(load_dump_pretty(r.content))