diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-07-27 16:53:50 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-07-27 16:53:50 -0400 |
commit | 81a9f17a71f9cac4c78ea5ce80b4a96e3bbb9324 (patch) | |
tree | ed9b2fe43f65d2e8fc705020d7cdd4c6307b8988 /cloudinit/distros/__init__.py | |
parent | 22cb92421234c31b783ed9df01439c734535ba01 (diff) | |
parent | d68b340f8a6abf40f4d5cb546c91122c8856aa83 (diff) | |
download | vyos-cloud-init-81a9f17a71f9cac4c78ea5ce80b4a96e3bbb9324.tar.gz vyos-cloud-init-81a9f17a71f9cac4c78ea5ce80b4a96e3bbb9324.zip |
merge from trunk
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r-- | cloudinit/distros/__init__.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 8a947867..71884b32 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -117,12 +117,11 @@ class Distro(object): arch = self.get_primary_arch() return _get_arch_package_mirror_info(mirror_info, arch) - def get_package_mirror_info(self, arch=None, - availability_zone=None): + def get_package_mirror_info(self, arch=None, data_source=None): # This resolves the package_mirrors config option # down to a single dict of {mirror_name: mirror_url} arch_info = self._get_arch_package_mirror_info(arch) - return _get_package_mirror_info(availability_zone=availability_zone, + return _get_package_mirror_info(data_source=data_source, mirror_info=arch_info) def apply_network(self, settings, bring_up=True): @@ -556,7 +555,7 @@ class Distro(object): LOG.info("Added user '%s' to group '%s'" % (member, name)) -def _get_package_mirror_info(mirror_info, availability_zone=None, +def _get_package_mirror_info(mirror_info, data_source=None, mirror_filter=util.search_for_mirror): # given a arch specific 'mirror_info' entry (from package_mirrors) # search through the 'search' entries, and fallback appropriately @@ -572,11 +571,14 @@ def _get_package_mirror_info(mirror_info, availability_zone=None, ec2_az_re = ("^[a-z][a-z]-(%s)-[1-9][0-9]*[a-z]$" % directions_re) subst = {} - if availability_zone: - subst['availability_zone'] = availability_zone + if data_source and data_source.availability_zone: + subst['availability_zone'] = data_source.availability_zone - if availability_zone and re.match(ec2_az_re, availability_zone): - subst['ec2_region'] = "%s" % availability_zone[0:-1] + if re.match(ec2_az_re, data_source.availability_zone): + subst['ec2_region'] = "%s" % data_source.availability_zone[0:-1] + + if data_source and data_source.region: + subst['region'] = data_source.region results = {} for (name, mirror) in mirror_info.get('failsafe', {}).items(): |