VMware vSphere 5.5 Cookbook
上QQ阅读APP看书,第一时间看更新

Creating an image profile by cloning a predefined profile

All the predefined image profiles available in an offline bundle are read-only. To customize such image profiles, you will need to clone them to form new image profiles. In this recipe, we will learn how to create a new image profile by cloning a predefined image profile.

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 three-step process:

  1. Adding an ESXi software depot.
  2. Listing available ESXi image profiles.
  3. Cloning a predefined ESXi image profile to form a new one.

Adding an ESXi software depot

The metadata of an ESXi offline bundle will have the definitions for the predefined image profiles contained in it. To be able to use the image profiles available in an offline bundle, it needs to be presented to a vSphere PowerCLI session as a software depot, which is nothing but PowerCLI's term for an offline bundle. The procedure to be followed is given next.

Before you begin, it is important to verify whether there are any software depots defined in the current session. This is recommended if you were about to use an already running PowerCLI session. If you have started a new PowerCLI session for the purpose of this task, then you won't have to do this verification.

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

$DefaultSoftwareDepots

The output is as shown:

Adding an ESXi software depot

Note that the command has not returned any values, meaning that there are no software depots defined in the current session. If the needed software depot has already been added, then the command output will list the depot.

Before you add a software depot, make sure that you have the offline bundle saved 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 driver bundle.

We already have the offline bundle downloaded to the C:\Offline Bundles directory as shown:

Adding an ESXi software depot

To add the downloaded software depot, issue the following command:

Add-EsxSoftwareDepot -DepotUrl C:\Offline-Bundles\VMware-ESXi-5.5.0-1331820-depot.zip

The output is as follows:

Adding an ESXi software depot

Once the software depot has been successfully added to the PowerCLI session, the command $DefaultSoftwareDepots should list the newly added software depot as shown in the following screenshot:

Adding an ESXi software depot

You could also just issue the command Get-EsxSoftwareDepot to list all the added depots (offline bundles). Here, you could use the newly added ESXi 5.5 bundle and a be2net driver bundle depot added as shown:

Adding an ESXi software depot

Listing available image profiles

Once the software depot has been added, the next step is to list all the currently available image profiles from the depot by issuing the following command:

Get-EsxImageProfile

The output is as follows:

Listing available image profiles

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 a predefined ESXi image profile to form a new one

Now that we know there are two image profiles available, the next step will be to clone the required image profile to form a new one. This is achieved 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 the variable $profiles:

$profiles = Get-EsxImageProfile

The $profiles variable now holds the two image profile names as array elements [0] and [1] sequentially. Refer to the following screenshot:

Cloning a predefined ESXi image profile to form a new one

Now the following command can be issued to clone the array element [0] ESXi-5.5.0-1331820-standard to form a new image profile, with the user-defined name Profile001:

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

Once the previous command has been successfully executed, you can issue the Get-EsxImageProfile command to list the newly created image profile, as shown:

Cloning a predefined ESXi image profile to form a new one

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 will list the depots added and show 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 required offline bundles to the server where you have PowerCLI installed. In this case, they were 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 that can then be customized by adding/removing VIBs. It can then be published as an offline bundle or an ISO. Now, there is a reason why we clone an image profile to customize it. The reason is that all predefined image profiles are read-only, hence they cannot be modified. Let's view the properties of a standard image profile:

How it works...

Note that it shows that the ReadOnly attribute/property of the image profile is set to True. This is generally the case with all the default/predefined image profiles in an offline bundle. For this purpose, in this task you will need to clone the predefined profile to form a new one.

However, the cloned image profiles will have the ReadOnly property set to False by default, as shown in the following screenshot:

How it works...

See also

  • For instructions on how to export an image profile, read the recipe Exporting an image profile as an ISO or offline bundle