Porting Windows to OpenStack

This blog post is a walk-through for porting the Windows operating system to OpenStack. It covers the following subjects:

  • Creating a New Windows KVM Image
  • Windows Install Using the VirtIO Hard Drive Driver
  • Configuring Windows Base Image
  • Windows Sysprep for OpenStack
  • Deploying the Windows Image to OpenStack
  • Running the First Windows Instance

It assumes that you are running OpenStack Bexar on Ubuntu 10.10 on a single developer workstation. You will need to get the KVM VirtIO Drivers for Windows ISO.

For information about KVM VirtIO drivers see: Windows VirtIO Drivers.

The drivers used for this walk-through can be found here: Download Latest VirtIO Win drivers from Fedora.

Creating a New Windows KVM Image

The section walks-through the building of a Windows KVM Image using Virtual Machine Manager 0.8.4.

1. Using Virtual Machine Manager create a new virtual machine.

2. In the New VM dialog box enter the Name of the new virtual machine.

3. Click Next.

4. On the Step 2 of 5 page, select the correct install media, Select the OS type and Version and click the Forward button.

5. On the Step 3 of 5 page, enter in the Memory and CPUs, and click Forward.

6. On the Step 4 of 5 page, uncheck the Enable storage for this virtual machine check box, and click Forward.

7. On the Step 5 of 5 page, click the Customize configuration before install check box, and click the Finished button.

8. On the virtual machine configuration before install screen, select the NIC device. In the Device model drop-down box, select virtio, click Apply.

9. Click the Add Hardware button.

10. On the Add new virtual hardware dialog box, Forward.

11. Enter in the image size, in the Device type drop-down box select the Virtio Disk option, and click the Forward button.

12. On the Finish Adding Virtual Hardware page, click the Finish button.

13. NOTE: Notice the Disk image location and file name (i.e., var/lib/libvirt/images/2011041901A.img). This is the location of your KVM image file that will be moved to OpenStack later.

14. Click on Boot Options, and notice the Boot device order is set to CDROM. Click the green check mark button.

15. The new virtual machine will now start.

Windows Install Using the VirtIO Hard Drive Driver

The section walks-through the Windows install using the VirtIO network driver. Before getting started you will need to setup a CDROM drive for the VirtIO drivers.

1. Shutdown the virtual machine using the Virtual Machine/Shut Down/Shut Down or Virtual Machine/Shut Down/Force Off menu options.

2. Select the View/Details menu option in the Virtual Machine Manager interface. NOTE: The last CDROM device is the one that will boot so you’ll need to map IDE CDROM 1 to the VirtIO driver ISO and create a second IDE CDROM 2 for the Windows CDROM.

3. Map the IDE CDROM 1 to the VirtIO driver ISO.

4. Create and map the second IDE CDROM 2 for the Windows CDROM.

5. Start the new virtual machine, when the Install Windows dialog box appears, click the Next button.

6. Click the Install now button.

7. Click the Next button.

8. This walk-through will install Windows Web Server 2008 R2 (Full Installation).
After selecting the Operating system version in the list box, click Next.

9. Check the I accept the license terms check box, and click Next.

10. Click on the Custom (advanced) installation option.

11. On the Where do you want to install Windows page, you notice the error message on the bottom of the page that says, “No drives were found.

12. Click the Load Driver link. On the Load Driver dialog box, click Browse.

13. In the Browse for Folder dialog box, drill down into the CDROM\viostor\Win7\amd64\ directory and click the OK button.

14. Windows Install will list the Red Hat VirtIO SCSI controller (E:\viostor\Win7\amd64\viostor.inf) driver. Click Next.

15. Windows Install will load the driver and locate Disk 0.

16. On the Where do you want to install Windows? page, click the Next button.

17. IMPORTANT: Once Windows Install is complete, you’ll need to stop the KVM guest, remove the install media, Remove the IDE CDROM 2 device.  You’ll be left with the IDE CDROM 1 device.

18. Change the Boot Options to Hard Disk (be sure to hit Apply).

19. Start your new Windows KVM image.

20. Wait while setup completes, enter in your administrative password, and move on to configuration.

Configuring Windows Base Image

The section walks-through the process to configure the VirtIO network driver.

1. Open Device Manager, and locate the Ethernet Controller under Other devices.

 2. Use the Update Driver Software context menu, and click the Browse my computer for driver software in the Update Driver Software – Ethernet Controller dialog box.

3. On the Browse my computer for driver software page, click the Browse… button, browse to the CDROM\NetKVM\Vista\amd64\ folder, click OK, and Next.

4. On the Windows Security dialog box, click the Install button.

5. After Windows installed the driver the Update Driver Software – Red Hat VirtIO Ethernet Adapter dialog will appear. Click close to complete the VirtIO network driver install.

6. Reboot the machine and verify that the driver is working properly.

NOTE: If the network is not connecting it is probably that the NIC Source device is incorrect. When using Virtual Machine Manager during the install it will grab the first bridge it finds (e.g., br100) and use it as the Source device for the NIC. To get your NIC connected to the network, Remove the current NIC and use Add Hardware to create new NIC with the correct Source device.

7. After you have a working NIC, run Windows Update to fully patch the guest virtual machine.

Windows Sysprep for OpenStack

The goal of this walk-through is to create a Windows sysprep image that can be used by OpenStack to spin up unique instances of Windows. The implementation utilizes sysprep, System Image Manager for creating the unattend.xml, and the RunSynchronousCommand in the specialized pass.

This document is not intended as a tutorial for these technologies.

The following links will be help to understand these technologies in order to craft a sysprep solution to meet your needs:

How Sysprep Works
How Configuration Passes Work
RunSynchronousCommand
Windows System Image Manager Technical Reference

The single biggest distinction between creating a Windows image for the OpenStack cloud vs. a hypervisor, such as KVM, Hyper-V, VMware, etc., is the image’s interface with the cloud’s Metadata Interoperability Layer for accessing data during instancing. OpenStack implements a Metadata Interoperability Layer API that is compatible with Amazon’s EC2 API.

The Windows base image that is illustrated here utilizes a custom unattend.xml file for sysprep that contains a RunSynchronousCommand. The RunSynchronousCommand calls a custom executable that calls the OpenStack metadata API at http://169.254.169.254/latest/user-data/ to pull user specified data (e.g., Administrator password) for configuration data. The custom executable than takes the configuration data and slams it into the cached copy of the unattend.xml file for sysprep to use to customize the Windows OS.

The following steps detail Windows Server configurations that will help you with your port to OpenStack and conclude with the sysprep command.

1. Enable Windows Remote Desktop.

2. Add the .NET Framework 3.5.1. Feature.

3. Run Windows update.

4. Install your custom sysprep solution (e.g., unattend.xml, custom executable, etc.)

Please feel free to contact me if you need a consultant to design, develop and deploy your custom solution!

5. Open CMD as Administrator and run the following sysprep command:

C:\windows\System32\sysprep\sysprep.exe /generalize /oobe /shutdown

Deploying the Windows Image to OpenStack

The following is a manual process to deploy your new a Windows base image. Please note that in the Cactus release this process is automated.

1. Open up terminal.

2. Load the Nova environment variables.

. ~/novarc

3. Create a new image directory in OpenStack to hold the Windows image file. We will use the directory name requirements based on the next version of OpenStack (i.e., “Cactus”) which requires 32bit Hex named directories.

sudo mkdir /var/lib/nova/images/77de106d

4. Copy the new image to the new the OpenStack image directory.

sudo cp /var/lib/libvirt/images/2011041901A.img /var/lib/nova/images/77de106d/image

5. Create the info.json file for the new image.

{
“imageId”: “77de106d”,
“imageLocation”: “77de106d”,
“imageOwnerId”: “admin”,
“imageState”: “available”,
“type”: “machine”,
“isPublic”: true,
“architecture”: “x86_64”
}

6. Change permissions on the directory.

sudo chown -R nova 77de106d/

 7. List the OpenStack images – you should see the new image, 77de106d listed as available.

euca-describe-images

8. Set the Administrator account password.

euca-run-instances -d ‘test!123’ -t m1.medium 77de106d

9. Verify that the metadata service address in OpenStack is up and available.

ip addr | grep 169

You should see:

inet 169.254.169.254/32 scope link lo

If you do not see the metadata service address, add the IP address to the interface (Cactus will automatically add the metadata service IP address to the OpenStack interface).

sudo ip addr add 169.254.169.254/32 scope link dev lo

10. Spin up the image.

euca-run-instances 77de106d

11. Check the instance.

euca-describe-instances

You should see something like the following:

RESERVATION r-mz8d9bzc admin default

INSTANCE i-00000009 77de106d 10.0.0.4 10.0.0.4 launching None (admin, PSMWKS20) 0

12. Once the status changes from launching to running your new Windows instance is now accessible via remote desktop.

Advertisements

About Sawtooth Punk

President and CEO of Big Wood Software, Inc., a Ketchum-based software firm that specializes in developing and marketing mobile and cloud applications that leverage the power and reach of social media. Over the past 15 years, William has founded and led a number of startups, raised private capital, and successfully launched products and services sold to consumer and enterprise customers. As a highly skilled software engineer, he has built real-time, high-volume, scalable and secure transactional systems that manage billions of dollars in assets for leading financial firms such as Goldman Sachs and Dodge & Cox. He was also a contributor to NASA’s Nebula private cloud. William holds a Bachelors degree in Economics from the University of New Mexico. He and his wife Angie moved their family from San Francisco, CA to Ketchum, ID in June 2013 to embrace a healthier, more balanced lifestyle. They are both excited to get involved with the local community and create living wage jobs for more families who want to be here year round.
This entry was posted in KVM, Private Cloud, Windows Image, Windows on OpenStack and tagged , , , . Bookmark the permalink.

4 Responses to Porting Windows to OpenStack

  1. Pingback: SquareCows.com » Community Weekly Newsletter (June 17 – 24)

  2. IvanZito says:

    My name is Ivanzito, congratulations.
    The article is very good. Thank you.

  3. Tahir says:

    Great article! We are trying to automate this on KVM hypervisor and using Libguestfish to inject “Unattend.xml” in Windows folder on run time as soon as the machine gets cloned from the template. . We have placed a .bat file in the template with the following command in it

    start /Windows/system32/sysprep/sysprep.exe /oobe /generalize /unattend:/Windows/Panther/unattend.xml

    As soon machine boots up, a task in Windows Task scheduler runs this bat script and does sysprep. The problem we are facing in that is, sometimes machines get stuck in “Recovery mode” for some reason. Looks like it doesn’t like the file injected by Libguestfish. Do you have any recommendations to improve this process?

    Please note that we have already automated the machines provisioning process and want to automate sysprep on these machines too.

    I await your response…

  4. Syble says:

    Its hard to find knowledgeable people on this topic, but you sound like you know what youre talking about! Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s