Merge ~smoser/cloud-init:feature/e24cloud into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Chad Smith
Approved revision: d2ad0df133654f1eb6a23b5c9ae480b37e338a2b
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~smoser/cloud-init:feature/e24cloud
Merge into: cloud-init:master
Diff against target: 179 lines (+59/-4)
7 files modified
cloudinit/apport.py (+1/-0)
cloudinit/sources/DataSourceEc2.py (+11/-1)
doc/rtd/topics/datasources.rst (+2/-1)
doc/rtd/topics/datasources/e24cloud.rst (+9/-0)
tests/unittests/test_datasource/test_ec2.py (+14/-1)
tests/unittests/test_ds_identify.py (+17/-1)
tools/ds-identify (+5/-0)
Reviewer Review Type Date Requested Status
Ryan Harper Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+372948@code.launchpad.net

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/ .
Updated chassis typo in zstack unit test docstring.

LP: #1696476

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:d2ad0df133654f1eb6a23b5c9ae480b37e338a2b
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1164/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1164//rebuild

review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

This looks fine. There's an unrelated Zstack documentation typo fix. Either drop that, or update commit message to take.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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 = [
22 'CloudSigma',22 'CloudSigma',
23 'CloudStack',23 'CloudStack',
24 'DigitalOcean',24 'DigitalOcean',
25 'E24Cloud',
25 'GCE - Google Compute Engine',26 'GCE - Google Compute Engine',
26 'Exoscale',27 'Exoscale',
27 'Hetzner Cloud',28 '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):
34 AWS = "aws"34 AWS = "aws"
35 BRIGHTBOX = "brightbox"35 BRIGHTBOX = "brightbox"
36 ZSTACK = "zstack"36 ZSTACK = "zstack"
37 E24CLOUD = "e24cloud"
37 # UNKNOWN indicates no positive id. If strict_id is 'warn' or 'false',38 # UNKNOWN indicates no positive id. If strict_id is 'warn' or 'false',
38 # then an attempt at the Ec2 Metadata service will be made.39 # then an attempt at the Ec2 Metadata service will be made.
39 UNKNOWN = "unknown"40 UNKNOWN = "unknown"
@@ -483,11 +484,16 @@ def identify_zstack(data):
483 return CloudNames.ZSTACK484 return CloudNames.ZSTACK
484485
485486
487def identify_e24cloud(data):
488 if data['vendor'] == 'e24cloud':
489 return CloudNames.E24CLOUD
490
491
486def identify_platform():492def identify_platform():
487 # identify the platform and return an entry in CloudNames.493 # identify the platform and return an entry in CloudNames.
488 data = _collect_platform_data()494 data = _collect_platform_data()
489 checks = (identify_aws, identify_brightbox, identify_zstack,495 checks = (identify_aws, identify_brightbox, identify_zstack,
490 lambda x: CloudNames.UNKNOWN)496 identify_e24cloud, lambda x: CloudNames.UNKNOWN)
491 for checker in checks:497 for checker in checks:
492 try:498 try:
493 result = checker(data)499 result = checker(data)
@@ -506,6 +512,7 @@ def _collect_platform_data():
506 uuid_source: 'hypervisor' (/sys/hypervisor/uuid) or 'dmi'512 uuid_source: 'hypervisor' (/sys/hypervisor/uuid) or 'dmi'
507 serial: dmi 'system-serial-number' (/sys/.../product_serial)513 serial: dmi 'system-serial-number' (/sys/.../product_serial)
508 asset_tag: 'dmidecode -s chassis-asset-tag'514 asset_tag: 'dmidecode -s chassis-asset-tag'
515 vendor: dmi 'system-manufacturer' (/sys/.../sys_vendor)
509516
510 On Ec2 instances experimentation is that product_serial is upper case,517 On Ec2 instances experimentation is that product_serial is upper case,
511 and product_uuid is lower case. This returns lower case values for both.518 and product_uuid is lower case. This returns lower case values for both.
@@ -534,6 +541,9 @@ def _collect_platform_data():
534541
535 data['asset_tag'] = asset_tag.lower()542 data['asset_tag'] = asset_tag.lower()
536543
544 vendor = util.read_dmi_data('system-manufacturer')
545 data['vendor'] = (vendor if vendor else '').lower()
546
537 return data547 return data
538548
539549
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:
2929
30 datasources/aliyun.rst30 datasources/aliyun.rst
31 datasources/altcloud.rst31 datasources/altcloud.rst
32 datasources/ec2.rst
33 datasources/azure.rst32 datasources/azure.rst
33 datasources/ec2.rst
34 datasources/e24cloud.rst
34 datasources/cloudsigma.rst35 datasources/cloudsigma.rst
35 datasources/cloudstack.rst36 datasources/cloudstack.rst
36 datasources/configdrive.rst37 datasources/configdrive.rst
diff --git a/doc/rtd/topics/datasources/e24cloud.rst b/doc/rtd/topics/datasources/e24cloud.rst
37new file mode 10064438new file mode 100644
index 0000000..de9a412
--- /dev/null
+++ b/doc/rtd/topics/datasources/e24cloud.rst
@@ -0,0 +1,9 @@
1.. _datasource_e24cloud:
2
3E24Cloud
4========
5`E24Cloud <https://www.e24cloud.com/en/>` platform provides an AWS Ec2 metadata
6service clone. It identifies itself to guests using the dmi
7system-manufacturer (/sys/class/dmi/id/sys_vendor).
8
9.. vi: textwidth=78
diff --git a/tests/unittests/test_datasource/test_ec2.py b/tests/unittests/test_datasource/test_ec2.py
index 6fabf25..5e1dd77 100644
--- a/tests/unittests/test_datasource/test_ec2.py
+++ b/tests/unittests/test_datasource/test_ec2.py
@@ -672,13 +672,14 @@ class TesIdentifyPlatform(test_helpers.CiTestCase):
672 'serial': 'H23-C4J3JV-R6',672 'serial': 'H23-C4J3JV-R6',
673 'uuid': '81c7e555-6471-4833-9551-1ab366c4cfd2',673 'uuid': '81c7e555-6471-4833-9551-1ab366c4cfd2',
674 'uuid_source': 'dmi',674 'uuid_source': 'dmi',
675 'vendor': 'tothecloud',
675 }676 }
676 unspecial.update(**kwargs)677 unspecial.update(**kwargs)
677 return unspecial678 return unspecial
678679
679 @mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')680 @mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')
680 def test_identify_zstack(self, m_collect):681 def test_identify_zstack(self, m_collect):
681 """zstack should be identified if cassis-asset-tag ends in .zstack.io682 """zstack should be identified if chassis-asset-tag ends in .zstack.io
682 """683 """
683 m_collect.return_value = self.collmock(asset_tag='123456.zstack.io')684 m_collect.return_value = self.collmock(asset_tag='123456.zstack.io')
684 self.assertEqual(ec2.CloudNames.ZSTACK, ec2.identify_platform())685 self.assertEqual(ec2.CloudNames.ZSTACK, ec2.identify_platform())
@@ -690,4 +691,16 @@ class TesIdentifyPlatform(test_helpers.CiTestCase):
690 m_collect.return_value = self.collmock(asset_tag='123456.buzzstack.io')691 m_collect.return_value = self.collmock(asset_tag='123456.buzzstack.io')
691 self.assertEqual(ec2.CloudNames.UNKNOWN, ec2.identify_platform())692 self.assertEqual(ec2.CloudNames.UNKNOWN, ec2.identify_platform())
692693
694 @mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')
695 def test_identify_e24cloud(self, m_collect):
696 """e24cloud identified if vendor is e24cloud"""
697 m_collect.return_value = self.collmock(vendor='e24cloud')
698 self.assertEqual(ec2.CloudNames.E24CLOUD, ec2.identify_platform())
699
700 @mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')
701 def test_identify_e24cloud_negative(self, m_collect):
702 """e24cloud identified if vendor is e24cloud"""
703 m_collect.return_value = self.collmock(vendor='e24cloudyday')
704 self.assertEqual(ec2.CloudNames.UNKNOWN, ec2.identify_platform())
705
693# vi: ts=4 expandtab706# 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):
613 """EC2: chassis asset tag ends with 'zstack.io'"""613 """EC2: chassis asset tag ends with 'zstack.io'"""
614 self._test_ds_found('Ec2-ZStack')614 self._test_ds_found('Ec2-ZStack')
615615
616 def test_e24cloud_is_ec2(self):
617 """EC2: e24cloud identified by sys_vendor"""
618 self._test_ds_found('Ec2-E24Cloud')
619
620 def test_e24cloud_not_active(self):
621 """EC2: bobrightbox.com in product_serial is not brightbox'"""
622 self._test_ds_not_found('Ec2-E24Cloud-negative')
623
616624
617class TestIsIBMProvisioning(DsIdentifyBase):625class TestIsIBMProvisioning(DsIdentifyBase):
618 """Test the is_ibm_provisioning method in ds-identify."""626 """Test the is_ibm_provisioning method in ds-identify."""
@@ -979,7 +987,15 @@ VALID_CFG = {
979 'Ec2-ZStack': {987 'Ec2-ZStack': {
980 'ds': 'Ec2',988 'ds': 'Ec2',
981 'files': {P_CHASSIS_ASSET_TAG: '123456.zstack.io\n'},989 'files': {P_CHASSIS_ASSET_TAG: '123456.zstack.io\n'},
982 }990 },
991 'Ec2-E24Cloud': {
992 'ds': 'Ec2',
993 'files': {P_SYS_VENDOR: 'e24cloud\n'},
994 },
995 'Ec2-E24Cloud-negative': {
996 'ds': 'Ec2',
997 'files': {P_SYS_VENDOR: 'e24cloudyday\n'},
998 }
983}999}
9841000
985# vi: ts=4 expandtab1001# 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() {
900 *.zstack.io) _RET="ZStack"; return 0;;900 *.zstack.io) _RET="ZStack"; return 0;;
901 esac901 esac
902902
903 local vendor="${DI_DMI_SYS_VENDOR}"
904 case "$vendor" in
905 e24cloud) _RET="E24cloud"; return 0;;
906 esac
907
903 # AWS http://docs.aws.amazon.com/AWSEC2/908 # AWS http://docs.aws.amazon.com/AWSEC2/
904 # latest/UserGuide/identify_ec2_instances.html909 # latest/UserGuide/identify_ec2_instances.html
905 local uuid="" hvuuid="${PATH_SYS_HYPERVISOR}/uuid"910 local uuid="" hvuuid="${PATH_SYS_HYPERVISOR}/uuid"

Subscribers

People subscribed via source and target branches