diff options
author | Markus Schade <markus.schade@hetzner.com> | 2020-10-30 19:12:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-30 14:12:25 -0400 |
commit | 0f8be879073148f1d67094df9ec895a873caa0d7 (patch) | |
tree | bba27990e18b65930471b3ac34c5aab3d27c6137 | |
parent | f72d0cb7a03cc311700ea8795edf2454172c7414 (diff) | |
download | vyos-cloud-init-0f8be879073148f1d67094df9ec895a873caa0d7.tar.gz vyos-cloud-init-0f8be879073148f1d67094df9ec895a873caa0d7.zip |
Hetzner: Fix instance_id / SMBIOS serial comparison (#640)
Fixes erroneous string/int comparison introduced in 1431c8a
metadata['instance-id'] is an integer but the value read from smbios is
a string. The comparision would cause TypeError.
-rw-r--r-- | cloudinit/sources/DataSourceHetzner.py | 2 | ||||
-rw-r--r-- | tests/unittests/test_datasource/test_hetzner.py | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/cloudinit/sources/DataSourceHetzner.py b/cloudinit/sources/DataSourceHetzner.py index 1d965bf7..8e4d4b69 100644 --- a/cloudinit/sources/DataSourceHetzner.py +++ b/cloudinit/sources/DataSourceHetzner.py @@ -82,7 +82,7 @@ class DataSourceHetzner(sources.DataSource): self.vendordata_raw = md.get("vendor_data", None) # instance-id and serial from SMBIOS should be identical - if self.metadata['instance-id'] != serial: + if self.get_instance_id() != serial: raise RuntimeError( "SMBIOS serial does not match instance ID from metadata" ) diff --git a/tests/unittests/test_datasource/test_hetzner.py b/tests/unittests/test_datasource/test_hetzner.py index fc3649a4..eadb92f1 100644 --- a/tests/unittests/test_datasource/test_hetzner.py +++ b/tests/unittests/test_datasource/test_hetzner.py @@ -80,7 +80,8 @@ class TestDataSourceHetzner(CiTestCase): @mock.patch('cloudinit.sources.DataSourceHetzner.get_hcloud_data') def test_read_data(self, m_get_hcloud_data, m_usermd, m_readmd, m_fallback_nic, m_net): - m_get_hcloud_data.return_value = (True, METADATA.get('instance-id')) + m_get_hcloud_data.return_value = (True, + str(METADATA.get('instance-id'))) m_readmd.return_value = METADATA.copy() m_usermd.return_value = USERDATA m_fallback_nic.return_value = 'eth0' |