Преглед изворни кода

add check for mount destination

There is a chance that some of the folders we try to mount bind, do not actually
exist inside the VM we are migrating. This adds a simple check before running the
mount command
y
Gabriel Adrian Samfira пре 9 година
родитељ
комит
881f2c87b3
1 измењених фајлова са 2 додато и 2 уклоњено
  1. 2 2
      coriolis/osmorphing/osmount/base.py

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

@@ -171,7 +171,7 @@ class BaseLinuxOSMountTools(BaseSSHOSMountTools):
         for dir in set(dirs).intersection(['proc', 'sys', 'dev', 'run']):
             mount_dir = os.path.join(os_root_dir, dir)
             self._exec_cmd(
-                'sudo mount -o bind /%(dir)s/ %(mount_dir)s' %
+                '[ -d %(mount_dir)s ] && sudo mount -o bind /%(dir)s/ %(mount_dir)s || echo "%(mount_dir)s does not exist in VM"' %
                 {'dir': dir, 'mount_dir': mount_dir})
             other_mounted_dirs.append(mount_dir)
 
@@ -184,4 +184,4 @@ class BaseLinuxOSMountTools(BaseSSHOSMountTools):
 
     def dismount_os(self, dirs):
         for dir in dirs:
-            self._exec_cmd('sudo umount %s' % dir)
+            self._exec_cmd('[ -d %s ] && sudo umount %s || true' % (dir, dir))