修改 port 及密碼

  1. instance cirros5 新增時使用 autoport,且沒設定連線密碼,現在使用 –property 選項設定 hw:port 及 hw:passwd 兩個 metadata。
    [root@ip110 ~]<demo># openstack server set --property hw:port=5995 --property hw:passwd=123321 cirros5
    
  2. 查詢 instance cirros5 的 properties 有印出設定的值。
    [root@ip110 ~]<demo># openstack server show cirros5
    +-----------------------------+----------------------------------------------------------+
    | 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-06T08:04:53.000000                               |
    | OS-SRV-USG:terminated_at    | None                                                     |
    | accessIPv4                  |                                                          |
    | accessIPv6                  |                                                          |
    | addresses                   | selfservice=192.168.10.44                                |
    | config_drive                |                                                          |
    | created                     | 2020-06-06T08:04:38Z                                     |
    | flavor                      | dyw.tiny (0)                                             |
    | hostId                      | 71c30f5bf734c2046ae66e4ceec5af8350decb8905a171de520776a9 |
    | id                          | c9a9f517-7e33-41dd-98eb-c95de8a11218                     |
    | image                       | cirros5 (c60627cd-df9c-4fdd-858c-a39fb94d9234)           |
    | key_name                    | None                                                     |
    | name                        | cirros5                                                  |
    | progress                    | 0                                                        |
    | project_id                  | 0abfdfea73d142d08192aab5cc051642                         |
    | properties                  | hw:passwd='123321', hw:port='5995'                       |
    | security_groups             | name='default'                                           |
    | status                      | ACTIVE                                                   |
    | updated                     | 2020-06-06T08:55:18Z                                     |
    | user_id                     | fdae41299d574ea59fc26bef4793885b                         |
    | volumes_attached            |                                                          |
    +-----------------------------+----------------------------------------------------------+
    
  3. 重新啟動 instance cirros5。
    [root@ip110 ~]<demo># openstack server reboot --hard cirros5
    
  4. 再查詢 instance cirros5 的 xml 檔,autoport='no',port 為 5995,passwd 為 123321。
    [root@ip110 ~]<demo># grep graphic /var/run/libvirt/qemu/instance-00000153.xml 
        <graphics type='spice' port='5995' autoport='no' listen='0.0.0.0' keymap='en-us' passwd='123321'>
        </graphics>
    [root@ip110 ~]<demo># grep graphic /etc/libvirt/qemu/instance-00000153.xml 
        <graphics type='spice' port='5995' autoport='no' listen='0.0.0.0' keymap='en-us' passwd='123321'>
        </graphics>