Przeglądaj źródła

Merged in aznashwan/coriolis/osmount-osdev (pull request #22)

Added OS boot device name return value to mount tools and paramter to morphing tools.
Nashwan Azhari 9 lat temu
rodzic
commit
d02c056487

+ 8 - 3
coriolis/osmorphing/base.py

@@ -13,9 +13,12 @@ from coriolis import utils
 class BaseOSMorphingTools(object):
     __metaclass__ = abc.ABCMeta
 
-    def __init__(self, conn, os_root_dir, hypervisor, platform, event_manager):
+    def __init__(
+            self, conn, os_root_dir, os_root_device,
+            hypervisor, platform, event_manager):
         self._conn = conn
         self._os_root_dir = os_root_dir
+        self._os_root_device = os_root_device
         self._hypervisor = hypervisor
         self._platform = platform
         self._distro = None
@@ -59,9 +62,11 @@ class BaseLinuxOSMorphingTools(BaseOSMorphingTools):
 
     _packages = {}
 
-    def __init__(self, conn, os_root_dir, hypervisor, platform, event_manager):
+    def __init__(self, conn, os_root_dir, os_root_dev,
+                 hypervisor, platform, event_manager):
         super(BaseLinuxOSMorphingTools, self).__init__(
-            conn, os_root_dir, hypervisor, platform, event_manager)
+            conn, os_root_dir, os_root_dev,
+            hypervisor, platform, event_manager)
         self._ssh = conn
 
     def get_packages(self):

+ 7 - 5
coriolis/osmorphing/factory.py

@@ -17,8 +17,9 @@ from coriolis.osmorphing import windows
 LOG = logging.getLogger(__name__)
 
 
-def get_os_morphing_tools(conn, os_type, os_root_dir, target_hypervisor,
-                          target_platform, event_manager):
+def get_os_morphing_tools(
+        conn, os_type, os_root_dir, os_root_dev,
+        target_hypervisor, target_platform, event_manager):
     os_morphing_tools_clss = {
         constants.OS_TYPE_LINUX: [debian.DebianMorphingTools,
                                   ubuntu.UbuntuMorphingTools,
@@ -26,15 +27,16 @@ def get_os_morphing_tools(conn, os_type, os_root_dir, target_hypervisor,
                                   redhat.RedHatMorphingTools,
                                   suse.SUSEMorphingTools],
         constants.OS_TYPE_WINDOWS: [windows.WindowsMorphingTools],
-        }
+    }
 
     if os_type and os_type not in os_morphing_tools_clss:
         raise exception.CoriolisException("Unsupported OS type: %s" % os_type)
 
     for cls in os_morphing_tools_clss.get(
             os_type, itertools.chain(*os_morphing_tools_clss.values())):
-        tools = cls(conn, os_root_dir, target_hypervisor, target_platform,
-                    event_manager)
+        tools = cls(
+            conn, os_root_dir, os_root_dev, target_hypervisor,
+            target_platform, event_manager)
         LOG.debug("Testing OS morphing tools: %s", cls.__name__)
         os_info = tools.check_os()
         if os_info:

+ 3 - 3
coriolis/osmorphing/manager.py

@@ -15,12 +15,12 @@ def morph_image(connection_info, os_type, target_hypervisor, target_platform,
         os_type, connection_info, event_manager, ignore_devices)
 
     event_manager.progress_update("Discovering and mounting OS partitions")
-    os_root_dir, other_mounted_dirs = os_mount_tools.mount_os()
+    os_root_dir, other_mounted_dirs, os_root_dev = os_mount_tools.mount_os()
 
     conn = os_mount_tools.get_connection()
     os_morphing_tools, os_info = osmorphing_factory.get_os_morphing_tools(
-        conn, os_type, os_root_dir, target_hypervisor, target_platform,
-        event_manager)
+        conn, os_type, os_root_dir, os_root_dev, target_hypervisor,
+        target_platform, event_manager)
 
     event_manager.progress_update('OS being migrated: %s' % str(os_info))
 

+ 3 - 1
coriolis/osmorphing/osmount/ubuntu.py

@@ -87,6 +87,7 @@ class UbuntuOSMountTools(base.BaseSSHOSMountTools):
                 utils.check_fs(self._ssh, fs_type, dev_path)
                 dev_paths_to_mount.append(dev_path)
 
+        os_root_device = None
         os_root_dir = None
         boot_dev_path = None
         for dev_path in dev_paths_to_mount:
@@ -98,6 +99,7 @@ class UbuntuOSMountTools(base.BaseSSHOSMountTools):
             if (not os_root_dir and 'etc' in dirs and 'bin' in dirs and
                     'sbin' in dirs):
                 os_root_dir = tmp_dir
+                os_root_device = dev_path
                 LOG.info("OS root device: %s", dev_path)
             # TODO: better ways to check for a linux boot dir?
             else:
@@ -127,7 +129,7 @@ class UbuntuOSMountTools(base.BaseSSHOSMountTools):
             self._exec_cmd('sudo mount %s %s' % (boot_dev_path, boot_dir))
             other_mounted_dirs.append(boot_dir)
 
-        return os_root_dir, other_mounted_dirs
+        return os_root_dir, other_mounted_dirs, os_root_device
 
     def dismount_os(self, dirs):
         for dir in dirs:

+ 1 - 1
coriolis/osmorphing/osmount/windows.py

@@ -89,7 +89,7 @@ class WindowsMountTools(base.BaseOSMountTools):
 
         for fs_root in [r for r in fs_roots if not r[:-1] == system_drive]:
             if self._conn.test_path("%sWindows\\System32" % fs_root):
-                return fs_root, []
+                return fs_root, [], None
 
     def dismount_os(self, dirs):
         for dir in dirs: