设为首页 收藏本站
查看: 893|回复: 0

[经验分享] [转]Windows Images for OpenStack

[复制链接]

尚未签到

发表于 2015-4-12 09:06:46 | 显示全部楼层 |阅读模式
  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  \
    -drive file=Windows-Server-2008-R2.qcow2,if=virtio \
    -drive file=,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 :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  
    $ 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  \
    -drive file=Windows-Server-2008-R2.qcow2,if=virtio \
    -drive file=,index=3,media=cdrom \
    -net nic,model=virtio \
    -net user \
    -nographic \
    -vnc :9 \
    -k fr \
    -usbdevice tablet
  •   Then connect again with xvncviewer:

    $ xvncviewer :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= is_public=true \
    container_format=bare disk_format=qcow2 <

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  --image  \
    --flavor  --nic net-id= \
    --meta admin_pass=
  •   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  
  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.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-56172-1-1.html 上篇帖子: Ubuntu Cloud Image in Openstack 下篇帖子: 【转】 [官版翻译]OpenStack centos版安装(五)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表