merge lp:~openstack-charmers/charms/trusty/quantum-gateway/next

This commit is contained in:
Hui Xiang 2014-12-25 18:21:54 +08:00
commit 1c6f69ceea
4 changed files with 58 additions and 2 deletions

View File

@ -115,6 +115,11 @@ options:
.
This network will be used for tenant network traffic in overlay
networks.
sysctl:
default:
description: |
YAML-formatted associative array of sysctl key/value pairs to be set
persistently e.g. '{ kernel.pid_max : 4194303 }'.>>>>>>> MERGE-SOURCE
# Legacy HA
ha-legacy-mode:
type: boolean

View File

@ -0,0 +1,41 @@
#
# Copyright 2014 Canonical Ltd.
#
# Authors:
# Edward Hope-Morley <opentastic@gmail.com>
#
import time
from charmhelpers.core.hookenv import (
log,
INFO,
)
def retry_on_exception(num_retries, base_delay=0, exc_type=Exception):
"""If the decorated function raises exception exc_type, allow num_retries
retry attempts before raise the exception.
"""
def _retry_on_exception_inner_1(f):
def _retry_on_exception_inner_2(*args, **kwargs):
retries = num_retries
multiplier = 1
while True:
try:
return f(*args, **kwargs)
except exc_type:
if not retries:
raise
delay = base_delay * multiplier
multiplier += 1
log("Retrying '%s' %d more times (delay=%s)" %
(f.__name__, retries, delay), level=INFO)
retries -= 1
if delay:
time.sleep(delay)
return _retry_on_exception_inner_2
return _retry_on_exception_inner_1

View File

@ -34,6 +34,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 (
@ -66,6 +67,7 @@ def install():
src = 'cloud:precise-folsom'
configure_installation_source(src)
apt_update(fatal=True)
apt_install('python-six', fatal=True) # Force upgrade
if valid_plugin():
apt_install(filter_installed_packages(get_early_packages()),
fatal=True)
@ -85,6 +87,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