Merge "Throw a proper error if the flavor is missing."
This commit is contained in:
commit
4400520aed
|
@ -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.")
|
||||
|
||||
|
|
|
@ -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']:
|
||||
|
|
Loading…
Reference in New Issue