From b94dc11908e1ebe9dedd227ef90b70f87f3654aa Mon Sep 17 00:00:00 2001 From: Mladen Uzunov Date: Thu, 9 Jun 2022 10:43:03 +0300 Subject: [PATCH] vminfo adding support for Solaris --- .eggs/README.txt | 6 ++++++ bin/vminfo | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .eggs/README.txt mode change 100644 => 100755 bin/vminfo diff --git a/.eggs/README.txt b/.eggs/README.txt new file mode 100644 index 0000000..5d01668 --- /dev/null +++ b/.eggs/README.txt @@ -0,0 +1,6 @@ +This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins. + +This directory caches those eggs to prevent repeated downloads. + +However, it is safe to delete this directory. + diff --git a/bin/vminfo b/bin/vminfo old mode 100644 new mode 100755 index 3cdfe3b..4e64f29 --- a/bin/vminfo +++ b/bin/vminfo @@ -44,9 +44,14 @@ class FactGetter: return data def generalInfo(self): + try: + osInfo = ["OS", self.data["os"]["value"]["distro"]["description"]] + except KeyError: + osInfo = ["OS", f'{self.data["os"]["value"]["name"]} {self.data["os"]["value"]["release"]["major"]}'] # Catching Solaris + data = [["Customer", self.data["customer"]["value"]], ["FQDN", self.data["fqdn"]["value"]], - ["OS", self.data["os"]["value"]["distro"]["description"]], + osInfo, ["Purpose", self.data["pp_purpose"]["value"]], ["Tier", self.data["tier"]["value"]], ["R10k Env", self.data["r10k_environment"]["value"]]] @@ -67,8 +72,12 @@ class FactGetter: def partitionInfo(self): partuuid = re.compile(r"^[\d\w]{8}\-[\d\w]{2}$") self.simpleTabulate([[colored("Partitions:", "green")]], "orgtbl") - self.complexTabulate(self.data["partitions"], additionalSpot={"size": 5, "location": 2}, + try: + self.complexTabulate(self.data["partitions"], additionalSpot={"size": 5, "location": 2}, excludeHeader="partuuid", excludeValue=partuuid) + except KeyError: + print(colored(" [Warning] This host is probably Solaris, therefore partitions are not available in PuppetDB facts.", "red")) + def networkInfo(self): data = [[interface, ','.join(ip)] for interface, ip in self.data["pp_ip_cidr"]["value"].items()] -- 2.39.5