nova 注入adminpass 添加用戶等設置


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM