File gcei-handle-missing-gsutil.patch of Package google-compute-engine-init.3436

From 6dfc6c00613fb2d5e51f13fa77d5258188489732 Mon Sep 17 00:00:00 2001
From: Robert Schweikert <rjschwei@suse.com>
Date: Fri, 14 Oct 2016 12:16:35 -0400
Subject: [PATCH] - Check for existence of external executable   + With the
 check we can exit early and provide a message to the user     that the
 executable is missing, rather than having the information about     the
 missing executable intermingled with a failed call thereof. Last     but not
 least it avoids the message that indicates that a download is     being
 attempted, which could lead to confusion.

---
 google_compute_engine/metadata_scripts/script_retriever.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/google_compute_engine/metadata_scripts/script_retriever.py b/google_compute_engine/metadata_scripts/script_retriever.py
index a5c77a5..0625b0a 100644
--- a/google_compute_engine/metadata_scripts/script_retriever.py
+++ b/google_compute_engine/metadata_scripts/script_retriever.py
@@ -50,6 +50,18 @@ class ScriptRetriever(object):
     Returns:
       string, the path to the file storing the metadata script.
     """
+    try:
+       subprocess.check_call(
+         ['which', 'gsutil'],
+         stdout=subprocess.PIPE,
+         stderr=subprocess.PIPE
+       )
+    except subprocess.CalledProcessError:
+      self.logger.warning(
+        'gsutil is not installed, cannot download items from Google Storage'
+      )
+      return None
+
     dest_file = tempfile.NamedTemporaryFile(dir=dest_dir, delete=False)
     dest_file.close()
     dest = dest_file.name
-- 
2.6.6

openSUSE Build Service is sponsored by