瀏覽代碼

Manually configure yum repos instead of using yum-config-manager

`yum-config-manager --add-repo` automatically adds and enables the
repos from a URL. This being against our ideal OSMorphing
functionality, this patch will manually download the repo file
and should also make sure to disable all downloaded repos.
Daniel Vincze 4 年之前
父節點
當前提交
8bac5c4fad
共有 1 個文件被更改,包括 10 次插入8 次删除
  1. 10 8
      coriolis/osmorphing/oracle.py

+ 10 - 8
coriolis/osmorphing/oracle.py

@@ -1,6 +1,8 @@
 # Copyright 2016 Cloudbase Solutions Srl
 # All Rights Reserved.
 
+import uuid
+
 from coriolis.osmorphing import redhat
 from coriolis.osmorphing.osdetect import oracle as oracle_detect
 
@@ -26,15 +28,15 @@ class BaseOracleMorphingTools(redhat.BaseRedHatMorphingTools):
         repos = []
         major_version = int(self._version.split(".")[0])
         if major_version < 8:
-            self._yum_install(
-                ['yum-utils'],
-                self._find_yum_repos(['ol%s_latest' % major_version]))
-            # TODO(apilotti): for ULN users, use the corresponding repos
-            # e.g.: ol7_x86_64_addons
+            repo_file_path = (
+                '/etc/yum.repos.d/%s.repo' % str(uuid.uuid4()))
+            self._exec_cmd_chroot(
+                "curl -L http://public-yum.oracle.com/public-yum-ol%s.repo "
+                "-o %s" % (major_version, repo_file_path))
+            # During OSMorphing, we temporarily enable needed package repos,
+            # so we make sure we disable all downloaded repos here.
             self._exec_cmd_chroot(
-                "yum-config-manager --add-repo "
-                "http://public-yum.oracle.com/public-yum-ol%s.repo" %
-                major_version)
+                'sed -i "s/^enabled=1$/enabled=0/g" %s' % repo_file_path)
 
             repos_to_enable = ["ol%s_software_collections" % major_version,
                                "ol%s_addons" % major_version,