From cab6858a9fe78d02243530da67fb02202cb7c47a Mon Sep 17 00:00:00 2001
From: David Ames <david.ames@canonical.com>
Date: Mon, 18 Jul 2016 09:46:07 -0700
Subject: [PATCH] Install python dependencies early for CH ip.py

When using charmhelpers.contrib.network.ip apt install was quietly
failing. Install python dependencies in the early install hook
(before install.real).

Charm-helpers sync to bring in apt_install with fatal=True

Change-Id: I5dd279a1a13b7b34c8392b576b6de4e029765b67
Partial-Bug: 1601972
---
 charmhelpers/contrib/network/ip.py      | 4 ++--
 charmhelpers/contrib/openstack/utils.py | 2 +-
 hooks/install                           | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/charmhelpers/contrib/network/ip.py b/charmhelpers/contrib/network/ip.py
index b5f457c7..d6dee17c 100644
--- a/charmhelpers/contrib/network/ip.py
+++ b/charmhelpers/contrib/network/ip.py
@@ -414,7 +414,7 @@ def ns_query(address):
     try:
         import dns.resolver
     except ImportError:
-        apt_install('python-dnspython')
+        apt_install('python-dnspython', fatal=True)
         import dns.resolver
 
     if isinstance(address, dns.name.Name):
@@ -458,7 +458,7 @@ def get_hostname(address, fqdn=True):
         try:
             import dns.reversename
         except ImportError:
-            apt_install("python-dnspython")
+            apt_install("python-dnspython", fatal=True)
             import dns.reversename
 
         rev = dns.reversename.from_address(address)
diff --git a/charmhelpers/contrib/openstack/utils.py b/charmhelpers/contrib/openstack/utils.py
index 519eae95..889ac044 100644
--- a/charmhelpers/contrib/openstack/utils.py
+++ b/charmhelpers/contrib/openstack/utils.py
@@ -145,7 +145,7 @@ SWIFT_CODENAMES = OrderedDict([
     ('mitaka',
         ['2.5.0', '2.6.0', '2.7.0']),
     ('newton',
-        ['2.8.0']),
+        ['2.8.0', '2.9.0']),
 ])
 
 # >= Liberty version->codename mapping
diff --git a/hooks/install b/hooks/install
index 83a9d3ce..29ff6894 100755
--- a/hooks/install
+++ b/hooks/install
@@ -2,7 +2,7 @@
 # Wrapper to deal with newer Ubuntu versions that don't have py2 installed
 # by default.
 
-declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml')
+declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml' 'dnspython')
 
 check_and_install() {
     pkg="${1}-${2}"