From b898aa96412367fb0cb0e920bb7d3b24933df414 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 24 Jul 2013 00:48:54 -0700 Subject: Use the same method for registering custom vs default. Instead of having a register default handler and a register custom handler, just use the same function to do both but provide a parameter to affect how overwritting of previously existing content-types (which default handlers use to not overwrite custom ones). --- cloudinit/stages.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'cloudinit/stages.py') diff --git a/cloudinit/stages.py b/cloudinit/stages.py index 3e49e8c5..d7211eb6 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -375,7 +375,8 @@ class Init(object): mod = importer.import_module(mod_locs[0]) mod = handlers.fixup_handler(mod) types = c_handlers.register(mod) - LOG.debug("Added handler for %s from %s", types, fname) + LOG.debug("Added custom handler for %s from %s", types, + fname) except Exception: util.logexc(LOG, "Failed to register handler from %s", fname) @@ -386,10 +387,10 @@ class Init(object): # Register any other handlers that come from the default set. This # is done after the cloud-dir handlers so that the cdir modules can # take over the default user-data handler content-types. - def_handlers = self._default_userdata_handlers() - applied_def_handlers = c_handlers.register_defaults(def_handlers) - if applied_def_handlers: - LOG.debug("Registered default handlers: %s", applied_def_handlers) + for mod in self._default_userdata_handlers(): + types = c_handlers.register(mod, overwrite=False) + if types: + LOG.debug("Added default handler for %s from %s", types, mod) # Form our cloud interface data = self.cloudify() -- cgit v1.2.3 From 18a625f958aaecf82a82db24b31290408d27882a Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 24 Jul 2013 00:51:14 -0700 Subject: Only do the debug log if types registered. --- cloudinit/stages.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cloudinit/stages.py') diff --git a/cloudinit/stages.py b/cloudinit/stages.py index d7211eb6..07c55802 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -375,8 +375,9 @@ class Init(object): mod = importer.import_module(mod_locs[0]) mod = handlers.fixup_handler(mod) types = c_handlers.register(mod) - LOG.debug("Added custom handler for %s from %s", types, - fname) + if types: + LOG.debug("Added custom handler for %s from %s", + types, fname) except Exception: util.logexc(LOG, "Failed to register handler from %s", fname) -- cgit v1.2.3