45 lines
1.7 KiB
Python
Executable File
45 lines
1.7 KiB
Python
Executable File
#!/usr/bin/python3
|
|
|
|
import argparse
|
|
import sys
|
|
|
|
def vmm_start(args):
|
|
if args.v >= 1:
|
|
print('Starting VM {0.vmid}.'.format(args))
|
|
|
|
def vmm_stop(args):
|
|
if args.v >= 1:
|
|
print('Stopping VM {0.vmid}.'.format(args))
|
|
|
|
def vmm_status(args):
|
|
if args.v >= 2:
|
|
print('Gathering status information for VM {0.vmid}.'.format(args))
|
|
|
|
def main():
|
|
print("MC VM Manager v0.1\nCopyright (c) M. Hauschild, 2013.\n")
|
|
|
|
parser = argparse.ArgumentParser(prog='bkvmm', description='Manages VMs')
|
|
subparsers = parser.add_subparsers(title='subcommands')
|
|
parser.add_argument('-v', action='count', default=0, help='increase verbosity')
|
|
|
|
parser_start = subparsers.add_parser('start', help='starts a VM')
|
|
parser_start.add_argument('vmid', action='store', help='the ID of the VM')
|
|
parser_start.add_argument('-v', action='count', default=0, help='increase verbosity')
|
|
parser_start.set_defaults(func=vmm_start)
|
|
|
|
parser_stop = subparsers.add_parser('stop', help='stop a VM')
|
|
parser_stop.add_argument('vmid', action='store', help='the ID of the VM')
|
|
parser_stop.add_argument('-v', action='count', default=0, help='increase verbosity')
|
|
parser_stop.set_defaults(func=vmm_stop)
|
|
|
|
parser_status = subparsers.add_parser('status', help='statuss a VM')
|
|
parser_status.add_argument('-v', action='count', help='increase verbosity')
|
|
parser_status.add_argument('vmid', action='store', default=0, help='the ID of the VM')
|
|
parser_status.set_defaults(func=vmm_status)
|
|
|
|
args = parser.parse_args()
|
|
args.func(args)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|