Ejemplo n.º 1
0
 def validateImagePath(self):
     """
     Validate that the image dir exists and valid. In the file volume repositories,
     the image dir must exists after creation its first volume.
     """
     imageDir = image.Image(self.repoPath).getImageDir(
         self.sdUUID, self.imgUUID)
     if not self.oop.os.path.isdir(imageDir):
         raise se.ImagePathError(imageDir)
     if not self.oop.os.access(imageDir, os.R_OK | os.W_OK | os.X_OK):
         raise se.ImagePathError(imageDir)
     self.imagePath = imageDir
Ejemplo n.º 2
0
 def validateImagePath(self):
     """
     Block SD supports lazy image dir creation
     """
     imageDir = image.ImageManifest(self.repoPath).getImageDir(
         self.sdUUID, self.imgUUID)
     if not os.path.isdir(imageDir):
         try:
             os.mkdir(imageDir, 0o755)
         except Exception:
             self.log.exception("Unexpected error")
             raise se.ImagePathError(imageDir)
     self._imagePath = imageDir
Ejemplo n.º 3
0
    def validateImagePath(self):
        """
        Block SD supports lazy image dir creation
        """
        imageDir = image.Image(self.repoPath).getImageDir(
            self.sdUUID, self.imgUUID)

        # Image directory may be a symlink to /run/vdsm/storage/sd/image
        # created when preparing an image before starting a vm.
        if os.path.islink(imageDir) and not os.path.exists(imageDir):
            self.log.warning("Removing stale image directory link %r",
                             imageDir)
            os.unlink(imageDir)

        if not os.path.isdir(imageDir):
            try:
                os.mkdir(imageDir, 0o755)
            except Exception:
                self.log.error("Unexpected error", exc_info=True)
                raise se.ImagePathError(imageDir)
        self.imagePath = imageDir