From 46456e389ee891670088b30eac75d376d5fbe072 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Wed, 8 Apr 2015 17:46:13 +0000 Subject: [PATCH] Pass list of config_files to git.upstart template --- charm-helpers-hooks.yaml | 2 +- .../contrib/openstack/templates/git.upstart | 2 ++ hooks/charmhelpers/core/hookenv.py | 15 ++++++++++++++- hooks/cinder_utils.py | 8 ++++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/charm-helpers-hooks.yaml b/charm-helpers-hooks.yaml index 5c6a8303..2a37274e 100644 --- a/charm-helpers-hooks.yaml +++ b/charm-helpers-hooks.yaml @@ -1,4 +1,4 @@ -branch: lp:charm-helpers +branch: lp:charm-helpers destination: hooks/charmhelpers include: - core diff --git a/hooks/charmhelpers/contrib/openstack/templates/git.upstart b/hooks/charmhelpers/contrib/openstack/templates/git.upstart index da94ad12..62af9204 100644 --- a/hooks/charmhelpers/contrib/openstack/templates/git.upstart +++ b/hooks/charmhelpers/contrib/openstack/templates/git.upstart @@ -9,5 +9,7 @@ respawn exec start-stop-daemon --start --chuid {{ user_name }} \ --chdir {{ start_dir }} --name {{ process_name }} \ --exec {{ executable_name }} -- \ + {% for config_file in config_files -%} --config-file={{ config_file }} \ + {% endfor -%} --log-file={{ log_file }} diff --git a/hooks/charmhelpers/core/hookenv.py b/hooks/charmhelpers/core/hookenv.py index 715dd4c5..86f805f1 100644 --- a/hooks/charmhelpers/core/hookenv.py +++ b/hooks/charmhelpers/core/hookenv.py @@ -20,11 +20,13 @@ # Authors: # Charm Helpers Developers +from __future__ import print_function import os import json import yaml import subprocess import sys +import errno from subprocess import CalledProcessError import six @@ -87,7 +89,18 @@ def log(message, level=None): if not isinstance(message, six.string_types): message = repr(message) command += [message] - subprocess.call(command) + # Missing juju-log should not cause failures in unit tests + # Send log output to stderr + try: + subprocess.call(command) + except OSError as e: + if e.errno == errno.ENOENT: + if level: + message = "{}: {}".format(level, message) + message = "juju-log: {}".format(message) + print(message, file=sys.stderr) + else: + raise class Serializable(UserDict): diff --git a/hooks/cinder_utils.py b/hooks/cinder_utils.py index 4b858548..d5787390 100644 --- a/hooks/cinder_utils.py +++ b/hooks/cinder_utils.py @@ -622,7 +622,7 @@ def git_post_install(projects_yaml): 'start_dir': '/var/lib/cinder', 'process_name': 'cinder-api', 'executable_name': '/usr/local/bin/cinder-api', - 'config_file': '/etc/cinder/cinder.conf', + 'config_files': ['/etc/cinder/cinder.conf'], 'log_file': '/var/log/cinder/cinder-api.log', } @@ -633,7 +633,7 @@ def git_post_install(projects_yaml): 'start_dir': '/var/lib/cinder', 'process_name': 'cinder-backup', 'executable_name': '/usr/local/bin/cinder-backup', - 'config_file': '/etc/cinder/cinder.conf', + 'config_files': ['/etc/cinder/cinder.conf'], 'log_file': '/var/log/cinder/cinder-backup.log', } @@ -644,7 +644,7 @@ def git_post_install(projects_yaml): 'start_dir': '/var/lib/cinder', 'process_name': 'cinder-scheduler', 'executable_name': '/usr/local/bin/cinder-scheduler', - 'config_file': '/etc/cinder/cinder.conf', + 'config_files': ['/etc/cinder/cinder.conf'], 'log_file': '/var/log/cinder/cinder-scheduler.log', } @@ -655,7 +655,7 @@ def git_post_install(projects_yaml): 'start_dir': '/var/lib/cinder', 'process_name': 'cinder-volume', 'executable_name': '/usr/local/bin/cinder-volume', - 'config_file': '/etc/cinder/cinder.conf', + 'config_files': ['/etc/cinder/cinder.conf'], 'log_file': '/var/log/cinder/cinder-volume.log', }