diff --git a/config.yaml b/config.yaml index 26fc7fee..814aa1ec 100644 --- a/config.yaml +++ b/config.yaml @@ -58,6 +58,11 @@ options: default: False type: boolean description: Enable verbose logging + use-syslog: + type: boolean + default: False + description: | + If set to True, supporting services will log to syslog. instance-mtu: type: int description: | diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 32ef8801..0da00f79 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -31,6 +31,9 @@ from charmhelpers.contrib.openstack.neutron import ( ) import charmhelpers.contrib.openstack.context as context +from charmhelpers.contrib.openstack.context import ( + SyslogContext +) import charmhelpers.contrib.openstack.templating as templating from charmhelpers.contrib.openstack.neutron import headers_package from quantum_contexts import ( @@ -177,7 +180,8 @@ NOVA_CONFIG_FILES = { context.SharedDBContext(ssl_dir=NOVA_CONF_DIR), context.PostgresqlDBContext(), NetworkServiceContext(), - QuantumGatewayContext()], + QuantumGatewayContext(), + SyslogContext()], 'services': ['nova-api-metadata'] }, } @@ -215,7 +219,8 @@ NEUTRON_SHARED_CONFIG_FILES.update(NOVA_CONFIG_FILES) QUANTUM_OVS_CONFIG_FILES = { QUANTUM_CONF: { 'hook_contexts': [context.AMQPContext(ssl_dir=QUANTUM_CONF_DIR), - QuantumGatewayContext()], + QuantumGatewayContext(), + SyslogContext()], 'services': ['quantum-l3-agent', 'quantum-dhcp-agent', 'quantum-metadata-agent', @@ -240,7 +245,8 @@ QUANTUM_OVS_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES) NEUTRON_OVS_CONFIG_FILES = { NEUTRON_CONF: { 'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR), - QuantumGatewayContext()], + QuantumGatewayContext(), + SyslogContext()], 'services': ['neutron-l3-agent', 'neutron-dhcp-agent', 'neutron-metadata-agent', diff --git a/templates/folsom/nova.conf b/templates/folsom/nova.conf index f78687c1..37728f5e 100644 --- a/templates/folsom/nova.conf +++ b/templates/folsom/nova.conf @@ -4,6 +4,7 @@ state_path=/var/lib/nova lock_path=/var/lock/nova root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf verbose=True +use_syslog = {{ use_syslog }} api_paste_config=/etc/nova/api-paste.ini enabled_apis=metadata multi_host=True diff --git a/templates/folsom/quantum.conf b/templates/folsom/quantum.conf index 00d88437..4feeb738 100644 --- a/templates/folsom/quantum.conf +++ b/templates/folsom/quantum.conf @@ -1,6 +1,7 @@ [DEFAULT] verbose = {{ verbose }} debug = {{ debug }} +use_syslog = {{ use_syslog }} lock_path = /var/lock/quantum core_plugin = {{ core_plugin }} rabbit_userid = {{ rabbitmq_user }} diff --git a/templates/havana/neutron.conf b/templates/havana/neutron.conf index 33f095d0..626da568 100644 --- a/templates/havana/neutron.conf +++ b/templates/havana/neutron.conf @@ -5,8 +5,9 @@ [DEFAULT] verbose = {{ verbose }} debug = {{ debug }} +use_syslog = {{ use_syslog }} lock_path = /var/lock/neutron -core_plugin = {{ core_plugin }} +core_plugin = {{ core_plugin }} {% include "parts/rabbitmq" %} control_exchange = neutron notification_driver = neutron.openstack.common.notifier.list_notifier diff --git a/templates/havana/nova.conf b/templates/havana/nova.conf index 86322927..da62c4a5 100644 --- a/templates/havana/nova.conf +++ b/templates/havana/nova.conf @@ -8,6 +8,7 @@ state_path=/var/lib/nova lock_path=/var/lock/nova root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf verbose= {{ verbose }} +use_syslog = {{ use_syslog }} api_paste_config=/etc/nova/api-paste.ini enabled_apis=metadata multi_host=True diff --git a/unit_tests/test_quantum_contexts.py b/unit_tests/test_quantum_contexts.py index 031948ea..d5b79e43 100644 --- a/unit_tests/test_quantum_contexts.py +++ b/unit_tests/test_quantum_contexts.py @@ -1,5 +1,10 @@ -from mock import MagicMock, patch +from mock import ( + Mock, + MagicMock, + patch +) import quantum_contexts +import sys from contextlib import contextmanager from test_utils import ( @@ -244,6 +249,19 @@ class TestHostIP(CharmTestCase): super(TestHostIP, self).setUp(quantum_contexts, TO_PATCH) self.config.side_effect = self.test_config.get + # Save and inject + self.mods = {'dns': None, 'dns.resolver': None} + for mod in self.mods: + if mod not in sys.modules: + sys.modules[mod] = Mock() + else: + del self.mods[mod] + + def tearDown(self): + super(TestHostIP, self).tearDown() + # Cleanup + for mod in self.mods.keys(): + del sys.modules[mod] def test_get_host_ip_already_ip(self): self.assertEquals(quantum_contexts.get_host_ip('10.5.0.1'),