Giter Club home page Giter Club logo

Comments (6)

adizohar avatar adizohar commented on August 15, 2024

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.

karthik-k-kamath avatar karthik-k-kamath commented on August 15, 2024

Thanks Jon, for the suggestion.
We will plan this enhancement request.

from oci-cli.

kevco-us avatar kevco-us commented on August 15, 2024

@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.

karthik-k-kamath avatar karthik-k-kamath commented on August 15, 2024

Jon can you try project o where this is possible?

from oci-cli.

jeliker avatar jeliker commented on August 15, 2024

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.

karthik-k-kamath avatar karthik-k-kamath commented on August 15, 2024

Understood and thanks for the suggestion Jon-Eric. We will consider this enhancement.

from oci-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.