def _get_next_hop(self): """Return the cell name for the next hop. If the next hop is the current cell, return None. """ if self.target_cell == self.routing_path: return self.state_manager.my_cell_state target_cell = self.target_cell routing_path = self.routing_path current_hops = routing_path.count(_PATH_CELL_SEP) next_hop_num = current_hops + 1 dest_hops = target_cell.count(_PATH_CELL_SEP) if dest_hops < current_hops: reason = _("destination is %(target_cell)s but routing_path " "is %(routing_path)s") % locals() raise exception.CellRoutingInconsistency(reason=reason) dest_name_parts = target_cell.split(_PATH_CELL_SEP) if (_PATH_CELL_SEP.join(dest_name_parts[:next_hop_num]) != routing_path): reason = _("destination is %(target_cell)s but routing_path " "is %(routing_path)s") % locals() raise exception.CellRoutingInconsistency(reason=reason) next_hop_name = dest_name_parts[next_hop_num] if self.direction == 'up': next_hop = self.state_manager.get_parent_cell(next_hop_name) else: next_hop = self.state_manager.get_child_cell(next_hop_name) if not next_hop: cell_type = 'parent' if self.direction == 'up' else 'child' reason = _("Unknown %(cell_type)s when routing to " "%(target_cell)s") % locals() raise exception.CellRoutingInconsistency(reason=reason) return next_hop
def test_compute_node_get_not_found(self): cell_compute_uuid = cells_utils.cell_with_item('cell1', uuids.cn_uuid) with mock.patch.object(self.host_api.cells_rpcapi, 'compute_node_get', side_effect=exception.CellRoutingInconsistency( reason='because_cells_v1')): self.assertRaises(exception.ComputeHostNotFound, self.host_api.compute_node_get, self.ctxt, cell_compute_uuid)