(redata, jdata, r_server, logger, replaceip=None)
return True
Perform the ip readd
Perform the ip readd
Perform the ip readd
def readd(redata, jdata, r_server, logger, replaceip=None):
    ''' Perform the ip readd '''

    usrdata = [
        ('z', redata['data']['domain']),
        ('tkn', redata['data']['apikey']),
        ('email', redata['data']['email'])]
    zone = redata['data']['domain']
    ip = redata['data']['ip']

    # Try and readd all removed zones
    readds = len(r_server.smembers(
        "domains:" + jdata['cid'] + ':' + zone + ":" + ip + ":deleted"))
    try:
        for item in range(0, readds + 1):
            deleted = r_server.spop(
                "domains:" + jdata['cid'] + ':' + zone + ":" + ip + ":deleted")
            add_data = []
            key = "domains:" + jdata['cid'] + ':' + zone + ":" + deleted + ":"
            ztype = r_server.get(key + "type")
            r_server.delete(key + "type")
            add_data.append(('type', ztype))

            ttl = r_server.get(key + "ttl")
            r_server.delete(key + "ttl")
            add_data.append(('ttl', ttl))

            name = r_server.get(key + "name")
            r_server.delete(key + "name")
            add_data.append(('name', name))

            if replaceip is None:
                content = r_server.get(key + "content")
                r_server.delete(key + "content")
            else:
                content = replaceip
                r_server.delete(key + "content")
            add_data.append(('content', content))

            service_mode = r_server.get(key + "service_mode")
            r_server.delete(key + "service_mode")
            add_data.append(('service_mode', service_mode))

            if ztype == "MX":
                prio = r_server.get(key + "prio")
                add_data.append(('prio', prio))
            r_server.delete(key + "prio")

            if service_mode == "1":
                result = cloudflail.addRecord(
                    add_data, usrdata, service_mode=True)
            else:
                result = cloudflail.addRecord(add_data, usrdata)
            if result:
                line = "cloudflare-ip-remove: Readding record %s to zone %s successful" % (name, zone)
                logger.info(line)
            else:
                line = "cloudflare-ip-remove: Readding record %s to zone %s false" % (name, zone)
                logger.info(line)
    except TypeError:
        line = "cloudflare-ip-remove: No records for ip %s in deleted queue for zone %s" % (ip, zone)
        logger.info(line)
    return True
def readd ( redata , jdata , r_server , logger , replaceip = None ) : usrdata = [ ( 'z' , redata [ 'data' ] [ 'domain' ] ) , ( 'tkn' , redata [ 'data' ] [ 'apikey' ] ) , ( 'email' , redata [ 'data' ] [ 'email' ] ) ] zone = redata [ 'data' ] [ 'domain' ] ip = redata [ 'data' ] [ 'ip' ] # Try and readd all removed zones readds = len ( r_server . smembers ( "domains:" + jdata [ 'cid' ] + ':' + zone + ":" + ip + ":deleted" ) ) try : for item in range ( 0 , readds + 1 ) : deleted = r_server . spop ( "domains:" + jdata [ 'cid' ] + ':' + zone + ":" + ip + ":deleted" ) add_data = [ ] key = "domains:" + jdata [ 'cid' ] + ':' + zone + ":" + deleted + ":" ztype = r_server . get ( key + "type" ) r_server . delete ( key + "type" ) add_data . append ( ( 'type' , ztype ) ) ttl = r_server . get ( key + "ttl" ) r_server . delete ( key + "ttl" ) add_data . append ( ( 'ttl' , ttl ) ) name = r_server . get ( key + "name" ) r_server . delete ( key + "name" ) add_data . append ( ( 'name' , name ) ) if replaceip is None : content = r_server . get ( key + "content" ) r_server . delete ( key + "content" ) else : content = replaceip r_server . delete ( key + "content" ) add_data . append ( ( 'content' , content ) ) service_mode = r_server . get ( key + "service_mode" ) r_server . delete ( key + "service_mode" ) add_data . append ( ( 'service_mode' , service_mode ) ) if ztype == "MX" : prio = r_server . get ( key + "prio" ) add_data . append ( ( 'prio' , prio ) ) r_server . delete ( key + "prio" ) if service_mode == "1" : result = cloudflail . addRecord ( add_data , usrdata , service_mode = True ) else : result = cloudflail . addRecord ( add_data , usrdata ) if result : line = "cloudflare-ip-remove: Readding record %s to zone %s successful" % ( name , zone ) logger . info ( line ) else : line = "cloudflare-ip-remove: Readding record %s to zone %s false" % ( name , zone ) logger . info ( line ) except TypeError : line = "cloudflare-ip-remove: No records for ip %s in deleted queue for zone %s" % ( ip , zone ) logger . info ( line ) return True