Răsfoiți Sursa

Adds RHEL 6.7 support

Alessandro Pilotti 10 ani în urmă
părinte
comite
a6ea926855

+ 11 - 1
coriolis/osmorphing/base.py

@@ -14,6 +14,8 @@ class BaseOSMorphingTools(object):
         self._os_root_dir = os_root_dir
         self._hypervisor = hypervisor
         self._platform = platform
+        self._distro = None
+        self._version = None
 
     def _test_path(self, chroot_path):
         path = os.path.join(self._os_root_dir, chroot_path)
@@ -51,8 +53,16 @@ class BaseOSMorphingTools(object):
         self._exec_cmd_chroot("cp /%s /%s" % (tmp_file, chroot_path))
         self._exec_cmd_chroot("rm /%s" % tmp_file)
 
-    @abc.abstractmethod
     def check_os(self):
+        if not self._distro:
+            os_info = self._check_os()
+            if os_info:
+                self._distro, self._version = os_info
+        if self._distro:
+            return self._distro, self._version
+
+    @abc.abstractmethod
+    def _check_os(self):
         pass
 
     def get_packages(self):

+ 1 - 1
coriolis/osmorphing/debian.py

@@ -12,7 +12,7 @@ class DebianMorphingTools(base.BaseOSMorphingTools):
         (None, constants.PLATFORM_OPENSTACK): [("cloud-init", True)],
     }
 
-    def check_os(self):
+    def _check_os(self):
         lsb_release_path = "etc/lsb-release"
         debian_version_path = "etc/debian_version"
         if self._test_path(lsb_release_path):

+ 11 - 2
coriolis/osmorphing/redhat.py

@@ -32,7 +32,7 @@ class RedHatMorphingTools(base.BaseOSMorphingTools):
     }
     _NETWORK_SCRIPTS_PATH = "etc/sysconfig/network-scripts"
 
-    def check_os(self):
+    def _check_os(self):
         redhat_release_path = "etc/redhat-release"
         if self._test_path(redhat_release_path):
             release_info = self._read_file(
@@ -97,6 +97,13 @@ class RedHatMorphingTools(base.BaseOSMorphingTools):
 
                 self._write_config_file(ifcfg_file, ifcfg)
 
+        network_cfg_file = "etc/sysconfig/network"
+        network_cfg = self._read_config_file(network_cfg_file,
+                                             check_exists=True)
+        if "GATEWAY" in network_cfg:
+            del network_cfg["GATEWAY"]
+            self._write_config_file(network_cfg_file, network_cfg)
+
     def _get_ifcfgs_by_type(self, ifcfg_type):
         ifcfgs = []
         for ifcfg_file in self._get_net_config_files():
@@ -133,7 +140,9 @@ class RedHatMorphingTools(base.BaseOSMorphingTools):
             if m:
                 kernel_version = m.groups()[0]
                 LOG.info("Generating initrd for kernel: %s", kernel_version)
-                self._exec_cmd_chroot("dracut -f --kver %s" % kernel_version)
+                self._exec_cmd_chroot(
+                    "dracut -f /boot/initramfs-%(version)s.img %(version)s" %
+                    {"version": kernel_version})
 
     def _get_default_cloud_user(self):
         cloud_cfg_path = os.path.join(self._os_root_dir, 'etc/cloud/cloud.cfg')

+ 1 - 1
coriolis/osmorphing/ubuntu.py

@@ -14,7 +14,7 @@ class UbuntuMorphingTools(debian.DebianMorphingTools):
         (None, constants.PLATFORM_OPENSTACK): [("cloud-init", True)],
     }
 
-    def check_os(self):
+    def _check_os(self):
         lsb_release_path = "etc/lsb-release"
         if self._test_path(lsb_release_path):
             out = self._read_file(lsb_release_path).decode()