X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=ceph%2Fsrc%2Fceph-volume%2Fceph_volume%2Fdevices%2Flvm%2Flisting.py;h=a84a39c182a512e4a6032e60be0afbf083dd1203;hb=28e407b858acd3bddc89f68583571f771bb42e46;hp=d1d96d7adb5a66968fdd3875f8c300bfbcb68146;hpb=dfcb7b53b2e4fcd2a5af0240d4975adc711ab96e;p=ceph.git diff --git a/ceph/src/ceph-volume/ceph_volume/devices/lvm/listing.py b/ceph/src/ceph-volume/ceph_volume/devices/lvm/listing.py index d1d96d7ad..a84a39c18 100644 --- a/ceph/src/ceph-volume/ceph_volume/devices/lvm/listing.py +++ b/ceph/src/ceph-volume/ceph_volume/devices/lvm/listing.py @@ -49,6 +49,9 @@ def pretty_report(report): value=value ) ) + output.append( + device_metadata_item_template.format(tag_name='devices', value=','.join(device['devices']))) + print(''.join(output)) @@ -74,6 +77,30 @@ class List(object): def __init__(self, argv): self.argv = argv + @property + def pvs(self): + """ + To avoid having to make an LVM API call for every single item being + reported, the call gets set only once, using that stored call for + subsequent calls + """ + if getattr(self, '_pvs', None) is not None: + return self._pvs + self._pvs = api.get_api_pvs() + return self._pvs + + def match_devices(self, lv_uuid): + """ + It is possible to have more than one PV reported *with the same name*, + to avoid incorrect or duplicate contents we correlated the lv uuid to + the one on the physical device. + """ + devices = [] + for device in self.pvs: + if device.get('lv_uuid') == lv_uuid: + devices.append(device['pv_name']) + return devices + @decorators.needs_root def list(self, args): # ensure everything is up to date before calling out @@ -152,6 +179,7 @@ class List(object): return self.full_report(lvs=lvs) if lv: + try: _id = lv.tags['ceph.osd_id'] except KeyError: @@ -159,9 +187,9 @@ class List(object): return report report.setdefault(_id, []) - report[_id].append( - lv.as_dict() - ) + lv_report = lv.as_dict() + lv_report['devices'] = self.match_devices(lv.lv_uuid) + report[_id].append(lv_report) else: # this has to be a journal/wal/db device (not a logical volume) so try @@ -202,9 +230,9 @@ class List(object): continue report.setdefault(_id, []) - report[_id].append( - lv.as_dict() - ) + lv_report = lv.as_dict() + lv_report['devices'] = self.match_devices(lv.lv_uuid) + report[_id].append(lv_report) for device_type in ['journal', 'block', 'wal', 'db']: device_uuid = lv.tags.get('ceph.%s_uuid' % device_type)