示例#1
0
    def delete(self, postZero, force, discard):
        """
        Delete volume.
            'postZero' - zeroing file before deletion
            'force' - required to remove shared and internal volumes
            'discard' - discard volume before deletion
        """
        self.log.info("Request to delete volume %s", self.volUUID)

        if discard:
            raise se.DiscardIsNotSupported(self.sdUUID, "file storage domain")
        vol_path = self.getVolumePath()
        lease_path = self._manifest.leaseVolumePath(vol_path)

        if not force:
            self.validateDelete()

        # Mark volume as illegal before deleting
        self.setLegality(sc.ILLEGAL_VOL)

        # try to cleanup as much as possible
        eFound = se.CannotDeleteVolume(self.volUUID)
        puuid = None
        try:
            # We need to blank parent record in our metadata
            # for parent to become leaf successfully.
            puuid = self.getParent()
            self.setParent(sc.BLANK_UUID)
            if puuid and puuid != sc.BLANK_UUID:
                pvol = FileVolume(self.repoPath, self.sdUUID, self.imgUUID,
                                  puuid)
                pvol.recheckIfLeaf()
        except Exception as e:
            eFound = e
            self.log.warning("cannot finalize parent volume %s",
                             puuid,
                             exc_info=True)

        try:
            self.oop.utils.rmFile(vol_path)
            self.oop.utils.rmFile(lease_path)
        except Exception as e:
            eFound = e
            self.log.error("cannot delete volume %s at path: %s",
                           self.volUUID,
                           vol_path,
                           exc_info=True)

        try:
            self.removeMetadata()
            return True
        except Exception as e:
            eFound = e
            self.log.error("cannot remove volume's %s metadata",
                           self.volUUID,
                           exc_info=True)

        raise eFound
示例#2
0
文件: fileSD.py 项目: gobindadas/vdsm
 def purgeImage(self, sdUUID, imgUUID, volsImgs, discard):
     self.log.debug("Purging image %s", imgUUID)
     if discard:
         raise se.DiscardIsNotSupported(sdUUID, "file storage domain")
     toDelDir = self.getDeletedImagePath(imgUUID)
     for volUUID in volsImgs:
         volPath = os.path.join(toDelDir, volUUID)
         self._deleteVolumeFile(volPath)
         self._deleteVolumeFile(volPath + fileVolume.META_FILEEXT)
         if self.hasVolumeLeases():
             self._deleteVolumeFile(volPath + LEASE_FILEEXT)
     self.log.debug("Removing directory: %s", toDelDir)
     try:
         self.oop.os.rmdir(toDelDir)
     except OSError as e:
         self.log.error("removed image dir: %s can't be removed", toDelDir)
         raise se.ImageDeleteError("%s %s" % (imgUUID, str(e)))
示例#3
0
 def zeroImage(self, sdUUID, imgUUID, volsImgs, discard):
     self.log.warning("image %s on a fileSD %s won't be zeroed." %
                      (imgUUID, sdUUID))
     if discard:
         raise se.DiscardIsNotSupported(sdUUID, "file storage domain")
     self.deleteImage(sdUUID, imgUUID, volsImgs)