compute node install
yum install libguestfs python-libguestfs libguestfs-tools-c
compute node config
[libvirt] inject_password=true inject_key=true inject_partition=-1
restart nova compute
systemctl restart openstack-nova-compute
设置root/adminstrator的密码
nova boot --admin-pass
添加新用户
nova boot --user-data
user-data example
#!/bin/sh passwd ubuntu<<EOF ubuntu ubuntu EOF sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config service ssh restart
备注:
1 https://cloud-images.ubuntu.com/ 上的ubuntu vm用该方法设置password
2 如果需要nova set-password起作用,需要image中装有qga,另外制作image时,需要设置meta中的 hw_qemu_guest_agent为yes
镜像中还需要指定用户名。可以参考m版的nova代码
def set_admin_password(self, instance, new_pass): self._can_set_admin_password(instance.image_meta) guest = self._host.get_guest(instance) user = instance.image_meta.properties.get("os_admin_user") if not user: if instance.os_type == "windows": user = "Administrator" else: user = "root" try: guest.set_user_password(user, new_pass)
参考:
https://kimizhang.wordpress.com/2014/03/18/how-to-inject-filemetassh-keyroot-passworduserdataconfig-drive-to-a-vm-during-nova-boot/
追加windows 密码设置的旧方法(不需要qga,需要cloudbase-init)
nova boot --key-name --meta admin-pass=yourpassword
事先在windows镜像中配置好cloudbase-init 来指定用户名。比如sds的环境中使用的镜像设置的用户名是admin