Commit c190f3ea authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

ci: Option to override image and flavor

Add option to use a custom image_id and flavor_id instead of getting
them from config file.
parent 03cba903
...@@ -47,21 +47,21 @@ def _green(msg): ...@@ -47,21 +47,21 @@ def _green(msg):
def _check_fabric(fun): def _check_fabric(fun):
"""Check if fabric env has been set""" """Check if fabric env has been set"""
def wrapper(self, *args): def wrapper(self, *args, **kwargs):
"""wrapper function""" """wrapper function"""
if not self.fabric_installed: if not self.fabric_installed:
self.setup_fabric() self.setup_fabric()
return fun(self, *args) return fun(self, *args, **kwargs)
return wrapper return wrapper
def _check_kamaki(fun): def _check_kamaki(fun):
"""Check if kamaki has been initialized""" """Check if kamaki has been initialized"""
def wrapper(self, *args): def wrapper(self, *args, **kwargs):
"""wrapper function""" """wrapper function"""
if not self.kamaki_installed: if not self.kamaki_installed:
self.setup_kamaki() self.setup_kamaki()
return fun(self, *args) return fun(self, *args, **kwargs)
return wrapper return wrapper
...@@ -199,16 +199,20 @@ class SynnefoCI(object): ...@@ -199,16 +199,20 @@ class SynnefoCI(object):
self._wait_transition(server_id, "ACTIVE", "DELETED") self._wait_transition(server_id, "ACTIVE", "DELETED")
@_check_kamaki @_check_kamaki
def create_server(self): def create_server(self, image_id=None, flavor_id=None):
"""Create slave server""" """Create slave server"""
self.logger.info("Create a new server..") self.logger.info("Create a new server..")
image = self._find_image() if image_id is None:
self.logger.debug("Will use image \"%s\"" % _green(image['name'])) image = self._find_image()
self.logger.debug("Image has id %s" % _green(image['id'])) self.logger.debug("Will use image \"%s\"" % _green(image['name']))
image_id = image["id"]
self.logger.debug("Image has id %s" % _green(image_id))
if flavor_id is None:
flavor_id = self.config.getint("Deployment", "flavor_id")
server = self.cyclades_client.create_server( server = self.cyclades_client.create_server(
self.config.get('Deployment', 'server_name'), self.config.get('Deployment', 'server_name'),
self.config.getint('Deployment', 'flavor_id'), flavor_id,
image['id']) image_id)
server_id = server['id'] server_id = server['id']
self.write_config('server_id', server_id) self.write_config('server_id', server_id)
self.logger.debug("Server got id %s" % _green(server_id)) self.logger.debug("Server got id %s" % _green(server_id))
......
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