X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=testsuites%2Fvstf%2Fvstf_scripts%2Fvstf%2Fagent%2Fenv%2Fbasic%2Fsource_manager.py;fp=testsuites%2Fvstf%2Fvstf_scripts%2Fvstf%2Fagent%2Fenv%2Fbasic%2Fsource_manager.py;h=0000000000000000000000000000000000000000;hb=fb9e1a726d3a598494fd38330848ef676219a47a;hp=5aca5368a121c2da72b91cd371f14f1b857ec2a8;hpb=6dff90faee27dc5569255f5cb6ba72ae5e22b924;p=bottlenecks.git diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/source_manager.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/source_manager.py deleted file mode 100644 index 5aca5368..00000000 --- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/source_manager.py +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -import os -import logging -import contextlib -from subprocess import CalledProcessError -from vstf.common.utils import check_call - -LOG = logging.getLogger(__name__) - - -@contextlib.contextmanager -def my_chdir(file_path): - old_cwd = os.path.realpath(os.curdir) - os.chdir(file_path) - LOG.info("cd %s", file_path) - yield - os.chdir(old_cwd) - LOG.info("cd %s", old_cwd) - - -class SourceCodeManager(object): - - def __init__(self): - super(SourceCodeManager, self).__init__() - self.base_path = '/opt/vstf/' - - @staticmethod - def _git_pull(url, dest): - if not os.path.isdir(dest): - check_call("git clone %s %s" % (url, dest), shell=True) - else: - with my_chdir(dest): - check_call("git pull", shell=True) - - @staticmethod - def _install(dest): - with my_chdir(dest): - try: - check_call("make && make install", shell=True) - except CalledProcessError: - LOG.info("retry make again") - check_call("make clean; make && make install", shell=True) - - def src_install(self, cfg): - for key, item in cfg.items(): - repo_type = item['repo_type'] - url = item['url'] - install = item['install'] - if install is True: - LOG.info("installing src repo:%s", key) - if repo_type == "git": - target = self.base_path + key - self._git_pull(url, target) - self._install(target) - else: - raise Exception("unsupported repo type:%s" % repo_type) - else: - LOG.info("skip src repo:%s", key) - return True - - -if __name__ == '__main__': - import argparse - import json - parser = argparse.ArgumentParser() - parser.add_argument('--config', help='config file to parse') - args = parser.parse_args() - logging.basicConfig(level=logging.INFO) - cfg = json.load(open(args.config)) - mgr = SourceCodeManager() - mgr.src_install(cfg)