diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_final_message.py | 6 | ||||
-rw-r--r-- | cloudinit/config/cc_ssh_authkey_fingerprints.py | 19 | ||||
-rw-r--r-- | cloudinit/settings.py | 4 | ||||
-rw-r--r-- | cloudinit/sources/DataSourceNone.py | 63 | ||||
-rw-r--r-- | cloudinit/sources/__init__.py | 4 | ||||
-rw-r--r-- | config/cloud.cfg | 1 |
7 files changed, 92 insertions, 9 deletions
@@ -1,4 +1,8 @@ 0.7.0: + - add the 'None' datasource (LP: #906669), which will allow jobs + to run even if there is no "real" datasource found. + - write ssh authorized keys to console, ssh_authkey_fingerprints + config module [Joshua Harlow] (LP: #1010582) - Added RHEVm and vSphere support as source AltCloud [Joseph VLcek] - add write-files module (LP: #1012854) - Add setuptools + cheetah to debian package build dependencies (LP: #1022101) diff --git a/cloudinit/config/cc_final_message.py b/cloudinit/config/cc_final_message.py index aff03c4e..6b864fda 100644 --- a/cloudinit/config/cc_final_message.py +++ b/cloudinit/config/cc_final_message.py @@ -28,7 +28,7 @@ frequency = PER_ALWAYS # Cheetah formated default message FINAL_MESSAGE_DEF = ("Cloud-init v. ${version} finished at ${timestamp}." - " Up ${uptime} seconds.") + " Datasource ${datasource}. Up ${uptime} seconds") def handle(_name, cfg, cloud, log, args): @@ -51,6 +51,7 @@ def handle(_name, cfg, cloud, log, args): 'uptime': uptime, 'timestamp': ts, 'version': cver, + 'datasource': str(cloud.datasource), } util.multi_log("%s\n" % (templater.render_string(msg_in, subs)), console=False, stderr=True) @@ -63,3 +64,6 @@ def handle(_name, cfg, cloud, log, args): util.write_file(boot_fin_fn, contents) except: util.logexc(log, "Failed to write boot finished file %s", boot_fin_fn) + + if cloud.datasource.is_disconnected: + log.warn("Used fallback datasource") diff --git a/cloudinit/config/cc_ssh_authkey_fingerprints.py b/cloudinit/config/cc_ssh_authkey_fingerprints.py index 6fb7d7fe..087cc15e 100644 --- a/cloudinit/config/cc_ssh_authkey_fingerprints.py +++ b/cloudinit/config/cc_ssh_authkey_fingerprints.py @@ -17,20 +17,23 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import base64 -import glob import hashlib -import os from prettytable import PrettyTable -from cloudinit import util from cloudinit import ssh_util +from cloudinit import util def _split_hash(bin_hash): split_up = [] +<<<<<<< TREE + for i in xrange(0, len(bin_hash), FP_SEGMENT_LEN): + split_up.append(bin_hash[i:i + FP_SEGMENT_LEN]) +======= for i in xrange(0, len(bin_hash), 2): split_up.append(bin_hash[i:i+2]) +>>>>>>> MERGE-SOURCE return split_up @@ -56,7 +59,8 @@ def _is_printable_key(entry): def _pprint_key_entries(user, key_fn, key_entries, hash_meth='md5', prefix='ci-info: '): if not key_entries: - message = "%sno authorized ssh keys fingerprints found for user %s." % (prefix, user) + message = ("%sno authorized ssh keys fingerprints found for user %s." + % (prefix, user)) util.multi_log(message) return tbl_fields = ['Keytype', 'Fingerprint (%s)' % (hash_meth), 'Options', 'Comment'] @@ -73,7 +77,8 @@ def _pprint_key_entries(user, key_fn, key_entries, hash_meth='md5', prefix='ci-i authtbl_lines = authtbl_s.splitlines() max_len = len(max(authtbl_lines, key=len)) lines = [ - util.center("Authorized keys fingerprints from %s for user %s" % (key_fn, user), "+", max_len), + util.center("Authorized keys fingerprints from %s for user %s" % + (key_fn, user), "+", max_len), ] lines.extend(authtbl_lines) for line in lines: @@ -86,6 +91,6 @@ def handle(name, cfg, cloud, log, _args): "logging of ssh fingerprints disabled"), name) user_name = util.get_cfg_option_str(cfg, "user", "ubuntu") - hash_meth = util.get_cfg_option_str(cfg, "authkey_hash", "md5") - (auth_key_fn, auth_key_entries) = ssh_util.extract_authorized_keys(user_name, cloud.paths) + extract = ssh_util.extract_authorized_keys + (auth_key_fn, auth_key_entries) = extract(user_name, cloud.paths) _pprint_key_entries(user_name, auth_key_fn, auth_key_entries, hash_meth) diff --git a/cloudinit/settings.py b/cloudinit/settings.py index cdfc31ae..8cc9e3b4 100644 --- a/cloudinit/settings.py +++ b/cloudinit/settings.py @@ -35,7 +35,9 @@ CFG_BUILTIN = { 'OVF', 'MAAS', 'Ec2', - 'CloudStack' + 'CloudStack', + # At the end to act as a 'catch' when none of the above work... + 'None', ], 'def_log_file': '/var/log/cloud-init.log', 'log_cfgs': [], diff --git a/cloudinit/sources/DataSourceNone.py b/cloudinit/sources/DataSourceNone.py new file mode 100644 index 00000000..b186113c --- /dev/null +++ b/cloudinit/sources/DataSourceNone.py @@ -0,0 +1,63 @@ +# vi: ts=4 expandtab +# +# Copyright (C) 2012 Yahoo! Inc. +# +# Author: Joshua Harlow <harlowja@yahoo-inc.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 +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +from cloudinit import log as logging +from cloudinit import sources +from cloudinit import util + +LOG = logging.getLogger(__name__) + + +class DataSourceNone(sources.DataSource): + def __init__(self, sys_cfg, distro, paths, ud_proc=None): + sources.DataSource.__init__(self, sys_cfg, distro, paths, ud_proc) + self.userdata = {} + self.metadata = {} + self.userdata_raw = '' + + def get_data(self): + # If the datasource config has any provided 'fallback' + # userdata or metadata, use it... + if 'userdata' in self.ds_cfg: + self.userdata = self.ds_cfg['userdata'] + self.userdata_raw = util.yaml_dumps(self.userdata) + if 'metadata' in self.ds_cfg: + self.metadata = self.ds_cfg['metadata'] + return True + + def get_instance_id(self): + return 'iid-datasource-none' + + def __str__(self): + return util.obj_name(self) + + @property + def is_disconnected(self): + return True + + +# Used to match classes to dependencies +datasources = [ + (DataSourceNone, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)), + (DataSourceNone, []), +] + + +# Return a list of data sources that match this set of dependencies +def get_datasource_list(depends): + return sources.list_from_depends(depends, datasources) diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index b25724a5..ca9f58e5 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -65,6 +65,10 @@ class DataSource(object): self.userdata = self.ud_proc.process(raw_data) return self.userdata + @property + def is_disconnected(self): + return False + def get_userdata_raw(self): return self.userdata_raw diff --git a/config/cloud.cfg b/config/cloud.cfg index 2b4d9e63..700f3d7a 100644 --- a/config/cloud.cfg +++ b/config/cloud.cfg @@ -59,6 +59,7 @@ cloud_final_modules: - scripts-per-boot - scripts-per-instance - scripts-user + - ssh-authkey-fingerprints - keys-to-console - phone-home - final-message |