Return data to a Cassandra ColumnFamily

def returner(ret):
    '''
    Return data to a Cassandra ColumnFamily
    '''

    consistency_level = getattr(pycassa.ConsistencyLevel,
                                __opts__['cassandra.consistency_level'])

    pool = pycassa.ConnectionPool(__opts__['cassandra.keyspace'],
                                  __opts__['cassandra.servers'])
    ccf = pycassa.ColumnFamily(pool, __opts__['cassandra.column_family'],
                               write_consistency_level=consistency_level)

    columns = {'fun': ret['fun'],
               'id': ret['id']}
    if isinstance(ret['return'], dict):
        for key, value in six.iteritems(ret['return']):
            columns['return.{0}'.format(key)] = six.text_type(value)
    else:
        columns['return'] = six.text_type(ret['return'])

    log.debug(columns)
    ccf.insert(ret['jid'], columns)