def get_all_by_host(cls, context, host, use_slave=False): try: db_computes = db.compute_node_get_all_by_host(context, host, use_slave) 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, use_slave) 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) # We can avoid an extra call to Service object in _from_db_object for db_compute in db_computes: db_compute["host"] = service.host return base.obj_make_list(context, cls(context), objects.ComputeNode, db_computes)
def get_all_by_host(cls, context, host, use_slave=False): try: db_computes = db.compute_node_get_all_by_host(context, host, use_slave) 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, use_slave) 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 # NOTE(sbauza): Yeah, the old model sucks, because there can only # be one node per host... db_computes = [db_compute] return base.obj_make_list(context, cls(context), objects.ComputeNode, db_computes)
def get_all_by_host(cls, context, host, use_slave=False): try: db_computes = db.compute_node_get_all_by_host( context, host, use_slave) 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, use_slave) 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) # We can avoid an extra call to Service object in _from_db_object for db_compute in db_computes: db_compute['host'] = service.host return base.obj_make_list(context, cls(context), objects.ComputeNode, db_computes)
def _db_compute_node_get_all_by_host(context, host, use_slave=False): return db.compute_node_get_all_by_host(context, host)
def get_all_by_host(cls, context, host, use_slave=False): db_computes = db.compute_node_get_all_by_host(context, host, use_slave) return base.obj_make_list(context, cls(context), objects.ComputeNode, db_computes)