Merge lp:~james-page/charm-helpers/remove-alternative into lp:charm-helpers

Proposed by James Page
Status: Merged
Merged at revision: 789
Proposed branch: lp:~james-page/charm-helpers/remove-alternative
Merge into: lp:charm-helpers
Diff against target: 36 lines (+21/-0)
2 files modified
charmhelpers/contrib/openstack/alternatives.py (+13/-0)
tests/contrib/openstack/test_alternatives.py (+8/-0)
To merge this branch: bzr merge lp:~james-page/charm-helpers/remove-alternative
Reviewer Review Type Date Requested Status
Alex Kavanagh Approve
Review via email: mp+330903@code.launchpad.net

Description of the change

Add helper for remove_alternative

To post a comment you must log in.
Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/openstack/alternatives.py'
--- charmhelpers/contrib/openstack/alternatives.py 2016-07-06 14:41:05 +0000
+++ charmhelpers/contrib/openstack/alternatives.py 2017-09-18 10:32:24 +0000
@@ -29,3 +29,16 @@
29 target, name, source, str(priority)29 target, name, source, str(priority)
30 ]30 ]
31 subprocess.check_call(cmd)31 subprocess.check_call(cmd)
32
33
34def remove_alternative(name, source):
35 """Remove an installed alternative configuration file
36
37 :param name: string name of the alternative to remove
38 :param source: string full path to alternative to remove
39 """
40 cmd = [
41 'update-alternatives', '--remove',
42 name, source
43 ]
44 subprocess.check_call(cmd)
3245
=== modified file 'tests/contrib/openstack/test_alternatives.py'
--- tests/contrib/openstack/test_alternatives.py 2013-10-10 10:39:05 +0000
+++ tests/contrib/openstack/test_alternatives.py 2017-09-18 10:32:24 +0000
@@ -66,3 +66,11 @@
66 TARGET, NAME, SOURCE, '50']66 TARGET, NAME, SOURCE, '50']
67 )67 )
68 _move.assert_not_called()68 _move.assert_not_called()
69
70 @patch('subprocess.check_call')
71 def test_remove_alternative(self, _check):
72 alternatives.remove_alternative(NAME, SOURCE)
73 _check.assert_called_with(
74 ['update-alternatives', '--remove',
75 NAME, SOURCE]
76 )

Subscribers

People subscribed via source and target branches