diff options
Diffstat (limited to 'cloudinit/CloudConfig/cc_rightscale_userdata.py')
-rw-r--r-- | cloudinit/CloudConfig/cc_rightscale_userdata.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/cloudinit/CloudConfig/cc_rightscale_userdata.py b/cloudinit/CloudConfig/cc_rightscale_userdata.py index 4875acbe..5ed0848f 100644 --- a/cloudinit/CloudConfig/cc_rightscale_userdata.py +++ b/cloudinit/CloudConfig/cc_rightscale_userdata.py @@ -1,8 +1,10 @@ # vi: ts=4 expandtab # # Copyright (C) 2011 Canonical Ltd. +# Copyright (C) 2012 Hewlett-Packard Development Company, L.P. # # Author: Scott Moser <scott.moser@canonical.com> +# Author: Juerg Haefliger <juerg.haefliger@hp.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3, as @@ -24,16 +26,17 @@ ## for cloud-init support, there will be a key named ## 'CLOUD_INIT_REMOTE_HOOK'. ## -## This cloud-config module will +## This cloud-config module will ## - read the blob of data from raw user data, and parse it as key/value -## - for each key that is found, download the content to +## - for each key that is found, download the content to ## the local instance/scripts directory and set them executable. ## - the files in that directory will be run by the user-scripts module ## Therefore, this must run before that. ## ## + import cloudinit.util as util -from cloudinit.CloudConfig import per_once, per_always, per_instance +from cloudinit.CloudConfig import per_instance from cloudinit import get_ipath_cur from urlparse import parse_qs @@ -41,7 +44,8 @@ frequency = per_instance my_name = "cc_rightscale_userdata" my_hookname = 'CLOUD_INIT_REMOTE_HOOK' -def handle(name,cfg,cloud,log,args): + +def handle(_name, _cfg, cloud, log, _args): try: ud = cloud.get_userdata_raw() except: @@ -49,25 +53,26 @@ def handle(name,cfg,cloud,log,args): return try: - mdict = parse_qs(cloud.get_userdata_raw()) - if not my_hookname in mdict: return + mdict = parse_qs(ud) + if not my_hookname in mdict: + return except: log.warn("failed to urlparse.parse_qa(userdata_raw())") raise scripts_d = get_ipath_cur('scripts') i = 0 - errors = [ ] first_e = None for url in mdict[my_hookname]: - fname = "%s/rightscale-%02i" % (scripts_d,i) - i = i +1 + fname = "%s/rightscale-%02i" % (scripts_d, i) + i = i + 1 try: content = util.readurl(url) util.write_file(fname, content, mode=0700) except Exception as e: - if not first_e: first_e = None + if not first_e: + first_e = None log.warn("%s failed to read %s: %s" % (my_name, url, e)) - + if first_e: raise(e) |