Auotport 新增 Instance

  1. 載入用戶 demo 環境變數。
    [root@ip110 ~]# . demo.token 
    [root@ip110 ~]<demo>#
    
  2. 查詢可用 flavor。
    [root@ip110 ~]<demo># openstack flavor list
    +----+-----------+------+------+-----------+-------+-----------+
    | ID | Name      |  RAM | Disk | Ephemeral | VCPUs | Is Public |
    +----+-----------+------+------+-----------+-------+-----------+
    | 0  | dyw.tiny  |   64 |    1 |         0 |     1 | True      |
    | 1  | dyw.ce8   | 4096 |   30 |         0 |     2 | True      |
    | 2  | dyw.large | 8192 |   16 |         0 |     4 | True      |
    | 3  | dyw.csa   | 2048 |   16 |         0 |     2 | True      |
    +----+-----------+------+------+-----------+-------+-----------+
    
  3. 查詢 flavor dyw.tiny 的各欄位值,沒有 extra_specs 設定。
    [root@ip110 ~]<demo># openstack flavor show dyw.tiny
    +----------------------------+----------+
    | Field                      | Value    |
    +----------------------------+----------+
    | OS-FLV-DISABLED:disabled   | False    |
    | OS-FLV-EXT-DATA:ephemeral  | 0        |
    | access_project_ids         | None     |
    | disk                       | 1        |
    | id                         | 0        |
    | name                       | dyw.tiny |
    | os-flavor-access:is_public | True     |
    | properties                 |          |
    | ram                        | 64       |
    | rxtx_factor                | 1.0      |
    | swap                       |          |
    | vcpus                      | 1        |
    +----------------------------+----------+
    
  4. 使用 flavor dyw.tiny 新增 instance cirros2。
    [root@ip110 ~]<demo># openstack server create --flavor dyw.tiny \
    --image cirros5 --nic net-id=6ed4de53-ecc1-4c79-a9d2-8e511b26557a \
    --security-group default --availability-zone nova:ip110:ip110 \
    cirros2 --wait
    +-----------------------------+------------------------------------------------+
    | Field                       | Value                                          |
    +-----------------------------+------------------------------------------------+
    | OS-DCF:diskConfig           | MANUAL                                         |
    | OS-EXT-AZ:availability_zone | nova                                           |
    | OS-EXT-STS:power_state      | Running                                        |
    | OS-EXT-STS:task_state       | None                                           |
    | OS-EXT-STS:vm_state         | active                                         |
    | OS-SRV-USG:launched_at      | 2020-06-05T11:23:18.000000                     |
    | OS-SRV-USG:terminated_at    | None                                           |
    | accessIPv4                  |                                                |
    | accessIPv6                  |                                                |
    | addresses                   | selfservice=192.168.10.33                      |
    | adminPass                   | qHLrZhi4MbAS                                   |
    | config_drive                |                                                |
    | created                     | 2020-06-05T11:22:55Z                           |
    | flavor                      | dyw.tiny (0)                                   |
    | hostId                      | 71c30f5bf734c2046ae66e4ceec5af8350decb8905a171 |
    | id                          | 62f81add-c3ca-4023-9bd4-a687116a7c8c           |
    | image                       | cirros5 (c60627cd-df9c-4fdd-858c-a39fb94d9234) |
    | key_name                    | None                                           |
    | name                        | cirros2                                        |
    | progress                    | 0                                              |
    | project_id                  | 0abfdfea73d142d08192aab5cc051642               |
    | properties                  |                                                |
    | security_groups             | name='default'                                 |
    | status                      | ACTIVE                                         |
    | updated                     | 2020-06-05T11:23:18Z                           |
    | user_id                     | fdae41299d574ea59fc26bef4793885b               |
    | volumes_attached            |                                                |
    +-----------------------------+------------------------------------------------+
    
  5. 載入管理者 admin 的環境變數,查詢 instance cirros2 的 xml 檔名稱為 instance-0000014f。
    [root@ip110 ~]<demo># . admin.token 
    [root@ip110 ~]<admin># nova list --all --fields=name,instance_name,status | grep cirros2
    | 62f81add-c3ca-4023-9bd4-a687116a7c8c | cirros2  | instance-0000014f | ACTIVE  |
    
  6. 查詢 instance-0000014f.xml 得知,其使用自動取得的 5902 埠號,沒有設定連線密碼。
    [root@ip110 ~]<admin># grep graphic /var/run/libvirt/qemu/instance-0000014f.xml 
          <graphics type='spice' port='5902' autoport='yes' listen='0.0.0.0' keymap='en-us'>
          </graphics>
    [root@ip110 ~]<admin># grep graphic /etc/libvirt/qemu/instance-0000014f.xml 
        <graphics type='spice' autoport='yes' listen='0.0.0.0' keymap='en-us'>
        </graphics>