summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceEc2.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-07-31 14:46:00 -0400
committerScott Moser <smoser@brickies.net>2017-07-31 14:46:00 -0400
commit19c248d009af6a7cff26fbb2febf5c958987084d (patch)
tree521cc4c8cd303fd7a9eb56bc4eb5975c48996298 /cloudinit/sources/DataSourceEc2.py
parentf47c7ac027fc905ca7f6bee776007e2a922c117e (diff)
parente586fe35a692b7519000005c8024ebd2bcbc82e0 (diff)
downloadvyos-cloud-init-19c248d009af6a7cff26fbb2febf5c958987084d.tar.gz
vyos-cloud-init-19c248d009af6a7cff26fbb2febf5c958987084d.zip
merge from master at 0.7.9-233-ge586fe35
Diffstat (limited to 'cloudinit/sources/DataSourceEc2.py')
-rw-r--r--cloudinit/sources/DataSourceEc2.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
index 2f9c7edf..4ec9592f 100644
--- a/cloudinit/sources/DataSourceEc2.py
+++ b/cloudinit/sources/DataSourceEc2.py
@@ -32,7 +32,12 @@ class Platforms(object):
AWS = "AWS"
BRIGHTBOX = "Brightbox"
SEEDED = "Seeded"
+ # UNKNOWN indicates no positive id. If strict_id is 'warn' or 'false',
+ # then an attempt at the Ec2 Metadata service will be made.
UNKNOWN = "Unknown"
+ # NO_EC2_METADATA indicates this platform does not have a Ec2 metadata
+ # service available. No attempt at the Ec2 Metadata service will be made.
+ NO_EC2_METADATA = "No-EC2-Metadata"
class DataSourceEc2(sources.DataSource):
@@ -65,6 +70,8 @@ class DataSourceEc2(sources.DataSource):
strict_mode, self.cloud_platform)
if strict_mode == "true" and self.cloud_platform == Platforms.UNKNOWN:
return False
+ elif self.cloud_platform == Platforms.NO_EC2_METADATA:
+ return False
try:
if not self.wait_for_metadata_service():
@@ -309,10 +316,16 @@ def identify_platform():
def _collect_platform_data():
- # returns a dictionary with all lower case values:
- # uuid: system-uuid from dmi or /sys/hypervisor
- # uuid_source: 'hypervisor' (/sys/hypervisor/uuid) or 'dmi'
- # serial: dmi 'system-serial-number' (/sys/.../product_serial)
+ """Returns a dictionary of platform info from dmi or /sys/hypervisor.
+
+ Keys in the dictionary are as follows:
+ uuid: system-uuid from dmi or /sys/hypervisor
+ uuid_source: 'hypervisor' (/sys/hypervisor/uuid) or 'dmi'
+ serial: dmi 'system-serial-number' (/sys/.../product_serial)
+
+ On Ec2 instances experimentation is that product_serial is upper case,
+ and product_uuid is lower case. This returns lower case values for both.
+ """
data = {}
try:
uuid = util.load_file("/sys/hypervisor/uuid").strip()