Ask Your Question
1

Format output of command line clients

asked 2015-11-25 04:35:06 -0600

Carlos Campderrós gravatar image

Is there any way to change/format the output of command line tools like nova? I'm looking for some way of easily parsing the output in shell scripts, without having to resort to the novaclient python library.

Specifically I'm trying to get the status field of an instance. Right now I'm doing some parsing with sed and awk, but it is ugly.

It would be wonderful if I could do something like (strongly based on rpm -q --queryformat):

status=$(nova show --format="%{status}" my-instance-name)
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2015-11-25 04:31:48 -0600

Carlos Campderrós gravatar image

After posting the question I just found what I wanted. There is the openstack command that I didn't know that existed (yum install python-openstackclient in fedora) that covers what I need:

status="$(openstack server show -c status --format value my-instance-name)"
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2015-11-25 03:56:58 -0600

Seen: 5,141 times

Last updated: Nov 25 '15