Merge ~jingni.wjj/cloud-init:aliyun_dev into cloud-init:master

Proposed by Junjie.Wang on 2017-04-27
Status: Merged
Merged at revision: 4a60af54957634920e84a928aa22b4fc9a6dfd11
Proposed branch: ~jingni.wjj/cloud-init:aliyun_dev
Merge into: cloud-init:master
Diff against target: 52 lines (+9/-1)
3 files modified
cloudinit/settings.py (+1/-0)
cloudinit/sources/DataSourceAliYun.py (+7/-1)
tests/unittests/test_datasource/test_common.py (+1/-0)
Reviewer Review Type Date Requested Status
Scott Moser Needs Fixing on 2017-05-22
Server Team CI bot continuous-integration 2017-04-27 Approve on 2017-04-27
Junjie.Wang (community) Approve on 2017-04-27
Review via email: mp+323306@code.launchpad.net

This proposal supersedes a proposal from 2017-04-27.

Commit Message

AliYun: Enable platform identification and enable by default.

AliYun cloud platform is now identifying themselves by setting the dmi product id to the well known value "Alibaba Cloud ECS". The changes here identify that properly in tools/ds-identify and in the DataSourceAliYun.

Since the 'get_data' for AliYun now identifies itself correctly, we
can enable AliYun by default.

LP: #1638931

Description of the Change

AliYunDataSource support get platform from bios dmi
Eanble AliYunDataSource by default

To post a comment you must log in.
Junjie.Wang (jingni.wjj) : Posted in a previous version of this proposal
review: Approve
Junjie.Wang (jingni.wjj) :
review: Approve
Junjie.Wang (jingni.wjj) wrote :

hi smoser,
I have some change here, and they seem to work fine.
    cloud_platform: get platform from bios,in our cloud platform , an instance vm could use an asm instructions `cpuid` (with eax setted to 0x40000100 ), it will returned our platform id keyword "AliYun" into register ebx and ecx, and if vm is not running on our environment, the value is others. so cloud-init will not block a long time when call datesource's get_data() method if it's use network

Scott Moser (smoser) wrote :

Junjie,
This looks great.

You should also make a change to tools/ds-identify.

Then, thanks!

I'll look at this again on monday.

review: Needs Fixing
Scott Moser (smoser) wrote :

Junjie,
Thanks again. I've put some changes in at
 http://paste.ubuntu.com/24625947/
And updated the commit message here.

Please integrate those changes into this branch, test and then comment.

I'm really happy to see AliYun supported by default.

Scott

review: Needs Fixing
Scott Moser (smoser) wrote :

Junjie,
I've proposed a merge at
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/324625
that has your changes and then my suggested changes on top.

I'd appreciate your feedback there.

Junjie.Wang (jingni.wjj) wrote :

> Junjie,
> I've proposed a merge at
> https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/324625
> that has your changes and then my suggested changes on top.
>
> I'd appreciate your feedback there.

I am sorry for late reply,i review this code that is good ,and test it in our AliYun paltform ,it also work fine.thanks very much

Scott Moser (smoser) wrote :

I marked this merged based on the other branch being merged.
Thanks again, Junjie.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/settings.py b/cloudinit/settings.py
2index dbafead..5b85fea 100644
3--- a/cloudinit/settings.py
4+++ b/cloudinit/settings.py
5@@ -20,6 +20,7 @@ RUN_CLOUD_CONFIG = '/run/cloud-init/cloud.cfg'
6 CFG_BUILTIN = {
7 'datasource_list': [
8 'NoCloud',
9+ 'AliYun',
10 'ConfigDrive',
11 'OpenNebula',
12 'DigitalOcean',
13diff --git a/cloudinit/sources/DataSourceAliYun.py b/cloudinit/sources/DataSourceAliYun.py
14index 9debe94..86dfbf1 100644
15--- a/cloudinit/sources/DataSourceAliYun.py
16+++ b/cloudinit/sources/DataSourceAliYun.py
17@@ -4,8 +4,10 @@ import os
18
19 from cloudinit import sources
20 from cloudinit.sources import DataSourceEc2 as EC2
21+from cloudinit import util
22
23 DEF_MD_VERSION = "2016-01-01"
24+ALIYUN_PRODUCT = "Alibaba Cloud ECS"
25
26
27 class DataSourceAliYun(EC2.DataSourceEc2):
28@@ -24,7 +26,11 @@ class DataSourceAliYun(EC2.DataSourceEc2):
29
30 @property
31 def cloud_platform(self):
32- return EC2.Platforms.ALIYUN
33+ product = util.read_dmi_data('system-product-name')
34+ if product == ALIYUN_PRODUCT:
35+ self._cloud_platform = EC2.Platforms.ALIYUN
36+
37+ return self._cloud_platform
38
39
40 def parse_public_keys(public_keys):
41diff --git a/tests/unittests/test_datasource/test_common.py b/tests/unittests/test_datasource/test_common.py
42index c08717f..7649b9a 100644
43--- a/tests/unittests/test_datasource/test_common.py
44+++ b/tests/unittests/test_datasource/test_common.py
45@@ -36,6 +36,7 @@ DEFAULT_LOCAL = [
46 ]
47
48 DEFAULT_NETWORK = [
49+ AliYun.DataSourceAliYun,
50 AltCloud.DataSourceAltCloud,
51 Azure.DataSourceAzureNet,
52 Bigstep.DataSourceBigstep,

Subscribers

People subscribed via source and target branches