- Moved sysctl logic to charmhelpers for make it compatible with ceph-osd
This commit is contained in:
parent
141e6bc872
commit
0ba34b5c0d
|
@ -155,3 +155,9 @@ options:
|
|||
order for this charm to function correctly, the privacy extension must be
|
||||
disabled and a non-temporary address must be configured/available on
|
||||
your network interface.
|
||||
sysctl:
|
||||
type: string
|
||||
default: ""
|
||||
description: |
|
||||
YAML formatted associative array of sysctl values, e.g.:
|
||||
'{ kernel.pid_max : 4194303 }'
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__author__ = 'Jorge Niedbalski R. <jorge.niedbalski@canonical.com>'
|
||||
|
||||
import yaml
|
||||
|
||||
from subprocess import check_call
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
log,
|
||||
DEBUG,
|
||||
)
|
||||
|
||||
|
||||
def create(sysctl_dict, sysctl_file):
|
||||
"""Creates a sysctl.conf file from a YAML associative array
|
||||
|
||||
:param sysctl_dict: a dict of sysctl options eg { 'kernel.max_pid': 1337 }
|
||||
:type sysctl_dict: dict
|
||||
:param sysctl_file: path to the sysctl file to be saved
|
||||
:type sysctl_file: str or unicode
|
||||
:returns: None
|
||||
"""
|
||||
sysctl_dict = yaml.load(sysctl_dict)
|
||||
|
||||
with open(sysctl_file, "w") as fd:
|
||||
for key, value in sysctl_dict.items():
|
||||
fd.write("{}={}\n".format(key, value))
|
||||
|
||||
log("Updating sysctl_file: %s values: %s" % (sysctl_file, sysctl_dict),
|
||||
level=DEBUG)
|
||||
|
||||
check_call(["sysctl", "-p", sysctl_file])
|
|
@ -45,6 +45,8 @@ from charmhelpers.contrib.network.ip import (
|
|||
format_ipv6_addr
|
||||
)
|
||||
|
||||
from charmhelpers.core.sysctl import create as create_sysctl
|
||||
|
||||
from utils import (
|
||||
render_template,
|
||||
get_public_addr,
|
||||
|
@ -119,6 +121,10 @@ def config_changed():
|
|||
log('Invalid OSD disk format configuration specified', level=ERROR)
|
||||
sys.exit(1)
|
||||
|
||||
sysctl_dict = config('sysctl')
|
||||
if sysctl_dict:
|
||||
create_sysctl(sysctl_dict, '/etc/sysctl.d/50-ceph-charm.conf')
|
||||
|
||||
emit_cephconf()
|
||||
|
||||
e_mountpoint = config('ephemeral-unmount')
|
||||
|
|
Loading…
Reference in New Issue