From 5f5354a73e3a838e6fb188f46de38c5b51cad0e2 Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Wed, 27 Nov 2013 10:08:06 -0800
Subject: [PATCH] Handle lack of rpms or debs in devstack-cache.

* modules/openstack_project/files/nodepool/scripts/devstack-cache.py:
When running on Ubuntu only debs will be listed for install, when
running on Fedora only RPMs will be listed for install. Handle the lack
of the other when checking which should be installed (use dict.get
instead of a normal index operation which will throw a KeyError instead
of returning None). Add an error message if no debs or rpms are found.

Change-Id: Iafb57f43ce6b51414593b909e1a9fde7c7c0ebf0
---
 .../files/nodepool/scripts/devstack-cache.py               | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/modules/openstack_project/files/nodepool/scripts/devstack-cache.py b/modules/openstack_project/files/nodepool/scripts/devstack-cache.py
index 9497c1ec91..1cb3e14ab1 100755
--- a/modules/openstack_project/files/nodepool/scripts/devstack-cache.py
+++ b/modules/openstack_project/files/nodepool/scripts/devstack-cache.py
@@ -116,13 +116,14 @@ def main():
     branches = local_prep(distribution)
     image_filenames = {}
     for branch_data in branches:
-        if branch_data['debs']:
+        if branch_data.get('debs'):
             run_local(['sudo', 'apt-get', '-y', '-d', 'install'] +
                       branch_data['debs'])
-
-        if branch_data['rpms']:
+        elif branch_data.get('rpms'):
             run_local(['sudo', 'yum', 'install', '-y', '--downloadonly'] +
                       branch_data['rpms'])
+        else:
+            sys.exit('No supported package data found.')
 
         for url in branch_data['images']:
             fname = url.split('/')[-1]