mirror of
https://github.com/gryf/boxpy.git
synced 2025-12-19 13:37:58 +01:00
Added list command.
This commit is contained in:
21
box.py
21
box.py
@@ -320,6 +320,19 @@ class VMDestroy:
|
|||||||
raise BoxVBoxFailure(f'Removing VM {self.vm_name_or_uuid} failed')
|
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():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Automate deployment and "
|
parser = argparse.ArgumentParser(description="Automate deployment and "
|
||||||
"maintenance of Ubuntu VMs using "
|
"maintenance of Ubuntu VMs using "
|
||||||
@@ -350,6 +363,14 @@ def main():
|
|||||||
destroy.add_argument('name', help='name or UUID of the VM')
|
destroy.add_argument('name', help='name or UUID of the VM')
|
||||||
destroy.set_defaults(func=VMDestroy)
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user