Commit 9e435c1b authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

ci: Specify directory to fetch packages to

parent 97d29620
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
""" """
""" """
import os
from utils import SynnefoCI from utils import SynnefoCI
from optparse import OptionParser from optparse import OptionParser
...@@ -51,9 +52,10 @@ def main(): ...@@ -51,9 +52,10 @@ def main():
parser.add_option("-i", "--image", dest="image", default=None, parser.add_option("-i", "--image", dest="image", default=None,
help="UUID of image to use for the server.") help="UUID of image to use for the server.")
parser.add_option("--fetch-packages", dest="fetch_packages", parser.add_option("--fetch-packages", dest="fetch_packages",
action="store_true", default=False, default=None,
help="Download the debian packages that were created" help="Download the debian packages that were created"
" during the '%s' step." % BUILD_SYNNEFO_CMD) " during the '%s' step in this directory" %
BUILD_SYNNEFO_CMD)
parser.add_option("--schema", dest="schema", default=None, parser.add_option("--schema", dest="schema", default=None,
help="Schema for snf-deploy.") help="Schema for snf-deploy.")
...@@ -91,7 +93,8 @@ def main(): ...@@ -91,7 +93,8 @@ def main():
if getattr(options, BUILD_SYNNEFO_CMD, False): if getattr(options, BUILD_SYNNEFO_CMD, False):
synnefo_ci.build_synnefo() synnefo_ci.build_synnefo()
if options.fetch_packages: if options.fetch_packages:
synnefo_ci.fetch_packages() dest = os.path.abspath(options.fetch_packages)
synnefo_ci.fetch_packages(dest=dest)
if getattr(options, DEPLOY_SYNNEFO_CMD, False): if getattr(options, DEPLOY_SYNNEFO_CMD, False):
synnefo_ci.deploy_synnefo(schema=options.schema) synnefo_ci.deploy_synnefo(schema=options.schema)
if getattr(options, TEST_SYNNEFO_CMD, False): if getattr(options, TEST_SYNNEFO_CMD, False):
......
...@@ -520,7 +520,7 @@ class SynnefoCI(object): ...@@ -520,7 +520,7 @@ class SynnefoCI(object):
_run(cmd, True) _run(cmd, True)
@_check_fabric @_check_fabric
def fetch_packages(self): def fetch_packages(self, dest=None):
"""Download Synnefo packages""" """Download Synnefo packages"""
self.logger.info("Download Synnefo packages") self.logger.info("Download Synnefo packages")
self.logger.debug("Create tarball with packages") self.logger.debug("Create tarball with packages")
...@@ -529,9 +529,16 @@ class SynnefoCI(object): ...@@ -529,9 +529,16 @@ class SynnefoCI(object):
""" """
_run(cmd, False) _run(cmd, False)
pkgs_dir = self.config.get('Global', 'pkgs_dir') if dest is None:
pkgs_dir = self.config.get('Global', 'pkgs_dir')
else:
pkgs_dir = dest
self.logger.debug("Fetch packages to local dir %s" % pkgs_dir) self.logger.debug("Fetch packages to local dir %s" % pkgs_dir)
os.makedirs(pkgs_dir) # Create package directory if missing
if not os.path.exists(pkgs_dir):
os.makedirs(pkgs_dir)
with fabric.quiet(): with fabric.quiet():
fabric.get("synnefo_build-area.tgz", pkgs_dir) fabric.get("synnefo_build-area.tgz", pkgs_dir)
...@@ -539,6 +546,12 @@ class SynnefoCI(object): ...@@ -539,6 +546,12 @@ class SynnefoCI(object):
self._check_hash_sum(pkgs_file, "synnefo_build-area.tgz") self._check_hash_sum(pkgs_file, "synnefo_build-area.tgz")
self.logger.debug("Untar packages file %s" % pkgs_file) self.logger.debug("Untar packages file %s" % pkgs_file)
os.system("cd %s; tar xzf synnefo_build-area.tgz" % pkgs_dir) cmd = """
cd %s
tar xzf synnefo_build-area.tgz
cp synnefo_build-area/* %s
rm -r synnefo_build-area
""" % (pkgs_dir, dest)
os.system(cmd)
self.logger.info("Downloaded debian packages to %s" % self.logger.info("Downloaded debian packages to %s" %
_green(pkgs_dir)) _green(pkgs_dir))
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