cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #06716
[Merge] ~smoser/cloud-init:feature/e24cloud into cloud-init:master
Scott Moser has proposed merging ~smoser/cloud-init:feature/e24cloud into cloud-init:master.
Commit message:
Add Support for e24cloud to Ec2 datasource.
e24cloud provides an EC2 compatible datasource.
This just identifies their platform based on dmi 'system-vendor'
having 'e24cloud'. https://www.e24cloud.com/en/ .
LP: #1696476
Requested reviews:
cloud-init Commiters (cloud-init-dev)
Related bugs:
Bug #1696476 in cloud-init: "Identification of e24cloud platform as using Ec2 datasource"
https://bugs.launchpad.net/cloud-init/+bug/1696476
For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/372948
see commit message
--
Your team cloud-init Commiters is requested to review the proposed merge of ~smoser/cloud-init:feature/e24cloud into cloud-init:master.
diff --git a/cloudinit/apport.py b/cloudinit/apport.py
index fde1f75..c6797f1 100644
--- a/cloudinit/apport.py
+++ b/cloudinit/apport.py
@@ -22,6 +22,7 @@ KNOWN_CLOUD_NAMES = [
'CloudSigma',
'CloudStack',
'DigitalOcean',
+ 'E24Cloud',
'GCE - Google Compute Engine',
'Exoscale',
'Hetzner Cloud',
diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
index 6c72ace..1d88c9b 100644
--- a/cloudinit/sources/DataSourceEc2.py
+++ b/cloudinit/sources/DataSourceEc2.py
@@ -34,6 +34,7 @@ class CloudNames(object):
AWS = "aws"
BRIGHTBOX = "brightbox"
ZSTACK = "zstack"
+ E24CLOUD = "e24cloud"
# 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"
@@ -483,11 +484,16 @@ def identify_zstack(data):
return CloudNames.ZSTACK
+def identify_e24cloud(data):
+ if data['vendor'] == 'e24cloud':
+ return CloudNames.E24CLOUD
+
+
def identify_platform():
# identify the platform and return an entry in CloudNames.
data = _collect_platform_data()
checks = (identify_aws, identify_brightbox, identify_zstack,
- lambda x: CloudNames.UNKNOWN)
+ identify_e24cloud, lambda x: CloudNames.UNKNOWN)
for checker in checks:
try:
result = checker(data)
@@ -506,6 +512,7 @@ def _collect_platform_data():
uuid_source: 'hypervisor' (/sys/hypervisor/uuid) or 'dmi'
serial: dmi 'system-serial-number' (/sys/.../product_serial)
asset_tag: 'dmidecode -s chassis-asset-tag'
+ vendor: dmi 'system-manufacturer' (/sys/.../sys_vendor)
On Ec2 instances experimentation is that product_serial is upper case,
and product_uuid is lower case. This returns lower case values for both.
@@ -534,6 +541,9 @@ def _collect_platform_data():
data['asset_tag'] = asset_tag.lower()
+ vendor = util.read_dmi_data('system-manufacturer')
+ data['vendor'] = (vendor if vendor else '').lower()
+
return data
diff --git a/doc/rtd/topics/datasources.rst b/doc/rtd/topics/datasources.rst
index a337c08..70fbe07 100644
--- a/doc/rtd/topics/datasources.rst
+++ b/doc/rtd/topics/datasources.rst
@@ -29,8 +29,9 @@ The following is a list of documents for each supported datasource:
datasources/aliyun.rst
datasources/altcloud.rst
- datasources/ec2.rst
datasources/azure.rst
+ datasources/ec2.rst
+ datasources/e24cloud.rst
datasources/cloudsigma.rst
datasources/cloudstack.rst
datasources/configdrive.rst
diff --git a/doc/rtd/topics/datasources/e24cloud.rst b/doc/rtd/topics/datasources/e24cloud.rst
new file mode 100644
index 0000000..de9a412
--- /dev/null
+++ b/doc/rtd/topics/datasources/e24cloud.rst
@@ -0,0 +1,9 @@
+.. _datasource_e24cloud:
+
+E24Cloud
+========
+`E24Cloud <https://www.e24cloud.com/en/>` platform provides an AWS Ec2 metadata
+service clone. It identifies itself to guests using the dmi
+system-manufacturer (/sys/class/dmi/id/sys_vendor).
+
+.. vi: textwidth=78
diff --git a/tests/unittests/test_datasource/test_ec2.py b/tests/unittests/test_datasource/test_ec2.py
index 6fabf25..e88d807 100644
--- a/tests/unittests/test_datasource/test_ec2.py
+++ b/tests/unittests/test_datasource/test_ec2.py
@@ -678,7 +678,7 @@ class TesIdentifyPlatform(test_helpers.CiTestCase):
@mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')
def test_identify_zstack(self, m_collect):
- """zstack should be identified if cassis-asset-tag ends in .zstack.io
+ """zstack should be identified if chassis-asset-tag ends in .zstack.io
"""
m_collect.return_value = self.collmock(asset_tag='123456.zstack.io')
self.assertEqual(ec2.CloudNames.ZSTACK, ec2.identify_platform())
@@ -690,4 +690,16 @@ class TesIdentifyPlatform(test_helpers.CiTestCase):
m_collect.return_value = self.collmock(asset_tag='123456.buzzstack.io')
self.assertEqual(ec2.CloudNames.UNKNOWN, ec2.identify_platform())
+ @mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')
+ def test_identify_e24cloud(self, m_collect):
+ """e24cloud identified if vendor is e24cloud"""
+ m_collect.return_value = self.collmock(vendor='e24cloud')
+ self.assertEqual(ec2.CloudNames.E24CLOUD, ec2.identify_platform())
+
+ @mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')
+ def test_identify_e24cloud_negative(self, m_collect):
+ """e24cloud identified if vendor is e24cloud"""
+ m_collect.return_value = self.collmock(vendor='e24cloudyday')
+ self.assertEqual(ec2.CloudNames.UNKNOWN, ec2.identify_platform())
+
# vi: ts=4 expandtab
diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
index 7aeeb91..4631dca 100644
--- a/tests/unittests/test_ds_identify.py
+++ b/tests/unittests/test_ds_identify.py
@@ -613,6 +613,14 @@ class TestDsIdentify(DsIdentifyBase):
"""EC2: chassis asset tag ends with 'zstack.io'"""
self._test_ds_found('Ec2-ZStack')
+ def test_e24cloud_is_ec2(self):
+ """EC2: e24cloud identified by sys_vendor"""
+ self._test_ds_found('Ec2-E24Cloud')
+
+ def test_e24cloud_not_active(self):
+ """EC2: bobrightbox.com in product_serial is not brightbox'"""
+ self._test_ds_not_found('Ec2-E24Cloud-negative')
+
class TestIsIBMProvisioning(DsIdentifyBase):
"""Test the is_ibm_provisioning method in ds-identify."""
@@ -979,7 +987,15 @@ VALID_CFG = {
'Ec2-ZStack': {
'ds': 'Ec2',
'files': {P_CHASSIS_ASSET_TAG: '123456.zstack.io\n'},
- }
+ },
+ 'Ec2-E24Cloud': {
+ 'ds': 'Ec2',
+ 'files': {P_SYS_VENDOR: 'e24cloud\n'},
+ },
+ 'Ec2-E24Cloud-negative': {
+ 'ds': 'Ec2',
+ 'files': {P_SYS_VENDOR: 'e24cloudyday\n'},
+ }
}
# vi: ts=4 expandtab
diff --git a/tools/ds-identify b/tools/ds-identify
index f76f2a6..c480a9d 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -900,6 +900,11 @@ ec2_identify_platform() {
*.zstack.io) _RET="ZStack"; return 0;;
esac
+ local vendor="${DI_DMI_SYS_VENDOR}"
+ case "$vendor" in
+ e24cloud) _RET="E24cloud"; return 0;;
+ esac
+
# AWS http://docs.aws.amazon.com/AWSEC2/
# latest/UserGuide/identify_ec2_instances.html
local uuid="" hvuuid="${PATH_SYS_HYPERVISOR}/uuid"
Follow ups