Return a dict of the last function called for all minions

def get_fun(fun):
    '''
    Return a dict of the last function called for all minions
    '''
    query = '''SELECT minion_id, last_fun FROM {keyspace}.minions
               WHERE last_fun = ?;'''.format(keyspace=_get_keyspace())

    ret = {}

    # cassandra_cql.cql_query may raise a CommandExecutionError
    try:
        data = __salt__['cassandra_cql.cql_query'](query, 'get_fun', [fun])
        if data:
            for row in data:
                minion = row.get('minion_id')
                last_fun = row.get('last_fun')
                if minion and last_fun:
                    ret[minion] = last_fun
    except CommandExecutionError:
        log.critical('Could not get the list of minions.')
        raise
    except Exception as e:
        log.critical(
            'Unexpected error while getting list of minions: %s', e)
        raise

    return ret