summaryrefslogtreecommitdiff
path: root/cloudinit/sources/helpers/openstack.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/sources/helpers/openstack.py')
-rw-r--r--cloudinit/sources/helpers/openstack.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py
index 3c3de7e4..a7dd05df 100644
--- a/cloudinit/sources/helpers/openstack.py
+++ b/cloudinit/sources/helpers/openstack.py
@@ -48,6 +48,7 @@ OS_LATEST = 'latest'
OS_FOLSOM = '2012-08-10'
OS_GRIZZLY = '2013-04-04'
OS_HAVANA = '2013-10-17'
+# keep this in chronological order. new supported versions go at the end.
OS_VERSIONS = (
OS_FOLSOM,
OS_GRIZZLY,
@@ -161,7 +162,7 @@ class BaseReader(object):
def _read_ec2_metadata(self):
pass
- def _find_working_version(self, version):
+ def _find_working_version(self):
try:
versions_available = self._fetch_available_versions()
except Exception as e:
@@ -169,19 +170,19 @@ class BaseReader(object):
self.base_path, e)
versions_available = []
- search_versions = [version] + list(OS_VERSIONS)
+ # openstack.OS_VERSIONS is stored in chronological order, so
+ # reverse it to check newest first.
+ supported = [v for v in reversed(list(OS_VERSIONS))]
selected_version = OS_LATEST
- for potential_version in search_versions:
+
+ for potential_version in supported:
if potential_version not in versions_available:
continue
selected_version = potential_version
break
- if selected_version != version:
- LOG.warn("Version '%s' not available, attempting to use "
- "version '%s' instead", version, selected_version)
- else:
- LOG.debug("Version '%s' was available.", version)
+ LOG.debug("Selected version '%s' from %s", selected_version,
+ versions_available)
return selected_version
def _read_content_path(self, item):
@@ -193,7 +194,7 @@ class BaseReader(object):
path = self._path_join(self.base_path, "openstack", *path_pieces)
return self._path_read(path)
- def read_v2(self, version=None):
+ def read_v2(self):
"""Reads a version 2 formatted location.
Return a dict with metadata, userdata, ec2-metadata, dsmode,
@@ -224,12 +225,11 @@ class BaseReader(object):
)
return files
- version = self._find_working_version(version)
results = {
'userdata': '',
'version': 2,
}
- data = datafiles(version)
+ data = datafiles(self._find_working_version())
for (name, (path, required, translator)) in data.iteritems():
path = self._path_join(self.base_path, path)
data = None
@@ -433,7 +433,6 @@ class MetadataReader(BaseReader):
self._versions = found
return self._versions
-
def _path_read(self, path):
def should_retry_cb(_request_args, cause):