Commit 22e9fd1b authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

ci: Get flavor by name

The option flavor_name support a list of flavors to try.

Refs #4192
parent af241a62
......@@ -32,6 +32,7 @@ kamaki_cloud =
# Server name to use for our machine
server_name = Synnefo Deployment
# Flavor name (reg expression) to use
# This is a list of flavor_names (comma seperated) to try
flavor_name = C8R8...D100drbd
# Image to use (name must contain this)
image_name = OldStable
......@@ -284,19 +284,23 @@ class SynnefoCI(object):
def _find_flavor(self, flavor_name):
"""Given a flavor_name (reg expression) find a flavor id to use"""
if flavor_name is None:
flavor_name = self.config.get('Deployment', 'flavor_name')
self.logger.debug("Try to find a flavor with name \"%s\"" % flavor_name)
# Get a list of flavor names from config file
flavor_names = self.config.get('Deployment', 'flavor_name').split(",")
if flavor_name is not None:
# If we have a flavor_name to use, add it to our list
flavor_names.insert(0, flavor_name)
flavors = self.compute_client.list_flavors()
flavors = [f for f in flavors
if, f['name']) is not None]
if flavors:
for flname in flavor_names:
sflname = flname.strip()
self.logger.debug("Try to find a flavor with name \"%s\"" % sflname)
fls = [f for f in flavors
if, f['name']) is not None]
if fls:
self.logger.debug("Will use %s with id %s"
% (flavors[0]['name'], flavors[0]['id']))
return flavors[0]['id']
% (fls[0]['name'], fls[0]['id']))
return fls[0]['id']
self.logger.error("No matching flavor found.. aborting")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment