Windows OpenStack Imaging Tools automates the generation of Windows images.
The tools are a bundle of PowerShell modules and scripts.
The supported target environments for the Windows images are:
- OpenStack with KVM, Hyper-V, VMware and baremetal hypervisor types
- MAAS with KVM, Hyper-V, VMware and baremetal
The generation environment needs to be a Windows one, with Hyper-V virtualization enabled.
If you plan to run the online Windows setup step on another system / hypervisor, the Hyper-V virtualization is not required.
The following versions of Windows images (both x86 / x64, if existent) to be generated are supported:
- Windows Server 2008 / 2008 R2
- Windows Server 2012 / 2012 R2
- Windows Server 2016
- Windows 7 / 8 / 8.1 / 10
To generate Windows Nano Server 2016, please use the following repository:
https://github.com/cloudbase/cloudbase-init-offline-install
- A Windows host, with Hyper-V virtualization enabled, PowerShell >=v4 support
and Windows Assessment and Deployment Kit (ADK) - A Windows installation ISO or DVD
- Windows compatible drivers, if required by the target environment
- Git environment
- Clone this repository
- Mount or extract the Windows ISO file
- Download and / or extract the Windows compatible drivers
- If the target environment is MAAS or the image generation is configured to install updates,
the windows-curtin-hooks and WindowsUpdates git submodules are required.
Rungit submodule update --init
to retrieve them - Import the WinImageBuilder.psm1 module
- Use the New-WindowsCloudImage or New-WindowsOnlineCloudImage methods with
the appropriate configuration options
git clone https://github.com/cloudbase/windows-openstack-imaging-tools.git
pushd windows-openstack-imaging-tools
Import-Module .\WinImageBuilder.psm1
# The Windows image file path that will be generated
$windowsImagePath = "C:\images\my-windows-image.qcow2"
# The wim file path is the installation image on the Windows ISO
$wimFilePath = "D:\Sources\install.wim"
# Every Windows ISO can contain multiple Windows flavors like Core, Standard, Datacenter
# Usually, the first image version is the Core one
$image = (Get-WimFileImagesInfo -WimFilePath $wimFilePath)[0]
$virtIOISOPath = "C:\images\virtio.iso"
# Note(avladu): Do not use stable 0.1.126 version because of this bug https://github.com/crobinso/virtio-win-pkg-scripts/issues/10
$virtIODownloadLink = "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.133-2/virtio-win.iso"
# Download the VirtIO drivers ISO from Fedora
(New-Object System.Net.WebClient).DownloadFile($virtIODownloadLink, $VirtIOISOPath)
New-WindowsOnlineImage -WimFilePath $wimFilePath -ImageName $image.ImageName `
-WindowsImagePath $windowsImagePath -Type 'KVM' -VirtioISOPath $virtIOISOPath `
-SizeBytes 30GB -CpuCores 4 -Memory 4GB -SwitchName 'external'
popd
This command does not require Hyper-V to be enabled, but the generated image
is not ready to be deployed, as it needs to be started manually on another hypervisor.
The image is ready to be used when it shuts down.
You can find a PowerShell example to generate a raw OpenStack Ironic image that also works on KVM
in Examples/create-windows-cloud-image.ps1
This command requires Hyper-V to be enabled, a VMSwitch to be configured for external
network connectivity if the updates are to be installed, which is highly recommended.
This command uses internally the New-WindowsCloudImage
to generate the base image and
start a Hyper-V instance using the base image. After the Hyper-V instance shuts down,
the resulting VHDX is shrinked to a minimum size and converted to the required format.
You can find a PowerShell example to generate a raw OpenStack Ironic image that also works on KVM
in Examples/create-windows-online-cloud-image.ps1
You will need PowerShell Pester package installed on your system.
It should already be installed on your system if you are running Windows 10.
If it is not installed you can install it on Windows 10 or greater:
Install-Package Pester
or you can clone it from: https://github.com/pester/Pester
Running the tests in a closed environment:
cmd /c 'powershell.exe -NonInteractive { Invoke-Pester }'
This will run all tests without polluting your current shell environment.
This is not needed if you run it in a Continuous Integration environment.