Merge lp:~thedac/charm-helpers/apparmor-profiles into lp:charm-helpers

Proposed by David Ames
Status: Merged
Merged at revision: 603
Proposed branch: lp:~thedac/charm-helpers/apparmor-profiles
Merge into: lp:charm-helpers
Diff against target: 71 lines (+11/-4)
2 files modified
charmhelpers/contrib/openstack/context.py (+3/-1)
tests/contrib/openstack/test_os_contexts.py (+8/-3)
To merge this branch: bzr merge lp:~thedac/charm-helpers/apparmor-profiles
Reviewer Review Type Date Requested Status
Ryan Beisner (community) Approve
Review via email: mp+299245@code.launchpad.net

Description of the change

Send LSB release to apparmor context templates

Set the LSB release to be consumed by apparmor context profiles

To post a comment you must log in.
Revision history for this message
Ryan Beisner (1chb1n) :
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/context.py'
2--- charmhelpers/contrib/openstack/context.py 2016-06-30 22:30:21 +0000
3+++ charmhelpers/contrib/openstack/context.py 2016-07-05 22:44:01 +0000
4@@ -59,6 +59,7 @@
5 mkdir,
6 write_file,
7 pwgen,
8+ lsb_release,
9 )
10 from charmhelpers.contrib.hahelpers.cluster import (
11 determine_apache_port,
12@@ -1438,7 +1439,8 @@
13 :return ctxt: Dictionary of the apparmor profile or None
14 """
15 if config('aa-profile-mode') in ['disable', 'enforce', 'complain']:
16- ctxt = {'aa_profile_mode': config('aa-profile-mode')}
17+ ctxt = {'aa_profile_mode': config('aa-profile-mode'),
18+ 'ubuntu_release': lsb_release()['DISTRIB_RELEASE']}
19 else:
20 ctxt = None
21 return ctxt
22
23=== modified file 'tests/contrib/openstack/test_os_contexts.py'
24--- tests/contrib/openstack/test_os_contexts.py 2016-06-30 22:30:21 +0000
25+++ tests/contrib/openstack/test_os_contexts.py 2016-07-05 22:44:01 +0000
26@@ -515,6 +515,7 @@
27 'sysctl_create',
28 'kv',
29 'pwgen',
30+ 'lsb_release',
31 ]
32
33
34@@ -567,6 +568,7 @@
35 self.get_host_ip.side_effect = lambda hostname: hostname
36 self.kv.side_effect = TestDB
37 self.pwgen.return_value = 'testpassword'
38+ self.lsb_release.return_value = {'DISTRIB_RELEASE': '16.04'}
39
40 def _patch(self, method):
41 _m = patch('charmhelpers.contrib.openstack.context.' + method)
42@@ -2921,7 +2923,8 @@
43 # Test complain mode
44 self.config.return_value = 'complain'
45 self.assertEquals(mock_aa_object.__call__(),
46- {'aa_profile_mode': 'complain'})
47+ {'aa_profile_mode': 'complain',
48+ 'ubuntu_release': '16.04'})
49
50 def test_apparmor_context_call_enforce(self):
51 ''' Tests for the apparmor context'''
52@@ -2929,7 +2932,8 @@
53 # Test enforce mode
54 self.config.return_value = 'enforce'
55 self.assertEquals(mock_aa_object.__call__(),
56- {'aa_profile_mode': 'enforce'})
57+ {'aa_profile_mode': 'enforce',
58+ 'ubuntu_release': '16.04'})
59
60 def test_apparmor_context_call_disable(self):
61 ''' Tests for the apparmor context'''
62@@ -2937,7 +2941,8 @@
63 # Test complain mode
64 self.config.return_value = 'disable'
65 self.assertEquals(mock_aa_object.__call__(),
66- {'aa_profile_mode': 'disable'})
67+ {'aa_profile_mode': 'disable',
68+ 'ubuntu_release': '16.04'})
69
70 def test_apparmor_setup_complain(self):
71 ''' Tests for the apparmor setup'''

Subscribers

People subscribed via source and target branches