[trivial] Resync charm-helpers

This commit is contained in:
james.page@ubuntu.com 2014-12-15 09:29:56 +00:00
parent b44f090ebe
commit 0ccc99781d
2 changed files with 16 additions and 1 deletions

View File

@ -21,11 +21,15 @@ from charmhelpers.core.hookenv import (
relation_set,
unit_get,
unit_private_ip,
charm_name,
DEBUG,
INFO,
WARNING,
ERROR,
)
from charmhelpers.core.sysctl import create as sysctl_create
from charmhelpers.core.host import (
mkdir,
write_file,
@ -1015,3 +1019,14 @@ class NotificationDriverContext(OSContextGenerator):
ctxt['notifications'] = "True"
return ctxt
class SysctlContext(OSContextGenerator):
"""This context check if the 'sysctl' option exists on configuration
then creates a file with the loaded contents"""
def __call__(self):
sysctl_dict = config('sysctl')
if sysctl_dict:
sysctl_create(sysctl_dict,
'/etc/sysctl.d/50-{0}.conf'.format(charm_name()))
return {'sysctl': sysctl_dict}

View File

@ -48,5 +48,5 @@ def render(source, target, context, owner='root', group='root',
level=hookenv.ERROR)
raise e
content = template.render(context)
host.mkdir(os.path.dirname(target))
host.mkdir(os.path.dirname(target), owner, group)
host.write_file(target, content, owner, group, perms)