def get_by_host_and_nodename(cls, context, host, nodename): try: db_compute = db.compute_node_get_by_host_and_nodename(context, host, nodename) except exception.ComputeHostNotFound: # FIXME(sbauza): Some old computes can still have no host record # We need to provide compatibility by using the old service_id # record. # We assume the compatibility as an extra penalty of one more DB # call but that's necessary until all nodes are upgraded. try: service = objects.Service.get_by_compute_host(context, host) db_computes = db.compute_nodes_get_by_service_id(context, service.id) except exception.ServiceNotFound: # We need to provide the same exception upstream raise exception.ComputeHostNotFound(host=host) db_compute = None for compute in db_computes: if compute["hypervisor_hostname"] == nodename: db_compute = compute # We can avoid an extra call to Service object in # _from_db_object db_compute["host"] = service.host break if not db_compute: raise exception.ComputeHostNotFound(host=host) return cls._from_db_object(context, cls(), db_compute)
def get_by_host_and_nodename(cls, context, host, nodename): try: db_compute = db.compute_node_get_by_host_and_nodename( context, host, nodename) except exception.ComputeHostNotFound: # FIXME(sbauza): Some old computes can still have no host record # We need to provide compatibility by using the old service_id # record. # We assume the compatibility as an extra penalty of one more DB # call but that's necessary until all nodes are upgraded. try: service = objects.Service.get_by_compute_host(context, host) db_computes = db.compute_nodes_get_by_service_id( context, service.id) except exception.ServiceNotFound: # We need to provide the same exception upstream raise exception.ComputeHostNotFound(host=host) db_compute = None for compute in db_computes: if compute['hypervisor_hostname'] == nodename: db_compute = compute # We can avoid an extra call to Service object in # _from_db_object db_compute['host'] = service.host break if not db_compute: raise exception.ComputeHostNotFound(host=host) return cls._from_db_object(context, cls(), db_compute)
def get_by_host_and_nodename(cls, context, host, nodename): try: db_compute = db.compute_node_get_by_host_and_nodename( context, host, nodename) except exception.ComputeHostNotFound: # FIXME(sbauza): Some old computes can still have no host record # We need to provide compatibility by using the old service_id # record. # We assume the compatibility as an extra penalty of one more DB # call but that's necessary until all nodes are upgraded. service = objects.Service.get_by_compute_host(context, host) # NOTE(sbauza): Here, the old model is buggy because there can only # be one compute node per service_id db_compute = db.compute_node_get_by_service_id(context, service.id) # We can avoid an extra call to Service object in _from_db_object db_compute['host'] = service.host return cls._from_db_object(context, cls(), db_compute)
def get_by_host_and_nodename(cls, context, host, nodename): db_compute = db.compute_node_get_by_host_and_nodename( context, host, nodename) return cls._from_db_object(context, cls(), db_compute)
def get_by_host_and_nodename(cls, context, host, nodename): db_compute = db.compute_node_get_by_host_and_nodename( context, host, nodename) return cls._from_db_object(context, cls(), db_compute)