[转]Windows Images for OpenStack

This note summarizes articles from other places about Microsoft Windows images for OpenStack creation, along with some first hand experience. The whole process of creating Windows 2008 and Windows 2012 images fully usable on OpenStack instances is described there.

Prerequisite

To achieve the creation of a qcow2 Windows image for OpenStack, we need the following ISO images:

  • An ISO image of the installation DVD for all OSes that we wish to use in OpenStack. These ISOs can usually be downloaded from a company‘s account on Microsoft website, once the appropriate contract has been signed. For testing purpose, Windows Server 2012 Evaluation ISO can be downloaded on Microsoft website.
  • The latest VirtIO drivers for Windows. These are optimized drivers to run Windows OSes with KVM virtualized hard disk controller and network devices.

Base image creation

The first step to build a Microsoft Windows image is to install the OS in a VM as we would have done on a bare metal computer. Gridcentric‘s article about Windows image creation describes this procedure in details.

The steps to follow are:

  • Create an empty qcow2 image (this will be the disk on which we‘ll install our OS). I typically use a 9 GB image for Windows 2008, and a 17 GB for Windows 2012 (although I think it should work with a 11 or 12 GB image). Example:

    $ qemu-img create -f qcow2 Windows-Server-2008-R2.qcow2 9G
  • Next step is to launch Windows‘ installation in a (KVM) virtual machine. The following command is an example for that:
    $ kvm     -m 2048     -cdrom <WINDOWS_INSTALLER_ISO>     -drive file=Windows-Server-2008-R2.qcow2,if=virtio     -drive file=<VIRTIO_DRIVERS_ISO>,index=3,media=cdrom     -net nic,model=virtio     -net user     -nographic     -vnc :9     -k fr     -usbdevice tablet
  • The following step consists in connecting to the display of the VM launched previously through VNC, in order to manually pursue the installation. This can be done with the following command:
    $ xvncviewer <IP_OF_HYPERVISOR>:9
  • During the installation, Windows will ask for the Hard Disk controller driver. We have to select the VirtIO driver, which is located on the VirtIO CDROM (WIN7 directory for Windows 2008, and WIN8 directory for Windows 2012).
  • Once the basic Windows installation is done, we have to set the appropriate Network device driver in the Windows Devices Manager. The Network device VirtIO driver is available in the same directory than the Hard Disk controller driver specified in the previous step.
  • Since VMs will be managed by RDP, we have to activate the service. This is done by navigating through the following menu: Computer (right-lick) -> Properties -> remote tab, and selecting the following option: allow connections from computers running any version of Remote Desktop.
  • An additional step consisting in opening the appropriate Firewall ports is required on Windows 2012: Network (right-click) -> Properties -> Windows Firewall -> Advanced Settings -> Inbound rules. Then enable: Remote Desktop - Shadow, Remote Desktop - User Mode TCP, Remote Desktop - User Mode UDP.

Customizing image for OpenStack

The previous steps allowed us to have Windows fully installed in a KVM virtual machine. The last steps consist in installing Cloud-Init for Windows, a Windows implementation of the Linux based Cloud-Init mechanism. This set of scripts transforms a legacy OS image into a ready for OpenStack image. At instantiation of a VM, Cloud-Init fetches from a meta-data server, data such as ssh public key and hostname that allows the instance to become unique. Cloud-Init base is Open source, and Cloudbase provides an installer on its blog. We‘ll install Cloud-Init by injecting the installer that we just downloaded. To to that, we have to follow these steps:

  • Shutdown Windows
  • Mount the qcow2 image on the hypervisor filesystem, then copy the installer on Windows‘ administrator desktop, with something like:
    $ sudo qemu-nbd -c /dev/nbd2 Windows-Server-2008-R2.qcow2
    $ sudo mount /dev/nbd2p2 mnt/
    $ cp <INSTALLER> <ADMINISTRATOR_DESKTOP_ON_WINDOWS>
    $ sudo umount mnt/
    $ sudo qemu-nbd -d /dev/nbd2
  • Restart Windows in KVM with the same command that we used to install Windows in the first place:
    $ kvm     -m 2048     -cdrom <WINDOWS_INSTALLER_ISO>     -drive file=Windows-Server-2008-R2.qcow2,if=virtio     -drive file=<VIRTIO_DRIVERS_ISO>,index=3,media=cdrom     -net nic,model=virtio     -net user     -nographic     -vnc :9     -k fr     -usbdevice tablet
  • Then connect again with xvncviewer:
    $ xvncviewer <IP_OF_HYPERVISOR>:9
  • This time, we have to launch the CloudbaseInitSetup_Beta.msi installer, and follow the instructions as described on Cloudbase blog. At the end of the installation, we have to check the "run sysprep" option, but not the "shutdown" one. Sysprep is the tool provided by Microsoft to make a VM unique (generates a unique OS ID to be used for some Microsoft services), once it‘s instantiated.
  • Once the installation is done, we can clean any temporary files created, then shutdown the system. The image is ready to be uploaded in OpenStack Glance:
    $ glance add name=<OPENSTACK_IMAGE_NAME> is_public=true     container_format=bare disk_format=qcow2 < <IMAGE_FILENAME>

Connecting to a Windows VM

The usual mechanism used in OpenStack to connect to VMs (running Linux) is ssh. A public key specified by the user launching the VM is set in the default user‘s authorized_keys file. This allows the user to connect to the VM by using the corresponding private key.

However, it is not currently possible to connect to a Windows VM with ssh (there is some work done in this direction that I‘ve not tested yet). Cloud-Init base creates an Admin user, with either:

  • a password specified by the user on the command line. Note that the password must respect Windows password strength constraints (upper and lower case characters, as well as numbers). If not it will be silently ignored. For instance:

    $ nova boot --key-name <KEYPAIR_NAME> --image <IMAGE_ID>     --flavor <FLAVOR_ID> --nic net-id=<NET_ID>     --meta admin_pass=<ADMIN_PASSWORD> <VM_NAME>
  • a password automatically generated during VM instantiation, and encrypted with the ssh public key provided when launching the VM. Such password can be retrieved and decrypted with the corresponding private ssh key, by using the following command (note that the private key is used locally):
    $ nova get-password <VM_NAME_OR_ID> <SSH_PRIVATE_KEY>

Note that to connect to a Windows VM from Linux, prefer using xfreerdp instead of rdesktop. The pointer is bogus when connecting to a windows 2012 VM using rdesktop.

[转]Windows Images for OpenStack

时间: 2024-10-10 17:21:16

[转]Windows Images for OpenStack的相关文章

Windows Images for OpenStack

This note summarizes articles from other places about Microsoft Windows images for OpenStack creation, along with some first hand experience. The whole process of creating Windows 2008 and Windows 2012 images fully usable on OpenStack instances is de

OpenStack云桌面系列【2】—Openstack和Spice

OpenStack和VNC Openstack默认安装的访问控制台基于VNC的,我们从Horizon进入主机实例的控制台,就是noVNC,我在之前的一篇文章里专门对noVNC也做过测试(http://blog.csdn.net/chao_beyond/article/details/24922397).这里不讨论noVNC的原理,主要罗列下我在使用OpenStack过程当中,关于VNC的几点记录: 1, 通过nova  get-vnc-console <server id>  novnc命令,

Windows API参考大全新编

书名:新编Windows API参考大全 作者:本书编写组 页数:981页 开数:16开 字数:2392千字 出版日期:2000年4月第二次印刷 出版社:电子工业出版社 书号:ISBN 7-5053-5777-8 定价:98.00元 内容简介 作为Microsoft 32位平台的应用程序编程接口,Win32 API是从事Windows应用程序开发所必备的.本书首先对Win32 API函数做完整的概述:然后收录五大类函数:窗口管理.图形设备接口.系统服务.国际特性以及网络服务:在附录部分,讲解如何

VMware vSphere :服务器虚拟化

前言 现在云计算和容器化越来越流行,大家开口闭口都是阿里云.腾讯云,或者 Kubernetes.容器.镜像.Docker 这样的字眼. 越来越多的中小公司选择把自己的服务进行拆分,微服务化,然后部署在各大云服务平台上. 但是云服务虽然好,开发环境总还是要在公司内部,为了方便维护硬件,虚拟化方案就显得很必要了. 一旦讲到服务器虚拟化,基本上就绕不开 Openstack 和 VMware,VMware 就像是操作系统领域的 Windows,而 Openstack 就相当于 VMware 的开源弱化版

openstack镜像之Windows(可重置密码)

环境声明: os windows2008r2 openstack mitaka 本文修改主机密码的方式为 metadata 注入方式,在云主机内部再配合一个修改密码.重置密码的脚本,达到修改.重置云主机密码的作用: 目前修改.重置密码的脚本都是python脚本,所以做此镜像需要在镜像中安装python,pywin32才行,因为目前测试的结果是,cloud-init在windows系统中,只会在初始化的时候启动一次,之后便不会再启动了,所以还有一个重置密码的脚本,重置密码的脚本会在系统中生成一个r

制作openstack windows镜像模板(官方镜像)

一.硬件及软件准备 1.物理机一台:要求支持硬件虚拟化,将centos7安装在物理机上 2.windows7的ISO ,可使用任意官方镜像,此处以windows7-x86为例. 3.下载virtio驱动 因为win默认不支持virtio驱动,而通过openstack管理虚拟机是需要virtio驱动的.需要两个virtio驱动,一个是硬盘的,一个是网卡 . 备注:要求对虚拟机进行内存监控,故在模版制作过程中需要安装virtio-balloon驱动 下载地址一: https://fedoraproj

[转] How to create Windows OpenStack images

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 r

Openstack中给windows加载virtion驱动

通过qemu-img将windows虚拟机的vmdk文件转换成qcow2,并将文件上传至openstack中时,发现虚拟机无法启动. 经过分析,原因是openstack默认使用的是virtio驱动,而windows虚拟机未安装virtion驱动. 解决办法:安装VirtIO驱动 1.通过virt-manager打开windows虚拟机 2.磁盘.网卡使用默认驱动,即磁盘使用ide.网卡使用rt 3.添加一块floopy设备 4.添加一块临时硬盘,设置为virtio模式 5.启动虚拟机,为新磁盘.

Openstack中给windows虚拟机加载virtion驱动

通过qemu-img将windows虚拟机的vmdk文件转换成qcow2,并将文件上传至openstack中时,发现虚拟机无法启动. 经过分析,原因是openstack默认使用的是virtio驱动,而windows虚拟机未安装virtion驱动. 解决办法:安装VirtIO驱动 1.通过virt-manager打开windows虚拟机 2.磁盘.网卡使用默认驱动,即磁盘使用ide.网卡使用rt 3.添加一块floopy设备 4.添加一块临时硬盘,设置为virtio模式 5.启动虚拟机,为新磁盘.