Creating an Image Profile by cloning an existing one

If you prefer practice to theory then this is the ideal book for learning how to install and configure VMware vSphere components. Packed with recipes, it’s a hands-on tutorial and reference guide for this unbeatable virtualization product.

(For more resources related to this topic, see here.)

How to do it

The following procedure will guide you through the steps required to clone a predefined ESXi Image Profile available from an ESXi Offline Bundle.

It is a four step process:

  1. Verifying the existence of a Software Depot in the current session.
  2. Adding a Software Depot.
  3. Listing available Image Profiles.
  4. Cloning an Image Profile to form a new one.

Verifying the existence of a Software Depot in the current session

To verify whether there are any existing Software Depots defined in the current PowerCLI session, issue the following command:

$DefaultSoftwareDepots

Note that the command has not returned any values. Meaning, there are no Software Depots defined in the current session. If the needed Software Depot was already added then the command output will list the depot. In that case, you can skip step 2, Add a Software Depot, and start with step 3, List available Image Profiles.

Adding a Software Depot

Before you add a Software Depot, make sure that you have the Offline Bundle saved on to your local disk. The Offline Bundle can be downloaded from VMware's website or from the OEM's website. The bundle can either be an ESXi Image or a device driver bundle.

We already have the Offline Bundle downloaded to the C:\AutoDeploy-VIBS directory.

Now, let's add this to the current PowerCLI session.

To add the downloaded Software Depot, issue the following command:

Add-EsxSoftwareDepot -DepotUrl C:\AutoDeploy-VIBS\ESXi500-201111001.zip

Once the Software Depot has been successfully added to the PowerCLI session, the command $DefaultSoftwareDepots should list the newly added Software Depot.

You could also just issue the command Get-EsxSoftwareDepot to list all the added depots (Offline Bundles).

Listing available Image Profiles

Once the Software Depot has been added, the next step will be to list all the currently available Image Profiles from the depot by issuing the following command:

Get-EsxImageProfile

We see that there are two image profiles that the ESXi Offline Bundle offers. One is an ESXi Image, with no VMware Tools ISOs bundled with it, and the other is the standard image, with the VMware Tools ISOs bundled with it.

Cloning an Image Profile to form a new one

Now that we know there are two Image Profiles available, the next step will be to clone a needed Image Profile to form a new one. This is done by using the New-ESXImageProfile cmdlet. The cmdlet can be supplied with the name of the Image Profile as an argument. However, in most cases remembering the names of the Image Profiles available would be difficult. So the best way to work around this difficulty is to define an array variable to hold the names of the Image Profiles and then the array elements (Image Profile names) can be easily and individually addressed in the command.

In this example, we will be using a user defined array variable $profiles to hold the output of the command Get-EsxImageProfile.

The following expression will save the output of the Get-ESXImageProfile command to a variable $profiles.

$profiles = Get-EsxImageProfile

The $profiles variable now holds the two Image Profile names as array elements [0] and [1] sequentially.

The following command can be issued to clone the array element [1] ESXi-5.1.10-799733-standard to form a new Image Profile, with a user defined name Profile001.

New-EsxImageProfile -CloneProfile $profiles[1] -Name "Profile001" -Vendor VMware

Once the command has been successfully executed, you can issue the Get-EsxImageProfile command to list the newly created Image Profile.

How it works

The PowerCLI session will have a list of Image Profiles available from the added Offline Bundle. During the process of creating a new Image profile, you verify whether a Software Depot is already added to the PowerCLI session using the $DefaultSoftwareDepots command. If there are no Software Depots added then the command will silently exit to the PowerCLI prompt. If there are Software Depots added then it would list the depots added showing the path to its XML file. This is referred to as a depot URL.

The process of adding the Software Depot is pretty straightforward. First you need to make sure that you have downloaded the needed Offline Bundles to the server where you have PowerCLI installed. In this case it was downloaded and saved to the C:\AutoDeploy-VIBs folder. Once the Offline Bundle is downloaded and saved to an accessible location, you can then issue the command Add-EsxSoftwareDepot to add the Offline Bundle as a depot to the PowerCLI session.

Once the software has been added, you can then list all the Image Profiles available from the Offline Bundle. Then the chosen Image Profile is cloned to form a new Image Profile, which can then be customized by adding/removing VIBs. It can then be published as an Offline Bundle or an ISO.

Summary

We saw that all the predefined Image Profiles were available from an Offline Bundle that were read-only. To customize such Image Profiles, you needed to clone them to form new Image Profiles. We learned how to create a new Image Profile by cloning an existing one.

Resources for Article :


Further resources on this subject:


Books to Consider

comments powered by Disqus