In SkyHiGh all virtual machines boots from images which is stored in the openstack image service (glance). Manipulation of these images is done trough the use of the glance client or trough the web interface. This page explains the glance client:
Image formats
As SkyHiGh utilizes KVM for the virtualization, a large range of image formats are supportet (vhd, vmdk, vdi, iso, qcow2, aki, ari, ami, raw). The preferred format is however raw images, as this enables the compute-node to create a root-disk for the virtual machine which is a COW (Copy-on-write) snapshot of the original image. This way it is not needed to take a full image before the virtual machine is booted. This speeds up the VM boot process a lot.
Determine image format
To determine what format a certain image is, qemu-img can be used like so:
$ qemu-img info trusty-server-cloudimg-amd64-disk1.img image: trusty-server-cloudimg-amd64-disk1.img file format: qcow2 virtual size: 2.2G (2361393152 bytes) disk size: 248M cluster_size: 65536 Format specific information: compat: 0.10 refcount bits: 16
Converting images
To convert images to the raw format, the utility "qemu-img" can be used:
$ qemu-img convert -f <original_image_type> -O <converted_image_type> <original_image> <converted_image>
So, to convert the qcow2 image "debian-8.2.0-openstack-amd64.qcow2" to a raw image, the following command could be used:
$ qemu-img convert -f qcow2 -O raw debian-8.2.0-openstack-amd64.qcow2 debian-8.2.0-openstack-amd64.raw
Uploading new images
To upload a new image to glance, the following command can be useful:
glance image-create --name <image_name> --file <image_location> --disk-format raw --container-format bare --is-public True --progress
For example, the following command would upload an ubuntu image:
glance image-create --name "Ubuntu Server 16.04 (Xenial) amd64" --file xenial-server-cloudimg-amd64-disk1.img.raw --disk-format raw --container-format bare --is-public True --progress
The "–is-public True" flag is used to indicate that all tenants should have access to this image, and the upload would then require admin credentials. In the case of an image upload which should only be accessible to the tenant uploading it, that flag can be omitted.
Change existing images
Creating Windows Images
Cloudbase.it provides tools for creating OpenStack-ready cloud images. They've created a Windows Server 2012R2 images, which is ready for use (download and instructions here). This image is already imported into our environment.
If you need an another Windows Version, you must build the image yourself, with good help from the automated cloudbase-scripts. It is recommended to create the image on a Windows 10 host or VM. The following examples is a list of what we did to create a cloud ready Windows 10 image.
- Install the Windows 10 ADK (download) and choose only Deployment Tools
- Download the Windows 10 Enterprise Evaluation ISO, and mount it in your host/VM (you need to login with your Microsoft account to download ISOs)
- Download the stable amd64 virto-win iso, following this link
- Download the Windows OpenStack Imaging Tools
- Change the following:
UnattendTemplate.xml: Change
InputLocale
andUserLocale
fromen-US
tonb-NO
- Added ntnu_wallpaper.png to the
UnattendResources
-folder - UnattendResources\Specialize.ps1:
- Change the line with
Wallpaper.png
tontnu_wallpaper.png
(do not change the destination filename in the copy-command, as the wallpaper is set through an imported local GPO) - Replace the ICMP-firewall-command with the following to commands:
netsh advfirewall firewall add rule name="All ICMP V4" protocol=icmpv4:any,any dir=in action=allow
andnetsh advfirewall firewall add rule name="All ICMP V6" protocol=icmpv6:any,any dir=in action=allow
- Change the line with
- Create the following powershell-script, modify the three path-variables, and run it:
- CreateOpenStackImage.ps1
Import-Module .\windows-openstack-imaging-tools-master\WinImageBuilder.psm1 $virtualDiskPath = "<C:\path\to\diskfile.raw>" $wimFilePath = "<windowsiso-mountpoint>\sources\install.wim>" $virtIOISOPath = "<C:\path\to\virtio-win-x.x.xxx.iso>" $images = Get-WimFileImagesInfo -WimFilePath $wimFilePath $image = $images[0] New-WindowsCloudImage -WimFilePath $wimFilePath -ImageName $image.ImageName -VirtualDiskFormat RAW -VirtualDiskPath $virtualDiskPath -SizeBytes 18GB -VirtIOISOPath $virtIOISOPath -InstallUpdates
You now have a .raw diskfile, which contains a Windows 10-installation that will automatically run sysprep once booted. Now you have to choices:
- Import the .raw file to glance (see Upload new images), and spawn an instance from the new image
- Create a new local KVM-vm (on a Linux host), be sure to choose a virtio NIC, attach the .raw-file, boot the VM
- Wait for the instance to shutdown (it will install updates, run the powershellscripts
Logon.ps1
,FirstLogon.ps1
andSpecialize.ps1
and finally run sysprep - If you chose 8a, create a public snapshot of the instance. This snapshot is your new cloud ready Windows 10 image.
- If you chose 8b, upload the .raw-file to glance (Upload new images)
When you spawn a Windows instance, be sure to attach a keypair. Cloudbase-init will generate a random password for the user Admin
, which can be retrived with:
nova get-password <instance-id> <private-key-file>