From 5e543fa2aabf47b19fae9a64985489aa007f87ba Mon Sep 17 00:00:00 2001 From: Ahmed Bilal Khalid Date: Sun, 1 Sep 2019 22:09:08 +0500 Subject: [PATCH] break vm_action into vm.start() and vm.stop() and image.list() -> image._list() --- .gitignore | 3 +++ commands/image.py | 2 +- commands/vm.py | 17 +++++++++++++---- ucloud.py | 1 - 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index bd69026..f934b7b 100755 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ venv/ .vscode/ .env __pycache__/ + +# To ignore specs files +*.json diff --git a/commands/image.py b/commands/image.py index 9fcf860..eb5b429 100755 --- a/commands/image.py +++ b/commands/image.py @@ -14,7 +14,7 @@ def image(): @image.command("list") @click.option("--public", is_flag=True) @click.option("--private", is_flag=True) -def list(public, private): +def _list(public, private): if public: r = requests.get(f"{config('UCLOUD_API_SERVER')}/image/list-public") print(load_dump_pretty(r.content)) diff --git a/commands/vm.py b/commands/vm.py index 0a3b055..204ee9a 100755 --- a/commands/vm.py +++ b/commands/vm.py @@ -35,14 +35,23 @@ def create(name, realm, seed, specs, image_uuid): print(load_dump_pretty(r.content)) -@vm.command("action") +@vm.command("start") @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) -@click.option("--command", required=True) -def vm_action(name, realm, seed, uuid, command): - r = vm_command(command, OTPCredentials(name, realm, seed), uuid) +def start(name, realm, seed, uuid): + r = vm_command("start", 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)) diff --git a/ucloud.py b/ucloud.py index b0d998d..ceb26fc 100755 --- a/ucloud.py +++ b/ucloud.py @@ -1,4 +1,3 @@ -import argparse import click from commands.vm import vm