openstack 命令行管理十八 - instance管理 (备忘)

相关帮助

[root@station140 ~(keystone_admin)]# nova boot
usage: nova boot [--flavor <flavor>] [--image <image>]
                 [--image-with <key=value>] [--boot-volume <volume_id>]
                 [--snapshot <snapshot_id>] [--num-instances <number>]
                 [--meta <key=value>] [--file <dst-path=src-path>]
                 [--key-name <key-name>] [--user-data <user-data>]
                 [--availability-zone <availability-zone>]
                 [--security-groups <security-groups>]
                 [--block-device-mapping <dev-name=mapping>]
                 [--block-device key1=value1[,key2=value2...]]
                 [--swap <swap_size>]
                 [--ephemeral size=<size>[,format=<format>]]
                 [--hint <key=value>]
                 [--nic <net-id=net-uuid,v4-fixed-ip=ip-addr,port-id=port-uuid>]
                 [--config-drive <value>] [--poll]
                 <name>


列出flavor-list

[root@station140 ~(keystone_admin)]# nova flavor-list | grep -E 'ID|computer|-'
+----+--------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name         | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+--------------+-----------+------+-----------+------+-------+-------------+-----------+
| 6  | m1.vcomputer | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
+----+--------------+-----------+------+-----------+------+-------+-------------+-----------+


列出镜像命名

[root@station140 ~(keystone_admin)]#  glance image-list | grep -v "+" | awk '{printf "%-35s %25s\n",  $2,$4}'
ID                                                       Name
2aad80bf-6fbb-4348-bb20-2c07dbf4f687          centos5.8_x86_64
2d6bb00d-002f-4675-ba84-73d90fdc1020                    cirros


等价命令

nova image-list | grep -v "+" | awk '{printf "%-35s %25s\n",  $2,$4}'



列出 keypair

[root@station140 ~(keystone_admin)]# nova keypair-list
+----------+-------------------------------------------------+
| Name     | Fingerprint                                     |
+----------+-------------------------------------------------+
| terrykey | 94:b8:9c:2a:31:8c:2c:87:7f:f5:80:24:23:73:f8:e9 |
+----------+-------------------------------------------------+



列出 secgroup

[root@station140 ~(keystone_admin)]# nova secgroup-list
+--------------------------------------+---------+--------------------+
| Id                                   | Name    | Description        |
+--------------------------------------+---------+--------------------+
| 91a191a6-b89e-4f87-99c0-0fb985985978 | default | default            |
| 6966a8e4-0980-40ad-a409-baac65b60287 | terry   | allow ping and ssh |
+--------------------------------------+---------+--------------------+



 

启动第一个实例 (只有一个网卡)

[root@station140 ~(keystone_admin)]# nova boot --flavor m1.vcomputer --image centos5.8_x86_64 --key-name terrykey --security-groups terry --nic net-id=d0e3f988-d62f-4f95-ab21-b73f4dae326b terry_instance1
+--------------------------------------+--------------------------------------+
| Property                             | Value                                |
+--------------------------------------+--------------------------------------+
| OS-EXT-STS:task_state                | scheduling                           |
| image                                | centos5.8_x86_64                     |
| OS-EXT-STS:vm_state                  | building                             |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000006                    |
| OS-SRV-USG:launched_at               | None                                 |
| flavor                               | m1.vcomputer                         |
| id                                   | 3760f47f-1b56-4429-a046-f77fb6d50d1a |
| security_groups                      | [{u'name': u'terry'}]                |
| user_id                              | 9b3904aef3f84d6b9432989f0e0e0194     |
| OS-DCF:diskConfig                    | MANUAL                               |
| accessIPv4                           |                                      |
| accessIPv6                           |                                      |
| progress                             | 0                                    |
| OS-EXT-STS:power_state               | 0                                    |
| OS-EXT-AZ:availability_zone          | nova                                 |
| config_drive                         |                                      |
| status                               | BUILD                                |
| updated                              | 2014-02-17T06:09:24Z                 |
| hostId                               |                                      |
| OS-EXT-SRV-ATTR:host                 | None                                 |
| OS-SRV-USG:terminated_at             | None                                 |
| key_name                             | terrykey                             |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | None                                 |
| name                                 | terry_instance1                      |
| adminPass                            | eQMSKUvs7oem                         |
| tenant_id                            | e3a71a59840c4e88b8740b789c3afb9c     |
| created                              | 2014-02-17T06:09:24Z                 |
| os-extended-volumes:volumes_attached | []                                   |
| metadata                             | {}                                   |
+--------------------------------------+--------------------------------------+


 

下面显示为虚拟机创建中

[root@station140 ~(keystone_admin)]# nova list
+--------------------------------------+-----------------+--------+------------+-------------+----------------+
| ID                                   | Name            | Status | Task State | Power State | Networks       |
+--------------------------------------+-----------------+--------+------------+-------------+----------------+
| 93d0c9c1-b38b-4fe3-9ae3-400f43276f60 | terry_instance1 | BUILD  | spawning   | NOSTATE     | net1=10.0.0.50 |
+--------------------------------------+-----------------+--------+------------+-------------+----------------+


下面显示为正常运行中的 instance

[root@station140 ~(network_admin)]# nova list
+--------------------------------------+-----------------+--------+------------+-------------+----------------+
| ID                                   | Name            | Status | Task State | Power State | Networks       |
+--------------------------------------+-----------------+--------+------------+-------------+----------------+
| 3760f47f-1b56-4429-a046-f77fb6d50d1a | terry_instance1 | ACTIVE | None       | Running     | net1=10.0.0.50 |
+--------------------------------------+-----------------+--------+------------+-------------+----------------+

 

列出主机部分信息

[root@station140 /(keystone_admin)]# nova list  --fields "networks,name,status" --name terry_instance1
+--------------------------------------+--------------------------------+-----------------+--------+
| ID                                   | Networks                       | Name            | Status |
+--------------------------------------+--------------------------------+-----------------+--------+
| f76bd659-da1d-482a-b74d-08b67b95c113 | net1=10.0.0.50, 192.168.48.142 | terry_instance1 | ACTIVE |
+--------------------------------------+--------------------------------+-----------------+--------+



注: fields 需使用小写进行定义

你可能感兴趣的:(openstack)