コード例 #1
0
def test_read_nodes_by_host_names(vnc_api_client, vnc_lib):
    node_1 = vnc_api.Node(name="esxi-1")
    node_2 = vnc_api.Node(name="esxi-2")
    node_3 = vnc_api.Node(name="esxi-3")
    vnc_lib.nodes_list.return_value = {
        "nodes": [
            {"uuid": "node-1-uuid"},
            {"uuid": "node-2-uuid"},
            {"uuid": "node-3-uuid"},
            {"uuid": "node-4-uuid"},
        ]
    }
    vnc_lib.node_read.side_effect = [
        node_1,
        node_2,
        node_3,
        vnc_api.NoIdError("node-4-uuid"),
    ]

    result = vnc_api_client.get_nodes_by_host_names(["esxi-1", "esxi-2"])

    assert len(result) == 2
    assert node_1 in result
    assert node_2 in result
コード例 #2
0
    def _make_fake_topology(cls):
        for node_name in cls.TOPOLOGY:
            node = vnc_api.Node(node_name, node_hostname=node_name)
            node_uuid = cls._vnc_api.node_create(node)
            cls._cleanup_topology_queue.append(('node', node_uuid))

            for port_name, port_pi in cls.TOPOLOGY[node_name].items():
                ll_obj = vnc_api.LocalLinkConnection(switch_info=port_pi[0],
                                                     port_id=port_pi[1])
                bm_info = vnc_api.BaremetalPortInfo(
                    address='00-00-00-00-00-00', local_link_connection=ll_obj)
                node_port = vnc_api.Port(port_name,
                                         node,
                                         bms_port_info=bm_info)
                port_uuid = cls._vnc_api.port_create(node_port)
                cls._cleanup_topology_queue.append(('port', port_uuid))
コード例 #3
0
def node():
    return vnc_api.Node("esxi-1")
コード例 #4
0
 def create_node(self, node_name, node_ip):
     esxi_host_info = vnc_api.ESXIHostInfo(esxi_name=node_ip)
     node = vnc_api.Node(name=node_name, esxi_info=esxi_host_info)
     node_uuid = self.vnc_lib.node_create(node)
     return self.read_node(node_uuid)