Example #1
0
def fetch_application_lbs(s3: botocore.client.BaseClient, bucket_name: str,
                          application: str) -> List[Tuple[str, str]]:
    try:
        response = s3.get_object(Bucket=bucket_name, Key=application)
    except botocore.exceptions.ClientError:
        print("Failed to fetch", application, "from S3")
        raise

    lines = [l.split(" ") for l in sorted(response["Body"].read().split("\n"))]

    return [(lb[0], lb[1]) for lb in lines]
def fetch_current_lb_config(s3: botocore.client.BaseClient, bucket_name: str,
                            application: Application) -> str:
    try:
        response = s3.get_object(Bucket=bucket_name, Key=application)
    except botocore.exceptions.ClientError:
        print("Failed to fetch currently registered upstreams for",
              application)
        raise

    lines = [l.split(" ") for l in sorted(response["Body"].read().split("\n"))]
    return [(lb[0], lb[1]) for lb in lines]