Merge lp:~thedac/charm-helpers/dnsha into lp:charm-helpers

Proposed by David Ames
Status: Merged
Merged at revision: 594
Proposed branch: lp:~thedac/charm-helpers/dnsha
Merge into: lp:charm-helpers
Diff against target: 83 lines (+12/-12)
2 files modified
charmhelpers/contrib/openstack/context.py (+8/-8)
tests/contrib/openstack/test_os_contexts.py (+4/-4)
To merge this branch: bzr merge lp:~thedac/charm-helpers/dnsha
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+298847@code.launchpad.net

Commit message

Make OS Apparmor context keys usable in templates

Change '-' to '_' to allow Apparmor context keys to be usable in templates.

Description of the change

Make OS Apparmor context keys usable in templates

Change '-' to '_' to allow Apparmor context keys to be usable in templates.

To post a comment you must log in.

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-05-25 12:22:42 +0000
+++ charmhelpers/contrib/openstack/context.py 2016-06-30 22:32:33 +0000
@@ -1438,7 +1438,7 @@
1438 :return ctxt: Dictionary of the apparmor profile or None1438 :return ctxt: Dictionary of the apparmor profile or None
1439 """1439 """
1440 if config('aa-profile-mode') in ['disable', 'enforce', 'complain']:1440 if config('aa-profile-mode') in ['disable', 'enforce', 'complain']:
1441 ctxt = {'aa-profile-mode': config('aa-profile-mode')}1441 ctxt = {'aa_profile_mode': config('aa-profile-mode')}
1442 else:1442 else:
1443 ctxt = None1443 ctxt = None
1444 return ctxt1444 return ctxt
@@ -1482,10 +1482,10 @@
1482 log("Not enabling apparmor Profile")1482 log("Not enabling apparmor Profile")
1483 return1483 return
1484 self.install_aa_utils()1484 self.install_aa_utils()
1485 cmd = ['aa-{}'.format(self.ctxt['aa-profile-mode'])]1485 cmd = ['aa-{}'.format(self.ctxt['aa_profile_mode'])]
1486 cmd.append(self.ctxt['aa-profile'])1486 cmd.append(self.ctxt['aa_profile'])
1487 log("Setting up the apparmor profile for {} in {} mode."1487 log("Setting up the apparmor profile for {} in {} mode."
1488 "".format(self.ctxt['aa-profile'], self.ctxt['aa-profile-mode']))1488 "".format(self.ctxt['aa_profile'], self.ctxt['aa_profile_mode']))
1489 try:1489 try:
1490 check_call(cmd)1490 check_call(cmd)
1491 except CalledProcessError as e:1491 except CalledProcessError as e:
@@ -1494,12 +1494,12 @@
1494 # apparmor is yet unaware of the profile and aa-disable aa-profile1494 # apparmor is yet unaware of the profile and aa-disable aa-profile
1495 # fails. If aa-disable learns to read profile files first this can1495 # fails. If aa-disable learns to read profile files first this can
1496 # be removed.1496 # be removed.
1497 if self.ctxt['aa-profile-mode'] == 'disable':1497 if self.ctxt['aa_profile_mode'] == 'disable':
1498 log("Manually disabling the apparmor profile for {}."1498 log("Manually disabling the apparmor profile for {}."
1499 "".format(self.ctxt['aa-profile']))1499 "".format(self.ctxt['aa_profile']))
1500 self.manually_disable_aa_profile()1500 self.manually_disable_aa_profile()
1501 return1501 return
1502 status_set('blocked', "Apparmor profile {} failed to be set to {}."1502 status_set('blocked', "Apparmor profile {} failed to be set to {}."
1503 "".format(self.ctxt['aa-profile'],1503 "".format(self.ctxt['aa_profile'],
1504 self.ctxt['aa-profile-mode']))1504 self.ctxt['aa_profile_mode']))
1505 raise e1505 raise e
15061506
=== modified file 'tests/contrib/openstack/test_os_contexts.py'
--- tests/contrib/openstack/test_os_contexts.py 2016-04-04 18:06:59 +0000
+++ tests/contrib/openstack/test_os_contexts.py 2016-06-30 22:32:33 +0000
@@ -95,7 +95,7 @@
95 super(FakeAppArmorContext, self).__call__()95 super(FakeAppArmorContext, self).__call__()
96 if not self.ctxt:96 if not self.ctxt:
97 return self.ctxt97 return self.ctxt
98 self._ctxt.update({'aa-profile': self.aa_profile})98 self._ctxt.update({'aa_profile': self.aa_profile})
99 return self.ctxt99 return self.ctxt
100100
101101
@@ -2921,7 +2921,7 @@
2921 # Test complain mode2921 # Test complain mode
2922 self.config.return_value = 'complain'2922 self.config.return_value = 'complain'
2923 self.assertEquals(mock_aa_object.__call__(),2923 self.assertEquals(mock_aa_object.__call__(),
2924 {'aa-profile-mode': 'complain'})2924 {'aa_profile_mode': 'complain'})
29252925
2926 def test_apparmor_context_call_enforce(self):2926 def test_apparmor_context_call_enforce(self):
2927 ''' Tests for the apparmor context'''2927 ''' Tests for the apparmor context'''
@@ -2929,7 +2929,7 @@
2929 # Test enforce mode2929 # Test enforce mode
2930 self.config.return_value = 'enforce'2930 self.config.return_value = 'enforce'
2931 self.assertEquals(mock_aa_object.__call__(),2931 self.assertEquals(mock_aa_object.__call__(),
2932 {'aa-profile-mode': 'enforce'})2932 {'aa_profile_mode': 'enforce'})
29332933
2934 def test_apparmor_context_call_disable(self):2934 def test_apparmor_context_call_disable(self):
2935 ''' Tests for the apparmor context'''2935 ''' Tests for the apparmor context'''
@@ -2937,7 +2937,7 @@
2937 # Test complain mode2937 # Test complain mode
2938 self.config.return_value = 'disable'2938 self.config.return_value = 'disable'
2939 self.assertEquals(mock_aa_object.__call__(),2939 self.assertEquals(mock_aa_object.__call__(),
2940 {'aa-profile-mode': 'disable'})2940 {'aa_profile_mode': 'disable'})
29412941
2942 def test_apparmor_setup_complain(self):2942 def test_apparmor_setup_complain(self):
2943 ''' Tests for the apparmor setup'''2943 ''' Tests for the apparmor setup'''

Subscribers

People subscribed via source and target branches