]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Ensure yum repo file exists before tweaking it
authorZack Cerza <zack@redhat.com>
Thu, 22 Jan 2015 21:47:50 +0000 (14:47 -0700)
committerZack Cerza <zack@redhat.com>
Thu, 22 Jan 2015 23:12:34 +0000 (16:12 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/task/install.py

index 4e122baaccff24cf654e1898de3997ada17b83f6..f4493e97ce49d5b82fa094d78255ba5ccccc27f5 100644 (file)
@@ -367,17 +367,15 @@ def _yum_fix_repo_priority(remote, project, uri):
     :param remote: the teuthology.orchestra.remote.Remote object
     :param project: the project whose repos need modification
     """
+    repo_path = '/etc/yum.repos.d/%s.repo' % project
     remote.run(
         args=[
-            'sudo',
-            'sed',
-            '-i',
-            '-e',
-            run.Raw(
-                '\':a;N;$!ba;s/enabled=1\\ngpg/enabled=1\\npriority=1\\ngpg/g\''),
+            'if', 'test', '-f', repo_path, run.Raw(';'), 'then',
+            'sudo', 'sed', '-i', '-e',
+            run.Raw('\':a;N;$!ba;s/enabled=1\\ngpg/enabled=1\\npriority=1\\ngpg/g\''),
             '-e',
             run.Raw("'s;ref/[a-zA-Z0-9_-]*/;{uri}/;g'".format(uri=uri)),
-            '/etc/yum.repos.d/%s.repo' % project,
+            repo_path, run.Raw(';'), 'fi'
         ]
     )
 
@@ -390,10 +388,13 @@ def _yum_fix_repo_host(remote, project):
     new_host = teuth_config.gitbuilder_host
     if new_host == old_host:
         return
+    repo_path = '/etc/yum.repos.d/%s.repo' % project
     host_sed_expr = "'s/{0}/{1}/'".format(old_host, new_host)
     remote.run(
-        args=['sudo', 'sed', '-i', '-e', run.Raw(host_sed_expr),
-              '/etc/yum.repos.d/%s.repo' % project]
+        args=[
+            'if', 'test', '-f', repo_path, run.Raw(';'), 'then',
+            'sudo', 'sed', '-i', '-e', run.Raw(host_sed_expr),
+            repo_path, run.Raw(';'), 'fi']
     )