summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorShixin Ruan <matboy_80@aliyun.com>2019-09-18 13:15:25 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-09-18 13:15:25 +0000
commit571f7c36e89f67f4c2d1cacfd8f9269bf864d560 (patch)
treeca88604c5f74aef35455e250dc781a4c1fc62f5b /cloudinit
parent4df0065998961ad21a9b733fb23ae2ebd78b7380 (diff)
downloadvyos-cloud-init-571f7c36e89f67f4c2d1cacfd8f9269bf864d560.tar.gz
vyos-cloud-init-571f7c36e89f67f4c2d1cacfd8f9269bf864d560.zip
Add datasource for ZStack platform.
Zstack platform provides a AWS Ec2 metadata service, and identifies their platform to the guest by setting the 'chassis asset tag' to a string that ends with '.zstack.io'. LP: #1841181
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/apport.py1
-rw-r--r--cloudinit/sources/DataSourceEc2.py16
2 files changed, 16 insertions, 1 deletions
diff --git a/cloudinit/apport.py b/cloudinit/apport.py
index 003ff1ff..fde1f75b 100644
--- a/cloudinit/apport.py
+++ b/cloudinit/apport.py
@@ -37,6 +37,7 @@ KNOWN_CLOUD_NAMES = [
'Scaleway',
'SmartOS',
'VMware',
+ 'ZStack',
'Other']
# Potentially clear text collected logs
diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
index 10107456..6c72ace2 100644
--- a/cloudinit/sources/DataSourceEc2.py
+++ b/cloudinit/sources/DataSourceEc2.py
@@ -33,6 +33,7 @@ class CloudNames(object):
ALIYUN = "aliyun"
AWS = "aws"
BRIGHTBOX = "brightbox"
+ ZSTACK = "zstack"
# 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"
@@ -477,10 +478,16 @@ def identify_brightbox(data):
return CloudNames.BRIGHTBOX
+def identify_zstack(data):
+ if data['asset_tag'].endswith('.zstack.io'):
+ return CloudNames.ZSTACK
+
+
def identify_platform():
# identify the platform and return an entry in CloudNames.
data = _collect_platform_data()
- checks = (identify_aws, identify_brightbox, lambda x: CloudNames.UNKNOWN)
+ checks = (identify_aws, identify_brightbox, identify_zstack,
+ lambda x: CloudNames.UNKNOWN)
for checker in checks:
try:
result = checker(data)
@@ -498,6 +505,7 @@ def _collect_platform_data():
uuid: system-uuid from dmi or /sys/hypervisor
uuid_source: 'hypervisor' (/sys/hypervisor/uuid) or 'dmi'
serial: dmi 'system-serial-number' (/sys/.../product_serial)
+ asset_tag: 'dmidecode -s chassis-asset-tag'
On Ec2 instances experimentation is that product_serial is upper case,
and product_uuid is lower case. This returns lower case values for both.
@@ -520,6 +528,12 @@ def _collect_platform_data():
data['serial'] = serial.lower()
+ asset_tag = util.read_dmi_data('chassis-asset-tag')
+ if asset_tag is None:
+ asset_tag = ''
+
+ data['asset_tag'] = asset_tag.lower()
+
return data