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
This commit is contained in:
Ravi Shekhar Jethani 2015-09-29 23:58:09 -07:00
parent 217e7c1849
commit c6a3c766ee

@ -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.