修改 port 及密碼

  1. instance 的 flavor extra spces 儲存於資料庫 nova 的資料表 instance_extra,其中 hw_set_port 為 5999,hw_set_passwd 為 123qwe。
    [root@ip110 ~]# mysql -unova -pxxxxxx -e "use nova; use nova;\
     select flavor from instance_extra where \
     instance_uuid='44267063-3f4f-4faf-813a-d4f367588934'\G"
    
    *************************** 1. row ***************************
    flavor: {"new": null, "old": null, "cur": {"nova_object.version": "1.2",
     "nova_object.changes": ["extra_specs"], "nova_object.name": "Flavor",
     "nova_object.data": {"disabled": false, "root_gb": 1, "description": null,
     "flavorid": "0", "deleted": false, "created_at": "2020-05-28T23:50:43Z",
     "ephemeral_gb": 0, "updated_at": null, "memory_mb": 64, "vcpus": 1,
     "extra_specs": {"hw_set_passwd": "123qwe", "hw_set_port": "5999"}, "swap": 0,
     "rxtx_factor": 1.0, "is_public": true, "deleted_at": null, "vcpu_weight": 0,
     "id": 14, "name": "dyw.tiny"}, "nova_object.namespace": "nova"}}
    
  2. 修改資料庫 nova 的資料表 instance_extra,設定其欄位 flavor 的 extra_specs,hw_set_port 為 5998,hw_set_passwd 為 123456。
    [root@ip110 ~]# mysql -unova -pxxxxxx -e "use nova; use nova;\
    update instance_extra set flavor=regexp_replace(flavor,'(extra_specs\": \
    {)[^}]*', '\\\1\"hw_set_passwd\": \"123456\", \"hw_set_port\": \"5998\"') \
    where instance_uuid='44267063-3f4f-4faf-813a-d4f367588934'\G"
    
  3. 再查詢 instance cirros3 的 flavor extra spces,其中 hw_set_port 改為 5998,hw_set_passwd 改為 123456。
    [root@ip110 ~]# mysql -unova -pxxxxxx -e "use nova; use nova;\
     select flavor from instance_extra \
    where instance_uuid='44267063-3f4f-4faf-813a-d4f367588934'\G"
    
    *************************** 1. row ***************************
    flavor: {"new": null, "old": null, "cur": {"nova_object.version": "1.2",
     "nova_object.changes": ["extra_specs"], "nova_object.name": "Flavor",
     "nova_object.data": {"disabled": false, "root_gb": 1, "description": null,
     "flavorid": "0", "deleted": false, "created_at": "2020-05-28T23:50:43Z",
     "ephemeral_gb": 0, "updated_at": null, "memory_mb": 64, "vcpus": 1,
     "extra_specs": {"hw_set_passwd": "123456", "hw_set_port": "5998"}, "swap": 0,
     "rxtx_factor": 1.0, "is_public": true, "deleted_at": null, "vcpu_weight": 0,
     "id": 14, "name": "dyw.tiny"}, "nova_object.namespace": "nova"}}
    
  4. 重新啟動 instance cirros3。
    [root@ip110 ~]<demo># openstack server reboot --hard cirros3
    
  5. 再查詢 instance cirros3 的 xml 檔,autoport='no',port 為 5998,passwd 為 123456。
    [root@ip110 ~]<demo># grep graphic /var/run/libvirt/qemu/instance-00000150.xml
       <graphics type='spice' port='5998' autoport='no' listen='0.0.0.0' keymap='en-us' passwd='123456'>
       </graphics>
    [root@ip110 ~]<demo># grep graphic /etc/libvirt/qemu/instance-00000150.xml 
      <graphics type='spice' port='5998' autoport='no' listen='0.0.0.0' keymap='en-us' passwd='123456'>
      </graphics>