2019-09-13 12:33:19 +00:00
|
|
|
from commands.helper import load_dump_pretty
|
2019-07-17 14:58:39 +00:00
|
|
|
from decouple import config
|
|
|
|
|
2019-09-13 12:33:19 +00:00
|
|
|
import click
|
|
|
|
import requests
|
2019-07-17 14:58:39 +00:00
|
|
|
|
|
|
|
@click.group()
|
|
|
|
def image():
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@image.command("list")
|
|
|
|
@click.option("--public", is_flag=True)
|
|
|
|
@click.option("--private", is_flag=True)
|
2019-09-01 17:09:08 +00:00
|
|
|
def _list(public, private):
|
2019-07-17 14:58:39 +00:00
|
|
|
if public:
|
2019-09-13 12:33:19 +00:00
|
|
|
r = requests.get("{}/image/list-public".format(config('UCLOUD_API_SERVER')))
|
2019-08-12 12:56:19 +00:00
|
|
|
print(load_dump_pretty(r.content))
|
2019-07-17 14:58:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
@image.command("create-from-file")
|
|
|
|
@click.option("--name", required=True)
|
|
|
|
@click.option("--uuid", required=True)
|
2019-10-25 06:49:04 +00:00
|
|
|
@click.option("--image-store-name", required=True)
|
2019-07-17 14:58:39 +00:00
|
|
|
def create_from_file(name, uuid, image_store_name):
|
|
|
|
data = {"name": name, "uuid": uuid, "image_store": image_store_name}
|
2019-09-13 12:33:19 +00:00
|
|
|
r = requests.post("{}/image/create".format(config('UCLOUD_API_SERVER')), json=data)
|
2019-08-12 12:56:19 +00:00
|
|
|
print(load_dump_pretty(r.content))
|