[trivial] Resync charm-helpers
This commit is contained in:
parent
1c3d5b6414
commit
dd6be5e1e9
@ -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}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user