summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--cloudinit/config/cc_final_message.py6
-rw-r--r--cloudinit/settings.py4
-rw-r--r--cloudinit/sources/DataSourceNone.py63
-rw-r--r--cloudinit/sources/__init__.py4
5 files changed, 77 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4e8bc11a..d6dfc80e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
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]
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/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