[root@cc ~]# nova help list
usage: nova list [--reservation-id <reservation-id>] [--ip <ip-regexp>]
[--ip6 <ip6-regexp>] [--name <name-regexp>]
[--instance-name <name-regexp>] [--status <status>]
[--flavor <flavor>] [--image <image>] [--host <hostname>]
[--all-tenants [<0|1>]] [--tenant [<tenant>]]
[--fields <fields>]
List active servers.
Optional arguments:
--reservation-id <reservation-id>
Only return instances that match reservation-id.
--ip <ip-regexp> Search with regular expression match by IP address
(Admin only).
--ip6 <ip6-regexp> Search with regular expression match by IPv6 address
(Admin only).
--name <name-regexp> Search with regular expression match by name
--instance-name <name-regexp>
Search with regular expression match by instance name
(Admin only).
--status <status> Search by server status
--flavor <flavor> Search by flavor name or ID
--image <image> Search by image name or ID
--host <hostname> Search instances by hostname to which they are
assigned (Admin only).
--all-tenants [<0|1>]
Display information from all tenants (Admin only).
--tenant [<tenant>] Display information from single tenant (Admin only).
--fields <fields> Comma-separated list of fields to display. Use the
show command to see which fields are available.
一般的用法:
比较实用的用法:
显示指定节点上的虚拟机
显示指定ip的虚拟机
显示使用指定镜像的虚拟机
显示使用指定规格的虚拟机
显示指定状态的虚拟机
显示虚拟机并且显示指定字段
usage: nova list [--reservation-id <reservation-id>] [--ip <ip-regexp>]
[--ip6 <ip6-regexp>] [--name <name-regexp>]
[--instance-name <name-regexp>] [--status <status>]
[--flavor <flavor>] [--image <image>] [--host <hostname>]
[--all-tenants [<0|1>]] [--tenant [<tenant>]]
[--fields <fields>]
List active servers.
Optional arguments:
--reservation-id <reservation-id>
Only return instances that match reservation-id.
--ip <ip-regexp> Search with regular expression match by IP address
(Admin only).
--ip6 <ip6-regexp> Search with regular expression match by IPv6 address
(Admin only).
--name <name-regexp> Search with regular expression match by name
--instance-name <name-regexp>
Search with regular expression match by instance name
(Admin only).
--status <status> Search by server status
--flavor <flavor> Search by flavor name or ID
--image <image> Search by image name or ID
--host <hostname> Search instances by hostname to which they are
assigned (Admin only).
--all-tenants [<0|1>]
Display information from all tenants (Admin only).
--tenant [<tenant>] Display information from single tenant (Admin only).
--fields <fields> Comma-separated list of fields to display. Use the
show command to see which fields are available.
一般的用法:
[root@cc ~]# nova list
+--------------------------------------+----------+-----------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------+-----------+------------+-------------+---------------+
| 14e9c941-1e3c-4848-9d07-7f4624831d03 | INSTANCE | ACTIVE | None | Running | test=10.0.0.5 |
| 9d0daae5-38dc-49c2-9f89-0a3d341889db | INSTANCE | ACTIVE | None | Running | test=10.0.0.2 |
| b8b71597-d2af-42ed-abe7-b994f63570bb | INSTANCE | SUSPENDED | None | Shutdown | test=10.0.0.4 |
+--------------------------------------+----------+-----------+------------+-------------+---------------+
比较实用的用法:
显示指定节点上的虚拟机
[root@cc ~]# nova list --host node_1
+--------------------------------------+----------+--------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------+--------+------------+-------------+---------------+
| 9d0daae5-38dc-49c2-9f89-0a3d341889db | INSTANCE | ACTIVE | None | Running | test=10.0.0.2 |
+--------------------------------------+----------+--------+------------+-------------+---------------+
显示指定ip的虚拟机
[root@cc ~]# nova list --ip 10.0.0.2
+--------------------------------------+----------+--------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------+--------+------------+-------------+---------------+
| 9d0daae5-38dc-49c2-9f89-0a3d341889db | INSTANCE | ACTIVE | None | Running | test=10.0.0.2 |
+--------------------------------------+----------+--------+------------+-------------+---------------+
显示使用指定镜像的虚拟机
[root@cc ~]# nova list --image c3f763fd-63c8-4dd8-97c9-4f5f4a39d6ab
+--------------------------------------+----------+-----------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------+-----------+------------+-------------+---------------+
| 14e9c941-1e3c-4848-9d07-7f4624831d03 | INSTANCE | ACTIVE | None | Running | test=10.0.0.5 |
| b8b71597-d2af-42ed-abe7-b994f63570bb | INSTANCE | SUSPENDED | None | Shutdown | test=10.0.0.4 |
+--------------------------------------+----------+-----------+------------+-------------+---------------+
显示使用指定规格的虚拟机
[root@cc ~]# nova list --flavor 2
+--------------------------------------+----------+-----------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------+-----------+------------+-------------+---------------+
| 14e9c941-1e3c-4848-9d07-7f4624831d03 | INSTANCE | ACTIVE | None | Running | test=10.0.0.5 |
| 9d0daae5-38dc-49c2-9f89-0a3d341889db | INSTANCE | ACTIVE | None | Running | test=10.0.0.2 |
+--------------------------------------+----------+-----------+------------+-------------+---------------+
显示指定状态的虚拟机
[root@cc ~]# nova list --status active
+--------------------------------------+----------+--------+------------+-------------+---------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------+--------+------------+-------------+---------------+
| 14e9c941-1e3c-4848-9d07-7f4624831d03 | INSTANCE | ACTIVE | None | Running | test=10.0.0.5 |
| 9d0daae5-38dc-49c2-9f89-0a3d341889db | INSTANCE | ACTIVE | None | Running | test=10.0.0.2 |
+--------------------------------------+----------+--------+------------+-------------+---------------+
显示虚拟机并且显示指定字段
[root@cc ~]# nova list --fields <字段>
我平时常用的一般有instance_name、host、image、flavor、vm_state等,非常实用,比如想去计算节点virsh命令里操作虚拟机,使用nova list --fields instance_name能够很快的得到虚拟机id与instance_name之间的对应关系。
[root@cc ~]# nova list --fields instance_name
+--------------------------------------+-------------------+
| ID | Instance Name |
+--------------------------------------+-------------------+
| b8b71597-d2af-42ed-abe7-b994f63570bb | instance-00000009 |
| 9d0daae5-38dc-49c2-9f89-0a3d341889db | instance-0000000a |
| 14e9c941-1e3c-4848-9d07-7f4624831d03 | instance-0000000b |
+--------------------------------------+-------------------+