Mass provisioning of VM’s

We have a need to provision a bunch of Linux VM’s relatively quickly. We could do them by hand, but frankly, I’m too lazy to build 150 VM’s by hand. This is a very rough way to do it.

First you need a Customization Specification filled out for each server. It’s entirely scriptable, but I won’t be going into the details of that. This is what the Customization Specification looks like

  <_type>vim.CustomizationSpecItem
 
    <_type>vim.CustomizationSpecInfo
    1274294433
    HandCodedVM1 
    2010-05-19T18:40:33Z
    HandCodedVM1
    Linux
 
    <_type>vim.vm.customization.Specification
 
      <_type>vim.vm.customization.GlobalIPSettings
 
        <_length>2
        <_type>string[]
        10.10.10.11
        10.10.10.12
 
        <_length>1
        <_type>string[]
        MyDomain.com
 
      <_type>vim.vm.customization.LinuxPrep
      sea1.com
 
        <_type>vim.vm.customization.FixedName
        HandCodedVM1
 
      true
      US/Pacific
 
      <_length>1
      <_type>vim.vm.customization.AdapterMapping[]
 
        <_type>vim.vm.customization.AdapterMapping
 
          <_type>vim.vm.customization.IPSettings
 
            <_length>2
            <_type>string[]
            10.10.66.1
 
            <_type>vim.vm.customization.FixedIp
            10.10.66.254
 
          255.255.254.0
 
      <_type>vim.vm.customization.LinuxOptions

I’m going to guess you know your environment well enough to recognize your DNS servers, your default gateway, subnet mask, the servers name, etc. Customize this file with the new settings you need. Once you have your new XML file, you’ll want to name it appropriately and import it into Virtual Center (I haven’t found a way to automate that yet.)

Since that’s done, you just need to fire up PowerShell (I’m using PowerShell on the same box as my Virtual Center.) This too is scriptable, but I haven’t written that script yet either. This is the rough framework you need to get started.

Connect-VIServer localhost (This connects you to the local VC.)
 
new-vm -name HandCodedVM1 -Template LINUX_TEMPLATE -OSCustomizationSpec HandCodedVM1 -VMHost HOST01 -Datastore OS01_NAS

Relatively easy to do, and it will save us a couple of days over doing it manually.