Explorar el Código

Fix chroot paths not joining as expected

Cristian Matiut hace 10 meses
padre
commit
17fb4c6f56
Se han modificado 1 ficheros con 5 adiciones y 0 borrados
  1. 5 0
      coriolis/osmorphing/base.py

+ 5 - 0
coriolis/osmorphing/base.py

@@ -253,18 +253,22 @@ class BaseLinuxOSMorphingTools(BaseOSMorphingTools):
         raise NotImplementedError()
         raise NotImplementedError()
 
 
     def _test_path(self, chroot_path):
     def _test_path(self, chroot_path):
+        chroot_path = chroot_path.lstrip('/')
         path = os.path.join(self._os_root_dir, chroot_path)
         path = os.path.join(self._os_root_dir, chroot_path)
         return utils.test_ssh_path(self._ssh, path)
         return utils.test_ssh_path(self._ssh, path)
 
 
     def _read_file(self, chroot_path):
     def _read_file(self, chroot_path):
+        chroot_path = chroot_path.lstrip('/')
         path = os.path.join(self._os_root_dir, chroot_path)
         path = os.path.join(self._os_root_dir, chroot_path)
         return utils.read_ssh_file(self._ssh, path)
         return utils.read_ssh_file(self._ssh, path)
 
 
     def _write_file(self, chroot_path, content):
     def _write_file(self, chroot_path, content):
+        chroot_path = chroot_path.lstrip('/')
         path = os.path.join(self._os_root_dir, chroot_path)
         path = os.path.join(self._os_root_dir, chroot_path)
         utils.write_ssh_file(self._ssh, path, content)
         utils.write_ssh_file(self._ssh, path, content)
 
 
     def _list_dir(self, chroot_path):
     def _list_dir(self, chroot_path):
+        chroot_path = chroot_path.lstrip('/')
         path = os.path.join(self._os_root_dir, chroot_path)
         path = os.path.join(self._os_root_dir, chroot_path)
         return utils.list_ssh_dir(self._ssh, path)
         return utils.list_ssh_dir(self._ssh, path)
 
 
@@ -320,6 +324,7 @@ class BaseLinuxOSMorphingTools(BaseOSMorphingTools):
         return self._read_config_file("etc/os-release", check_exists=True)
         return self._read_config_file("etc/os-release", check_exists=True)
 
 
     def _read_config_file(self, chroot_path, check_exists=False):
     def _read_config_file(self, chroot_path, check_exists=False):
+        chroot_path = chroot_path.lstrip('/')
         full_path = os.path.join(self._os_root_dir, chroot_path)
         full_path = os.path.join(self._os_root_dir, chroot_path)
         return utils.read_ssh_ini_config_file(
         return utils.read_ssh_ini_config_file(
             self._ssh, full_path, check_exists=check_exists)
             self._ssh, full_path, check_exists=check_exists)