From 278be9341a01499178dec83a92e561049a96cfb6 Mon Sep 17 00:00:00 2001 From: Inflatador Date: Tue, 14 Nov 2017 23:27:46 +0000 Subject: [PATCH] added method to detect hostname using hostnamectl --- .gitignore | 2 ++ patcher.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index ded6067..0a81dfc 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,8 @@ develop-eggs lib lib64 __pycache__ +#Iso files downloaded by the patcher +*.iso # Installer logs pip-log.txt diff --git a/patcher.py b/patcher.py index 762ec98..f3860ae 100755 --- a/patcher.py +++ b/patcher.py @@ -902,6 +902,21 @@ def unmount_cd(): if debug == True: print("Detected HOST UUID: " + HOSTUUID) +# Try finding host UUID by comparing to hostnamectl +if HOSTUUID == "" or HOSTUUID == ['']: + out = None + err = None + get_host_uuid_cmd = str(xecli) + str(' host-list name-label=`hostnamectl --static` params=uuid --minimal') + get_host_uuid = subprocess.Popen([get_host_uuid_cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + if debug == True: + print("Getting host list using: " + get_host_uuid_cmd) + (out, err) = get_host_uuid.communicate() + if not err and out != None: + HOSTUUID_utf8 = out.decode("utf8") + HOSTUUID = str(HOSTUUID_utf8.replace('\n', '')) + if debug == True: + print("Detected HOST UUID: " + HOSTUUID) + # Trap if the HostUUID is still null if HOSTUUID == "" or HOSTUUID == ['']: print("Error: Failed to obtain HOSTUUID from XE CLI")