[trivial] Resync charm-helpers
This commit is contained in:
parent
4cae1f3b24
commit
af93db0add
@ -21,11 +21,15 @@ from charmhelpers.core.hookenv import (
|
|||||||
relation_set,
|
relation_set,
|
||||||
unit_get,
|
unit_get,
|
||||||
unit_private_ip,
|
unit_private_ip,
|
||||||
|
charm_name,
|
||||||
DEBUG,
|
DEBUG,
|
||||||
INFO,
|
INFO,
|
||||||
WARNING,
|
WARNING,
|
||||||
ERROR,
|
ERROR,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from charmhelpers.core.sysctl import create as sysctl_create
|
||||||
|
|
||||||
from charmhelpers.core.host import (
|
from charmhelpers.core.host import (
|
||||||
mkdir,
|
mkdir,
|
||||||
write_file,
|
write_file,
|
||||||
@ -1015,3 +1019,14 @@ class NotificationDriverContext(OSContextGenerator):
|
|||||||
ctxt['notifications'] = "True"
|
ctxt['notifications'] = "True"
|
||||||
|
|
||||||
return ctxt
|
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)
|
level=hookenv.ERROR)
|
||||||
raise e
|
raise e
|
||||||
content = template.render(context)
|
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)
|
host.write_file(target, content, owner, group, perms)
|
||||||
|
Loading…
Reference in New Issue
Block a user