Adam Litke has uploaded a new change for review. Change subject: VolumeMetadata: move newMetadata ......................................................................
VolumeMetadata: move newMetadata Change-Id: I115fb4da48ef39bbbda5475cefbed1ab26ee1764 Signed-off-by: Adam Litke <[email protected]> --- M vdsm/storage/blockVolume.py M vdsm/storage/fileVolume.py M vdsm/storage/volume.py 3 files changed, 56 insertions(+), 45 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/42001/1 diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py index 73b6a5e..d80c2a8 100644 --- a/vdsm/storage/blockVolume.py +++ b/vdsm/storage/blockVolume.py @@ -253,6 +253,16 @@ # tags self.setMetaParam(volume.IMAGE, imgUUID) + def removeMetadata(self, metaId): + """ + Just wipe meta. + """ + try: + self._putMetadata(metaId, {"NONE": "#" * (sd.METASIZE - 10)}) + except Exception as e: + self.log.error(e, exc_info=True) + raise se.VolumeMetadataWriteError("%s: %s" % (metaId, e)) + class BlockVolume(volume.Volume): """ Actually represents a single volume (i.e. part of virtual disk). @@ -646,23 +656,9 @@ lvs = lvm.lvsByTag(sdUUID, "%s%s" % (TAG_PREFIX_IMAGE, imgUUID)) return [lv.name for lv in lvs] - def removeMetadata(self, metaId): - """ - Just wipe meta. - """ - try: - self.__putMetadata(metaId, {"NONE": "#" * (sd.METASIZE - 10)}) - except Exception as e: - self.log.error(e, exc_info=True) - raise se.VolumeMetadataWriteError("%s: %s" % (metaId, e)) - @classmethod def __putMetadata(cls, metaId, meta): cls.MetadataClass._putMetadata(metaId, meta) - - @classmethod - def createMetadata(cls, metaId, meta): - cls.__putMetadata(metaId, meta) def getMetaOffset(self): return self.md.getMetaOffset() diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py index cfd05f8..06ac8f8 100644 --- a/vdsm/storage/fileVolume.py +++ b/vdsm/storage/fileVolume.py @@ -210,6 +210,15 @@ """ self.setMetaParam(volume.IMAGE, imgUUID) + def removeMetadata(self): + """ + Remove the meta file + """ + metaPath = self._getMetaVolumePath() + if self.oop.os.path.lexists(metaPath): + self.log.debug("Removing: %s", metaPath) + self.oop.os.unlink(metaPath) + class FileVolume(volume.Volume): """ Actually represents a single volume (i.e. part of virtual disk). @@ -411,22 +420,9 @@ if not self.oop.os.access(volPath, os.R_OK): raise se.VolumeAccessError(volPath) - def removeMetadata(self): - """ - Remove the meta file - """ - metaPath = self._getMetaVolumePath() - if self.oop.os.path.lexists(metaPath): - self.log.debug("Removing: %s", metaPath) - self.oop.os.unlink(metaPath) - @classmethod def __putMetadata(cls, metaId, meta): FileVolumeMetadata._putMetadata(metaId, meta) - - @classmethod - def createMetadata(cls, metaId, meta): - cls.__putMetadata(metaId, meta) @classmethod def getImageVolumes(cls, repoPath, sdUUID, imgUUID): diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py index abbd906..c8a7dc0 100644 --- a/vdsm/storage/volume.py +++ b/vdsm/storage/volume.py @@ -430,9 +430,36 @@ if self.getChildren(): raise se.VolumeImageHasChildren(self) + @classmethod + def createMetadata(cls, metaId, meta): + cls._putMetadata(metaId, meta) + + @classmethod + def newMetadata(cls, metaId, sdUUID, imgUUID, puuid, size, format, type, + voltype, disktype, desc="", legality=ILLEGAL_VOL): + meta = { + FORMAT: str(format), + TYPE: str(type), + VOLTYPE: str(voltype), + DISKTYPE: str(disktype), + SIZE: int(size), + CTIME: int(time.time()), + sd.DMDK_POOLS: "", # obsolete + DOMAIN: str(sdUUID), + IMAGE: str(imgUUID), + DESCRIPTION: str(desc), + PUUID: str(puuid), + MTIME: 0, + LEGALITY: str(legality), + } + + cls.createMetadata(metaId, meta) + return meta + class Volume(object): log = logging.getLogger('Storage.Volume') + MetadataClass = VolumeMetadata def __init__(self, md): self.md = md @@ -497,6 +524,9 @@ Set the read/write permission on the volume (deprecated) """ self.md._setrw(rw) + + def removeMetadata(self): + self.md.removeMetadata() @classmethod def _getModuleAndClass(cls): @@ -1069,24 +1099,9 @@ @classmethod def newMetadata(cls, metaId, sdUUID, imgUUID, puuid, size, format, type, voltype, disktype, desc="", legality=ILLEGAL_VOL): - meta = { - FORMAT: str(format), - TYPE: str(type), - VOLTYPE: str(voltype), - DISKTYPE: str(disktype), - SIZE: int(size), - CTIME: int(time.time()), - sd.DMDK_POOLS: "", # obsolete - DOMAIN: str(sdUUID), - IMAGE: str(imgUUID), - DESCRIPTION: str(desc), - PUUID: str(puuid), - MTIME: 0, - LEGALITY: str(legality), - } - - cls.createMetadata(metaId, meta) - return meta + return cls.MetadataClass.newMetadata( + metaId, sdUUID, imgUUID, puuid, size, format, type, voltype, + disktype, desc, legality) def getInfo(self): return self.md.getInfo() @@ -1136,3 +1151,7 @@ by reducing the lv to minimal size required """ pass + + @classmethod + def createMetadata(cls, metaId, meta): + return cls.MetadataClass.createMetadata(metaId, meta) -- To view, visit https://gerrit.ovirt.org/42001 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I115fb4da48ef39bbbda5475cefbed1ab26ee1764 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
