break vm_action into vm.start() and vm.stop() and image.list() -> image._list()

This commit is contained in:
ahmadbilalkhalid 2019-09-01 22:09:08 +05:00
parent 61d1633599
commit 5e543fa2aa
4 changed files with 17 additions and 6 deletions

3
.gitignore vendored
View file

@ -3,3 +3,6 @@ venv/
.vscode/ .vscode/
.env .env
__pycache__/ __pycache__/
# To ignore specs files
*.json

View file

@ -14,7 +14,7 @@ def image():
@image.command("list") @image.command("list")
@click.option("--public", is_flag=True) @click.option("--public", is_flag=True)
@click.option("--private", is_flag=True) @click.option("--private", is_flag=True)
def list(public, private): def _list(public, private):
if public: if public:
r = requests.get(f"{config('UCLOUD_API_SERVER')}/image/list-public") r = requests.get(f"{config('UCLOUD_API_SERVER')}/image/list-public")
print(load_dump_pretty(r.content)) print(load_dump_pretty(r.content))

View file

@ -35,14 +35,23 @@ def create(name, realm, seed, specs, image_uuid):
print(load_dump_pretty(r.content)) print(load_dump_pretty(r.content))
@vm.command("action") @vm.command("start")
@click.option("--name", envvar="OTP_NAME", required=True) @click.option("--name", envvar="OTP_NAME", required=True)
@click.option("--realm", envvar="OTP_REALM", required=True) @click.option("--realm", envvar="OTP_REALM", required=True)
@click.option("--seed", envvar="OTP_SEED", required=True) @click.option("--seed", envvar="OTP_SEED", required=True)
@click.option("--uuid", required=True) @click.option("--uuid", required=True)
@click.option("--command", required=True) def start(name, realm, seed, uuid):
def vm_action(name, realm, seed, uuid, command): r = vm_command("start", OTPCredentials(name, realm, seed), uuid)
r = vm_command(command, OTPCredentials(name, realm, seed), uuid) print(load_dump_pretty(r.content))
@vm.command("stop")
@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("--uuid", required=True)
def stop(name, realm, seed, uuid):
r = vm_command("stop", OTPCredentials(name, realm, seed), uuid)
print(load_dump_pretty(r.content)) print(load_dump_pretty(r.content))

View file

@ -1,4 +1,3 @@
import argparse
import click import click
from commands.vm import vm from commands.vm import vm