(redata, jdata, r_server, logger)
return True
Perform the ip removal
Perform the ip removal
Perform the ip removal
def remove(redata, jdata, r_server, logger):
    ''' Perform the ip removal '''
    usrdata = [
        ('z', redata['data']['domain']),
        ('tkn', redata['data']['apikey']),
        ('email', redata['data']['email'])]
    zone = redata['data']['domain']

    # Check the CloudFlare Zone
    falserecs, falsedata = cloudflail.checkZone(
        redata['data']['ip'], usrdata)
    numrecs = len(falserecs)
    if numrecs > 0:
        line = "cloudflare-ip-remove: %d records found to remove" % numrecs
        logger.debug(line)
        for rec in falserecs:
            result = cloudflail.delRecord(rec, usrdata)
            if result:
                # Log Removal to Redis for later checks
                key = 'domains:' + jdata['cid'] + ':' + zone + ':' + rec
                rdata = falsedata[rec]
                for item in rdata.keys():
                    r_server.set(key + ":" + item, rdata[item])
                r_server.sadd(
                    'domains:' + jdata['cid'] + ':' + zone + ':' + rdata["content"] + ':deleted', rec)
                # Log in jdata success
                line = "cloudflare-ip-remove: Removal of record %s successful" % rec
                logger.info(line)
            else:
                line = "cloudflare-ip-remove: Removal of record %s false" % rec
                logger.info(line)
    else:
        line = "cloudflare-ip-remove: IP %s not found in zone" % redata[
            'data']['ip']
        logger.debug(line)
    return True
def remove ( redata , jdata , r_server , logger ) : usrdata = [ ( 'z' , redata [ 'data' ] [ 'domain' ] ) , ( 'tkn' , redata [ 'data' ] [ 'apikey' ] ) , ( 'email' , redata [ 'data' ] [ 'email' ] ) ] zone = redata [ 'data' ] [ 'domain' ] # Check the CloudFlare Zone falserecs , falsedata = cloudflail . checkZone ( redata [ 'data' ] [ 'ip' ] , usrdata ) numrecs = len ( falserecs ) if numrecs > 0 : line = "cloudflare-ip-remove: %d records found to remove" % numrecs logger . debug ( line ) for rec in falserecs : result = cloudflail . delRecord ( rec , usrdata ) if result : # Log Removal to Redis for later checks key = 'domains:' + jdata [ 'cid' ] + ':' + zone + ':' + rec rdata = falsedata [ rec ] for item in rdata . keys ( ) : r_server . set ( key + ":" + item , rdata [ item ] ) r_server . sadd ( 'domains:' + jdata [ 'cid' ] + ':' + zone + ':' + rdata [ "content" ] + ':deleted' , rec ) # Log in jdata success line = "cloudflare-ip-remove: Removal of record %s successful" % rec logger . info ( line ) else : line = "cloudflare-ip-remove: Removal of record %s false" % rec logger . info ( line ) else : line = "cloudflare-ip-remove: IP %s not found in zone" % redata [ 'data' ] [ 'ip' ] logger . debug ( line ) return True