1
0
mirror of https://github.com/gryf/boxpy.git synced 2025-12-19 21:47:59 +01:00

Added list command.

This commit is contained in:
2021-04-08 21:47:25 +02:00
parent 69ff7206e5
commit 70248bd23b

21
box.py
View File

@@ -320,6 +320,19 @@ class VMDestroy:
raise BoxVBoxFailure(f'Removing VM {self.vm_name_or_uuid} failed')
class VMList:
def __init__(self, args):
self.running = args.running
self.long = args.long
def run(self):
subcommand = 'runningvms' if self.running else 'vms'
long_list = '-l' if self.long else '-s'
subprocess.call(['vboxmanage', 'list', subcommand, long_list])
def main():
parser = argparse.ArgumentParser(description="Automate deployment and "
"maintenance of Ubuntu VMs using "
@@ -350,6 +363,14 @@ def main():
destroy.add_argument('name', help='name or UUID of the VM')
destroy.set_defaults(func=VMDestroy)
list_vms = subparsers.add_parser('list', help='list VMs')
list_vms.add_argument('-l', '--long', action='store_true',
help='show detailed information '
'about VMs')
list_vms.add_argument('-r', '--running', action='store_true',
help='show only running VMs')
list_vms.set_defaults(func=VMList)
args = parser.parse_args()
try: