'Return capacities for a given cell or all cells.'

@extensions.expected_errors((404, 501))
@common.check_cells_enabled
def capacities(self, req, id=None):

    context = req.environ['nova.context']
    context.can(cells_policies.BASE_POLICY_NAME)
    try:
        capacities = self.cells_rpcapi.get_capacities(context, cell_name=id)
    except exception.CellNotFound as e:
        raise exc.HTTPNotFound(explanation=e.format_message())
    return dict(cell={'capacities': capacities})
