Skip to content

Instantly share code, notes, and snippets.

@brightzheng100
Created April 13, 2018 04:39
Show Gist options
  • Save brightzheng100/c851f11ab6eaf0e562f0a82448b7d948 to your computer and use it in GitHub Desktop.
Save brightzheng100/c851f11ab6eaf0e562f0a82448b7d948 to your computer and use it in GitHub Desktop.
List all service instances in PCF foundation
#!/bin/bash
ORIGINAL_TARGET_ORG=`cf target | awk '/org:/{ print $2 }'`
ORIGINAL_TARGET_SPACE=`cf target | awk '/space:/{ print $2 }'`
ALL_ORGS=(`cf orgs | awk 'NR > 3'`)
# flag for printing the header
PRINT_HEADER=0
for ORG in $ALL_ORGS
do
# target to one org
cf target -o $ORG > /dev/null;
ALL_SPACES=(`cf spaces | awk 'NR > 3'`);
for SPACE in $ALL_SPACES
do
cf target -s $SPACE > /dev/null
if [ $PRINT_HEADER -eq 0 ]
then
cf services | awk 'NR >= 4';
set PRINT_HEADER=1
else
cf services | awk 'NR > 4';
fi
done
done
# back to orginal position
cf target -o $ORIGINAL_TARGET_ORG -s $ORIGINAL_TARGET_SPACE > /dev/null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment