summaryrefslogtreecommitdiff
path: root/cloudinit/handlers/__init__.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-08 18:42:54 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-08 18:42:54 -0700
commit65a2249c9ba9503afe8c2da06afd54a63cf68fbd (patch)
treee2bbdfc61648415cbf162e4099682ccad8cefcb3 /cloudinit/handlers/__init__.py
parentc6ed90775e79fb31c467bf1222fb06ca17f1aa21 (diff)
downloadvyos-cloud-init-65a2249c9ba9503afe8c2da06afd54a63cf68fbd.tar.gz
vyos-cloud-init-65a2249c9ba9503afe8c2da06afd54a63cf68fbd.zip
Move how handler module names are found to here as well as a fixup module function for bad modules.
Diffstat (limited to 'cloudinit/handlers/__init__.py')
-rw-r--r--cloudinit/handlers/__init__.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/cloudinit/handlers/__init__.py b/cloudinit/handlers/__init__.py
index 3b0cdd4e..ae74b683 100644
--- a/cloudinit/handlers/__init__.py
+++ b/cloudinit/handlers/__init__.py
@@ -36,6 +36,7 @@ LOG = logging.getLogger(__name__)
DEF_HANDLER_VERSION = 1
DEF_FREQ = PER_INSTANCE
+HANDLER_TPL = "cc_%s"
# reads a cloudconfig module list, returns
@@ -230,3 +231,25 @@ def update_package_sources():
def install_packages(pkglist):
update_package_sources()
apt_get("install", pkglist)
+
+
+def form_module_name(name):
+ canon_name = name.replace("-", "_")
+ if canon_name.endswith(".py"):
+ canon_name = canon_name[0:(len(canon_name) - 3)]
+ canon_name = canon_name.strip()
+ if not canon_name:
+ return None
+ return HANDLER_TPL % (canon_name)
+
+
+def fixup_module(mod):
+ freq = getattr(mod, "frequency", None)
+ if not freq:
+ setattr(mod, 'frequency', PER_INSTANCE)
+ handler = getattr(mod, "handle", None)
+ if not handler:
+ def empty_handle(_name, _cfg, _cloud, _log, _args):
+ pass
+ setattr(mod, 'handle', empty_handle)
+ return mod