def get_cloud_foundry_configuration()

in application-workloads/bosh/bosh-cf-crossregion/scripts/setup_env.py [0:0]


def get_cloud_foundry_configuration(scenario, settings):
    config = {}
    for key in ["SUBNET_ADDRESS_RANGE_FOR_CLOUD_FOUNDRY", "VNET_NAME", "VNET_NAME_SECONDARY", "SUBNET_NAME_FOR_CLOUD_FOUNDRY", "CLOUD_FOUNDRY_PUBLIC_IP", "NSG_NAME_FOR_CLOUD_FOUNDRY"]:
        config[key] = settings[key]

    with open('cloudfoundry.cert', 'r') as tmpfile:
        ssl_cert = tmpfile.read()
    with open('cloudfoundry.key', 'r') as tmpfile:
        ssl_key = tmpfile.read()
    ssl_cert_and_key = "{0}{1}".format(ssl_cert, ssl_key)
    indentation = " " * 8
    ssl_cert_and_key = ("\n"+indentation).join([line for line in ssl_cert_and_key.split('\n')])
    config["SSL_CERT_AND_KEY"] = ssl_cert_and_key

    ip = netaddr.IPNetwork(settings['SUBNET_ADDRESS_RANGE_FOR_CLOUD_FOUNDRY'])
    config["GATEWAY_IP"] = str(ip[1])
    config["RESERVED_IP_FROM"] = str(ip[2])
    config["RESERVED_IP_TO"] = str(ip[3])
    config["CLOUD_FOUNDRY_INTERNAL_IP"] = str(ip[4])
    # config["SYSTEM_DOMAIN"] = "{0}.xip.io".format(settings["CLOUD_FOUNDRY_PUBLIC_IP"])

    # Get and replace SYSTEM_DOMAIN from parameter json, e.g custom domain that is mapped to Traffic Manager
    config["SYSTEM_DOMAIN"] = settings["CUSTOM_SYSTEM_DOMAIN"]
    # Get and replace for REPLACE_WITH_EXTERNAL_DATABASE_ENDPOINT from parameter json, e.g dxmariadblb.northeurope.cloudapp.azure.com 
    config["EXTERNAL_DATABASE_ENDPOINT"] = settings["EXTERNAL_DATABASE_ENDPOINT"]
    # Get and replace REPLACE_WITH_EXTERNAL_NFS_ENDPOINT with external NFS cluster from parameter json
    config["EXTERNAL_NFS_ENDPOINT"] = settings["EXTERNAL_NFS_ENDPOINT"]
    # Get and replace REPLACE_WITH_STORAGE_ACCOUNT_NAME_SECONDARY
    config["STORAGE_ACCOUNT_NAME_SECONDARY"] = settings["STORAGE_ACCOUNT_NAME_SECONDARY"]
    # Get and replace REPLACE_WITH_CLOUD_FOUNDRY_PUBLIC_IP_SECONDARY
    config["CLOUD_FOUNDRY_PUBLIC_IP_SECONDARY"] = settings["CLOUD_FOUNDRY_PUBLIC_IP_SECONDARY"]
    # Get and replace parameters related to storage account
    
    config["STORAGE_ACCOUNT_NAME_PRIMARY"] = settings["STORAGE_ACCOUNT_NAME_PRIMARY"]
    config["STORAGE_ACCOUNT_NAME_SECONDARY"] = settings["STORAGE_ACCOUNT_NAME_SECONDARY"]


    config["STATIC_IP_FROM"] = str(ip[4])
    config["STATIC_IP_TO"] = str(ip[100])
    config["HAPROXY_IP"] = str(ip[4])
    config["POSTGRES_IP"] = str(ip[11])
    config["ROUTER_IP"] = str(ip[12])
    config["NATS_IP"] = str(ip[13])
    config["ETCD_IP"] = str(ip[14])
    config["NFS_IP"] = str(ip[15])
    config["CONSUL_IP"] = str(ip[16])

    return config