def list_deployment_ext_network(deployment_id, project):
    logger.debug("List external network.")
    deployment = get_openstack_deployment(deployment_id)
    os_username = "******"
    os_password = deployment["admin_password"]
    os_auth_url = "http://%s:5000/v2.0" % deployment["controller_ip"]

    neutron = neutron_client.Client(username=os_username, password=os_password, tenant_name=project, auth_url=os_auth_url)
    nets = neutron.list_networks()

    ext_nets = []
    for all_network in nets["networks"]:
        if all_network["status"] == "ACTIVE" and all_network["router:external"]:
            ext_nets.append(all_network)

    return json.dumps(ext_nets)
def __do_deploy(os_deployment_id, cf_domain, project, deployment_id, nfs_server_network, is_neutron, public_net_id,ftp_host):
    os_deployment = get_openstack_deployment(os_deployment_id)
    uaa_urls = "\"uaa.%s\", \"\login.%s\"" % (cf_domain, cf_domain)
    ccdb_type = "pgsql"
    ntp_server = os_deployment["ntp_server"][0]
    monitor_ip = os_deployment["monitor_server_ip"]
    orchestrator_ip = CONF.get("ProcessController","endpoint").split(":")[0]
    dns_nameservers = os_deployment["tor_dns"]
    heat_auth_url = "http://%s:5000/v2.0" % os_deployment["controller_ip"]
    openstack_username = "******"
    openstack_password = os_deployment["admin_password"]
    is_neutron_str = str(is_neutron)
    mco_client_ip = CONF.get("MCO","MCO_Client_IP")
    mco_client_username = CONF.get("MCO","MCO_Client_Username")
    mco_client_password = CONF.get("MCO","MCO_Client_Password")
    
    headers = {'content-type': 'application/json'}
    parameter_data = {}
    parameter_data["cf_domain"] = cf_domain
    parameter_data["deployment_id"] = deployment_id
    parameter_data["uaa_urls"] = uaa_urls
    parameter_data["ccdb_type"] = ccdb_type
    parameter_data["ntp_server"] = ntp_server
    parameter_data["monitor_ip"] = monitor_ip
    parameter_data["orchestrator_ip"] = orchestrator_ip
    parameter_data["nfs_server_network"] = nfs_server_network
    parameter_data["dns_nameservers"] = dns_nameservers
    parameter_data["heat_auth_url"] = heat_auth_url
    parameter_data["openstack_username"] = openstack_username
    parameter_data["openstack_password"] = openstack_password
    parameter_data["neutron"] = is_neutron_str
    parameter_data["mco_client_ip"] = mco_client_ip
    parameter_data["mco_client_username"] = mco_client_username
    parameter_data["mco_client_password"] = mco_client_password
    parameter_data["public_net_id"] = public_net_id
    parameter_data["ftp_host"] = ftp_host

    data = {}
    data["parameters"] = parameter_data
    data["timeout_mins"] = time_out_to_install_cloudfoundry

    process_controller("/contrib/CFV2InstallProcess/create_cf_cluster/%s/%s" % (project, deployment_id), "post", pay_load=json.dumps(data), headers=headers)
def list_deployment_projects(deployment_id):
    logger.debug("List all Projects: %s" % deployment_id)
    deployment = get_openstack_deployment(deployment_id)

    os_username = "******"
    os_password = deployment["admin_password"]
    os_auth_url = "http://%s:5000/v2.0" % deployment["controller_ip"]

    keystone = keystone_client.Client(username=os_username, password=os_password, auth_url=os_auth_url)

    project_list = []
    for one_project_obj in keystone.tenants.list():
        one_project = {}
        one_project["id"] = one_project_obj.id
        one_project["name"] = one_project_obj.name
        one_project["description"] = one_project_obj.description
        one_project["enabled"] = one_project_obj.enabled
        project_list.append(one_project)

    return json.dumps(project_list)
def get_openstack_deployment_api(deployment_id):
    return json.dumps(get_openstack_deployment(deployment_id))