Merge lp:~harlowja/cloud-init/none-ds into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Joshua Harlow
Status: Merged
Merged at revision: 624
Proposed branch: lp:~harlowja/cloud-init/none-ds
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 96 lines (+70/-1)
3 files modified
cloudinit/settings.py (+3/-1)
cloudinit/sources/DataSourceNone.py (+63/-0)
cloudinit/sources/__init__.py (+4/-0)
To merge this branch: bzr merge lp:~harlowja/cloud-init/none-ds
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+120455@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/settings.py'
2--- cloudinit/settings.py 2012-08-08 18:36:41 +0000
3+++ cloudinit/settings.py 2012-08-20 19:23:42 +0000
4@@ -35,7 +35,9 @@
5 'OVF',
6 'MAAS',
7 'Ec2',
8- 'CloudStack'
9+ 'CloudStack',
10+ # At the end to act as a 'catch' when none of the above work...
11+ 'None',
12 ],
13 'def_log_file': '/var/log/cloud-init.log',
14 'log_cfgs': [],
15
16=== added file 'cloudinit/sources/DataSourceNone.py'
17--- cloudinit/sources/DataSourceNone.py 1970-01-01 00:00:00 +0000
18+++ cloudinit/sources/DataSourceNone.py 2012-08-20 19:23:42 +0000
19@@ -0,0 +1,63 @@
20+# vi: ts=4 expandtab
21+#
22+# Copyright (C) 2012 Yahoo! Inc.
23+#
24+# Author: Joshua Harlow <harlowja@yahoo-inc.com>
25+#
26+# This program is free software: you can redistribute it and/or modify
27+# it under the terms of the GNU General Public License version 3, as
28+# published by the Free Software Foundation.
29+#
30+# This program is distributed in the hope that it will be useful,
31+# but WITHOUT ANY WARRANTY; without even the implied warranty of
32+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33+# GNU General Public License for more details.
34+#
35+# You should have received a copy of the GNU General Public License
36+# along with this program. If not, see <http://www.gnu.org/licenses/>.
37+
38+from cloudinit import log as logging
39+from cloudinit import sources
40+from cloudinit import util
41+
42+LOG = logging.getLogger(__name__)
43+
44+
45+class DataSourceNone(sources.DataSource):
46+ def __init__(self, sys_cfg, distro, paths, ud_proc=None):
47+ sources.DataSource.__init__(self, sys_cfg, distro, paths, ud_proc)
48+ self.userdata = {}
49+ self.metadata = {}
50+ self.userdata_raw = ''
51+
52+ def get_data(self):
53+ # If the datasource config has any provided 'fallback'
54+ # userdata or metadata, use it...
55+ if 'userdata' in self.ds_cfg:
56+ self.userdata = self.ds_cfg['userdata']
57+ self.userdata_raw = util.yaml_dumps(self.userdata)
58+ if 'metadata' in self.ds_cfg:
59+ self.metadata = self.ds_cfg['metadata']
60+ return True
61+
62+ def get_instance_id(self):
63+ return 'iid-datasource-none'
64+
65+ def __str__(self):
66+ return util.obj_name(self)
67+
68+ @property
69+ def is_disconnected(self):
70+ return True
71+
72+
73+# Used to match classes to dependencies
74+datasources = [
75+ (DataSourceNone, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),
76+ (DataSourceNone, []),
77+]
78+
79+
80+# Return a list of data sources that match this set of dependencies
81+def get_datasource_list(depends):
82+ return sources.list_from_depends(depends, datasources)
83
84=== modified file 'cloudinit/sources/__init__.py'
85--- cloudinit/sources/__init__.py 2012-06-21 15:38:12 +0000
86+++ cloudinit/sources/__init__.py 2012-08-20 19:23:42 +0000
87@@ -65,6 +65,10 @@
88 self.userdata = self.ud_proc.process(raw_data)
89 return self.userdata
90
91+ @property
92+ def is_disconnected(self):
93+ return False
94+
95 def get_userdata_raw(self):
96 return self.userdata_raw
97