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
1=== modified file 'charmhelpers/contrib/openstack/context.py'
2--- charmhelpers/contrib/openstack/context.py 2016-05-25 12:22:42 +0000
3+++ charmhelpers/contrib/openstack/context.py 2016-06-30 22:32:33 +0000
4@@ -1438,7 +1438,7 @@
5 :return ctxt: Dictionary of the apparmor profile or None
6 """
7 if config('aa-profile-mode') in ['disable', 'enforce', 'complain']:
8- ctxt = {'aa-profile-mode': config('aa-profile-mode')}
9+ ctxt = {'aa_profile_mode': config('aa-profile-mode')}
10 else:
11 ctxt = None
12 return ctxt
13@@ -1482,10 +1482,10 @@
14 log("Not enabling apparmor Profile")
15 return
16 self.install_aa_utils()
17- cmd = ['aa-{}'.format(self.ctxt['aa-profile-mode'])]
18- cmd.append(self.ctxt['aa-profile'])
19+ cmd = ['aa-{}'.format(self.ctxt['aa_profile_mode'])]
20+ cmd.append(self.ctxt['aa_profile'])
21 log("Setting up the apparmor profile for {} in {} mode."
22- "".format(self.ctxt['aa-profile'], self.ctxt['aa-profile-mode']))
23+ "".format(self.ctxt['aa_profile'], self.ctxt['aa_profile_mode']))
24 try:
25 check_call(cmd)
26 except CalledProcessError as e:
27@@ -1494,12 +1494,12 @@
28 # apparmor is yet unaware of the profile and aa-disable aa-profile
29 # fails. If aa-disable learns to read profile files first this can
30 # be removed.
31- if self.ctxt['aa-profile-mode'] == 'disable':
32+ if self.ctxt['aa_profile_mode'] == 'disable':
33 log("Manually disabling the apparmor profile for {}."
34- "".format(self.ctxt['aa-profile']))
35+ "".format(self.ctxt['aa_profile']))
36 self.manually_disable_aa_profile()
37 return
38 status_set('blocked', "Apparmor profile {} failed to be set to {}."
39- "".format(self.ctxt['aa-profile'],
40- self.ctxt['aa-profile-mode']))
41+ "".format(self.ctxt['aa_profile'],
42+ self.ctxt['aa_profile_mode']))
43 raise e
44
45=== modified file 'tests/contrib/openstack/test_os_contexts.py'
46--- tests/contrib/openstack/test_os_contexts.py 2016-04-04 18:06:59 +0000
47+++ tests/contrib/openstack/test_os_contexts.py 2016-06-30 22:32:33 +0000
48@@ -95,7 +95,7 @@
49 super(FakeAppArmorContext, self).__call__()
50 if not self.ctxt:
51 return self.ctxt
52- self._ctxt.update({'aa-profile': self.aa_profile})
53+ self._ctxt.update({'aa_profile': self.aa_profile})
54 return self.ctxt
55
56
57@@ -2921,7 +2921,7 @@
58 # Test complain mode
59 self.config.return_value = 'complain'
60 self.assertEquals(mock_aa_object.__call__(),
61- {'aa-profile-mode': 'complain'})
62+ {'aa_profile_mode': 'complain'})
63
64 def test_apparmor_context_call_enforce(self):
65 ''' Tests for the apparmor context'''
66@@ -2929,7 +2929,7 @@
67 # Test enforce mode
68 self.config.return_value = 'enforce'
69 self.assertEquals(mock_aa_object.__call__(),
70- {'aa-profile-mode': 'enforce'})
71+ {'aa_profile_mode': 'enforce'})
72
73 def test_apparmor_context_call_disable(self):
74 ''' Tests for the apparmor context'''
75@@ -2937,7 +2937,7 @@
76 # Test complain mode
77 self.config.return_value = 'disable'
78 self.assertEquals(mock_aa_object.__call__(),
79- {'aa-profile-mode': 'disable'})
80+ {'aa_profile_mode': 'disable'})
81
82 def test_apparmor_setup_complain(self):
83 ''' Tests for the apparmor setup'''

Subscribers

People subscribed via source and target branches