Revision e2dc37b2

b/ci/snf-ci
2 2

  
3 3
"""
4 4
"""
5
import os
5 6
from utils import SynnefoCI
6 7
from optparse import OptionParser
7 8

  
......
51 52
    parser.add_option("-i", "--image", dest="image", default=None,
52 53
                      help="UUID of image to use for the server.")
53 54
    parser.add_option("--fetch-packages", dest="fetch_packages",
54
                      action="store_true", default=False,
55
                      default=None,
55 56
                      help="Download the debian packages that were created"
56
                           " during the '%s' step." % BUILD_SYNNEFO_CMD)
57
                           " during the '%s' step in this directory" %
58
                           BUILD_SYNNEFO_CMD)
57 59
    parser.add_option("--schema", dest="schema", default=None,
58 60
                      help="Schema for snf-deploy.")
59 61

  
......
91 93
    if getattr(options, BUILD_SYNNEFO_CMD, False):
92 94
        synnefo_ci.build_synnefo()
93 95
    if options.fetch_packages:
94
        synnefo_ci.fetch_packages()
96
        dest = os.path.abspath(options.fetch_packages)
97
        synnefo_ci.fetch_packages(dest=dest)
95 98
    if getattr(options, DEPLOY_SYNNEFO_CMD, False):
96 99
        synnefo_ci.deploy_synnefo(schema=options.schema)
97 100
    if getattr(options, TEST_SYNNEFO_CMD, False):
b/ci/utils.py
520 520
        _run(cmd, True)
521 521

  
522 522
    @_check_fabric
523
    def fetch_packages(self):
523
    def fetch_packages(self, dest=None):
524 524
        """Download Synnefo packages"""
525 525
        self.logger.info("Download Synnefo packages")
526 526
        self.logger.debug("Create tarball with packages")
......
529 529
        """
530 530
        _run(cmd, False)
531 531

  
532
        pkgs_dir = self.config.get('Global', 'pkgs_dir')
532
        if dest is None:
533
            pkgs_dir = self.config.get('Global', 'pkgs_dir')
534
        else:
535
            pkgs_dir = dest
536

  
533 537
        self.logger.debug("Fetch packages to local dir %s" % pkgs_dir)
534
        os.makedirs(pkgs_dir)
538
        # Create package directory if missing
539
        if not os.path.exists(pkgs_dir):
540
            os.makedirs(pkgs_dir)
541

  
535 542
        with fabric.quiet():
536 543
            fabric.get("synnefo_build-area.tgz", pkgs_dir)
537 544

  
......
539 546
        self._check_hash_sum(pkgs_file, "synnefo_build-area.tgz")
540 547

  
541 548
        self.logger.debug("Untar packages file %s" % pkgs_file)
542
        os.system("cd %s; tar xzf synnefo_build-area.tgz" % pkgs_dir)
549
        cmd = """
550
        cd %s
551
        tar xzf synnefo_build-area.tgz
552
        cp synnefo_build-area/* %s
553
        rm -r synnefo_build-area
554
        """ % (pkgs_dir, dest)
555
        os.system(cmd)
543 556
        self.logger.info("Downloaded debian packages to %s" %
544 557
                         _green(pkgs_dir))

Also available in: Unified diff