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
=== modified file 'charmhelpers/contrib/openstack/context.py'
--- charmhelpers/contrib/openstack/context.py 2016-06-30 22:30:21 +0000
+++ charmhelpers/contrib/openstack/context.py 2016-07-05 22:44:01 +0000
@@ -59,6 +59,7 @@
59 mkdir,59 mkdir,
60 write_file,60 write_file,
61 pwgen,61 pwgen,
62 lsb_release,
62)63)
63from charmhelpers.contrib.hahelpers.cluster import (64from charmhelpers.contrib.hahelpers.cluster import (
64 determine_apache_port,65 determine_apache_port,
@@ -1438,7 +1439,8 @@
1438 :return ctxt: Dictionary of the apparmor profile or None1439 :return ctxt: Dictionary of the apparmor profile or None
1439 """1440 """
1440 if config('aa-profile-mode') in ['disable', 'enforce', 'complain']:1441 if config('aa-profile-mode') in ['disable', 'enforce', 'complain']:
1441 ctxt = {'aa_profile_mode': config('aa-profile-mode')}1442 ctxt = {'aa_profile_mode': config('aa-profile-mode'),
1443 'ubuntu_release': lsb_release()['DISTRIB_RELEASE']}
1442 else:1444 else:
1443 ctxt = None1445 ctxt = None
1444 return ctxt1446 return ctxt
14451447
=== modified file 'tests/contrib/openstack/test_os_contexts.py'
--- tests/contrib/openstack/test_os_contexts.py 2016-06-30 22:30:21 +0000
+++ tests/contrib/openstack/test_os_contexts.py 2016-07-05 22:44:01 +0000
@@ -515,6 +515,7 @@
515 'sysctl_create',515 'sysctl_create',
516 'kv',516 'kv',
517 'pwgen',517 'pwgen',
518 'lsb_release',
518]519]
519520
520521
@@ -567,6 +568,7 @@
567 self.get_host_ip.side_effect = lambda hostname: hostname568 self.get_host_ip.side_effect = lambda hostname: hostname
568 self.kv.side_effect = TestDB569 self.kv.side_effect = TestDB
569 self.pwgen.return_value = 'testpassword'570 self.pwgen.return_value = 'testpassword'
571 self.lsb_release.return_value = {'DISTRIB_RELEASE': '16.04'}
570572
571 def _patch(self, method):573 def _patch(self, method):
572 _m = patch('charmhelpers.contrib.openstack.context.' + method)574 _m = patch('charmhelpers.contrib.openstack.context.' + method)
@@ -2921,7 +2923,8 @@
2921 # Test complain mode2923 # Test complain mode
2922 self.config.return_value = 'complain'2924 self.config.return_value = 'complain'
2923 self.assertEquals(mock_aa_object.__call__(),2925 self.assertEquals(mock_aa_object.__call__(),
2924 {'aa_profile_mode': 'complain'})2926 {'aa_profile_mode': 'complain',
2927 'ubuntu_release': '16.04'})
29252928
2926 def test_apparmor_context_call_enforce(self):2929 def test_apparmor_context_call_enforce(self):
2927 ''' Tests for the apparmor context'''2930 ''' Tests for the apparmor context'''
@@ -2929,7 +2932,8 @@
2929 # Test enforce mode2932 # Test enforce mode
2930 self.config.return_value = 'enforce'2933 self.config.return_value = 'enforce'
2931 self.assertEquals(mock_aa_object.__call__(),2934 self.assertEquals(mock_aa_object.__call__(),
2932 {'aa_profile_mode': 'enforce'})2935 {'aa_profile_mode': 'enforce',
2936 'ubuntu_release': '16.04'})
29332937
2934 def test_apparmor_context_call_disable(self):2938 def test_apparmor_context_call_disable(self):
2935 ''' Tests for the apparmor context'''2939 ''' Tests for the apparmor context'''
@@ -2937,7 +2941,8 @@
2937 # Test complain mode2941 # Test complain mode
2938 self.config.return_value = 'disable'2942 self.config.return_value = 'disable'
2939 self.assertEquals(mock_aa_object.__call__(),2943 self.assertEquals(mock_aa_object.__call__(),
2940 {'aa_profile_mode': 'disable'})2944 {'aa_profile_mode': 'disable',
2945 'ubuntu_release': '16.04'})
29412946
2942 def test_apparmor_setup_complain(self):2947 def test_apparmor_setup_complain(self):
2943 ''' Tests for the apparmor setup'''2948 ''' Tests for the apparmor setup'''

Subscribers

People subscribed via source and target branches