下载disk.config:
wget http://10.254.3.75/images/configdrive/disk.config
修改libvirt.xml,更换cdrom为disk.config:
<disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/var/image-create/cn_windows_server_2012_r2_vl_x64_dvd_2979220.iso'/> <!--光盘镜像路径--> <target dev='hda' bus='ide'/> <readonly/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/var/image-create/disk.config'/> <target dev='hdb' bus='ide'/> <readonly/> </disk> <disk type='file' device='floppy'> <driver name='qemu' type='raw' cache='none'/> <source file='/var/image-create/virtio-win-0.1.96_amd64.vfd'/> <target dev='fda' bus='fdc'/> </disk>
1. 安装cloudbase-init
1)进入disk.config/openstack_windows_images_config/softwares/中,选择对应的cloudbase-init版本进行安装,
安装过程中,选择username:administrator,不要选择网络,log选择com1
2) 将openstack_windows_images_config/1_cloudbase-init中的三个文件夹替换掉安装的cloudbase-init
3) 注意,conf/cloudbase-init.conf中,user一定要写administrator
2. Ovirt-guest-agent安装
1)拷贝cdrom中的2_ovirt-guest-agent到C:program files或者C:program files(x86)下;
2)配置python 环境变量 Path设置为:C:program files(x86)cloudbase solutionscloudbase-initPython27
3)cd c:program filesovirt-guest-agentovirt-guest-agent 32位
cd c:program files (x86)ovirt-guest-agentovirt-guest-agent 64位
4)python OvirtGuestService.py install
5)vim ovirt-guest-agent.ini 修改handler_logfile 中日志的位置
6)设置OVirt-guest-agent自动启动,如下图:
测试
下载testsock.py:wget http://10.254.3.75/images/libvirt/testsocket.py
执行测试脚本:python testsocket.py
运行成功,重启系统看是否成功修改密码为‘123456’
制作完成,上传镜像:
scp bcec-windows-2012-R2-standard-amd64-10G.qcow2 10.254.3.1:/var/
scp bcec-windows-2012-R2-standard-amd64-10G.qcow2 10.254.3.2:/var/
glance image-create --name "ImageName" --disk-format qcow2 --container-format bare --is-public True --min-disk 10 --progress --file /var/bcec-windows-2012-R2-standard-amd64-10G.qcow2