Skip to content

Commit

Permalink
feat: Identify Samsung Cloud Platform as OpenStack (#5924)
Browse files Browse the repository at this point in the history
  • Loading branch information
us0310306 authored Dec 19, 2024
1 parent bc26e15 commit 1304fe9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions cloudinit/apport.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"OVF",
"RbxCloud - (HyperOne, Rootbox, Rubikon)",
"OpenTelekomCloud",
"Samsung Cloud Platform",
"SAP Converged Cloud",
"Scaleway",
"SmartOS",
Expand Down
2 changes: 2 additions & 0 deletions cloudinit/sources/DataSourceOpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
# -> compute.defaults.vmware.smbios_asset_tag for this value
DMI_ASSET_TAG_SAPCCLOUD = "SAP CCloud VM"
DMI_ASSET_TAG_HUAWEICLOUD = "HUAWEICLOUD"
DMI_ASSET_TAG_SAMSUNGCLOUDPLATFORM = "Samsung Cloud Platform"
VALID_DMI_ASSET_TAGS = VALID_DMI_PRODUCT_NAMES
VALID_DMI_ASSET_TAGS += [
DMI_ASSET_TAG_HUAWEICLOUD,
DMI_ASSET_TAG_OPENTELEKOM,
DMI_ASSET_TAG_SAMSUNGCLOUDPLATFORM,
DMI_ASSET_TAG_SAPCCLOUD,
]

Expand Down
4 changes: 2 additions & 2 deletions doc/rtd/reference/datasources/openstack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ checks the following environment attributes as a potential OpenStack platform:
``product_name=OpenStack Nova``.
* ``DMI product_name``: Either ``Openstack Nova`` or ``OpenStack Compute``.
* ``DMI chassis_asset_tag`` is ``HUAWEICLOUD``, ``OpenTelekomCloud``,
``SAP CCloud VM``, ``OpenStack Nova`` (since 19.2) or
``OpenStack Compute`` (since 19.2).
``SAP CCloud VM``, ``Samsung Cloud Platform``,
``OpenStack Nova`` (since 19.2) or ``OpenStack Compute`` (since 19.2).

Configuration
=============
Expand Down
21 changes: 21 additions & 0 deletions tests/unittests/sources/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,27 @@ def fake_asset_tag_dmi_read(dmi_key):
"Expected ds_detect == True on Huawei Cloud VM",
)

@test_helpers.mock.patch(MOCK_PATH + "dmi.read_dmi_data")
def test_ds_detect_samsung_cloud_platform_chassis_asset_tag(
self, m_dmi, m_is_x86
):
"""Return True on OpenStack reporting
Samsung Cloud Platform VM asset-tag."""
m_is_x86.return_value = True

def fake_asset_tag_dmi_read(dmi_key):
if dmi_key == "system-product-name":
return "c7.large.2" # No match
if dmi_key == "chassis-asset-tag":
return "Samsung Cloud Platform"
assert False, "Unexpected dmi read of %s" % dmi_key

m_dmi.side_effect = fake_asset_tag_dmi_read
self.assertTrue(
self._fake_ds().ds_detect(),
"Expected ds_detect == True on Samsung Cloud Platform VM",
)

@test_helpers.mock.patch(MOCK_PATH + "dmi.read_dmi_data")
def test_ds_detect_oraclecloud_chassis_asset_tag(self, m_dmi, m_is_x86):
"""Return True on OpenStack reporting Oracle cloud asset-tag."""
Expand Down
10 changes: 10 additions & 0 deletions tests/unittests/test_ds_identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,10 @@ def test_openstack_huawei_cloud(self):
"""Open Huawei Cloud identification."""
self._test_ds_found("OpenStack-HuaweiCloud")

def test_openstack_samsung_cloud_platform(self):
"""Open Samsung Cloud Platform identification."""
self._test_ds_found("OpenStack-SamsungCloudPlatform")

def test_openstack_asset_tag_nova(self):
"""OpenStack identification via asset tag OpenStack Nova."""
self._test_ds_found("OpenStack-AssetTag-Nova")
Expand Down Expand Up @@ -2120,6 +2124,12 @@ def _print_run_output(rc, out, err, cfg, files):
"files": {P_CHASSIS_ASSET_TAG: "HUAWEICLOUD\n"},
"mocks": [MOCK_VIRT_IS_KVM],
},
"OpenStack-SamsungCloudPlatform": {
# Samsung Cloud Platform hosts use OpenStack
"ds": "OpenStack",
"files": {P_CHASSIS_ASSET_TAG: "Samsung Cloud Platform\n"},
"mocks": [MOCK_VIRT_IS_KVM],
},
"OpenStack-AssetTag-Nova": {
# VMware vSphere can't modify product-name, LP: #1669875
"ds": "OpenStack",
Expand Down
1 change: 1 addition & 0 deletions tools/.github-cla-signers
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ tsanghan
tSU-RooT
tyb-truth
tylerschultz
us0310306
vorlonofportland
vteratipally
Vultaire
Expand Down
4 changes: 4 additions & 0 deletions tools/ds-identify
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,10 @@ dscheck_OpenStack() {
return ${DS_FOUND}
fi

if dmi_chassis_asset_tag_matches "Samsung Cloud Platform"; then
return ${DS_FOUND}
fi

# LP: #1669875 : allow identification of OpenStack by asset tag
if dmi_chassis_asset_tag_matches "$nova"; then
return ${DS_FOUND}
Expand Down

0 comments on commit 1304fe9

Please sign in to comment.