list user files, list user vm added
This commit is contained in:
parent
a82bbb5ab1
commit
c4cf097b99
1 changed files with 32 additions and 14 deletions
46
ucloud.py
46
ucloud.py
|
@ -30,6 +30,14 @@ images_parser.add_argument("--list",
|
|||
choices=["public", "private"],
|
||||
required=True)
|
||||
|
||||
user_parser = subparser.add_parser("user")
|
||||
user_subparser = user_parser.add_subparsers(dest="usercommand")
|
||||
|
||||
user_list_vms_parser = user_subparser.add_parser("list")
|
||||
user_list_vms_parser.add_argument("--files", action='store_true')
|
||||
user_list_vms_parser.add_argument("--vms", action='store_true')
|
||||
add_otp(user_list_vms_parser)
|
||||
|
||||
vm_parser = subparser.add_parser("vm")
|
||||
vm_subparser = vm_parser.add_subparsers(dest="vmcommand")
|
||||
|
||||
|
@ -42,17 +50,15 @@ vm_create_parser.add_argument("--image_uuid", required=True)
|
|||
vm_start_parser = vm_subparser.add_parser("start")
|
||||
vm_suspend_parser = vm_subparser.add_parser("suspend")
|
||||
vm_resume_parser = vm_subparser.add_parser("resume")
|
||||
vm_shutdown_parser = vm_subparser.add_parser("shutdown")
|
||||
vm_status_parser = vm_subparser.add_parser("status")
|
||||
|
||||
add_vmid(add_otp(vm_start_parser))
|
||||
add_vmid(add_otp(vm_suspend_parser))
|
||||
add_vmid(add_otp(vm_resume_parser))
|
||||
add_vmid(add_otp(vm_shutdown_parser))
|
||||
add_vmid(add_otp(vm_status_parser))
|
||||
|
||||
|
||||
vm_list_parser = vm_subparser.add_parser("list")
|
||||
add_otp(vm_list_parser)
|
||||
|
||||
args = argparser.parse_args()
|
||||
|
||||
if args.command == "create-image-from-file":
|
||||
|
@ -86,16 +92,8 @@ elif args.command == "vm":
|
|||
r = requests.post(f"{config('UCLOUD_API_SERVER')}/vm/create",
|
||||
json=data)
|
||||
print(json.loads(r.content))
|
||||
elif args.vmcommand == "list":
|
||||
data = {
|
||||
"name": args.name,
|
||||
"realm": args.realm,
|
||||
"token": TOTP(args.seed).now()
|
||||
}
|
||||
r = requests.get(f"{config('UCLOUD_API_SERVER')}/user/vms",
|
||||
json=data)
|
||||
print(json.loads(r.content))
|
||||
elif args.vmcommand in ["start", "suspend", "resume", "status"]:
|
||||
elif args.vmcommand in ["start", "suspend", "resume",
|
||||
"status", "shutdown"]:
|
||||
data = {
|
||||
"name": args.name,
|
||||
"realm": args.realm,
|
||||
|
@ -107,3 +105,23 @@ elif args.command == "vm":
|
|||
else:
|
||||
r = requests.post(f"{config('UCLOUD_API_SERVER')}/vm/{args.vmcommand}", json=data)
|
||||
print(json.loads(r.content))
|
||||
|
||||
elif args.command == "user":
|
||||
if args.usercommand == "list" and args.vms:
|
||||
data = {
|
||||
"name": args.name,
|
||||
"realm": args.realm,
|
||||
"token": TOTP(args.seed).now()
|
||||
}
|
||||
r = requests.get(f"{config('UCLOUD_API_SERVER')}/user/vms",
|
||||
json=data)
|
||||
print(json.loads(r.content))
|
||||
elif args.usercommand == "list" and args.files:
|
||||
data = {
|
||||
"name": args.name,
|
||||
"realm": args.realm,
|
||||
"token": TOTP(args.seed).now()
|
||||
}
|
||||
r = requests.get(f"{config('UCLOUD_API_SERVER')}/user/files",
|
||||
json=data)
|
||||
print(json.loads(r.content))
|
Loading…
Reference in a new issue