diff options
author | Junjie Wang <jingni.wjj@alibaba-inc.com> | 2017-04-21 20:06:09 +0800 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-05-30 16:35:51 -0400 |
commit | 4a60af54957634920e84a928aa22b4fc9a6dfd11 (patch) | |
tree | 1aa31a796ae8b0f5f718b1be9ac79fec523b3023 /cloudinit/sources/DataSourceAliYun.py | |
parent | 16a7302f6acb69adb0aee75eaf12392fa3688853 (diff) | |
download | vyos-cloud-init-4a60af54957634920e84a928aa22b4fc9a6dfd11.tar.gz vyos-cloud-init-4a60af54957634920e84a928aa22b4fc9a6dfd11.zip |
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
Diffstat (limited to 'cloudinit/sources/DataSourceAliYun.py')
-rw-r--r-- | cloudinit/sources/DataSourceAliYun.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/cloudinit/sources/DataSourceAliYun.py b/cloudinit/sources/DataSourceAliYun.py index 9debe947..380e27cb 100644 --- a/cloudinit/sources/DataSourceAliYun.py +++ b/cloudinit/sources/DataSourceAliYun.py @@ -4,8 +4,10 @@ import os from cloudinit import sources from cloudinit.sources import DataSourceEc2 as EC2 +from cloudinit import util DEF_MD_VERSION = "2016-01-01" +ALIYUN_PRODUCT = "Alibaba Cloud ECS" class DataSourceAliYun(EC2.DataSourceEc2): @@ -24,7 +26,17 @@ class DataSourceAliYun(EC2.DataSourceEc2): @property def cloud_platform(self): - return EC2.Platforms.ALIYUN + if self._cloud_platform is None: + if _is_aliyun(): + self._cloud_platform = EC2.Platforms.ALIYUN + else: + self._cloud_platform = EC2.Platforms.NO_EC2_METADATA + + return self._cloud_platform + + +def _is_aliyun(): + return util.read_dmi_data('system-product-name') == ALIYUN_PRODUCT def parse_public_keys(public_keys): |