Revision 1d9f2031

b/ci/new_config
3 3
build_timeout = 240
4 4
# Apt repository to use
5 5
apt_repo = http://apt.dev.grnet.gr squeeze/
6
# Synnefo git repo
6
# Synnefo git repo.
7
# If not set, snf-ci will copy and use the local repo.
7 8
synnefo_repo = https://code.grnet.gr/git/synnefo
8 9
# Git branch to test (specify sha1 or branch name). If not set, the
9 10
# branch/sha will result from the current repository.
b/ci/snf-ci
80 80
                           BUILD_DOCS_SYNNEFO_CMD)
81 81
    parser.add_option("--schema", dest="schema", default=None,
82 82
                      help="Schema for snf-deploy.")
83
    parser.add_option("--local-repo", dest="local_repo", default=False,
84
                      action="store_true",
85
                      help="Instead of cloning from the official Synnefo"
86
                           " repo, copy and use the local one.")
83 87

  
84 88
    (options, args) = parser.parse_args()
85 89

  
......
111 115
        synnefo_ci.create_server(flavor_name=options.flavor,
112 116
                                 image_id=options.image,
113 117
                                 ssh_keys=options.ssh_keys)
114
        synnefo_ci.clone_repo()
118
        synnefo_ci.clone_repo(local_repo=options.local_repo)
115 119
    if getattr(options, BUILD_SYNNEFO_CMD, False):
116 120
        synnefo_ci.build_synnefo()
117 121
        if options.fetch_packages:
b/ci/utils.py
441 441
            sys.exit(-1)
442 442

  
443 443
    @_check_fabric
444
    def clone_repo(self):
444
    def clone_repo(self, local_repo=False):
445 445
        """Clone Synnefo repo from slave server"""
446 446
        self.logger.info("Configure repositories on remote server..")
447 447
        self.logger.debug("Setup apt, install curl and git")
......
459 459
                   self.config.get('Global', 'git_config_mail'))
460 460
        _run(cmd, False)
461 461

  
462
        # Find synnefo_repo and synnefo_branch to use
462 463
        synnefo_repo = self.config.get('Global', 'synnefo_repo')
463 464
        synnefo_branch = self.config.get("Global", "synnefo_branch")
464 465
        if synnefo_branch == "":
......
472 473
                        ["git", "rev-parse", "--short", "HEAD"],
473 474
                        stdout=subprocess.PIPE).communicate()[0].strip()
474 475
        self.logger.info("Will use branch %s" % synnefo_branch)
475
        # Currently clonning synnefo can fail unexpectedly
476
        cloned = False
477
        for i in range(10):
478
            self.logger.debug("Clone synnefo from %s" % synnefo_repo)
479
            try:
480
                _run("git clone %s synnefo" % synnefo_repo, False)
481
                cloned = True
482
                break
483
            except BaseException:
484
                self.logger.warning("Clonning synnefo failed.. retrying %s"
485
                                    % i)
476

  
477
        if local_repo or synnefo_branch == "":
478
            # Use local_repo
479
            self.logger.debug("Push local repo to server")
480
            # Firstly create the remote repo
481
            _run("git init synnefo", False)
482
            # Then push our local repo over ssh
483
            # We have to pass some arguments to ssh command
484
            # namely to disable host checking.
485
            (temp_ssh_file_handle, temp_ssh_file) = tempfile.mkstemp()
486
            os.close(temp_ssh_file_handle)
487
            cmd = """
488
            echo 'exec ssh -o "StrictHostKeyChecking no" \
489
                           -o "UserKnownHostsFile /dev/null" \
490
                           -q "$@"' > {4}
491
            chmod u+x {4}
492
            export GIT_SSH="{4}"
493
            echo "{0}" | git push --mirror ssh://{1}@{2}:{3}/~/synnefo
494
            rm -f {4}
495
            """.format(fabric.env.password,
496
                       fabric.env.user,
497
                       fabric.env.host_string,
498
                       fabric.env.port,
499
                       temp_ssh_file)
500
            os.system(cmd)
501
        else:
502
            # Clone Synnefo from remote repo
503
            # Currently clonning synnefo can fail unexpectedly
504
            cloned = False
505
            for i in range(10):
506
                self.logger.debug("Clone synnefo from %s" % synnefo_repo)
507
                try:
508
                    _run("git clone %s synnefo" % synnefo_repo, False)
509
                    cloned = True
510
                    break
511
                except BaseException:
512
                    self.logger.warning(
513
                        "Clonning synnefo failed.. retrying %s" % i)
514
            if not cloned:
515
                self.logger.error("Can not clone Synnefo repo.")
516
                sys.exit(-1)
517

  
518
        # Checkout the desired synnefo_branch
519
        self.logger.debug("Checkout %s branch/commit" % synnefo_branch)
486 520
        cmd = """
487 521
        cd synnefo
488 522
        for branch in `git branch -a | grep remotes | \
......
493 527
        """ % (synnefo_branch)
494 528
        _run(cmd, False)
495 529

  
496
        if not cloned:
497
            self.logger.error("Can not clone Synnefo repo.")
498
            sys.exit(-1)
499

  
500 530
    @_check_fabric
501 531
    def build_synnefo(self):
502 532
        """Build Synnefo packages"""

Also available in: Unified diff