summaryrefslogtreecommitdiff
path: root/cloudinit/handlers
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-15 21:33:55 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-15 21:33:55 -0700
commit450261a1fcf1f8929a2f7a25c2c278ba40689289 (patch)
tree83430d74ea63c5a11df3fb774e281d0f8efce8f3 /cloudinit/handlers
parent784edb7689d60b81a4334d5171603841cc83da98 (diff)
downloadvyos-cloud-init-450261a1fcf1f8929a2f7a25c2c278ba40689289.tar.gz
vyos-cloud-init-450261a1fcf1f8929a2f7a25c2c278ba40689289.zip
Fixups to ensure that pylint does not find anything major wrong.
Diffstat (limited to 'cloudinit/handlers')
-rw-r--r--cloudinit/handlers/boot_hook.py14
-rw-r--r--cloudinit/handlers/cloud_config.py4
-rw-r--r--cloudinit/handlers/shell_script.py5
-rw-r--r--cloudinit/handlers/upstart_job.py7
4 files changed, 17 insertions, 13 deletions
diff --git a/cloudinit/handlers/boot_hook.py b/cloudinit/handlers/boot_hook.py
index c75aeb72..b3aab366 100644
--- a/cloudinit/handlers/boot_hook.py
+++ b/cloudinit/handlers/boot_hook.py
@@ -32,9 +32,9 @@ LOG = logging.getLogger(__name__)
class BootHookPartHandler(ud.PartHandler):
- def __init__(self, boothook_dir, instance_id):
+ def __init__(self, paths, instance_id, **_kwargs):
ud.PartHandler.__init__(self, PER_ALWAYS)
- self.boothook_dir = boothook_dir
+ self.boothook_dir = paths.get_ipath("boothooks")
self.instance_id = instance_id
def list_types(self):
@@ -54,13 +54,15 @@ class BootHookPartHandler(ud.PartHandler):
start = len(prefix) + 1
filepath = os.path.join(self.boothook_dir, filename)
- util.write_file(filepath, payload[start:], 0700)
+ contents = payload[start:]
+ util.write_file(filepath, contents, 0700)
try:
env = os.environ.copy()
- env['INSTANCE_ID'] = str(self.instance_id)
+ if self.instance_id:
+ env['INSTANCE_ID'] = str(self.instance_id)
util.subp([filepath], env=env)
- except util.ProcessExecutionError as e:
+ except util.ProcessExecutionError:
util.logexc(LOG, "Boothooks script %s execution error", filepath)
- except Exception as e:
+ except Exception:
util.logexc(LOG, ("Boothooks unknown "
"error when running %s"), filepath)
diff --git a/cloudinit/handlers/cloud_config.py b/cloudinit/handlers/cloud_config.py
index f0e88eeb..12d1bd96 100644
--- a/cloudinit/handlers/cloud_config.py
+++ b/cloudinit/handlers/cloud_config.py
@@ -30,10 +30,10 @@ LOG = logging.getLogger(__name__)
class CloudConfigPartHandler(ud.PartHandler):
- def __init__(self, cloud_fn):
+ def __init__(self, paths, **_kwargs):
ud.PartHandler.__init__(self, PER_ALWAYS)
self.cloud_buf = []
- self.cloud_fn = cloud_fn
+ self.cloud_fn = paths.get_ipath("cloud_config")
def list_types(self):
return [
diff --git a/cloudinit/handlers/shell_script.py b/cloudinit/handlers/shell_script.py
index 564e4623..f6e2ef16 100644
--- a/cloudinit/handlers/shell_script.py
+++ b/cloudinit/handlers/shell_script.py
@@ -32,10 +32,9 @@ LOG = logging.getLogger(__name__)
class ShellScriptPartHandler(ud.PartHandler):
-
- def __init__(self, script_dir):
+ def __init__(self, paths, **_kwargs):
ud.PartHandler.__init__(self, PER_ALWAYS)
- self.script_dir = script_dir
+ self.script_dir = paths.get_ipath_cur('scripts')
def list_types(self):
return [
diff --git a/cloudinit/handlers/upstart_job.py b/cloudinit/handlers/upstart_job.py
index 568a644a..059a4851 100644
--- a/cloudinit/handlers/upstart_job.py
+++ b/cloudinit/handlers/upstart_job.py
@@ -33,9 +33,9 @@ LOG = logging.getLogger(__name__)
class UpstartJobPartHandler(ud.PartHandler):
- def __init__(self, upstart_dir):
+ def __init__(self, paths, **_kwargs):
ud.PartHandler.__init__(self, PER_INSTANCE)
- self.upstart_dir = upstart_dir
+ self.upstart_dir = paths.upstart_conf_d
def list_types(self):
return [
@@ -46,6 +46,9 @@ class UpstartJobPartHandler(ud.PartHandler):
if ctype in ud.CONTENT_SIGNALS:
return
+ if not self.upstart_dir:
+ return
+
filename = util.clean_filename(filename)
(_name, ext) = os.path.splitext(filename)
if not ext: