]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
vminfo now shows disk name
authorMladen Uzunov <mladen.uzunov@digitaspixelpark.com>
Tue, 7 Jun 2022 09:05:52 +0000 (12:05 +0300)
committerMladen Uzunov <mladen.uzunov@digitaspixelpark.com>
Tue, 7 Jun 2022 09:05:52 +0000 (12:05 +0300)
bin/vminfo

index 32767fab5c514d77e5fdb17567396458a6826372..3cdfe3bce1d20d5849a153b5b57d6b70357e6f5e 100644 (file)
@@ -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 <mladen.uzunov@pixelpark.com>'
-__copyright__ = '(C) 2022 by Mladen Uzunov, Pixelpark GmbH, Berlin'
\ No newline at end of file
+__copyright__ = '(C) 2022 by Mladen Uzunov, Pixelpark GmbH, Berlin'