From 1d0d202d04a01fb8b806f7b7bd2128b1aa5db9e3 Mon Sep 17 00:00:00 2001 From: Mladen Uzunov Date: Tue, 7 Jun 2022 12:05:52 +0300 Subject: [PATCH] vminfo now shows disk name --- bin/vminfo | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/vminfo b/bin/vminfo index 32767fa..3cdfe3b 100644 --- a/bin/vminfo +++ b/bin/vminfo @@ -62,7 +62,7 @@ class FactGetter: def diskInfo(self): serialNum = re.compile(r'^\d{20}$') self.simpleTabulate([[colored("Disks:", "green")]], "orgtbl") - self.complexTabulate(self.data["disks"], excludeValue=serialNum, excludeHeader="serial") + self.complexTabulate(self.data["disks"], excludeValue=serialNum, excludeHeader="serial", zeroIndex="Name") def partitionInfo(self): partuuid = re.compile(r"^[\d\w]{8}\-[\d\w]{2}$") @@ -82,24 +82,25 @@ class FactGetter: else: print(tabulate(data, tablefmt=self.tableFormat)) - def complexTabulate(self, data, excludeValue=None, excludeHeader=None, additionalSpot=None): + def complexTabulate(self, data, excludeValue=None, excludeHeader=None, additionalSpot=None, zeroIndex=None): finalData = [] for items in data["value"].items(): - if excludeValue is not None: - values = [x for x in items[1].values() if x != - excludeValue and not re.match(excludeValue, str(x))] + if excludeValue: + values = [x for x in items[1].values() if x != excludeValue and not re.match(excludeValue, str(x))] + if zeroIndex: + values.insert(0, items[0]) else: values = [x for x in items[1].values()] - if excludeHeader is not None: - headers = [x for x in items[1].keys() if x != - excludeHeader and not re.match(excludeHeader, str(x))] + if excludeHeader: + headers = [x for x in items[1].keys() if x != excludeHeader and not re.match(excludeHeader, str(x))] else: headers = [x for x in items[1].keys()] - if additionalSpot is not None: + if additionalSpot: if len(values) < additionalSpot["size"]: values.insert(additionalSpot["location"], "--") finalData.append(values) + headers.insert(0, zeroIndex) print(tabulate(finalData, headers=headers, tablefmt=self.tableFormat)) @@ -129,6 +130,5 @@ facter.diskInfo() facter.partitionInfo() facter.networkInfo() - __author__ = 'Mladen Uzunov ' -__copyright__ = '(C) 2022 by Mladen Uzunov, Pixelpark GmbH, Berlin' \ No newline at end of file +__copyright__ = '(C) 2022 by Mladen Uzunov, Pixelpark GmbH, Berlin' -- 2.39.5