So you want to take a look at CloudPlatform but want more than the CentOS template that is included.   If your like me you need a Windows Server template for this to even be a part of the discussion.  I find that the easiest way to build a template in Citrix CloudPlatform is to first build a VM from scratch and then turn that instance into a template.  This document will walk through the steps needed to do this.  Do understand that you can also build a VM outside CloudPlatform and then import the vhd into the platform as a template.

Why do you want this?  Well once you have this template you can create a service offering in your Cloud for say “Application Server” and have a nice Windows Server provisioned all automatically via a self service portal for your users.

So here we go…

Step 1:  Import Windows install ISO into CloudPlatform

1.  You will need to place your Windows 2012 R2 iso file onto a web server as this is how you get ISO files as well as templates into CloudPlatform.

2.  If this is a local web server you will need to set the secstorage global setting to the IP address of that web server.  This will allow importing from that web server. In a production environment this can be a range or subnet.

3. Enter your IP address and click the Green checkbox 

4. You will see a pop up, click close.

5.  You now need to restart the management service on your CloudPlatform management server

6.  Enter the command

service cloudstack-management restart

7.  Wait for this to finish.

8.  Log back into CloudPlatform and navigate to Templates and click on +Register Template.

9.  Fill out the form with a name and description, the IP address and filename of your ISO file and the OS type.  You can also check Public and Featured.

Note: you should also create a MIME type of ISO and none/none on your IIS server as well as VHD none/none to allow correct access to the files from the server.

10.  Once you click ok you want to wait until you see Upload Complete.

11.  You now have access to the Windows 2012 R2 install ISO for any VM instance you create.

Step 2:  Build your Template VM Instance

  1. Click on Instance
  2. Select + Add Instance
  3. Select ISO from the wizard step 1 page
  4. If you checked Featured for your ISO then you will see it on the next page as shown below
  5. Select an appropriate Compute offering.  (If you have not created one see the admin guide for how to add an offering.)
  6. Select an appropriate disk offering

  7.  Continue through the wizard and then name your VM on the last step.  Clock the Launch button and wait for your VM to be created.

  8. This could take some time.  Once your VM is shown as Running you can open the console to view the Windows 2012 R2 setup screens.


  9. Once you have the console open you will setup Windows 2012 R2 as you would normally.
  10. Install and configure anything you want to include in the template including patches etc.

Step 3:  The Answer File

  1. To really get the feel for the automation you are going to want to create an answer file for the windows setup that you will place on this template VM before you run sysprep.  One way to do this is to download and install the Windows Assessment and Deployment Kit otherwise known as ADK.  You want the latest one as there are multiple versions.  Search for this.
  2. The current URL as of this writing is: http://www.microsoft.com/en-US/download/details.aspx?id=39982
  3. Install that package on your Desktop of PC.  This does NOT get installed in your template VM.
  4. You now need to obtain the install.wim from the Windows 2012 R2 media.  If your on Windows 8.1 you can easily mount ISO files by right clicking them.  You can also just use the CD/DVD media.
  5. Locate the install.wim file in the \sources directory of the install media
  6. Copy that file to a folder on your local system.
  7. Start the Windows System Image Manager, which is part of the Windows ADK
  8. In the Windows Image pane, right click the Select a Windows image or catalog file option to load the install.wim file you just copied
  9. When you load the inastall.wim it will bring up a box with the edition you want to use.  Select the version you used when creating your template VM above.
  10. Click File -> New Answer File and the Image Manager should look like this
  11. Generate the answer file from the Windows System Image Manager.  The first page you need to automate is the Language and Country or Region Selection page.  To automate this, expand Components in your Windows Image pane, right-click and add the Microsoft-Windows-International-Core setting to Pass 7 oobeSystem. In your Answer File pane, configure the InputLocale, SystemLocale, UILanguage, and UserLocale with the appropriate settings for your language and country or region.
  12. You need to automate the Software License Terms Selection page, otherwise known as the End-User License Agreement (EULA). To do this, expand the Microsoft-Windows-Shell-Setup component. High-light the OOBE setting, and add the setting to the Pass 7 oobeSystem. In Settings, set HideEULAPage to true.
     
  13. You need to automate is the Change Administrator Password page. Expand the Microsoft-Windows-Shell-Setup component (if it is not still expanded), expand UserAccounts, right-click on AdministratorPassword, and add the setting to the Pass 7 oobeSystem configuration pass of your answer file. Under Settings, specify a password next to Value
  14.  Make sure the license key is properly set.
  15. Click File -> Save Answer File As and place somewhere on your network where your Template VM can get to it.
  16. From your template VM you need to place that answer file (unattend.xml) in the c:\windows\system32\sysprep filder.

Step 4: Sysprep

  1.  From your Windows 2012 R2 Templkate instance VM open an admin command prompt.
  2. Run the sysprep tool as follows:
    a.  cd c:\Windows\System32\sysprep
    b.  sysprep.exe /oobe /generalize /shutdown
  3. This will then shut the VM down when its done.

Step 5: Create the Template

  1.  Now that your VM is stopped you can click on the quickview + and select View Volumes at the bottom.
  2. From the volume page you can then turn that volume into a template by clicking on Create Template
  3. This will open the Template dialog box.  Enter a name, description, select Windows 2012R2 for the OS Type and click on Public and featured.
  4. Click OK and this will create the template.

This will take some time as what is happening is the volume is being copied from the current hosting cluster’s primary storage to the zone secondary storage.

Once this is complete you can then create other VMs from that template.  This will also leave the current Template VM in CloudPlatform to leverage as well or keep for updates.

If there is interest I can follow this article up with how you would then leverage Citrix CloudPortal Business Manager to leverage this template in a self-service IT store.