(redata, jdata, logger, r_server)
This method reverts the heavy lifting
This method reverts the heavy lifting
This method reverts the heavy lifting
def revert_reaction(redata, jdata, logger, r_server):
    ''' This method reverts the heavy lifting '''
    readded = 0
    result = r_server.smembers("cloudflare-dns-failover:%s:%s" %
                               (jdata['cid'], redata['id']))
    if len(result) < 1:
        logger.debug("cloudflare-dns-failover: no removed records found")
        return None
    zoneid = cloudflare.get_zoneid(redata['data']['email'],
                                   redata['data']['apikey'],
                                   redata['data']['domain'],
                                   logger)
    if zoneid is None:
        logger.debug("cloudflare-dns-failover: could not pull zoneid")
        return False

    for item in result:
        logger.debug("cloudflare-dns-failover: Working on Redis item " + item)
        redis_data = json.loads(item)
        redis_data.pop("id", None)
        readd = cloudflare.add_rec(redata['data']['email'],
                                   redata['data']['apikey'],
                                   zoneid,
                                   logger,
                                   redis_data)
        if readd:
            result = r_server.srem("cloudflare-dns-failover:%s:%s" %
                                   (jdata['cid'], redata['id']), item)
            logger.debug("cloudflare-dns-failover: Re-added record %s" % item)
            readded = readded + 1
        else:
            logger.debug("cloudflare-dns-failover: Could not re-add record %s" % item)
    if readded > 0:
        return True
    else:
        return None
def revert_reaction ( redata , jdata , logger , r_server ) : readded = 0 result = r_server . smembers ( "cloudflare-dns-failover:%s:%s" % ( jdata [ 'cid' ] , redata [ 'id' ] ) ) if len ( result ) < 1 : logger . debug ( "cloudflare-dns-failover: no removed records found" ) return None zoneid = cloudflare . get_zoneid ( redata [ 'data' ] [ 'email' ] , redata [ 'data' ] [ 'apikey' ] , redata [ 'data' ] [ 'domain' ] , logger ) if zoneid is None : logger . debug ( "cloudflare-dns-failover: could not pull zoneid" ) return False for item in result : logger . debug ( "cloudflare-dns-failover: Working on Redis item " + item ) redis_data = json . loads ( item ) redis_data . pop ( "id" , None ) readd = cloudflare . add_rec ( redata [ 'data' ] [ 'email' ] , redata [ 'data' ] [ 'apikey' ] , zoneid , logger , redis_data ) if readd : result = r_server . srem ( "cloudflare-dns-failover:%s:%s" % ( jdata [ 'cid' ] , redata [ 'id' ] ) , item ) logger . debug ( "cloudflare-dns-failover: Re-added record %s" % item ) readded = readded + 1 else : logger . debug ( "cloudflare-dns-failover: Could not re-add record %s" % item ) if readded > 0 : return True else : return None