Optimize hypervisor API calls
The nova CDM builder code and notification handling code had some inefficiencies when it came to looking up a hypevisor to get details. The general pattern used before was: 1. get the minimal hypervisor information by hypervisor_hostname 2. make another query to get the hypervisor details by id In the notifications case, it was actually three calls because the first is listing hyprvisors to filter client-side by service host. This change collapses 1 and 2 above into a single API call to get the hypervisor by hypervisor_hostname with details which will include the service (compute) host information which is what get_compute_node_by_id() was being used for. Now that nothing is using get_compute_node_by_id it is removed. There is more work we could do in get_compute_node_by_hostname if the compute API allowed filtering hypervisors by service host so a TODO is left for that. One final thing: the TODO in get_compute_node_by_hostname about there being more than one hypervisor per compute service host for vmware vcenter is not accurate - nova's vcenter driver hasn't supported a host:node 1:M topology like that since the Liberty release [1]. The only in-tree driver in nova that supports 1:M is the ironic baremetal driver, so the comment is updated. [1] Ifc17c5049e3ed29c8dd130339207907b00433960 Depends-On: https://review.opendev.org/661785/ Change-Id: I5e0e88d7b2dd1a69117ab03e0e66851c687606da
This commit is contained in:
@@ -258,19 +258,15 @@ class ModelBuilder(object):
|
||||
[node.hypervisor_hostname for node in all_nodes])
|
||||
LOG.debug("compute nodes: %s", compute_nodes)
|
||||
for node_name in compute_nodes:
|
||||
# TODO(mriedem): Change this to list hypervisors with details
|
||||
# so we don't have to call get_compute_node_by_id. It requires
|
||||
# changes to python-novaclient.
|
||||
cnode = self.nova_helper.get_compute_node_by_name(node_name,
|
||||
servers=True)
|
||||
servers=True,
|
||||
detailed=True)
|
||||
if cnode:
|
||||
# Get the node details (like the service.host).
|
||||
node_info = self.nova_helper.get_compute_node_by_id(
|
||||
cnode[0].id)
|
||||
node_info = cnode[0]
|
||||
self.add_compute_node(node_info)
|
||||
# node.servers is a list of server objects
|
||||
# New in nova version 2.53
|
||||
instances = getattr(cnode[0], "servers", None)
|
||||
instances = getattr(node_info, "servers", None)
|
||||
self.add_instance_node(node_info, instances)
|
||||
|
||||
def add_compute_node(self, node):
|
||||
|
||||
Reference in New Issue
Block a user