def getMetadata(self, metaid=None, nocache=False): """ Get Meta data array of key,values lines """ if nocache: out = self.metaCache() if out: return out if not metaid: vgname = self.sdUUID offs = self.getMetaOffset() else: vgname = metaid[0] offs = metaid[1] try: meta = misc.readblockSUDO(lvm.lvPath(vgname, sd.METADATA), offs * VOLUME_METASIZE, VOLUME_METASIZE) out = {} for l in meta: if l.startswith("EOF"): return out if l.find("=") < 0: continue key, value = l.split("=") out[key.strip()] = value.strip() except Exception, e: self.log.error(e, exc_info=True) raise se.VolumeMetadataReadError(str(metaid) + ":" + str(e))
def readlines(self): # Fetch the metadata from metadata volume lvm.activateLVs(self._vgName, self._lvName) m = misc.readblockSUDO(self.metavol, self._offset, self._size) # Read from metadata volume will bring a load of zeroes trailing # actual metadata. Strip it out. metadata = [i for i in m if len(i) > 0 and i[0] != '\x00' and "=" in i] return metadata