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
=== modified file 'charmhelpers/contrib/network/ip.py'
--- charmhelpers/contrib/network/ip.py 2016-07-06 14:41:05 +0000
+++ charmhelpers/contrib/network/ip.py 2016-07-18 16:04:26 +0000
@@ -414,7 +414,7 @@
414 try:414 try:
415 import dns.resolver415 import dns.resolver
416 except ImportError:416 except ImportError:
417 apt_install('python-dnspython')417 apt_install('python-dnspython', fatal=True)
418 import dns.resolver418 import dns.resolver
419419
420 if isinstance(address, dns.name.Name):420 if isinstance(address, dns.name.Name):
@@ -458,7 +458,7 @@
458 try:458 try:
459 import dns.reversename459 import dns.reversename
460 except ImportError:460 except ImportError:
461 apt_install("python-dnspython")461 apt_install("python-dnspython", fatal=True)
462 import dns.reversename462 import dns.reversename
463463
464 rev = dns.reversename.from_address(address)464 rev = dns.reversename.from_address(address)
465465
=== modified file 'tests/contrib/network/test_ip.py'
--- tests/contrib/network/test_ip.py 2016-05-27 09:20:25 +0000
+++ tests/contrib/network/test_ip.py 2016-07-18 16:04:26 +0000
@@ -641,7 +641,7 @@
641 fake_dns = FakeDNS('5.5.5.5')641 fake_dns = FakeDNS('5.5.5.5')
642 with patch(builtin_import, side_effect=[ImportError, fake_dns]):642 with patch(builtin_import, side_effect=[ImportError, fake_dns]):
643 nsq = net_ip.ns_query('5.5.5.5')643 nsq = net_ip.ns_query('5.5.5.5')
644 apt_install.assert_called_with('python-dnspython')644 apt_install.assert_called_with('python-dnspython', fatal=True)
645 self.assertEquals(nsq, '5.5.5.5')645 self.assertEquals(nsq, '5.5.5.5')
646646
647 @patch('charmhelpers.contrib.network.ip.apt_install')647 @patch('charmhelpers.contrib.network.ip.apt_install')
@@ -708,7 +708,7 @@
708 with patch(builtin_import, side_effect=[ImportError, fake_dns,708 with patch(builtin_import, side_effect=[ImportError, fake_dns,
709 fake_dns]):709 fake_dns]):
710 hn = net_ip.get_hostname('4.2.2.1')710 hn = net_ip.get_hostname('4.2.2.1')
711 apt_install.assert_called_with('python-dnspython')711 apt_install.assert_called_with('python-dnspython', fatal=True)
712 self.assertEquals(hn, 'www.ubuntu.com')712 self.assertEquals(hn, 'www.ubuntu.com')
713713
714 @patch('charmhelpers.contrib.network.ip.socket.gethostbyaddr')714 @patch('charmhelpers.contrib.network.ip.socket.gethostbyaddr')

Subscribers

People subscribed via source and target branches