Checkpoint changes to build the upstart conf files

This commit is contained in:
Ken Thomas 2012-02-17 14:54:29 -08:00
parent 18a9617940
commit 191cb45402
3 changed files with 75 additions and 4 deletions

View File

@ -34,6 +34,12 @@ rabbit_host = ${RABBIT_HOST:-$(host:ip)}
# Sys log enabled or not
syslog = 0
# These flags are used for starting components under upstart
[upstart]
respawn = 1
start_event = nova_start
stop_event = nova_stop
[host]
# Set api host endpoint
@ -71,6 +77,7 @@ admin_user = admin
# Should nova be in verbose mode?
verbose = ${NOVA_VERBOSE:-1}
logdir = ${NOVA_LOGDIR:-/var/log/nova}
# Allow the admin api to be accessible?
allow_admin_api = 1

View File

@ -0,0 +1,11 @@
# This is a primative starting point for generic upstart configuration files
# for various nova components.
author "DevstackPy"
description "This is the upstart file for %IMAGE%"
start on %START_EVENT%
stop on %STOP_EVENT%
%RESPAWN%
exec python %BINDIR%/%IMAGE% --flagfile %CFGFILE%

View File

@ -39,8 +39,10 @@ LOG = logging.getLogger('devstack.components.nova')
#special generated conf
API_CONF = 'nova.conf'
UPSTART_CONF_TMPL = 'upstart.conf'
#normal conf
PASTE_CONF = 'nova-api-paste.ini'
CONFIGS = [PASTE_CONF]
#this db will be dropped then created
@ -142,7 +144,7 @@ APP_OPTIONS = {
'nova-scheduler': ['--flagfile', '%CFGFILE%'],
'nova-cert': ['--flagfile', '%CFGFILE%'],
'nova-objectstore': ['--flagfile', '%CFGFILE%'],
'nova-consoleauth': [],
'nova-consoleauth': ['--flagfile', '%CFGFILE%'],
'nova-xvpvncproxy': ['--flagfile', '%CFGFILE%'],
}
@ -275,8 +277,15 @@ class NovaInstaller(comp.PythonInstallComponent):
def _get_symlinks(self):
links = dict()
for fn in self._get_config_files():
LOG.info("getting symlink for fn:%s" % (fn))
source_fn = self._get_target_config_name(fn)
links[source_fn] = sh.joinpths("/", "etc", "nova", fn)
LOG.info("symlink for source_fn:%s" % (source_fn))
# Anything in APP_OPTIONS is actually an upstart config
# and will go into /etc/init
if fn in APP_OPTIONS:
links[source_fn] = sh.joinpths("/", "etc", "init", fn + ".conf")
else:
links[source_fn] = sh.joinpths("/", "etc", "nova", fn)
source_fn = sh.joinpths(self.cfgdir, API_CONF)
links[source_fn] = sh.joinpths("/", "etc", "nova", API_CONF)
return links
@ -297,7 +306,9 @@ class NovaInstaller(comp.PythonInstallComponent):
self.cfg.get("passwords", pw_key)
def _get_config_files(self):
return list(CONFIGS)
# We'll include the keys from APP_OPTIONS since we want to create
# upstart config files for those.
return CONFIGS + APP_OPTIONS.keys()
def _setup_network(self):
LOG.info("Creating your nova network to be used with instances.")
@ -385,11 +396,45 @@ class NovaInstaller(comp.PythonInstallComponent):
srcfn = sh.joinpths(self.appdir, "etc", "nova", 'api-paste.ini')
contents = sh.load_file(srcfn)
return (srcfn, contents)
elif config_fn in APP_OPTIONS:
# This is one of the upstart configs, use our general template
# for the source
LOG.info("Loading upstart template to be used by:%s" % (config_fn))
(_, contents) = utils.load_template('general', UPSTART_CONF_TMPL)
return (config_fn, contents)
else:
# It's not an upstart config, just do what we used to do
return comp.PythonInstallComponent._get_source_config(self, config_fn)
def _get_target_config_name(self, config_fn):
if config_fn in APP_OPTIONS:
# This is one of the upstart configs. It'll eventually get
# symlinked to /etc/init. Use the APP_OPTIONS key as the base filename
result = sh.joinpths(self.cfgdir, config_fn + ".conf")
LOG.info("Generated upstart config name:%s" % (result))
return result
else:
# It's not an upstart config, just do what we used to do
return comp.PkgInstallComponent._get_target_config_name(self, config_fn)
def _get_param_map(self, config_fn):
return keystone.get_shared_params(self.cfg)
if config_fn in APP_OPTIONS:
# We're processing an upstart config file. We'll need to set
# specific values from the general upstart config template
LOG.info("Returning parms for update config:%s" % (config_fn))
params = dict()
params['CFGFILE'] = sh.joinpths(self.cfgdir, API_CONF)
params['BINDIR'] = self.bindir
params['IMAGE'] = config_fn
if self.cfg.get('upstart', 'respawn'):
params['RESPAWN'] = "respawn"
else:
params['RESPAWN'] = ""
params['START_EVENT'] = self.cfg.get('upstart', 'start_event')
params['STOP_EVENT'] = self.cfg.get('upstart', 'stop_event')
return params
else:
return keystone.get_shared_params(self.cfg)
def configure(self):
am = comp.PythonInstallComponent.configure(self)
@ -547,6 +592,14 @@ class NovaConfConfigurator(object):
#verbose on?
if self._getbool('verbose'):
nova_conf.add_simple('verbose')
# Check if we have a logdir specified. If we do, we'll make
# sure that it exists. We will *not* use tracewrite because we
# don't want to lose the logs when we uninstall
logdir = self._getstr('logdir', '/var/log/nova')
if logdir:
LOG.info("Making sure that logdir exists:%s" % logdir)
nova_conf.add('logdir', logdir)
sh.mkdir(logdir, True)
#allow the admin api?
if self._getbool('allow_admin_api'):