Comments (6)
Hi,
The simple way is to create python script list_compartment.py with below code and execute using
pytnon3 list_compartment.py
import oci
config = oci.config.from_file(oci.config.DEFAULT_LOCATION, oci.config.DEFAULT_PROFILE)
identity_client = oci.identity.IdentityClient(config)
tenant_id = config['tenancy']
compartments = oci.pagination.list_call_get_all_results(
identity_client.list_compartments,
compartment_id=tenant_id,
compartment_id_in_subtree=True).data
for c in compartments:
print(f"{c.name}\t{c.lifecycle_state}")
from oci-cli.
Thanks Jon, for the suggestion.
We will plan this enhancement request.
from oci-cli.
@jeliker Check out https://github.com/oracle/oci-cli/blob/master/scripts/examples/project_o/README.md
Project "o" provides several output options, one of which is tsv.
To do what you want, install "o". Then run:
$ o -o 'name lifecycle' list compart -ciis true -all .
oci iam compartment list \
--compartment-id-in-subtree true \
--all
outpost ACTIVE
sandbox1 ACTIVE
workload.spbAEuEo DELETED
workshop ACTIVE
Note: there's a "tab" character in between name and lifecycle in the command.
o will convert the above command into a complete oci command, select output based on "-o fields", and format results into tsv. All from that brief little command.
I've never used tsv but figured someone would want it one day!
My everyday format is the default table out - without the ascii decorations.
$ o -qo name#state list compart -ciis true -all .
name lifecycle-state
outpost ACTIVE
sandbox1 ACTIVE
workload.spbAEuEo DELETED
workshop ACTIVE
Default "o" output is meant to be useful for humans.
from oci-cli.
Jon can you try project o where this is possible?
from oci-cli.
Thank you for the work-around suggestion but, as described, I have a work-around now that doesn't require additional tools installed. In my scenarios it is not often feasible to install additional software so still hoping for a native solution.
Note I could have always opted to use another tool whether the o
script or jq
or others. My suggestion is for improvement in this tool itself.
from oci-cli.
Understood and thanks for the suggestion Jon-Eric. We will consider this enhancement.
from oci-cli.
Related Issues (20)
- oci compute compute-capacity-report says invalid json with generated sample json HOT 5
- oci compute capacity report is not correct in which ad has status AVAILABLE
- Cannot supply `attribute-sets` parameter for `identity-domains groups search`
- OCI CLI to alert CR+LF line breaks used in the PEM formatted key files
- Running db node stop does a shutdown abort even if srvctl specifies immediate stop option HOT 2
- Cannot update resource manager stack working-director
- Cannot download stack-tf-config using cli
- OCI CLI install.sh fails on Alpine
- Cloud shell is not listing the compartments in Private Network Definition HOT 3
- oci iam user update cannot set email that is previously empty HOT 1
- question regarding rate limiting HOT 2
- FILE command when using CLI container fails HOT 2
- oci kms management key-version cancel-deletion has no response body HOT 4
- Add support for Python 3.12, install.sh fails (distutils module removed)
- Location of file "suggestion_variable.txt"
- Get Refresh Token for oci iam db-token HOT 3
- Update optional DB dependency from obsolete 'cx_Oracle' to 'oracledb'
- `3.43.0` fails on python `3.12.x` with invalid escape sequence errors
- Error in command log-analytics storage purge-storage-data HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oci-cli.