summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-02-13 10:39:39 -0500
committerScott Moser <smoser@ubuntu.com>2014-02-13 10:39:39 -0500
commit18b8d40d96d2e19f1a949b06b55a3dac54595b23 (patch)
tree38f73307b65a5d60e4b34a97db64a76adf9ce9a2
parentf7ac086a434b511b076346839818de7cf34e18a2 (diff)
downloadvyos-cloud-init-18b8d40d96d2e19f1a949b06b55a3dac54595b23.tar.gz
vyos-cloud-init-18b8d40d96d2e19f1a949b06b55a3dac54595b23.zip
cloudsigma: change default dsmode to 'net'
Previously this had 'local' as the default datasource mode, meaning that user-data code such as boot hooks and such would not be guaranteed to have network access. That would be out of sync with the expectation on other platforms where the default is 'network up'. The user can still specify 'dsmode' as local if necessary and the local datasource will claim itself found.
-rw-r--r--cloudinit/sources/DataSourceCloudSigma.py27
-rw-r--r--doc/sources/cloudsigma/README.rst6
2 files changed, 23 insertions, 10 deletions
diff --git a/cloudinit/sources/DataSourceCloudSigma.py b/cloudinit/sources/DataSourceCloudSigma.py
index 78acd8a4..e734d7e5 100644
--- a/cloudinit/sources/DataSourceCloudSigma.py
+++ b/cloudinit/sources/DataSourceCloudSigma.py
@@ -45,18 +45,25 @@ class DataSourceCloudSigma(sources.DataSource):
Metadata is the whole server context and /meta/cloud-config is used
as userdata.
"""
+ dsmode = None
try:
server_context = self.cepko.all().result
server_meta = server_context['meta']
- self.userdata_raw = server_meta.get('cloudinit-user-data', "")
- self.metadata = server_context
- self.ssh_public_key = server_meta['ssh_public_key']
-
- if server_meta.get('cloudinit-dsmode') in VALID_DSMODES:
- self.dsmode = server_meta['cloudinit-dsmode']
except:
util.logexc(LOG, "Failed reading from the serial port")
return False
+
+ dsmode = server_meta.get('cloudinit-dsmode', self.dsmode)
+ if dsmode not in VALID_DSMODES:
+ LOG.warn("Invalid dsmode %s, assuming default of 'net'", dsmode)
+ dsmode = 'net'
+ if dsmode == "disabled" or dsmode != self.dsmode:
+ return False
+
+ self.userdata_raw = server_meta.get('cloudinit-user-data', "")
+ self.metadata = server_context
+ self.ssh_public_key = server_meta['ssh_public_key']
+
return True
def get_hostname(self, fqdn=False, resolve_ip=False):
@@ -76,11 +83,17 @@ class DataSourceCloudSigma(sources.DataSource):
return self.metadata['uuid']
+class DataSourceCloudSigmaNet(DataSourceCloudSigma):
+ def __init__(self, sys_cfg, distro, paths):
+ DataSourceCloudSigma.__init__(self, sys_cfg, distro, paths)
+ self.dsmode = 'net'
+
+
# Used to match classes to dependencies. Since this datasource uses the serial
# port network is not really required, so it's okay to load without it, too.
datasources = [
(DataSourceCloudSigma, (sources.DEP_FILESYSTEM)),
- (DataSourceCloudSigma, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),
+ (DataSourceCloudSigmaNet, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),
]
diff --git a/doc/sources/cloudsigma/README.rst b/doc/sources/cloudsigma/README.rst
index 8cb2b0fe..1d9160a2 100644
--- a/doc/sources/cloudsigma/README.rst
+++ b/doc/sources/cloudsigma/README.rst
@@ -23,9 +23,9 @@ You can provide user-data to the VM using the dedicated `meta field`_ in the `se
header could be omitted. However since this is a raw-text field you could provide any of the valid
`config formats`_.
-If your user-data needs an internet connection you have to create a `meta field`_ in the `server context`_
-``cloudinit-dsmode`` and set "net" as value. If this field does not exist the default value is "local".
-
+If your user-data does not need an internet connection you can create a
+`meta field`_ in the `server context`_ ``cloudinit-dsmode`` and set "local" as value.
+If this field does not exist the default value is "net".
.. _CloudSigma: http://cloudsigma.com/