diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-03-04 17:00:16 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-03-04 17:00:16 -0500 |
commit | 068ee3d324350fd998e2a27e5be2991ea9bab52f (patch) | |
tree | f7a1e0f8a2dc15e5555a3b97982c0475ec1e09dd /cloudinit/config/cc_emit_upstart.py | |
parent | c808b84f1f6cdfe090a18b759a602eb504f36026 (diff) | |
parent | e7cce1a06429813b8d2acc87e6609671d39a3254 (diff) | |
download | vyos-cloud-init-068ee3d324350fd998e2a27e5be2991ea9bab52f.tar.gz vyos-cloud-init-068ee3d324350fd998e2a27e5be2991ea9bab52f.zip |
pull in 'snappy' support
This allows config to disable some of the config modules that were
failing and logging WARN on snapy. Also adds the snappy module
and changes the syslog perms to take a list of user:groups rather
than just a single.
LP: #1428139
Diffstat (limited to 'cloudinit/config/cc_emit_upstart.py')
-rw-r--r-- | cloudinit/config/cc_emit_upstart.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/cloudinit/config/cc_emit_upstart.py b/cloudinit/config/cc_emit_upstart.py index 6d376184..e1b9a4c2 100644 --- a/cloudinit/config/cc_emit_upstart.py +++ b/cloudinit/config/cc_emit_upstart.py @@ -21,11 +21,32 @@ import os from cloudinit.settings import PER_ALWAYS +from cloudinit import log as logging from cloudinit import util frequency = PER_ALWAYS distros = ['ubuntu', 'debian'] +LOG = logging.getLogger(__name__) + + +def is_upstart_system(): + if not os.path.isfile("/sbin/initctl"): + LOG.debug(("Skipping module named %s," + " no /sbin/initctl located"), name) + return False + + myenv = os.environ.copy() + if 'UPSTART_SESSION' in myenv: + del myenv['UPSTART_SESSION'] + check_cmd = ['initctl', 'version'] + try: + (out, err) = util.subp(check_cmd, env=myenv) + return 'upstart' in out + except util.ProcessExecutionError as e: + LOG.debug("'%s' returned '%s', not using upstart", + ' '.join(check_cmd), e.exit_code) + return False def handle(name, _cfg, cloud, log, args): @@ -34,10 +55,11 @@ def handle(name, _cfg, cloud, log, args): # Default to the 'cloud-config' # event for backwards compat. event_names = ['cloud-config'] - if not os.path.isfile("/sbin/initctl"): - log.debug(("Skipping module named %s," - " no /sbin/initctl located"), name) + + if not is_upstart_system(): + log.debug("not upstart system, '%s' disabled") return + cfgpath = cloud.paths.get_ipath_cur("cloud_config") for n in event_names: cmd = ['initctl', 'emit', str(n), 'CLOUD_CFG=%s' % cfgpath] |