Merge lp:~thedac/charm-helpers/bug1601972 into lp:charm-helpers

Proposed by David Ames
Status: Merged
Merged at revision: 611
Proposed branch: lp:~thedac/charm-helpers/bug1601972
Merge into: lp:charm-helpers
Diff against target: 43 lines (+4/-4)
2 files modified
charmhelpers/contrib/network/ip.py (+2/-2)
tests/contrib/network/test_ip.py (+2/-2)
To merge this branch: bzr merge lp:~thedac/charm-helpers/bug1601972
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+300354@code.launchpad.net

Description of the change

Make apt_install fatal=True for dnspython install

The ns_query code was installing python-dnspython without fatal=True.
The charm would assume it was installed and then fail hard when that module
was not available. Make the apt_install fatal=True

Fixes LP#1601972

To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) wrote :

LGTM, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/network/ip.py'
2--- charmhelpers/contrib/network/ip.py 2016-07-06 14:41:05 +0000
3+++ charmhelpers/contrib/network/ip.py 2016-07-18 16:04:26 +0000
4@@ -414,7 +414,7 @@
5 try:
6 import dns.resolver
7 except ImportError:
8- apt_install('python-dnspython')
9+ apt_install('python-dnspython', fatal=True)
10 import dns.resolver
11
12 if isinstance(address, dns.name.Name):
13@@ -458,7 +458,7 @@
14 try:
15 import dns.reversename
16 except ImportError:
17- apt_install("python-dnspython")
18+ apt_install("python-dnspython", fatal=True)
19 import dns.reversename
20
21 rev = dns.reversename.from_address(address)
22
23=== modified file 'tests/contrib/network/test_ip.py'
24--- tests/contrib/network/test_ip.py 2016-05-27 09:20:25 +0000
25+++ tests/contrib/network/test_ip.py 2016-07-18 16:04:26 +0000
26@@ -641,7 +641,7 @@
27 fake_dns = FakeDNS('5.5.5.5')
28 with patch(builtin_import, side_effect=[ImportError, fake_dns]):
29 nsq = net_ip.ns_query('5.5.5.5')
30- apt_install.assert_called_with('python-dnspython')
31+ apt_install.assert_called_with('python-dnspython', fatal=True)
32 self.assertEquals(nsq, '5.5.5.5')
33
34 @patch('charmhelpers.contrib.network.ip.apt_install')
35@@ -708,7 +708,7 @@
36 with patch(builtin_import, side_effect=[ImportError, fake_dns,
37 fake_dns]):
38 hn = net_ip.get_hostname('4.2.2.1')
39- apt_install.assert_called_with('python-dnspython')
40+ apt_install.assert_called_with('python-dnspython', fatal=True)
41 self.assertEquals(hn, 'www.ubuntu.com')
42
43 @patch('charmhelpers.contrib.network.ip.socket.gethostbyaddr')

Subscribers

People subscribed via source and target branches