- Khởi tạo image với property ( mục đích tạo socket từ compute đến VM)
glance image-create --name cirros \
--disk-format raw \
--container-format bare \
--file cirros-0.3.3-x86_64-disk.raw \
--is-public True \
--property hw_qemu_guest_agent=yes \
--progress
hoặc có thể cập nhật cho image thông qua metadata
openstack image set --property hw_qemu_guest_agent=yes centos7
- Cài đặt qemu-guest-agent trên VM
yum install -y qemu-guest-agent
systemctl start qemu-guest-agent
systemctl enable qemu-guest-agent
-
Sử dụng qemu-guest-command trên compute node
-
Thực hiện ping đến VM trê các compute node
- Đối với các VM chưa cài ( chưa start ) qemu-guest-agent sẽ trả về
error: argument unsupported: QEMU guest agent is not configured
- Đối với các với VM đã start qemu-guest-agent sẽ trả về
"return":{}}
- Đối với các VM chưa cài ( chưa start ) qemu-guest-agent sẽ trả về
qemu-agent-command instance-0000000f '{ "execute": "guest-ping"}'
- Đối với các VM đang enable selinux thì return error **Command **
qemu-agent-command instance-0000000f '{ "execute": "guest-set-user-password", "arguments": { "crypted": false, "username": "root", "password": "123123Aa" } }'
Error
error: internal error: unable to execute QEMU agent command 'guest-set-user-password': child process has failed to set user password
- Thực hiện disable selinux trên VM
setenforce 0
hoặc
- Trong trường hợp máy ảo đang ở bật Selinux (Enforcing). Thực hiện set policy trong VM
yum -y reinstall selinux-policy-targeted
semanage permissive -a virt_qemu_ga_t
- Sau đó thực hiện set password cho các VM ( The letter must be encoded with bas64 )
echo -n '123@123Aa' | base64
virsh qemu-agent-command instance-0000000f '{ "execute": "guest-set-user-password","arguments": { "crypted": false,"username": "root","password": "MTIzQDEyM0Fh" } }'
- Thực hiện tắt selinux trên VM
setenforce 0 ( tạm thời )
- Thực hiện set password cho VM
nova set-password test-vm
- Log
2019-03-11 10:05:48.739 26109 INFO nova.compute.manager [req-3f9396e7-b2d7-421a-891c-51be1aaab692 cd5d06997a9a450ca89fb2bb9f7855b2 e65a56e7115c4f02a559608959ee7d27 - default default] [instance: 8eba7690-fb73-4dc8-bd19-a7c2af8b95e4] Admin password set
-
Khi khởi tạo một Openstack Windows Instance , admin_pass được sử dụng để set-password cho user được cấu hình dưới các clodu-agent, tuy nhiên khi các admin_pass không được người dùng gửi xuống cloud-base sẽ khởi tạo admin_pass nhiên thông qua và truyền xuống instance thông Nova metadata service và các password này được mã hoá với public key. Để giải mã được password này không có cách nào ngoài sử dụng private key trong cặp key này.
-
Lưu ý các password được khởi tạo ngẫu nhiên sẽ sử dụng cho các user được cấu hình bởi các cloud-agent ( cloud-base init )
-
Get mật khẩu đã được mã hoá
nova get-password $instance_uuid
- Get password được mã hóa bằng private key
nova get-password $instance_uuid /root/privatekey.key