def getMetadata(self, metaId=None): """ Get Meta data array of key,values lines """ if not metaId: metaId = self.getMetadataId() vgname, offs = metaId try: meta = misc.readblock(lvm.lvPath(vgname, sd.METADATA), offs * volume.METADATA_SIZE, volume.METADATA_SIZE) # TODO: factor out logic below for sharing with file volumes out = {} for l in meta: if l.startswith("EOF"): return out if l.find("=") < 0: continue key, value = l.split("=", 1) out[key.strip()] = value.strip() except Exception as e: self.log.error(e, exc_info=True) raise se.VolumeMetadataReadError("%s: %s" % (metaId, e)) return out
def getMetadata(self, metaId=None): """ Get Meta data array of key,values lines """ if not metaId: metaId = self.getMetadataId() vgname, offs = metaId try: meta = misc.readblock(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 as e: self.log.error(e, exc_info=True) raise se.VolumeMetadataReadError("%s: %s" % (metaId, e)) return out
def readlines(self): # Fetch the metadata from metadata volume lvm.activateLVs(self._vgName, self._lvName) m = misc.readblock(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