summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceGCE.py
diff options
context:
space:
mode:
authorDaniel Watkins <daniel.watkins@canonical.com>2015-07-22 13:06:34 +0100
committerDaniel Watkins <daniel.watkins@canonical.com>2015-07-22 13:06:34 +0100
commitbc7d57a0ae827978c87919c833bb5e8d2d5143c6 (patch)
tree4a3e97d4f0760f00682b9e84888c4b3f001c3777 /cloudinit/sources/DataSourceGCE.py
parent73c5bbfa31b922a0ba403216c0fc1f63b22a9262 (diff)
downloadvyos-cloud-init-bc7d57a0ae827978c87919c833bb5e8d2d5143c6.tar.gz
vyos-cloud-init-bc7d57a0ae827978c87919c833bb5e8d2d5143c6.zip
Add DataSource.region and use it in mirror selection.
Also implement DataSource.region for EC2 and GCE data sources.
Diffstat (limited to 'cloudinit/sources/DataSourceGCE.py')
-rw-r--r--cloudinit/sources/DataSourceGCE.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py
index 1b28a68c..7e7fc033 100644
--- a/cloudinit/sources/DataSourceGCE.py
+++ b/cloudinit/sources/DataSourceGCE.py
@@ -152,6 +152,10 @@ class DataSourceGCE(sources.DataSource):
def availability_zone(self):
return self.metadata['availability-zone']
+ @property
+ def region(self):
+ return self.availability_zone.rsplit('-', 1)[0]
+
# Used to match classes to dependencies
datasources = [
(DataSourceGCE, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),