mirror of
https://github.com/gryf/boxpy.git
synced 2025-12-20 22:27:58 +01:00
Remove unneeded intermediate function for invoking action class.
This commit is contained in:
15
box.py
15
box.py
@@ -286,18 +286,17 @@ class VMCreate:
|
|||||||
subprocess.call(['rm', '-fr', self._tmp])
|
subprocess.call(['rm', '-fr', self._tmp])
|
||||||
|
|
||||||
|
|
||||||
def _create(args):
|
|
||||||
return VMCreate(args).run()
|
|
||||||
|
|
||||||
|
|
||||||
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 "
|
||||||
"VirtualBox and Ubuntu cloud images")
|
"VirtualBox and Ubuntu cloud images")
|
||||||
subparsers = parser.add_subparsers(help='supported commands')
|
subparsers = parser.add_subparsers(help='supported commands')
|
||||||
create = subparsers.add_parser('create')
|
|
||||||
create.add_argument('name')
|
create = subparsers.add_parser('create', help='create and configure VM, '
|
||||||
create.set_defaults(func=_create)
|
'create corresponding assets, config '
|
||||||
|
'drive and run')
|
||||||
|
create.set_defaults(func=VMCreate)
|
||||||
|
create.add_argument('name', help='name of the VM')
|
||||||
create.add_argument('-m', '--memory', default=12288, type=int,
|
create.add_argument('-m', '--memory', default=12288, type=int,
|
||||||
help="amount of memory in Megabytes, default 12GB")
|
help="amount of memory in Megabytes, default 12GB")
|
||||||
create.add_argument('-c', '--cpus', default=6, type=int,
|
create.add_argument('-c', '--cpus', default=6, type=int,
|
||||||
@@ -316,7 +315,7 @@ def main():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return args.func(args)
|
return args.func(args).run()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
parser.exit()
|
parser.exit()
|
||||||
|
|||||||
Reference in New Issue
Block a user