Permalink
Browse files

Add run_name to available values in a service

  • Loading branch information...
1 parent d5d9c32 commit d33e6e4a0963d06d44aa571e1c6680c10635d343 @oldpatricka oldpatricka committed Mar 27, 2012
Showing with 8 additions and 5 deletions.
  1. +7 −4 cloudinitd/services.py
  2. +1 −1 cloudinitd/user_api.py
@@ -68,7 +68,7 @@ def cancel(self):
def poll(self):
return self._multi_top.poll()
- def new_service(self, s, db, boot=None, ready=None, terminate=None, log=None, logfile=None):
+ def new_service(self, s, db, boot=None, ready=None, terminate=None, log=None, logfile=None, run_name=None):
if s.name in self.services.keys():
raise APIUsageException("A service by the name of %s is already know to this boot configuration. Please check your config files and try another name" % (s.name))
@@ -87,7 +87,7 @@ def new_service(self, s, db, boot=None, ready=None, terminate=None, log=None, lo
self._logfile = logfile
# logname = <log dir>/<runname>/s.name
- svc = SVCContainer(db, s, self, log=log, callback=self._service_callback, boot=boot, ready=ready, terminate=terminate, logfile=self._logfile)
+ svc = SVCContainer(db, s, self, log=log, callback=self._service_callback, boot=boot, ready=ready, terminate=terminate, logfile=self._logfile, run_name=run_name)
self.services[s.name] = svc
return svc
@@ -125,7 +125,7 @@ class SVCContainer(object):
that consists of up to 3 other pollable types a level pollable is used to keep the other MultiLevelPollable moving in order
"""
- def __init__(self, db, s, top_level, boot=True, ready=True, terminate=False, log=logging, callback=None, reload=False, logfile=None):
+ def __init__(self, db, s, top_level, boot=True, ready=True, terminate=False, log=logging, callback=None, reload=False, logfile=None, run_name=None):
self._log = log
self._attr_bag = {}
self._myname = s.name
@@ -136,6 +136,7 @@ def __init__(self, db, s, top_level, boot=True, ready=True, terminate=False, log
self._readypgm = s.readypgm
self._s = s
self.name = s.name
+ self.run_name = run_name
self._db = db
self._top_level = top_level
self._logfile = logfile
@@ -418,11 +419,13 @@ def get_dep(self, key):
rc = self._s.hostname
elif key == "instance_id":
rc = self._s.instance_id
+ elif key == "run_name":
+ rc = self.run_name
else:
try:
rc = self._attr_bag[key]
except Exception, ex:
- # if it isn't in the attr bad pull it from the services db defs. This should allow the user the ability
+ # if it isn't in the attr bag pull it from the services db defs. This should allow the user the ability
# to query everything about the service
try:
rc = self._s.__getattribute__(key)
@@ -134,7 +134,7 @@ def func_name(cloudservice, action, msg)
try:
(s_log, logfile) = cloudinitd.make_logger(log_level, self.run_name, logdir=logdir, servicename=s.name)
- svc = self._boot_top.new_service(s, self._db, log=s_log, logfile=logfile)
+ svc = self._boot_top.new_service(s, self._db, log=s_log, logfile=logfile, run_name=self.run_name)
# if boot is not set we assume it was already booted and we expand
if not boot:

0 comments on commit d33e6e4

Please sign in to comment.