Convert the repos.yaml to adapt BOSS
authorHasan Wan <hasan.wan@intel.com>
Mon, 16 Sep 2013 06:16:54 +0000 (09:16 +0300)
committerEduard Bartosh <eduard.bartosh@intel.com>
Mon, 16 Sep 2013 07:01:07 +0000 (00:01 -0700)
Fixes: #1304

Change-Id: I581b835b481f15e4ba74852e88a690d7f57462bf
Signed-off-by: Hasan Wan <hasan.wan@intel.com>
Reviewed-on: https://otctools.jf.intel.com/review/6451
Tested-by: OTC Tools Tester <ed.bartosh@linux.intel.com>
Reviewed-by: Eduard Bartosh <eduard.bartosh@intel.com>
common/backenddb.py
job_load_repos.yaml.py

index 9b637a9..97b8653 100644 (file)
@@ -172,13 +172,6 @@ class BackendDB():
         names = set()
         mapkeys = set()
         for repo in repos:
-
-            # Temporary solution for path trim
-            repo['SnapshotDir'] = repo['SnapshotDir'].replace('/srv/', '')
-            if 'PrereleaseDir' not in repo:
-                repo['PrereleaseDir'] = \
-                    repo['SnapshotDir'].replace('snapshots', 'prerelease')
-
             name = repo.pop('Name')
             names.add(name)
             db_repos[name] = repo
index 84566e1..78bc237 100755 (executable)
@@ -8,7 +8,7 @@ This code is called by gerrit-plugin to load the backend config to redis.
 import os
 import sys
 import tempfile
-import shutil
+import yaml
 
 from common.backenddb import BackendDB
 from common.gerrit import get_gerrit_event
@@ -38,8 +38,13 @@ def update_repos_conf_on_filesystem(path_to_new_repos_conf,
          path_to_new_repos_conf (str): path to new repos.yaml file location
          path_to_repos_conf (str): the path of repos.yaml on repos server
     """
-
-    shutil.copyfile(path_to_new_repos_conf, path_to_repos_conf)
+    with open(path_to_new_repos_conf, 'r') as repo_fh:
+        repos = yaml.load(repo_fh)
+        # add the prefix /srv/ for BOSS
+        for repo in repos['Repositories']:
+            repo['SnapshotDir'] = os.path.join('/srv',
+                                               repo['SnapshotDir'])
+    os.write(path_to_repos_conf, yaml.dump(repos))
 
 def main():
     """Script entry point.