http://www.cloudbase.it/create-windows-openstack-images/
We get regularly a lot of requests what to generate Windows OpenStack images, especially for KVM, where the proper Vi Rtio drivers need to be installed.
This article provides all the step required to build one, as we do for the official OpenStack Windows Server-R2 Eval Uation Images
All the scripts is publicly available on Github.
For people familiar with Linux unattended deployment solutions like Kickstart or preseed files, Windows have a roughly SIMI Lar model based on XML files which can is automatically generated with a freely available tool currently called Windows as Sessment and Deployment Kit (ADK in short). The ADK isn't 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 can do some more advanced provisioning by running Y Our own scripts. That's also. The difference is, we split the work in 3 specific areas:
- Synchronouscommands during the Specialize step. The earliest moment in which we can run some custom actions. Scripts'll be executed with the SYSTEM credentials and won ' t being able to access some OS features that is not yet Availab Le, for example WMI. The your script, especially if you expect a reboot to load your features.
- Synchronouscommands During the first logon. These commands get executed when the setup is basically do with the Administrator ' s credentials (or whatever are specifie D in the XML file), just before the user can log in. As a comparison, this is the closest thing-a "post" script in a Kickstart file.
- asysncronouscommands during logon. These commands is executed after the setup and is really useful if you need to execute work this requires an unspecified Number of additional reboots. We use the It mainly to execute Windows updates.
To make things simpler, during all of the above steps we download and execute a Powershell script from the Github reposit Ory instead of adding every single action then we want to run into the XML file. This is a lot more flexibility and troubleshooting issues while writing those scripts becomes a cakewalk, Especia Lly using virtual machine snapshots.
Here is the actions that is performed in Detail:specialize
- The most important feature:setting the Cloudbase Solutions wallpaper.
- Enabling ping response in the firewall (NOTE:RDP access was enabled in the XML file).
- Downloading the Firstlogon script.
Firstlogon
- Detecting what platform we is running on (KVM, Hyper-V, ESXi, etc). This requires WMI and was the reason why this and the next step were not executed during the Specialize phase.
- Installing the relevant platform drivers and tools:virtio drivers on KVM and VMWare tools on ESXi. Nothing was needed on hyper-V, as the relevant tools is already included starting with Windows Server 2008. Note:the VirtIO Drivers is unsigned, so we use a trick to get the job done in a fully unattended.
Important Note: The Fedora VirtIO drivers version 0.1-65 generate a blue screen when you attach a volume. Use the stable version instead.
- Downloading the logon script.
Logon
- Installing Pswindowsupdate, a Powershell module to handle, well, Windows Updates.
- Installing the updates. At the end of each updates round a reboot are performed if needed and after reboot the same step is repeated until the Syst EM is up to date. Might take a while, mostly depending on your Internet connection speed.
- Downloading and installing the latest Cloudbase-init version.
- Finally running Sysprep, using Cloudbase-init ' s unattended.xml and rebooting.
All of the prepare an image, are to start a VM with the Autounattend.xml file on a virtual floppy, the Windows S Erver ISO connected on the first Dvdrom Drive and the optional platform tools (VirtIO drivers, VMWare tools, etc) on the S Econd Dvdrom Drive.
When the image was done, it would shut down automatically, and ready was put in Glance.
Fairly easy, no? How to automate the image creation on KVM
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-dr Ive 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 is going (5901 in the Example). It's very important not to interact with the OS while the scripts run, but it's a great the how things progress. How to automate the image creation on Hyper-V
PowerShell
$vmname = "OpenStack WS-R2 standard Evaluation" # Set the extension to VHD instead of VHDX if you plan to deploy # This image on Grizzly or on windows/hyper-v Server 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 =" Exte Rnal "New-vhd $vhdpath-dynamic-sizebytes (* 1024x768 * 1024x768) $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-R2 Standard Evaluation"
# Set the extension to VHDs instead of VHDX only if you plan to deploy
# This image on Grizzly or on windows/hyper-v Server 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!