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"""
|