http://www.cloudbase.it/create-windows-openstack-images/
We get regularly a lot of requests about how to generate Windows OpenStack images, especially for KVM, where the proper VirtIO drivers need to be installed.
This article provides all the step required to build one, as we did for the official OpenStack Windows Server 2012 R2 Evaluation images
All the scripts are publicly available on Github.
For people familiar with Linux unattended deployment solutions like kickstart or preseed files, Windows has a roughly similar model based on XML files which can be automatically generated with a freely available tool currently called Windows Assessment and Deployment Kit (ADK in short). The ADK is not necessary if you’re fine with tweaking XML files manually as we usually do.
Kickstart and Preseed files in Linux provide a “post” script where you can do some more advanced provisioning by running your own scripts. That’s also what we do here. The difference is that we split the work in 3 specific areas:
To make things simpler, during each of the above steps we download and execute a Powershell script from the Github repository instead of adding every single action that we want to run into the XML file. This way we have a lot more flexibility and troubleshooting issues while writing those scripts becomes a cakewalk, especially using virtual machine snapshots.
Here are the actions that are performed in detail:
Important note: The Fedora VirtIO drivers version 0.1-65 generate a blue screen when you attach a volume. Use the stable version instead.
All you have to do to prepare an image, is to start a VM with the Autounattend.xml file on a virtual floppy, the Windows Server ISO connected on the first DVDRom drive and the optional platform tools (VirtIO drivers, VMWare tools, etc) on the second DVDRom drive.
When the image is done, it will shut down automatically, ready to be put in Glance.
Fairly easy, no?
Shell
IMAGE=windows-server-2012-r2.qcow2 FLOPPY=Autounattend.vfd VIRTIO_ISO=virtio-win-0.1-52.iso ISO=9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO KVM=/usr/libexec/qemu-kvm if [ ! -f "$KVM" ]; then KVM=/usr/bin/kvm fi qemu-img create -f qcow2 -o preallocation=metadata $IMAGE 16G $KVM -m 2048 -smp 2 -cdrom $ISO -drive file=$VIRTIO_ISO,index=3,media=cdrom -fda $FLOPPY $IMAGE \ -boot d -vga std -k en-us -vnc :1
IMAGE=windows-server-2012-r2.qcow2
FLOPPY=Autounattend.vfd
VIRTIO_ISO=virtio-win-0.1-52.iso
ISO=9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO
KVM=/usr/libexec/qemu-kvm
if [ ! -f "$KVM" ]; then
KVM=/usr/bin/kvm
fi
qemu-img create -f qcow2 -o preallocation=metadata $IMAGE 16G
$KVM -m 2048 -smp 2 -cdrom $ISO -drive file=$VIRTIO_ISO,index=3,media=cdrom -fda $FLOPPY $IMAGE \
-boot d -vga std -k en-us -vnc :1
Note: don’t forget to open the VNC port on the hypervisor’s firewall if you want to check of things are going (5901 in the example). It’s very important not to interact with the OS while the scripts run, but it’s a great way to see how things progress.
PowerShell
$vmname = "OpenStack WS 2012 R2 Standard Evaluation" # Set the extension to VHD instead of VHDX only if you plan to deploy # this image on Grizzly or on Windows / Hyper-V Server 2008 R2 $vhdpath = "C:\VM\windows-server-2012-r2.vhdx" $isoPath = "C:\your\path\9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO" $floppyPath = "C:\your\path\Autounattend.vfd" # Set the vswitch accordingly with your configuration $vmSwitch = "external" New-VHD $vhdpath -Dynamic -SizeBytes (16 * 1024 * 1024 * 1024) $vm = New-VM $vmname -MemoryStartupBytes (2048 * 1024 *1024) $vm | Set-VM -ProcessorCount 2 $vm.NetworkAdapters | Connect-VMNetworkAdapter -SwitchName $vmSwitch $vm | Add-VMHardDiskDrive -ControllerType IDE -Path $vhdpath $vm | Add-VMDvdDrive -Path $isopath $vm | Set-VMFloppyDiskDrive -Path $floppyPath $vm | Start-Vm
$vmname = "OpenStack WS 2012 R2 Standard Evaluation"
# Set the extension to VHD instead of VHDX only if you plan to deploy
# this image on Grizzly or on Windows / Hyper-V Server 2008 R2
$vhdpath = "C:\VM\windows-server-2012-r2.vhdx"
$isoPath = "C:\your\path\9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO"
$floppyPath = "C:\your\path\Autounattend.vfd"
# Set the vswitch accordingly with your configuration
$vmSwitch = "external"
New-VHD $vhdpath -Dynamic -SizeBytes (16 * 1024 * 1024 * 1024)
$vm = New-VM $vmname -MemoryStartupBytes (2048 * 1024 *1024)
$vm | Set-VM -ProcessorCount 2
$vm.NetworkAdapters | Connect-VMNetworkAdapter -SwitchName $vmSwitch
$vm | Add-VMHardDiskDrive -ControllerType IDE -Path $vhdpath
$vm | Add-VMDvdDrive -Path $isopath
$vm | Set-VMFloppyDiskDrive -Path $floppyPath
$vm | Start-Vm
Check the README file of the project for updates, we’re definitely going to add more hypervisor options!
[转] How to create Windows OpenStack images,布布扣,bubuko.com
[转] How to create Windows OpenStack images
原文地址:http://www.cnblogs.com/popsuper1982/p/3816358.html