diff options
author | Adrian Vladu <avladu@cloudbasesolutions.com> | 2020-10-15 22:39:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-15 15:39:09 -0400 |
commit | d76d6e6749315634efe0494501270740e8fef206 (patch) | |
tree | b70eef9adf2b414556154f1d2ec5c104a337944a /tests | |
parent | 3b05b1a6c58dfc7533a16f795405bda0e53aa9d8 (diff) | |
download | vyos-cloud-init-d76d6e6749315634efe0494501270740e8fef206.tar.gz vyos-cloud-init-d76d6e6749315634efe0494501270740e8fef206.zip |
openstack: consider product_name as valid chassis tag (#580)
Consider valid product names as valid chassis asset tags when detecting
OpenStack platform before crawling for OpenStack metadata.
As `ds-identify` tool uses product name as valid chassis asset tags,
let's replicate the behaviour in the OpenStack platform detection too.
This change should be backwards compatible and a temporary fix for the
current limitations on the OpenStack platform detection.
LP: #1895976
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_datasource/test_openstack.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_openstack.py b/tests/unittests/test_datasource/test_openstack.py index 3cfba74d..9b0c1b8a 100644 --- a/tests/unittests/test_datasource/test_openstack.py +++ b/tests/unittests/test_datasource/test_openstack.py @@ -548,6 +548,36 @@ class TestDetectOpenStack(test_helpers.CiTestCase): ds.detect_openstack(accept_oracle=False), 'Expected detect_openstack == False.') + def _test_detect_openstack_nova_compute_chassis_asset_tag(self, m_dmi, + m_is_x86, + chassis_tag): + """Return True on OpenStack reporting generic asset-tag.""" + m_is_x86.return_value = True + + def fake_dmi_read(dmi_key): + if dmi_key == 'system-product-name': + return 'Generic OpenStack Platform' + if dmi_key == 'chassis-asset-tag': + return chassis_tag + assert False, 'Unexpected dmi read of %s' % dmi_key + + m_dmi.side_effect = fake_dmi_read + self.assertTrue( + ds.detect_openstack(), + 'Expected detect_openstack == True on Generic OpenStack Platform') + + @test_helpers.mock.patch(MOCK_PATH + 'util.read_dmi_data') + def test_detect_openstack_nova_chassis_asset_tag(self, m_dmi, + m_is_x86): + self._test_detect_openstack_nova_compute_chassis_asset_tag( + m_dmi, m_is_x86, 'OpenStack Nova') + + @test_helpers.mock.patch(MOCK_PATH + 'util.read_dmi_data') + def test_detect_openstack_compute_chassis_asset_tag(self, m_dmi, + m_is_x86): + self._test_detect_openstack_nova_compute_chassis_asset_tag( + m_dmi, m_is_x86, 'OpenStack Compute') + @test_helpers.mock.patch(MOCK_PATH + 'util.get_proc_env') @test_helpers.mock.patch(MOCK_PATH + 'util.read_dmi_data') def test_detect_openstack_by_proc_1_environ(self, m_dmi, m_proc_env, |