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
1=== modified file 'charmhelpers/contrib/openstack/alternatives.py'
2--- charmhelpers/contrib/openstack/alternatives.py 2016-07-06 14:41:05 +0000
3+++ charmhelpers/contrib/openstack/alternatives.py 2017-09-18 10:32:24 +0000
4@@ -29,3 +29,16 @@
5 target, name, source, str(priority)
6 ]
7 subprocess.check_call(cmd)
8+
9+
10+def remove_alternative(name, source):
11+ """Remove an installed alternative configuration file
12+
13+ :param name: string name of the alternative to remove
14+ :param source: string full path to alternative to remove
15+ """
16+ cmd = [
17+ 'update-alternatives', '--remove',
18+ name, source
19+ ]
20+ subprocess.check_call(cmd)
21
22=== modified file 'tests/contrib/openstack/test_alternatives.py'
23--- tests/contrib/openstack/test_alternatives.py 2013-10-10 10:39:05 +0000
24+++ tests/contrib/openstack/test_alternatives.py 2017-09-18 10:32:24 +0000
25@@ -66,3 +66,11 @@
26 TARGET, NAME, SOURCE, '50']
27 )
28 _move.assert_not_called()
29+
30+ @patch('subprocess.check_call')
31+ def test_remove_alternative(self, _check):
32+ alternatives.remove_alternative(NAME, SOURCE)
33+ _check.assert_called_with(
34+ ['update-alternatives', '--remove',
35+ NAME, SOURCE]
36+ )

Subscribers

People subscribed via source and target branches