List All VMs in OpenStack Region

Problem

The need exists to obtain a complete list of all Virtual Machines running in an OpenStack region.

Environment

  • Platform9 Managed OpenStack - All Versions

  • OpenStack Unified CLI

Procedure

  1. Source the admin RC file for your environment.

$ source [your_rc_file].rc
  1. Get a list of all VMs across all projects and users and copy it to a text file.

$ openstack server list --all-projects > all_vms
  1. This list can be pretty long if your environment has many users and only one region. In that case, you can filter the output using various parameters. For eg., you can use this command to get a list of only those instances which are in an 'Active' state.

$ openstack server list --all-projects --status ACTIVE
  1. Additional filters are available and can be explored by using the '-h' flag on the server list command.

$ openstack server list -h usage: openstack server list [-h] [-f {csv,json,table,value,yaml}] [-c COLUMN]  [--max-width [integer]] [--fit-width]  [--print-empty] [--noindent]  [--quote {all,minimal,none,nonnumeric}]  [--sort-column SORT_COLUMN]  [--reservation-id [reservation-id]]  [--ip [ip-address-regex]]  [--ip6 [ip-address-regex]] [--name [name-regex]]  [--instance-name [server-name]]  [--status [status]] [--flavor [flavor]]  [--image [image]] [--host [hostname]]  [--all-projects] [--project [project]]  [--project-domain [project-domain]]  [--user [user]] [--user-domain [user-domain]]  [--long] [-n | --name-lookup-one-by-one]  [--marker [server]] [--limit [num-servers]]  [--deleted] [--changes-since [changes-since]]
  1. The output can be printed out in various data formats depending on how you plan to consume this list.

  1. The command can also be used to output a single column if all the headers not needed. For eg., the following command will output only a list VM by their UUIDs

Additional Information

Last updated