From dd6be5e1e95e03429bf20541a88e1dc67c023521 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 15 Dec 2014 09:24:17 +0000 Subject: [PATCH] [trivial] Resync charm-helpers --- hooks/charmhelpers/contrib/openstack/context.py | 15 +++++++++++++++ hooks/charmhelpers/core/templating.py | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hooks/charmhelpers/contrib/openstack/context.py b/hooks/charmhelpers/contrib/openstack/context.py index eebe8c03..eb108910 100644 --- a/hooks/charmhelpers/contrib/openstack/context.py +++ b/hooks/charmhelpers/contrib/openstack/context.py @@ -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} diff --git a/hooks/charmhelpers/core/templating.py b/hooks/charmhelpers/core/templating.py index 83133fa4..569eaed6 100644 --- a/hooks/charmhelpers/core/templating.py +++ b/hooks/charmhelpers/core/templating.py @@ -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)