c36ff1
From f284c2925b7076b81afb9207161f01718ba70951 Mon Sep 17 00:00:00 2001
c36ff1
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
c36ff1
Date: Fri, 14 Jan 2022 16:50:18 +0100
c36ff1
Subject: [PATCH 3/5] Update dscheck_VMware's rpctool check (#970)
c36ff1
c36ff1
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
c36ff1
RH-MergeRequest: 17: Datasource for VMware
c36ff1
RH-Commit: [3/5] 0739bc18b46b8877fb3825d13f7cda57acda2dde (eesposit/cloud-init-centos-)
c36ff1
RH-Bugzilla: 2040090
c36ff1
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
c36ff1
RH-Acked-by: Eduardo Otubo <otubo@redhat.com>
c36ff1
c36ff1
commit 7781dec3306e9467f216cfcb36b7e10a8b38547a
c36ff1
Author: Shreenidhi Shedi <53473811+sshedi@users.noreply.github.com>
c36ff1
Date:   Fri Aug 13 00:40:39 2021 +0530
c36ff1
c36ff1
    Update dscheck_VMware's rpctool check (#970)
c36ff1
c36ff1
    This patch updates the dscheck_VMware function's use of "vmware-rpctool".
c36ff1
c36ff1
    When checking to see if a "guestinfo" property is set.
c36ff1
    Because a successful exit code can occur even if there is an empty
c36ff1
    string returned, it is possible that the VMware datasource will be
c36ff1
    loaded as a false-positive. This patch ensures that in addition to
c36ff1
    validating the exit code, the emitted output is also examined to ensure
c36ff1
    a non-empty value is returned by rpctool before returning "${DS_FOUND}"
c36ff1
    from "dscheck_VMware()".
c36ff1
c36ff1
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
c36ff1
---
c36ff1
 tools/ds-identify | 15 +++++++++------
c36ff1
 1 file changed, 9 insertions(+), 6 deletions(-)
c36ff1
c36ff1
diff --git a/tools/ds-identify b/tools/ds-identify
c36ff1
index c01eae3d..0e12298f 100755
c36ff1
--- a/tools/ds-identify
c36ff1
+++ b/tools/ds-identify
c36ff1
@@ -141,6 +141,7 @@ error() {
c36ff1
     debug 0 "$@"
c36ff1
     stderr "$@"
c36ff1
 }
c36ff1
+
c36ff1
 warn() {
c36ff1
     set -- "WARN:" "$@"
c36ff1
     debug 0 "$@"
c36ff1
@@ -344,7 +345,6 @@ geom_label_status_as() {
c36ff1
     return $ret
c36ff1
 }
c36ff1
 
c36ff1
-
c36ff1
 read_fs_info_freebsd() {
c36ff1
     local oifs="$IFS" line="" delim=","
c36ff1
     local ret=0 labels="" dev="" label="" ftype="" isodevs=""
c36ff1
@@ -404,7 +404,6 @@ cached() {
c36ff1
     [ -n "$1" ] && _RET="$1" && return || return 1
c36ff1
 }
c36ff1
 
c36ff1
-
c36ff1
 detect_virt() {
c36ff1
     local virt="${UNAVAILABLE}" r="" out=""
c36ff1
     if [ -d /run/systemd ]; then
c36ff1
@@ -450,7 +449,7 @@ detect_virt() {
c36ff1
 read_virt() {
c36ff1
     cached "$DI_VIRT" && return 0
c36ff1
     detect_virt
c36ff1
-    DI_VIRT=${_RET}
c36ff1
+    DI_VIRT="$(echo "${_RET}" | tr '[:upper:]' '[:lower:]')"
c36ff1
 }
c36ff1
 
c36ff1
 is_container() {
c36ff1
@@ -1370,16 +1369,20 @@ vmware_has_rpctool() {
c36ff1
     command -v vmware-rpctool >/dev/null 2>&1
c36ff1
 }
c36ff1
 
c36ff1
+vmware_rpctool_guestinfo() {
c36ff1
+    vmware-rpctool "info-get guestinfo.${1}" 2>/dev/null | grep "[[:alnum:]]"
c36ff1
+}
c36ff1
+
c36ff1
 vmware_rpctool_guestinfo_metadata() {
c36ff1
-    vmware-rpctool "info-get guestinfo.metadata"
c36ff1
+    vmware_rpctool_guestinfo "metadata"
c36ff1
 }
c36ff1
 
c36ff1
 vmware_rpctool_guestinfo_userdata() {
c36ff1
-    vmware-rpctool "info-get guestinfo.userdata"
c36ff1
+    vmware_rpctool_guestinfo "userdata"
c36ff1
 }
c36ff1
 
c36ff1
 vmware_rpctool_guestinfo_vendordata() {
c36ff1
-    vmware-rpctool "info-get guestinfo.vendordata"
c36ff1
+    vmware_rpctool_guestinfo "vendordata"
c36ff1
 }
c36ff1
 
c36ff1
 dscheck_VMware() {
c36ff1
-- 
c36ff1
2.27.0
c36ff1