Virtual Machine Templates in System Center 2012 SP1 VMM: Build Your Private Cloud (Series)

Today’s blog post in our “Build Your Private Cloud in a Month” series is the fourth of a 5-part mini-series we’re calling “Deploying Private Cloud Workloads”.  This week we (Kevin Remde, Blain Barton and I) are going to detail and demonstrate some of the key areas in System Center 2012 SP1 Virtual Machine Manager that support the foundational concepts and objects in your Private Cloud environment.  The mini-series parts are listed here:
1.  Hardware Profiles (Monday)

2.  Guest OS Profiles (Tuesday)

3.  Application Profiles (Wednesday)

4.  VM Templates (Thursday) <—Today!

5.  Service Templates (Friday)

Required if following along in the lab:

System Center 2012 w/SP1 Virtual Machine Manager should be installed properly on the domain with at least one Hyper-V host managed in the instance.  For my lab guide on deploying VMM check here:

http://www.virtuallycloud9.com/index.php/2013/04/build-your-private-cloud-installing-virtual-machine-manager-step-by-step/

What is a VM Template?

VM templates are preconfigured virtual machines images and configurations that are included in the library of Virtual Machine Manager(VMM), which are used for deploying new virtual machines into the environment.

Why is a VM Template useful?

Let’s suppose you have a gold image of Server 2012 that has software and settings customized to your particular needs by templating this image, it can be used to deploy future virtual servers without the need to walk through the same post OS installation steps time and time again.  VM templates can also be used as part of a VMM Service deployment as well, where a group of VMs are deployed to handle a given workload.  In this case, a web server might already be configured to work in a load balancing scenario so that the deployment of an extra VM into the cloud service takes minimal time. We will not be tackling cloud services in this module today however.

How do I create a Virtual Machines template?

There are two methods for importing virtual machine templates into the library.

1. Importing from a current template or virtual disk already in the library

2. Importing a template from a machine currently presented on a Hyper-V host

In today’s article I will tackle the first of these options.  For this exercise I will be using the prepped default image for Server 2012 which can be downloaded here: http://aka.ms/ws2012tp First we need to copy the prepped VHD to the VMM library share.  On my lab environment this is located at \vmm01MSSCVMMLibraryVHDs

When finished it should look like this:

00a

Now we may need to refresh the library, since the system only scans the library for new templates and VHDs every hour by default.  Open up the Powershell ISE and issue the following commands:

Set-ExecutionPolicy  -ExecutionPolicy  RemoteSigned

Import-Module  -Name  “virtualmachinemanager”

Set-SCVMMServer  -LibraryRefresherEnabled  $True  -LibraryRefresherFrequency  1

002

Back in the VMM Console select Library from the bottom left of the screen and then right click VM Templates.  Select “Create VM Template”:

image

The first option is already highlighted for us, simply click on Browse and then select the Server2012.VHD file from the list shown, and then click on OK.  Click Next.

image

Now we must give our template a name.  Notice in the illustration below that I followed the server name with XXXX.  During the Hardware profiles setup we can tell the VMM system to automatically assign a subsequent number in place of the #### for each machine deployed.  This is especially handy in cloud environments.  Kevin covered the details on this in his prior posts on profiles(see links above for the series). In the case of this particular article I will pretend that we have no hardware profiles created yet.

image

Per the main SCVMM Technet article on templates, consider the following before finishing the hardware profile:

  • If you intend to deploy the virtual machine to a private cloud, under Capability you must select a cloud capability profile that is supported by the private cloud.
  • If you configure a network adapter to use static IP addresses, you must also set the media access control (MAC) address to static.
  • In System Center 2012 (without Service Pack 1 (SP1)), it is a known issue that the Enable spoofing of MAC addresses check box does not actually change the setting. You must enable spoofing of MAC addresses if you want to deploy a service to a Windows Server 2008 R2–based Hyper-V host (with or without SP1) with Network Load Balancing (NLB) enabled. To enable MAC spoofing, you must first create the template and then use the Virtual Machine Manager (VMM) command shell to configure the setting either in the template or in the hardware profile that you use for the template. For more information, see the Windows PowerShell commands in How to Configure NLB for a Service Tier.
  • If you are running System Center 2012 SP1 and the virtual machine will be on a host cluster, you can configure virtual machine priority for the virtual machine. For more information, see How to Configure Priority for a Virtual Machine on a Host Cluster in System Center 2012 SP1.

Notice that I have the options of a normal virtual machine now ready to be configured.  One thing I wish to highlight is the “Compatibility” section, here we can tell VMM which host types this template can apply to within our private cloud deployment.  I selected Hyper-V of course.

image

Now let’s assign the default CPU count, memory, network connection and other settings required for your installation.  Save the Hardware profile and set it in the drop down list then click Next.

image
image
image
image

The next window has us configure the operating system, join a domain, set a product key, admin password(recommended) and other settings.  In this example I provided server#### for the Identity information, set the OS to 64 Bit Windows Server, and supplied an administrator password.  Since Kevin covered this topic in detail in the prior posts we will continue you on.  Click next once you have allocated the proper profile or created one.

image

Note: Application deployment settings do not apply if you use the template for stand-alone virtual machines that are not part of a service. Click Next.

image

Select the OS Compatibility options that best work with the application in the service.  Again this is only required when creating cloud services or templates.

image

Note: SQL Server settings do not apply if you use the template for stand-alone virtual machines that are not part of a service. Click Next.

image

Select to view the Script if desired, then click Create:

image

The Jobs window will display the template creation process status.  When the status says Completed we can close the window.

image

Back in the main console of VMM, right click the newly made template and click Create Virtual Machine:

image

Since we provided a variable for the server name in the profile there is no need to provide one here, click Next:

image

This section of the wizard lets you review and change any of the parameters for this particular VM deployment, if no changes are desired click Next:

image
image

Now we have the option of placing the VM on a host of our choice or letting the wizard decide which host is best.  Click Next:

image

Notice that the wizard presents us with any Hyper-V hosts that belong to this instance of VMM, the status of the host is displayed along with a Rating.  The rating is the VMM’s overall view of performance of the Hyper-V host.  CPU usage, Memory consumption, Disk I/O, and Network utilization are considered.  Select the host and click Next:

image

Review the settings provided by the profiles and then click Next:

image

Next we need to add a property for this VM which will tell the Hyper-V host whether the VM should be booted up in the event of a host reboot.   The bottom selection might be a wiser choice in some datacenters in order to keep retired VMs not yet removed from production from booting up.  Click Next:

image
image

If you wish the VM to start up as soon as it is finished with deployment, select the box and then click Next:

image

Your VM is now ready for use once the Jobs window shows a status of Completed:

image

To verify the VM is complete view it in the VMM Console or launch Hyper-V manager and login to the console of the virtual machine:

image

We hope you enjoy the series, please check back for the next post soon!

Additional reading: http://technet.microsoft.com/en-us/library/hh882403.aspx

Comments

TechNet Blogs

[...] Define and Deploy VM Templates by Tommy Patterson [...]

TechNet Blogs

[...] Define and Deploy VM Templates by Tommy Patterson [...]