From c6a3c766ee336a6ba873b041a5ec5711a20a911a Mon Sep 17 00:00:00 2001 From: Ravi Shekhar Jethani Date: Tue, 29 Sep 2015 23:58:09 -0700 Subject: [PATCH] Check flavor option before image checks Currently flavor option is checked after performing the image checks which results in unnecessary image checks even if flavor option is not passed at all. Moved flavor option check at the beginning of the method to eliminate the expensive operations performed as part of image check. Closes-Bug: #1502866 Change-Id: Ic68690b3d985d78ba0312bf5421989ccba7ceea8 --- novaclient/v2/shell.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index bb5a3f857..67f5dc93c 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -150,6 +150,9 @@ def _parse_block_device_mapping_v2(args, image): def _boot(cs, args): """Boot a new server.""" + if not args.flavor: + raise exceptions.CommandError(_("you need to specify a Flavor ID.")) + if args.image: image = _find_image(cs, args.image) else: @@ -162,9 +165,6 @@ def _boot(cs, args): # are selecting the first of many? image = images[0] - if not args.flavor: - raise exceptions.CommandError(_("you need to specify a Flavor ID ")) - min_count = 1 max_count = 1 # Don't let user mix num_instances and max_count/min_count.