def test_match_node_metadata_to_vcenter_node_does_not_match(self): vsphere = VsphereVcenter(vcenter_host="fake_vcenter", vcenter_user="******", vcenter_password="******") self.m_vim_cluster.name = "Fake Cluster" cluster_metadata = proto_patch_encryption_support(CurieSettings.Cluster)() cluster_metadata.cluster_name = "Fake Cluster" cluster_metadata.cluster_hypervisor_info.esx_info.SetInParent() for index in range(3): # Add first 3 nodes by hostname curr_node = cluster_metadata.cluster_nodes.add() curr_node.id = "fake_host_%d" % index curr_node = cluster_metadata.cluster_nodes.add() curr_node.id = '10.60.5.222' # Add last node by ip vcenter_info = cluster_metadata.cluster_management_server_info.vcenter_info vcenter_info.vcenter_host = "fake_vmm_server_address" vcenter_info.vcenter_user = "******" vcenter_info.vcenter_password = "******" vcenter_info.vcenter_datacenter_name = "fake_datacenter" vcenter_info.vcenter_cluster_name = "fake_cluster" vcenter_info.vcenter_datastore_name = "fake_share_name" vcenter_info.vcenter_network_name = "fake_network" self.assertEqual(4, len(cluster_metadata.cluster_nodes)) with self.assertRaises(CurieTestException) as ar: vsphere.match_node_metadata_to_vcenter(self.m_vim_cluster, cluster_metadata) self.assertEqual(4, len(cluster_metadata.cluster_nodes)) self.assertEqual("Node with ID '10.60.5.222' is in the Curie cluster metadata, but not " "found in vSphere cluster 'Fake Cluster'.", str(ar.exception.cause))
def test_match_node_metadata_to_vcenter_multiple_node_matches(self): vsphere = VsphereVcenter(vcenter_host="fake_vcenter", vcenter_user="******", vcenter_password="******") self.m_vim_cluster.name = "Fake Cluster" cluster_metadata = proto_patch_encryption_support(CurieSettings.Cluster)() cluster_metadata.cluster_name = "Fake Cluster" cluster_metadata.cluster_hypervisor_info.esx_info.SetInParent() for index in range(3): # Add first 3 nodes by hostname curr_node = cluster_metadata.cluster_nodes.add() curr_node.id = "fake_host_%d" % index curr_node = cluster_metadata.cluster_nodes.add() curr_node.id = '10.60.5.61' # Add last node by ip self.m_vim_cluster.host[0].config.network.vnic[0].spec.ip.ipAddress = '10.60.5.61' # Add repeated address vcenter_info = cluster_metadata.cluster_management_server_info.vcenter_info vcenter_info.vcenter_host = "fake_vmm_server_address" vcenter_info.vcenter_user = "******" vcenter_info.vcenter_password = "******" vcenter_info.vcenter_datacenter_name = "fake_datacenter" vcenter_info.vcenter_cluster_name = "fake_cluster" vcenter_info.vcenter_datastore_name = "fake_share_name" vcenter_info.vcenter_network_name = "fake_network" self.assertEqual(4, len(cluster_metadata.cluster_nodes)) with self.assertRaises(CurieTestException) as ar: vsphere.match_node_metadata_to_vcenter(self.m_vim_cluster, cluster_metadata) self.assertEqual(4, len(cluster_metadata.cluster_nodes)) self.assertEqual("More than one node in the vSphere cluster " "'Fake Cluster' matches node ID '10.60.5.61'. The " "matching nodes are: fake_host_0, fake_host_1.", str(ar.exception.cause))
def test_match_node_metadata_to_vcenter_one_node_added_by_ip(self): vsphere = VsphereVcenter(vcenter_host="fake_vcenter", vcenter_user="******", vcenter_password="******") cluster_metadata = proto_patch_encryption_support(CurieSettings.Cluster)() cluster_metadata.cluster_name = "Fake Cluster" cluster_metadata.cluster_hypervisor_info.esx_info.SetInParent() for index in range(3): # Add first 3 nodes by hostname to curie metadata curr_node = cluster_metadata.cluster_nodes.add() curr_node.id = "fake_host_%d" % index curr_node = cluster_metadata.cluster_nodes.add() curr_node.id = '10.60.5.63' # Add last node by ip vcenter_info = cluster_metadata.cluster_management_server_info.vcenter_info vcenter_info.vcenter_host = "fake_vmm_server_address" vcenter_info.vcenter_user = "******" vcenter_info.vcenter_password = "******" vcenter_info.vcenter_datacenter_name = "fake_datacenter" vcenter_info.vcenter_cluster_name = "fake_cluster" vcenter_info.vcenter_datastore_name = "fake_share_name" vcenter_info.vcenter_network_name = "fake_network" self.assertEqual(4, len(cluster_metadata.cluster_nodes)) vsphere.match_node_metadata_to_vcenter(self.m_vim_cluster, cluster_metadata) self.assertEqual(4, len(cluster_metadata.cluster_nodes)) for index, cluster_node in enumerate(cluster_metadata.cluster_nodes): self.assertEqual("fake_host_%d" % index, cluster_node.id)