Ask Your Question

how to list all VMs with projects name, power status, ipaddress?

asked 2018-03-30 02:26:27 -0500

I want to list all the openstack VMs with projects name, powerstatus, ipaddress. The following command will shows all the VMs but it shows with tenant ID but I want to list with tenant name.

nova list --all-tenants

Any other command or python script to list all openstack setup VMs with tenant name?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2020-05-26 13:48:39 -0500

Joris gravatar image

I have this script that you can work upon; it prints all project names and their resp. tenants:

for id in  $(openstack server list --all --long | awk '{print $2}'); 
    instance_name=$(openstack server show $id | grep "^| name  " | awk '{print $4}'); 
    project_id=$(openstack server show $id | grep project_id | awk '{print $4}');
    project_name=$(openstack project show $project_id | grep name | awk '{print $4}');
        echo "$instance_name <--- $project_name"; 

It has been tested for Stein.

edit flag offensive delete link more

answered 2018-03-30 06:55:46 -0500

updated 2018-03-30 08:32:03 -0500

Idea for a shell script. Don't expect it to be fast:

for server in $(openstack server list --all-projects -c ID -f value)
    # the -f shell option sets environment variables
    eval $(openstack server show $server -f shell -c id -c OS-EXT-STS:power_state -c addresses -c project_id --all-projects)
    project_name=$(openstack project show -f value -c name $project_id)
    echo $id $os_ext_sts_power_state $addresses $project_name

A script around the API is probably quicker.

Or nova list piped into an awk script.

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


Asked: 2018-03-30 02:26:27 -0500

Seen: 3,024 times

Last updated: Mar 30 '18