much better cli
This commit is contained in:
parent
c4cf097b99
commit
d045d70609
11 changed files with 210 additions and 121 deletions
30
commands/host.py
Normal file
30
commands/host.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import click
|
||||
import json
|
||||
import requests
|
||||
|
||||
from decouple import config
|
||||
from helper import OTPCredentials
|
||||
|
||||
|
||||
@click.group()
|
||||
def host():
|
||||
pass
|
||||
|
||||
|
||||
@host.command("add")
|
||||
@click.option("--name", required=True)
|
||||
@click.option("--realm", required=True)
|
||||
@click.option("--seed", required=True)
|
||||
@click.option("--specs", required=True)
|
||||
@click.option("--hostname", required=True)
|
||||
def add_host(name, realm, seed, specs, hostname):
|
||||
with open(specs, "r") as specs_f:
|
||||
specs = json.loads(specs_f.read())
|
||||
data = {
|
||||
**OTPCredentials(name, realm, seed).get_json(),
|
||||
"specs": specs,
|
||||
"hostname": hostname,
|
||||
}
|
||||
r = requests.post(f"{config('UCLOUD_API_SERVER')}/host/create", json=data)
|
||||
|
||||
print(json.loads(r.content))
|
||||
Loading…
Add table
Add a link
Reference in a new issue