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
1diff --git a/cloudinit/apport.py b/cloudinit/apport.py
2index fde1f75..c6797f1 100644
3--- a/cloudinit/apport.py
4+++ b/cloudinit/apport.py
5@@ -22,6 +22,7 @@ KNOWN_CLOUD_NAMES = [
6 'CloudSigma',
7 'CloudStack',
8 'DigitalOcean',
9+ 'E24Cloud',
10 'GCE - Google Compute Engine',
11 'Exoscale',
12 'Hetzner Cloud',
13diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
14index 6c72ace..1d88c9b 100644
15--- a/cloudinit/sources/DataSourceEc2.py
16+++ b/cloudinit/sources/DataSourceEc2.py
17@@ -34,6 +34,7 @@ class CloudNames(object):
18 AWS = "aws"
19 BRIGHTBOX = "brightbox"
20 ZSTACK = "zstack"
21+ E24CLOUD = "e24cloud"
22 # UNKNOWN indicates no positive id. If strict_id is 'warn' or 'false',
23 # then an attempt at the Ec2 Metadata service will be made.
24 UNKNOWN = "unknown"
25@@ -483,11 +484,16 @@ def identify_zstack(data):
26 return CloudNames.ZSTACK
27
28
29+def identify_e24cloud(data):
30+ if data['vendor'] == 'e24cloud':
31+ return CloudNames.E24CLOUD
32+
33+
34 def identify_platform():
35 # identify the platform and return an entry in CloudNames.
36 data = _collect_platform_data()
37 checks = (identify_aws, identify_brightbox, identify_zstack,
38- lambda x: CloudNames.UNKNOWN)
39+ identify_e24cloud, lambda x: CloudNames.UNKNOWN)
40 for checker in checks:
41 try:
42 result = checker(data)
43@@ -506,6 +512,7 @@ def _collect_platform_data():
44 uuid_source: 'hypervisor' (/sys/hypervisor/uuid) or 'dmi'
45 serial: dmi 'system-serial-number' (/sys/.../product_serial)
46 asset_tag: 'dmidecode -s chassis-asset-tag'
47+ vendor: dmi 'system-manufacturer' (/sys/.../sys_vendor)
48
49 On Ec2 instances experimentation is that product_serial is upper case,
50 and product_uuid is lower case. This returns lower case values for both.
51@@ -534,6 +541,9 @@ def _collect_platform_data():
52
53 data['asset_tag'] = asset_tag.lower()
54
55+ vendor = util.read_dmi_data('system-manufacturer')
56+ data['vendor'] = (vendor if vendor else '').lower()
57+
58 return data
59
60
61diff --git a/doc/rtd/topics/datasources.rst b/doc/rtd/topics/datasources.rst
62index a337c08..70fbe07 100644
63--- a/doc/rtd/topics/datasources.rst
64+++ b/doc/rtd/topics/datasources.rst
65@@ -29,8 +29,9 @@ The following is a list of documents for each supported datasource:
66
67 datasources/aliyun.rst
68 datasources/altcloud.rst
69- datasources/ec2.rst
70 datasources/azure.rst
71+ datasources/ec2.rst
72+ datasources/e24cloud.rst
73 datasources/cloudsigma.rst
74 datasources/cloudstack.rst
75 datasources/configdrive.rst
76diff --git a/doc/rtd/topics/datasources/e24cloud.rst b/doc/rtd/topics/datasources/e24cloud.rst
77new file mode 100644
78index 0000000..de9a412
79--- /dev/null
80+++ b/doc/rtd/topics/datasources/e24cloud.rst
81@@ -0,0 +1,9 @@
82+.. _datasource_e24cloud:
83+
84+E24Cloud
85+========
86+`E24Cloud <https://www.e24cloud.com/en/>` platform provides an AWS Ec2 metadata
87+service clone. It identifies itself to guests using the dmi
88+system-manufacturer (/sys/class/dmi/id/sys_vendor).
89+
90+.. vi: textwidth=78
91diff --git a/tests/unittests/test_datasource/test_ec2.py b/tests/unittests/test_datasource/test_ec2.py
92index 6fabf25..5e1dd77 100644
93--- a/tests/unittests/test_datasource/test_ec2.py
94+++ b/tests/unittests/test_datasource/test_ec2.py
95@@ -672,13 +672,14 @@ class TesIdentifyPlatform(test_helpers.CiTestCase):
96 'serial': 'H23-C4J3JV-R6',
97 'uuid': '81c7e555-6471-4833-9551-1ab366c4cfd2',
98 'uuid_source': 'dmi',
99+ 'vendor': 'tothecloud',
100 }
101 unspecial.update(**kwargs)
102 return unspecial
103
104 @mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')
105 def test_identify_zstack(self, m_collect):
106- """zstack should be identified if cassis-asset-tag ends in .zstack.io
107+ """zstack should be identified if chassis-asset-tag ends in .zstack.io
108 """
109 m_collect.return_value = self.collmock(asset_tag='123456.zstack.io')
110 self.assertEqual(ec2.CloudNames.ZSTACK, ec2.identify_platform())
111@@ -690,4 +691,16 @@ class TesIdentifyPlatform(test_helpers.CiTestCase):
112 m_collect.return_value = self.collmock(asset_tag='123456.buzzstack.io')
113 self.assertEqual(ec2.CloudNames.UNKNOWN, ec2.identify_platform())
114
115+ @mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')
116+ def test_identify_e24cloud(self, m_collect):
117+ """e24cloud identified if vendor is e24cloud"""
118+ m_collect.return_value = self.collmock(vendor='e24cloud')
119+ self.assertEqual(ec2.CloudNames.E24CLOUD, ec2.identify_platform())
120+
121+ @mock.patch('cloudinit.sources.DataSourceEc2._collect_platform_data')
122+ def test_identify_e24cloud_negative(self, m_collect):
123+ """e24cloud identified if vendor is e24cloud"""
124+ m_collect.return_value = self.collmock(vendor='e24cloudyday')
125+ self.assertEqual(ec2.CloudNames.UNKNOWN, ec2.identify_platform())
126+
127 # vi: ts=4 expandtab
128diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
129index 7aeeb91..4631dca 100644
130--- a/tests/unittests/test_ds_identify.py
131+++ b/tests/unittests/test_ds_identify.py
132@@ -613,6 +613,14 @@ class TestDsIdentify(DsIdentifyBase):
133 """EC2: chassis asset tag ends with 'zstack.io'"""
134 self._test_ds_found('Ec2-ZStack')
135
136+ def test_e24cloud_is_ec2(self):
137+ """EC2: e24cloud identified by sys_vendor"""
138+ self._test_ds_found('Ec2-E24Cloud')
139+
140+ def test_e24cloud_not_active(self):
141+ """EC2: bobrightbox.com in product_serial is not brightbox'"""
142+ self._test_ds_not_found('Ec2-E24Cloud-negative')
143+
144
145 class TestIsIBMProvisioning(DsIdentifyBase):
146 """Test the is_ibm_provisioning method in ds-identify."""
147@@ -979,7 +987,15 @@ VALID_CFG = {
148 'Ec2-ZStack': {
149 'ds': 'Ec2',
150 'files': {P_CHASSIS_ASSET_TAG: '123456.zstack.io\n'},
151- }
152+ },
153+ 'Ec2-E24Cloud': {
154+ 'ds': 'Ec2',
155+ 'files': {P_SYS_VENDOR: 'e24cloud\n'},
156+ },
157+ 'Ec2-E24Cloud-negative': {
158+ 'ds': 'Ec2',
159+ 'files': {P_SYS_VENDOR: 'e24cloudyday\n'},
160+ }
161 }
162
163 # vi: ts=4 expandtab
164diff --git a/tools/ds-identify b/tools/ds-identify
165index f76f2a6..c480a9d 100755
166--- a/tools/ds-identify
167+++ b/tools/ds-identify
168@@ -900,6 +900,11 @@ ec2_identify_platform() {
169 *.zstack.io) _RET="ZStack"; return 0;;
170 esac
171
172+ local vendor="${DI_DMI_SYS_VENDOR}"
173+ case "$vendor" in
174+ e24cloud) _RET="E24cloud"; return 0;;
175+ esac
176+
177 # AWS http://docs.aws.amazon.com/AWSEC2/
178 # latest/UserGuide/identify_ec2_instances.html
179 local uuid="" hvuuid="${PATH_SYS_HYPERVISOR}/uuid"

Subscribers

People subscribed via source and target branches