[niedbalski,r=hopem]

Adds sysctl configuration support.

Closes-Bug: #1396613
This commit is contained in:
Edward Hope-Morley 2014-12-19 15:21:18 +00:00
commit 3ecd3807d9
3 changed files with 17 additions and 2 deletions

View File

@ -115,3 +115,9 @@ options:
.
This network will be used for tenant network traffic in overlay
networks.
sysctl:
type: string
default:
description: |
YAML-formatted associative array of sysctl key/value pairs to be set
persistently e.g. '{ kernel.pid_max : 4194303 }'.

View File

@ -33,6 +33,7 @@ from charmhelpers.contrib.openstack.utils import (
openstack_upgrade_available,
)
from charmhelpers.payload.execd import execd_preinstall
from charmhelpers.core.sysctl import create as create_sysctl
import sys
from quantum_utils import (
@ -78,6 +79,11 @@ def config_changed():
global CONFIGS
if openstack_upgrade_available(get_common_package()):
CONFIGS = do_openstack_upgrade()
sysctl_dict = config('sysctl')
if sysctl_dict:
create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf')
# Re-run joined hooks as config might have changed
for r_id in relation_ids('shared-db'):
db_joined(relation_id=r_id)

View File

@ -40,7 +40,8 @@ TO_PATCH = [
'lsb_release',
'stop_services',
'b64decode',
'is_relation_made'
'is_relation_made',
'create_sysctl',
]
@ -98,6 +99,7 @@ class TestQuantumHooks(CharmTestCase):
def test_config_changed(self):
def mock_relids(rel):
return ['relid']
self.test_config.set('sysctl', '{ kernel.max_pid: "1337"}')
self.openstack_upgrade_available.return_value = True
self.valid_plugin.return_value = True
self.relation_ids.side_effect = mock_relids
@ -112,6 +114,7 @@ class TestQuantumHooks(CharmTestCase):
self.assertTrue(_pgsql_db_joined.called)
self.assertTrue(_amqp_joined.called)
self.assertTrue(_amqp_nova_joined.called)
self.create_sysctl.assert_called()
def test_config_changed_upgrade(self):
self.openstack_upgrade_available.return_value = True