问题描述
我正在考虑编写一个unix shell脚本来列出Cloud Foundry中与之相关的组织和空间。但是有问题,因为我们只能在定位到组织之后才能列出与组织关联的空间。
I am thinking to write a unix shell script to list orgs and spaces associated with it in Cloud Foundry. But had issues, as we can list spaces associated with an org only after targeting it.
我不能同时使用以下两个Orgs来定位:Orb1 Org2中i的
;做cf target -o $ i;完成
I cannot target 2 Orgs at a time using :for i in Org1 Org2 ; do cf target -o $i ; done
因此,如果我将所有组织放入文本文件中,例如:
Hence, if i put all the orgs in a text file and like this :
cat Orgs.txt
; cf空格$ i;完成
for i in cat Orgs.txt
; do cf spaces $i ; done
请提出您的意见。谢谢!
Please suggest your views. Thank you!
推荐答案
cf org
命令将显示有关组织(包括空格),因此不必分别定位每个组织:
The cf org
command will show information about an organization, including spaces, so it's unnecessary to target each org individually:
$ cf target
API endpoint: https://api.local.pcfdev.io
API version: 2.65.0
User: admin
No org or space targeted, use 'cf target -o ORG -s SPACE'
$ cf org pcfdev-org
Getting info for org pcfdev-org as admin...
OK
pcfdev-org:
domains: local.pcfdev.io, tcp.local.pcfdev.io
quota: default (102400M memory limit, unlimited instance memory limit, 100 routes, -1 services, paid services allowed, unlimited app instance limit, unlimited route ports)
spaces: pcfdev-space
space quotas:
我想您可以简单地遍历组织列表,获取每个组织的空间,然后执行稍加字符串替换,以适当的组织名称开头空格列表:
I think you can simply iterate over the list of orgs, getting the spaces for each, and do a little string substitution to preface the spaces list with the appropriate org name:
$ for org in $( cf orgs | tail +4 ); do \
cf org "$org" | grep spaces | sed "s/spaces/$org/"; \
done
demos: spring-cloud, services, chaos-engineering
pcfdev-org: pcfdev-space
system: system
我浏览了,但是我没有找到没有提供比您要求更多的信息的东西。我能很快找到的是
I looked through the list of CF CLI plugins, but I didn't find anything that didn't provide way more information than you're asking. Closest I could find quickly was the Usage Report plugin.
这篇关于需要列出Cloud Foundry中的组织和空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!