Pivotal Cloud Foundry (PCF) 2.0
This article explains how you can find out the 'org' and 'space' a specific route belongs to.
While operating the PCF environments, it may be helpful to be able to quickly identify the org and space a specific route belongs to if there are many orgs and spaces in the foundation. The article will provide a quick way to identify them.
cf login' to log in to each PCF foundation and '
cf t -o system -s system'
cf check-route <HOSTNAME> <DOMAIN>' to check if the specific route exists in the PCF foundation. The HOSTNAME and DOMAIN can be retrieved from the specific route and they are separated from each other by the first period ("dot"). For example,
ROUTE: spring-music-busy-buffalo.cfapps.pivotal.io HOSTNAME: spring-music-busy-buffalo DOMAIN: cfapps.pivotal.io
COMMAND: cf check-route spring-music-busy-buffalo cfapps.pivotal.io
3. Save the shell script below as a file 'route_org_space.sh' and then run it with 'bash route_org_space.sh'. The small script will prompt you to input the HOSTNAME and then show you the org & space the specific route belongs to.
#!/bin/bash # prompt users to input the host name of a specific route
echo "Hello, what's the host name you are looking for?"
echo # get corresponding space info and store it into one temproray file
cf curl `cf curl /v2/routes | grep -w $HOSTNAME -A 10 | grep '"space_url"' | cut -d'"' -f 4` > /tmp/space_info.out # display the org name
echo "The org is: "
cf curl `grep '"organization_url"' /tmp/space_info.out | cut -d'"' -f 4` | jq .entity.name # display the space name
echo "The space is: "
cat /tmp/space_info.out | jq .entity.name # clear the temporary file
rm -rf /tmp/space_info.out