def format(cls, sdUUID): """Format detached storage domain. This removes all data from the storage domain. """ # Remove the directory tree try: domaindir = cls.findDomainPath(sdUUID) except (se.StorageDomainDoesNotExist): pass else: fileUtils.cleanupdir(domaindir, ignoreErrors=True) # Remove special metadata and service volumes # Remove all volumes LV if exists _removeVMSfs(lvm.lvPath(sdUUID, MASTERLV)) try: lvs = lvm.getLV(sdUUID) except se.LogicalVolumeDoesNotExistError: lvs = () # No LVs in this VG (domain) for lv in lvs: # Fix me: Should raise and get resource lock. try: lvm.removeLVs(sdUUID, lv.name) except se.CannotRemoveLogicalVolume as e: cls.log.warning("Remove logical volume failed %s/%s %s", sdUUID, lv.name, str(e)) lvm.removeVG(sdUUID) return True
# Remove special metadata and service volumes # Remove all volumes LV if exists _removeVMSfs(lvm.lvPath(sdUUID, MASTERLV)) try: lvs = lvm.getLV(sdUUID) except se.LogicalVolumeDoesNotExistError: lvs = () #No LVs in this VG (domain) for lv in lvs: #Fix me: Should raise and get resource lock. try: lvm.removeLVs(sdUUID, lv.name) except se.CannotRemoveLogicalVolume, e: cls.log.warning("Remove logical volume failed %s/%s %s", sdUUID, lv.name, str(e)) lvm.removeVG(sdUUID) return True def getInfo(self): """ Get storage domain info """ ##self.log.info("sdUUID=%s", self.sdUUID) # First call parent getInfo() - it fills in all the common details info = sd.StorageDomain.getInfo(self) # Now add blockSD specific data vg = lvm.getVG(self.sdUUID) #vg.name = self.sdUUID info['vguuid'] = vg.uuid info['state'] = vg.partial return info
# Remove all volumes LV if exists _removeVMSfs(lvm.lvPath(sdUUID, MASTERLV)) try: lvs = lvm.getLV(sdUUID) except se.LogicalVolumeDoesNotExistError: lvs = () #No LVs in this VG (domain) for lv in lvs: #Fix me: Should raise and get resource lock. try: lvm.removeLVs(sdUUID, lv.name) except se.CannotRemoveLogicalVolume, e: cls.log.warning("Remove logical volume failed %s/%s %s", sdUUID, lv.name, str(e)) lvm.removeVG(sdUUID) return True def getInfo(self): """ Get storage domain info """ ##self.log.info("sdUUID=%s", self.sdUUID) # First call parent getInfo() - it fills in all the common details info = sd.StorageDomain.getInfo(self) # Now add blockSD specific data vg = lvm.getVG(self.sdUUID) #vg.name = self.sdUUID info['vguuid'] = vg.uuid info['state'] = vg.partial return info