summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-16 13:06:02 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-16 13:06:02 -0700
commitc9c3de2fad73af119cf9002799a875c71fda7b7a (patch)
tree48670e8ba36c7958e79f687c78e5d56d2e16505e
parent37da8d7e9dc74e65537bd64ea406cdebe0a6b539 (diff)
downloadvyos-cloud-init-c9c3de2fad73af119cf9002799a875c71fda7b7a.tar.gz
vyos-cloud-init-c9c3de2fad73af119cf9002799a875c71fda7b7a.zip
When a handler version is set but to an unknown non-int convertable value, treat it as 1
-rw-r--r--cloudinit/handlers/__init__.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/cloudinit/handlers/__init__.py b/cloudinit/handlers/__init__.py
index afa9ec3b..156e228d 100644
--- a/cloudinit/handlers/__init__.py
+++ b/cloudinit/handlers/__init__.py
@@ -98,11 +98,18 @@ def run_part(mod, data, ctype, filename, payload, frequency):
(frequency == PER_INSTANCE and mod_freq == PER_INSTANCE)):
return
mod_ver = mod.handler_version
+ # Sanity checks on version (should be an int convertable)
try:
- if mod_ver == 1:
- mod.handle_part(data, ctype, filename, payload)
- else:
+ mod_ver = int(mod_ver)
+ except:
+ mod_ver = None
+ try:
+ if mod_ver and mod_ver >= 2:
+ # Treat as v. 2 which does get a frequency
mod.handle_part(data, ctype, filename, payload, frequency)
+ else:
+ # Treat as v. 1 which gets no frequency
+ mod.handle_part(data, ctype, filename, payload)
except:
util.logexc(LOG, ("Failed calling handler %s (%s, %s, %s)"
" with frequency %s"),