Java: How to find out user, org, application


CF_genn <CF_subscription@...>
 

Hi CF-DEV,
I have a Java app deployed and running. Is it possible to find out from the
application
- in what org / space it is running?
- can it find out its own name? (as shown in "cf apps")

Thank you!





--
View this message in context: http://cf-dev.70369.x6.nabble.com/Java-How-to-find-out-user-org-application-tp6729.html
Sent from the CF Dev mailing list archive at Nabble.com.


Eitan Suez <esuez@...>
 

the space name and space id should be available in/via the VCAP_APPLICATION
environment variable. / eitan

On Tue, Apr 11, 2017 at 5:46 AM, CF_genn <CF_subscription(a)streber24.de>
wrote:

Hi CF-DEV,
I have a Java app deployed and running. Is it possible to find out from the
application
- in what org / space it is running?
- can it find out its own name? (as shown in "cf apps")

Thank you!





--
View this message in context: http://cf-dev.70369.x6.nabble.
com/Java-How-to-find-out-user-org-application-tp6729.html
Sent from the CF Dev mailing list archive at Nabble.com.


David Farrell
 

Hi,

To find *Org name* you could use something like

*cf curl /v2/apps/`cf app spring-music --guid`/summary | jq -r
".space_guid" | xargs -I '<guid>' cf curl '/v2/spaces/<guid>' | jq -r
".entity.organization_url" | xargs -I '<org_url>' cf curl '<org_url>' | jq
-r '.entity.name <http://entity.name>' | xargs -I '<org_name>' echo Org
Name : '<org_name>' *

To find *Space name* you could use something like

*cf curl /v2/apps/`cf app spring-music --guid`/summary | jq -r
".space_guid" | xargs -I '<guid>' cf curl '/v2/spaces/<guid>' | jq -r
".entity.name <http://entity.name>" | xargs -I '<space_name>' echo Space
name : '<space_name>' *

Replace *spring-music *with your app name

Note. You might have to install jq [0] or else replace with something like
sed, awk and grep


[0] - https://stedolan.github.io/jq/

On 11 April 2017 at 11:46, CF_genn <CF_subscription(a)streber24.de> wrote:

Hi CF-DEV,
I have a Java app deployed and running. Is it possible to find out from the
application
- in what org / space it is running?
- can it find out its own name? (as shown in "cf apps")

Thank you!





--
View this message in context: http://cf-dev.70369.x6.nabble.
com/Java-How-to-find-out-user-org-application-tp6729.html
Sent from the CF Dev mailing list archive at Nabble.com.
--
Kind Regards,

David Farrell

Pivotal Global Support Services (GSS)

Email: dafarrell(a)pivotal.io
Office #: +353 21 4238482
Office Hours: Mon-Fri 8:30 AM to 5PM <GMT+1>
Out of Office Hours Contact +1 877-477-2269

Pivotal GSS Contact & Escalations:
https://discuss.zendesk.com/hc/en-us/articles/203809556



pivotal.io


Stanislav German-Evtushenko
 

Hi,


On Linux or MacOS the following shell scripts may help. They show details across organizations and spaces you have access to.
https://github.com/rakutentech/cf-tools/blob/master/cf-applist.sh
https://github.com/rakutentech/cf-tools/blob/master/cf-routelist.sh

Best regards,
Stanislav German-Evtushenko

On 11 April 2017 at 11:46, CF_genn <CF_subscription(a)streber24.de<mailto:CF_subscription(a)streber24.de>> wrote:
Hi CF-DEV,
I have a Java app deployed and running. Is it possible to find out from the
application
- in what org / space it is running?
- can it find out its own name? (as shown in "cf apps")

Thank you!





--
View this message in context: http://cf-dev.70369.x6.nabble.com/Java-How-to-find-out-user-org-application-tp6729.html
Sent from the CF Dev mailing list archive at Nabble.com.



--
Kind Regards,

David Farrell

Pivotal Global Support Services (GSS)

Email: dafarrell(a)pivotal.io<mailto:dafarrell(a)pivotal.io>
Office #: +353 21 4238482
Office Hours: Mon-Fri 8:30 AM to 5PM <GMT+1>
Out of Office Hours Contact +1 877-477-2269

Pivotal GSS Contact & Escalations:
https://discuss.zendesk.com/hc/en-us/articles/203809556


[https://docs.google.com/a/pivotal.io/uc?id=0BzyCyw2nYNQ_dnNvM0l6YzV1bzg&export=download]
pivotal.io<http://pivotal.io/>