New patch submitted by Eduardo Warszawski (ewarszaw@redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/641
commit 4ef2f06aca02bc48f63c3b5f7d48ae83e191b3ba Author: Eduardo Warszawski ewarszaw@redhat.com Date: Thu Jun 30 16:18:50 2011 +0300
BZ#717658 - Simplify recycle function.
Change-Id: I9cf3106f0fb5d5cd067907d48ff02fe50493a66c
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index 29206f5..c4fa249 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -1190,6 +1190,15 @@ class HSM: return SDF.produce(sdUUID=sdUUID).validate()
+ #TODO: Remove this function when formatStorageDomain() is removed. + def _recycle(self, sd): + try: + SDF.manuallyRemoveDomain(sd.sdUUID) + except KeyError: + self.log.warn("Storage domain %s doesn't exist in cache. Trying recycle leftovers ...", sd.sdUUID) + + sd.format(sd.sdUUID) + def public_formatStorageDomain(self, sdUUID, autoDetach = False, options = None): """ Formats a detached storage domain. @@ -1198,6 +1207,7 @@ class HSM: This removes all data from the storage domain.
:param sdUUID: The UUID for the storage domain you want to format. + :param autoDetach: DEPRECATED :type sdUUID: UUID :param options: ?
@@ -1214,22 +1224,17 @@ class HSM: raise se.CannotFormatStorageDomainInConnectedPool(sdUUID)
# For domains that attached to disconnected pool, format domain if 'autoDetach' flag set - if not misc.parseBool(autoDetach): + sd = SDF.produce(sdUUID=sdUUID) + try: + #TODO: autoDetach is True + if not misc.parseBool(autoDetach) and sd.getPools(): + raise se.CannotFormatAttachedStorageDomain(sdUUID) # Allow format also for broken domain - try: - if len(SDF.produce(sdUUID=sdUUID).getPools()) > 0: - raise se.CannotFormatAttachedStorageDomain(sdUUID) - - except (se.StorageDomainMetadataNotFound, se.MetaDataGeneralError, se.MiscFileReadException, - se.MiscBlockReadException, se.MiscBlockReadIncomplete), e: - self.log.warn("Domain %s has problem with metadata. Continue formating... (%s)", sdUUID, str(e)) - except se.CannotFormatAttachedStorageDomain: - raise - except Exception: - self.log.warn("Domain %s can't be formated", sdUUID, exc_info=True) - raise se.StorageDomainFormatError(sdUUID) + except (se.StorageDomainMetadataNotFound, se.MetaDataGeneralError, se.MiscFileReadException, + se.MiscBlockReadException, se.MiscBlockReadIncomplete), e: + self.log.warn("Domain %s has problem with metadata. Continue formating... (%s)", sdUUID, str(e))
- SDF.recycle(sdUUID=sdUUID) + self._recycle(sd)
def public_setStorageDomainDescription(self, sdUUID, description, options = None): diff --git a/vdsm/storage/sdf.py b/vdsm/storage/sdf.py index 16faa3e..5e0577d 100644 --- a/vdsm/storage/sdf.py +++ b/vdsm/storage/sdf.py @@ -20,6 +20,9 @@ class StorageDomainFactory: storage_repository = config.get('irs', 'repository') __sdc = sdc.StorageDomainCache(storage_repository)
+ @classmethod + def manuallyRemoveDomain(cls, sdUUID): + cls.__sdc.manuallyRemoveDomain(sdUUID)
@classmethod def produce(cls, sdUUID): @@ -66,33 +69,6 @@ class StorageDomainFactory:
@classmethod - def recycle(cls, sdUUID): - """ - Cleanly destroys the domain - """ - import nfsSD - import localFsSD - import blockSD - - try: - cls.__sdc.manuallyRemoveDomain(sdUUID) - except Exception: - cls.log.warn("Storage domain %s doesn't exist. Trying recycle leftovers ...", sdUUID) - - for domClass in (blockSD.BlockStorageDomain, nfsSD.NfsStorageDomain, localFsSD.LocalFsStorageDomain): - try: - domClass.findDomainPath(sdUUID) - except (se.StorageDomainDoesNotExist): - pass - except Exception: - cls.log.error("Can't find out domain %s", sdUUID, exc_info=True) - else: - return domClass.format(sdUUID) - - raise se.StorageDomainTypeError(sdUUID) - - - @classmethod def getAllUUIDs(cls): return cls.__sdc.getUUIDs()
New patch submitted by Eduardo Warszawski (ewarszaw@redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/641
commit f95164e82a96e052940f35215d451567b93c2936 Author: Eduardo Warszawski ewarszaw@redhat.com Date: Thu Jun 30 16:18:50 2011 +0300
BZ#717658 - Simplify recycle function.
Change-Id: I9cf3106f0fb5d5cd067907d48ff02fe50493a66c
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index b0ee212..84e688a 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -1228,6 +1228,15 @@ class HSM: return SDF.produce(sdUUID=sdUUID).validate()
+ #TODO: Remove this function when formatStorageDomain() is removed. + def _recycle(self, sd): + try: + SDF.manuallyRemoveDomain(sd.sdUUID) + except KeyError: + self.log.warn("Storage domain %s doesn't exist in cache. Trying recycle leftovers ...", sd.sdUUID) + + sd.format(sd.sdUUID) + def public_formatStorageDomain(self, sdUUID, autoDetach = False, options = None): """ Formats a detached storage domain. @@ -1236,6 +1245,7 @@ class HSM: This removes all data from the storage domain.
:param sdUUID: The UUID for the storage domain you want to format. + :param autoDetach: DEPRECATED :type sdUUID: UUID :param options: ?
@@ -1252,24 +1262,18 @@ class HSM: raise se.CannotFormatStorageDomainInConnectedPool(sdUUID)
# For domains that attached to disconnected pool, format domain if 'autoDetach' flag set - if not misc.parseBool(autoDetach): + sd = SDF.produce(sdUUID=sdUUID) + try: + sd.invalidateMetadata() + #TODO: autoDetach is True + if not misc.parseBool(autoDetach) and sd.getPools(): + raise se.CannotFormatAttachedStorageDomain(sdUUID) # Allow format also for broken domain - try: - dom = SDF.produce(sdUUID=sdUUID) - dom.invalidateMetadata() - if len(dom.getPools()) > 0: - raise se.CannotFormatAttachedStorageDomain(sdUUID) - - except (se.StorageDomainMetadataNotFound, se.MetaDataGeneralError, se.MiscFileReadException, - se.MiscBlockReadException, se.MiscBlockReadIncomplete), e: - self.log.warn("Domain %s has problem with metadata. Continue formating... (%s)", sdUUID, str(e)) - except se.CannotFormatAttachedStorageDomain: - raise - except Exception: - self.log.warn("Domain %s can't be formated", sdUUID, exc_info=True) - raise se.StorageDomainFormatError(sdUUID) + except (se.StorageDomainMetadataNotFound, se.MetaDataGeneralError, se.MiscFileReadException, + se.MiscBlockReadException, se.MiscBlockReadIncomplete), e: + self.log.warn("Domain %s has problem with metadata. Continue formating... (%s)", sdUUID, str(e))
- SDF.recycle(sdUUID=sdUUID) + self._recycle(sd)
def public_setStorageDomainDescription(self, sdUUID, description, options = None): diff --git a/vdsm/storage/sdf.py b/vdsm/storage/sdf.py index f13c933..c2587d8 100644 --- a/vdsm/storage/sdf.py +++ b/vdsm/storage/sdf.py @@ -31,6 +31,9 @@ class StorageDomainFactory: storage_repository = config.get('irs', 'repository') __sdc = sdc.StorageDomainCache(storage_repository)
+ @classmethod + def manuallyRemoveDomain(cls, sdUUID): + cls.__sdc.manuallyRemoveDomain(sdUUID)
@classmethod def produce(cls, sdUUID): @@ -77,26 +80,6 @@ class StorageDomainFactory:
@classmethod - def recycle(cls, sdUUID): - """ - Cleanly destroys the domain - """ - import nfsSD - import localFsSD - import blockSD - - try: - cls.__sdc.manuallyRemoveDomain(sdUUID) - except Exception: - cls.log.warn("Storage domain %s doesn't exist. Trying recycle leftovers ...", sdUUID) - - for domClass in (blockSD.BlockStorageDomain, nfsSD.NfsStorageDomain, localFsSD.LocalFsStorageDomain): - return domClass.format(sdUUID) - - raise se.StorageDomainTypeError(sdUUID) - - - @classmethod def getAllUUIDs(cls): return cls.__sdc.getUUIDs()
Dan Kenigsberg has posted comments on this change.
Change subject: Simplify recycle function for removing the sdf.py ......................................................................
Patch Set 3: Looks good to me, approved
-- To view, visit http://gerrit.usersys.redhat.com/641 To unsubscribe, visit http://gerrit.usersys.redhat.com/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I9cf3106f0fb5d5cd067907d48ff02fe50493a66c Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Eduardo Warszawski ewarszaw@redhat.com Gerrit-Reviewer: Ayal Baron Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Eduardo Warszawski ewarszaw@redhat.com Gerrit-Reviewer: Yotam Oron yoron@redhat.com
Dan Kenigsberg has posted comments on this change.
Change subject: Simplify recycle function for removing the sdf.py ......................................................................
Patch Set 4: Verified; Looks good to me, approved
-- Gerrit-MessageType: comment Gerrit-Change-Id: I9cf3106f0fb5d5cd067907d48ff02fe50493a66c Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Eduardo Warszawski ewarszaw@redhat.com Gerrit-Reviewer: Ayal Baron Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Eduardo Warszawski ewarszaw@redhat.com Gerrit-Reviewer: Yotam Oron yoron@redhat.com
Dan Kenigsberg has submitted this change and it was merged.
Change subject: Simplify recycle function for removing the sdf.py ......................................................................
Simplify recycle function for removing the sdf.py
Change-Id: I9cf3106f0fb5d5cd067907d48ff02fe50493a66c --- M vdsm/storage/hsm.py M vdsm/storage/sdf.py 2 files changed, 23 insertions(+), 36 deletions(-)
Approvals: Dan Kenigsberg: Verified; Looks good to me, approved
-- Gerrit-MessageType: merged Gerrit-Change-Id: I9cf3106f0fb5d5cd067907d48ff02fe50493a66c Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Eduardo Warszawski ewarszaw@redhat.com Gerrit-Reviewer: Ayal Baron Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Eduardo Warszawski ewarszaw@redhat.com Gerrit-Reviewer: Yotam Oron yoron@redhat.com
Dan Kenigsberg has posted comments on this change.
Change subject: Simplify recycle function for removing the sdf.py ......................................................................
-- Gerrit-MessageType: comment Gerrit-Change-Id: I9cf3106f0fb5d5cd067907d48ff02fe50493a66c Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Eduardo Warszawski ewarszaw@redhat.com Gerrit-Reviewer: Ayal Baron Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Eduardo Warszawski ewarszaw@redhat.com Gerrit-Reviewer: Yotam Oron yoron@redhat.com
vdsm-patches@lists.fedorahosted.org