Fix --name support in oneshot

This commit is contained in:
fnux 2020-01-30 08:54:58 +01:00
parent 9e2751c41e
commit 8797e93baf

View file

@ -16,7 +16,7 @@ arg_parser = argparse.ArgumentParser('oneshot', add_help=False)
arg_parser.add_argument('--list', action='store_true',
help='list UUID and name of running VMs')
arg_parser.add_argument('--start', nargs=3,
metavar=('IMAGE', 'UPSTREAM_INTERFACE', 'NETWORK'),
metavar=('NAME', 'IMAGE', 'UPSTREAM_INTERFACE', 'NETWORK'),
help='start a VM using the OS IMAGE (full path), configuring networking on NETWORK IPv6 prefix')
arg_parser.add_argument('--stop', metavar='UUID',
help='stop a VM')
@ -95,9 +95,10 @@ def main(arguments):
update_radvd_conf([network])
elif arguments['start']:
# Extract from --start positional arguments. Quite fragile.
vm_config['image'] = arguments['start'][0]
vm_config['network'] = arguments['start'][1]
vm_config['upstream_interface'] = arguments['start'][2]
vm_config['name'] = arguments['start'][0]
vm_config['image'] = arguments['start'][1]
vm_config['network'] = arguments['start'][2]
vm_config['upstream_interface'] = arguments['start'][3]
vm_config['tap_interface'] = "uc{}".format(len(vmm.discover()))
vm = virtualmachine.VM(vmm, vm_config)