Skip to content

Commit 3cee0bf

Browse files
blackboxswServer Team CI Bot
authored andcommitted
oracle: fix detect_openstack to report True on OracleCloud.com DMI data
The OpenStack datasource in 18.3 changed to detect data in the init-local stage instead of init-network and attempted to redetect OpenStackLocal datasource on Oracle across reboots. The function detect_openstack was added to quickly detect whether a platform is OpenStack based on dmi product_name or chassis_asset_tag and it was a bit too strict for Oracle in checking for 'OpenStack Nova'/'Compute' DMI product_name. Oracle's DMI product_name reports 'SAtandard PC (i440FX + PIIX, 1996)' and DMI chassis_asset_tag is 'OracleCloud.com'. detect_openstack function now adds 'OracleCloud.com' as a supported value 'OracleCloud.com' to valid chassis-asset-tags for the OpenStack datasource. LP: #1784685
1 parent 361ae34 commit 3cee0bf

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

cloudinit/sources/DataSourceOpenStack.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
DMI_PRODUCT_COMPUTE = 'OpenStack Compute'
2929
VALID_DMI_PRODUCT_NAMES = [DMI_PRODUCT_NOVA, DMI_PRODUCT_COMPUTE]
3030
DMI_ASSET_TAG_OPENTELEKOM = 'OpenTelekomCloud'
31-
VALID_DMI_ASSET_TAGS = [DMI_ASSET_TAG_OPENTELEKOM]
31+
DMI_ASSET_TAG_ORACLE_CLOUD = 'OracleCloud.com'
32+
VALID_DMI_ASSET_TAGS = [DMI_ASSET_TAG_OPENTELEKOM, DMI_ASSET_TAG_ORACLE_CLOUD]
3233

3334

3435
class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):

tests/unittests/test_datasource/test_openstack.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,24 @@ def fake_dmi_read(dmi_key):
510510
ds.detect_openstack(),
511511
'Expected detect_openstack == True on OpenTelekomCloud')
512512

513+
@test_helpers.mock.patch(MOCK_PATH + 'util.read_dmi_data')
514+
def test_detect_openstack_oraclecloud_chassis_asset_tag(self, m_dmi,
515+
m_is_x86):
516+
"""Return True on OpenStack reporting Oracle cloud asset-tag."""
517+
m_is_x86.return_value = True
518+
519+
def fake_dmi_read(dmi_key):
520+
if dmi_key == 'system-product-name':
521+
return 'Standard PC (i440FX + PIIX, 1996)' # No match
522+
if dmi_key == 'chassis-asset-tag':
523+
return 'OracleCloud.com'
524+
assert False, 'Unexpected dmi read of %s' % dmi_key
525+
526+
m_dmi.side_effect = fake_dmi_read
527+
self.assertTrue(
528+
ds.detect_openstack(),
529+
'Expected detect_openstack == True on OracleCloud.com')
530+
513531
@test_helpers.mock.patch(MOCK_PATH + 'util.get_proc_env')
514532
@test_helpers.mock.patch(MOCK_PATH + 'util.read_dmi_data')
515533
def test_detect_openstack_by_proc_1_environ(self, m_dmi, m_proc_env,

0 commit comments

Comments
 (0)