Procházet zdrojové kódy

Adds ignore_devices in osmorphing

Alessandro Pilotti před 10 roky
rodič
revize
b1f10be486

+ 2 - 2
coriolis/osmorphing/manager.py

@@ -7,9 +7,9 @@ LOG = logging.getLogger(__name__)
 
 
 def morph_image(connection_info, os_type, target_hypervisor, target_platform,
-                nics_info, event_manager):
+                nics_info, event_manager, ignore_devices=[]):
     os_mount_tools = osmount_factory.get_os_mount_tools(
-        os_type, connection_info, event_manager)
+        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()

+ 2 - 1
coriolis/osmorphing/osmount/base.py

@@ -11,8 +11,9 @@ LOG = logging.getLogger(__name__)
 class BaseOSMountTools(object):
     __metaclass__ = abc.ABCMeta
 
-    def __init__(self, connection_info, event_manager):
+    def __init__(self, connection_info, event_manager, ignore_devices):
         self._event_manager = event_manager
+        self._ignore_devices = ignore_devices
         self._connect(connection_info)
 
     @abc.abstractmethod

+ 3 - 2
coriolis/osmorphing/osmount/factory.py

@@ -10,7 +10,8 @@ from coriolis.osmorphing.osmount import windows
 LOG = logging.getLogger(__name__)
 
 
-def get_os_mount_tools(os_type, connection_info, event_manager):
+def get_os_mount_tools(os_type, connection_info, event_manager,
+                       ignore_devices):
     os_mount_tools = {constants.OS_TYPE_LINUX: [ubuntu.UbuntuOSMountTools],
                       constants.OS_TYPE_WINDOWS: [windows.WindowsMountTools]}
 
@@ -19,7 +20,7 @@ def get_os_mount_tools(os_type, connection_info, event_manager):
 
     for cls in os_mount_tools.get(os_type,
                                   itertools.chain(*os_mount_tools.values())):
-        tools = cls(connection_info, event_manager)
+        tools = cls(connection_info, event_manager, ignore_devices)
         LOG.debug("Testing OS mount tools: %s", cls.__name__)
         if tools.check_os():
             return tools

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

@@ -39,7 +39,12 @@ class UbuntuOSMountTools(base.BaseSSHOSMountTools):
         # Skip this instance's current root device (first in the list)
         volume_devs = ["/dev/%s" % d for d in volume_devs if
                        not re.match(r"^.*\d+$", d)][1:]
-        LOG.info("Volume block devices: %s", str(volume_devs))
+
+        LOG.debug("Ignoring block devices: %s", self._ignore_devices)
+        volume_devs = [d for d in volume_devs if d
+                       not in self._ignore_devices]
+
+        LOG.info("Volume block devices: %s", volume_devs)
         return volume_devs
 
     def mount_os(self):