summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2011-01-24 14:03:01 -0500
committerScott Moser <smoser@ubuntu.com>2011-01-24 14:03:01 -0500
commitb9b0a79b5a1b142b9e1176d64f294cf9c9f84157 (patch)
tree35e2bf3d87a451fdb1c87b8cbfa1216e46813126
parent9ebce731fe86e534ecb2bedca6dea27ce5179f44 (diff)
parent0b7f896201348ab791e89bb9f736d62a2941c14d (diff)
downloadvyos-cloud-init-b9b0a79b5a1b142b9e1176d64f294cf9c9f84157.tar.gz
vyos-cloud-init-b9b0a79b5a1b142b9e1176d64f294cf9c9f84157.zip
merge in fixes to get to functioning point
-rwxr-xr-xcloud-init.py6
-rw-r--r--cloudinit/CloudConfig/cc_update_hostname.py11
-rw-r--r--cloudinit/__init__.py11
3 files changed, 16 insertions, 12 deletions
diff --git a/cloud-init.py b/cloud-init.py
index 7c261c26..347982d7 100755
--- a/cloud-init.py
+++ b/cloud-init.py
@@ -60,7 +60,7 @@ def main():
try:
cloudinit.initfs()
except Exception, e:
- warn("failed to initfs, likely bad things to come: %s" % str(e))
+ warn("failed to initfs, likely bad things to come: %s\n" % str(e))
cloudinit.logging_set_from_cfg_file()
@@ -104,10 +104,10 @@ def main():
cfg_path = cloudinit.get_ipath_cur("cloud_config")
cc = CC.CloudConfig(cfg_path, cloud)
- modules_list = CC.read_cc_modules(cc.cfg,"cloud_init_modules")
+ module_list = CC.read_cc_modules(cc.cfg,"cloud_init_modules")
failures = []
- if len(modules_list):
+ if len(module_list):
failures = CC.run_cc_modules(cc,module_list,log)
else:
msg = "no cloud_init_modules to run"
diff --git a/cloudinit/CloudConfig/cc_update_hostname.py b/cloudinit/CloudConfig/cc_update_hostname.py
index c06a434b..3663c0ab 100644
--- a/cloudinit/CloudConfig/cc_update_hostname.py
+++ b/cloudinit/CloudConfig/cc_update_hostname.py
@@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import cloudinit.util as util
import subprocess
+import errno
from cloudinit.CloudConfig import per_always
frequency = per_always
@@ -50,10 +51,10 @@ def read_hostname(filename, default=None):
if line:
return line
except IOError, e:
- if e.errno == errno.ENOENT: pass
+ if e.errno != errno.ENOENT: raise
return default
-def update_hostname(hostname, previous, log):
+def update_hostname(hostname, prev_file, log):
etc_file = "/etc/hostname"
hostname_prev = None
@@ -61,9 +62,9 @@ def update_hostname(hostname, previous, log):
try:
hostname_prev = read_hostname(prev_file)
- except:
- log.warn("Failed to open %s" % prev_file)
-
+ except Exception, e:
+ log.warn("Failed to open %s: %s" % (prev_file, e))
+
try:
hostname_in_etc = read_hostname(etc_file)
except:
diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py
index 12bd0fe1..d5180c05 100644
--- a/cloudinit/__init__.py
+++ b/cloudinit/__init__.py
@@ -88,6 +88,7 @@ def logging_set_from_cfg(cfg, logfile=None):
if not len(log_cfgs):
sys.stderr.write("Warning, no logging configured\n")
+ return
for logcfg in log_cfgs:
try:
@@ -483,7 +484,7 @@ class CloudInit:
# reference, but did not have a cloudinit handle
# (ie, no cloudinit.get_cpath())
def get_cpath(self,name=None):
- return(get_cpath,name)
+ return(get_cpath(name))
def initfs():
@@ -495,15 +496,17 @@ def initfs():
util.ensure_dirs(dlist)
cfg = util.get_base_cfg(system_config,cfg_builtin,parsed_cfgs)
+ log_file = None
if 'def_log_file' in cfg:
- fp = open(def_log_file,"ab")
+ log_file = cfg['def_log_file']
+ fp = open(log_file,"ab")
fp.close()
- if 'syslog_fix_perms' in cfg:
+ if log_file and 'syslog' in cfg:
perms = cfg['syslog']
(u,g) = perms.split(':',1)
if u == "-1" or u == "None": u = None
if g == "-1" or g == "None": g = None
- util.chownbyname(def_log_file, u, g)
+ util.chownbyname(log_file, u, g)
def purge_cache():
try: