import click from uncloud_cli.commands.helper import add_otp_options, make_request, add_vm_options @click.group() def vm(): pass @vm.command('create') @add_otp_options @add_vm_options @click.option('--cpu', required=True, type=int) @click.option('--ram', required=True) @click.option('--os-ssd', required=True) @click.option('--hdd', default=list(), multiple=True) @click.option('--image', required=True) @click.option('--network', default=list(), multiple=True) def create(**kwargs): kwargs['specs'] = { 'cpu': kwargs.pop('cpu'), 'ram': kwargs.pop('ram'), 'os-ssd': kwargs.pop('os_ssd'), 'hdd': kwargs.pop('hdd') } make_request('vm', kwargs.pop('action'), data=kwargs) @vm.command('start') @add_otp_options @add_vm_options def start(**kwargs): make_request('vm', 'action', data=kwargs) @vm.command('stop') @add_otp_options @add_vm_options def stop(**kwargs): make_request('vm', 'action', data=kwargs) @vm.command('delete') @add_otp_options @add_vm_options def delete(**kwargs): make_request('vm', 'action', data=kwargs) @vm.command('status') @add_otp_options @click.option('--vm-name', required=True) def status(**kwargs): make_request('vm', 'status', data=kwargs) @vm.command('migrate') @add_otp_options @click.option('--vm-name', required=True) @click.option('--destination', required=True) def vm_migration(**kwargs): make_request('vm', 'migrate', data=kwargs)