Merge "Throw a proper error if the flavor is missing."

This commit is contained in:
Jenkins 2013-02-25 23:44:11 +00:00 committed by Gerrit Code Review
commit 4400520aed
2 changed files with 7 additions and 0 deletions

View File

@ -200,6 +200,10 @@ class UserKeyPairMissing(OpenstackException):
message = _("The Key (%(key_name)s) could not be found.")
class FlavorMissing(OpenstackException):
message = _("The Flavor ID (%(flavor_id)s) could not be found.")
class ImageNotFound(OpenstackException):
message = _("The Image (%(image_name)s) could not be found.")

View File

@ -243,10 +243,13 @@ class Instance(resource.Resource):
logger.info("Image %s was not found in glance" % image_name)
raise exception.ImageNotFound(image_name=image_name)
flavor_id = None
flavor_list = self.nova().flavors.list()
for o in flavor_list:
if o.name == flavor:
flavor_id = o.id
if flavor_id is None:
raise exception.FlavorMissing(flavor_id=flavor)
tags = {}
if self.properties['Tags']: