def verify_django_maintenance_announcement(
    rds_deployer, node, retries_remaining=3,
):
    """
    Ensure that the maintenance announcement exists and remove it.
    """
    rds_instance = node.boto_instance
    conf = rds_deployer.deployment.deployment_confs[
        'rds'
    ][rds_deployer.node_name]['conf']

    # First need to authorize this ip to connect to the DB
    security_group = rds_instance.security_group
    ip = rds_deployer.get_ip()
    cidr = "%s/32" % ip
    try:
        security_group.authorize(cidr_ip=cidr)
    except BotoServerError:
        # Authorization might already exist
        logger.warning("BotoServerError attempting to authorize IP")

    # Using multiprocess to avoid Django database-switching madness
    import pstat.settings as settings
    process_kwargs = {
        'settings': settings,
        'rds_instance': rds_instance,
        'master_password': conf['rds_master_password'],
    }
    verify_announcement_p = Process(
        target=_verify_django_maintenance_announcement,
        kwargs=process_kwargs,
    )
    verify_announcement_p.start()
    verify_announcement_p.join()

    if verify_announcement_p.exitcode != 0:
        if retries_remaining > 0:
            logger.warning("Error verifying announcement")
            logger.warning("%s retries remaining", retries_remaining)
            return rds_deployer.verify_seed_data(
                node, retries_remaining=retries_remaining - 1)
        else:
            logger.critical("Error verifying announcement")
            logger.critical("All retries exhausted. Failing.")
            exit(1)

    # Now remove the authorization for this ip
    try:
        security_group.revoke(cidr_ip=cidr)
    except BotoServerError:
        # If this goes quickly, authorization might be in the authoring
        # state
        pass
dataset/ETHPy150Open winhamwr/neckbeard/neckbeard/cloud_provisioners/aws/contrib_hooks.py/verify_django_maintenance_announcement/original