summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceGCE.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-04-03 11:52:06 -0400
committerScott Moser <smoser@brickies.net>2017-04-03 11:52:06 -0400
commit3b2e493b51153cd5bc1fa91e6ac52f59d41fe3fb (patch)
tree678b118605245e5bb1b218565728270702aba5b4 /cloudinit/sources/DataSourceGCE.py
parente018fa910fdf0dbf3aa22e59e935461babd205c4 (diff)
parent61eb03fef92f435434d974fb46439189ef0b5f97 (diff)
downloadvyos-cloud-init-3b2e493b51153cd5bc1fa91e6ac52f59d41fe3fb.tar.gz
vyos-cloud-init-3b2e493b51153cd5bc1fa91e6ac52f59d41fe3fb.zip
merge from master at 0.7.9-90-g61eb03fe
Diffstat (limited to 'cloudinit/sources/DataSourceGCE.py')
-rw-r--r--cloudinit/sources/DataSourceGCE.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py
index b1a1c8f2..637c9505 100644
--- a/cloudinit/sources/DataSourceGCE.py
+++ b/cloudinit/sources/DataSourceGCE.py
@@ -62,6 +62,9 @@ class DataSourceGCE(sources.DataSource):
return public_key
def get_data(self):
+ if not platform_reports_gce():
+ return False
+
# url_map: (our-key, path, required, is_text)
url_map = [
('instance-id', ('instance/id',), True, True),
@@ -144,6 +147,21 @@ class DataSourceGCE(sources.DataSource):
return self.availability_zone.rsplit('-', 1)[0]
+def platform_reports_gce():
+ pname = util.read_dmi_data('system-product-name') or "N/A"
+ if pname == "Google Compute Engine":
+ return True
+
+ # system-product-name is not always guaranteed (LP: #1674861)
+ serial = util.read_dmi_data('system-serial-number') or "N/A"
+ if serial.startswith("GoogleCloud-"):
+ return True
+
+ LOG.debug("Not running on google cloud. product-name=%s serial=%s",
+ pname, serial)
+ return False
+
+
# Used to match classes to dependencies
datasources = [
(DataSourceGCE, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),