Exemple #1
0
 def test_get_host_info(self):
     host_info = DataSourceVMware.get_host_info()
     self.assertTrue(host_info)
     self.assertTrue(host_info["hostname"])
     self.assertTrue(host_info["local-hostname"])
     self.assertTrue(host_info["local_hostname"])
     self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4])
Exemple #2
0
 def test_get_subplatform(self, m_fn):
     m_fn.side_effect = [VMW_METADATA_YAML, "", "", "", "", ""]
     ds = self.assert_get_data_ok(m_fn, m_fn_call_count=4)
     self.assertEqual(
         ds.subplatform,
         "%s (%s)" % (
             DataSourceVMware.DATA_ACCESS_METHOD_GUESTINFO,
             DataSourceVMware.get_guestinfo_key_name("metadata"),
         ),
     )
Exemple #3
0
 def test_get_host_info_ipv4(self, m_fn_ipaddr):
     m_fn_ipaddr.return_value = ("10.10.10.1", None)
     host_info = DataSourceVMware.get_host_info()
     self.assertTrue(host_info)
     self.assertTrue(host_info["hostname"])
     self.assertTrue(host_info["hostname"] == "host.cloudinit.test")
     self.assertTrue(host_info["local-hostname"])
     self.assertTrue(host_info["local_hostname"])
     self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4])
     self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4] == "10.10.10.1")
     self.assertFalse(host_info.get(DataSourceVMware.LOCAL_IPV6))
Exemple #4
0
 def test_get_host_info_ipv6(self, m_fn_ipaddr):
     m_fn_ipaddr.return_value = (None, "2001:db8::::::8888")
     host_info = DataSourceVMware.get_host_info()
     self.assertTrue(host_info)
     self.assertTrue(host_info["hostname"])
     self.assertTrue(host_info["hostname"] == "host.cloudinit.test")
     self.assertTrue(host_info["local-hostname"])
     self.assertTrue(host_info["local_hostname"])
     self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV6])
     self.assertTrue(
         host_info[DataSourceVMware.LOCAL_IPV6] == "2001:db8::::::8888")
     self.assertFalse(host_info.get(DataSourceVMware.LOCAL_IPV4))
Exemple #5
0
 def test_get_host_info_dual(self, m_fn_ipaddr):
     m_fn_ipaddr.return_value = ("10.10.10.1", "2001:db8::::::8888")
     host_info = DataSourceVMware.get_host_info()
     self.assertTrue(host_info)
     self.assertTrue(host_info["hostname"])
     self.assertTrue(host_info["hostname"] == "host.cloudinit.test")
     self.assertTrue(host_info["local-hostname"])
     self.assertTrue(host_info["local_hostname"])
     self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4])
     self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4] == "10.10.10.1")
     self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV6])
     self.assertTrue(
         host_info[DataSourceVMware.LOCAL_IPV6] == "2001:db8::::::8888")
Exemple #6
0
def get_ds(temp_dir):
    ds = DataSourceVMware.DataSourceVMware(
        settings.CFG_BUILTIN, None, helpers.Paths({"run_dir": temp_dir})
    )
    ds.vmware_rpctool = "vmware-rpctool"
    return ds
Exemple #7
0
 def test_metadata_multiple_ssh_keys(self, m_fn):
     metadata = DataSourceVMware.load_json_or_yaml(VMW_METADATA_YAML)
     metadata["public_keys"] = VMW_MULTIPLE_KEYS
     metadata_yaml = safeyaml.dumps(metadata)
     m_fn.side_effect = [metadata_yaml, "", "", ""]
     self.assert_metadata(metadata, m_fn, m_fn_call_count=4)