Commit 1e589d38 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis Committed by Christos Stavrakakis
Browse files

ci: Get flavor by name

The option flavor_name support a list of flavors to try.

Refs #4192
parent e31ab3fa
......@@ -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,21 +284,25 @@ 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 re.search(flavor_name, f['name']) is not None]
if flavors:
self.logger.debug("Will use %s with id %s"
% (flavors[0]['name'], flavors[0]['id']))
return flavors[0]['id']
else:
self.logger.error("No matching flavor found.. aborting")
sys.exit(1)
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 re.search(sflname, f['name']) is not None]
if fls:
self.logger.debug("Will use %s with id %s"
% (fls[0]['name'], fls[0]['id']))
return fls[0]['id']
self.logger.error("No matching flavor found.. aborting")
sys.exit(1)
def _find_image(self):
"""Find a suitable image to use
......
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