Tips for writing Vester test files, part 2

20/02/2019

This post is the second part in a series about writing effective Vester test files. The previous part can be found here.

When there is no easy Get and Set

An example, we want to create a test to check the Cluster DPM settings. The Get-Cluster cmdlet can show many properties, however the options of the corresponding Set-Cluster cmdlet are limited. You can see for yourself running the following command:


PS> help Set-Cluster -Parameter *

Commands like Get-Cluster, Get-VMHost, Get-Datacenter are practical, easy to use but have some limitations, like not showing all info and are not blazing fast.

Time to meet the Get-View cmdlet, a bit less user-friendly, but much quicker and very useful. The equivalent for the Get-Cluster cmdlet is:


PS> Get-View -ViewType ClusterComputeResource</span>

To select a specific Cluster, use the -Filter parameter, like:


PS> Get-View -ViewType ClusterComputeResource -Filter  @{"NAME"="Cluster01"}

Another way is:


PS> Get-Cluster -Name Cluster01 | Get-View

Time to create the first DPM test. To test if DPM is enabled, execute the following commands:


PS> $Cluster = Get-Cluster -Name Cluster01 | Get-View

And run this:


PS> $Cluster

You can see all properties, note there is “Configuration” and “ConfigurationEx”. Run both:


PS> $Cluster.Configuration
PS> $Cluster.ConfigurationEx

And note the difference, $Cluster.ConfigurationEx has a “DpmConfigInfo” section. The following line will show the current DPM configuration for Cluster “Cluster01”


PS> $Cluster.ConfigurationEx.DpmConfigInfo.Enabled

Enabled DefaultDpmBehavior HostPowerActionRate Option
------- ------------------ ------------------- ------
   True          automated                   4    

We can now write the first part for the DPM enabled test.


$Title = 'DRS Power Management enabled'
$Description = 'Enable Power Management DPM'
$Desired = $cfg.cluster.drsDpmEnable
$Type = 'bool'

# The command(s) to pull the actual value for comparison
# $Object will scope to the folder this test is in (Cluster, Host, etc.)
[ScriptBlock]$Actual = {
    ($Object | Get-View).Configurationex.DpmConfigInfo.Enabled
}

# The command(s) to match the environment to the config
# Use $Object to help filter, and $Desired to set the correct value
[ScriptBlock]$Fix = {
	????
}

Read the rest of this entry »


Tips for writing Vester test files, part 1

10/02/2019

Over the last couple of weeks, I took a look at the Desired State Configuration Resources for VMware (later more on that…).

But above all, I spent quite some time exploring Vester. Vester can be really useful, and it is relatively easy to create additional test files and get more configuration settings under Vester control. While working on new test files, I gathered some lessons learned that can be useful for others.

Naming Test file and the components

Choose a descriptive name for a new test file. Although test files are organized in folders, when the number of test files is increasing descriptive names can be helpful.
What makes a good name? Refer to something that is known and unique.
E.g. For vCenter Clusters, most settings are related to DRS or HA settings, the output of the following command can be helpful:

> Get-Cluster -Name Cluster01 | select *
VsanEnabled               : False
VsanDiskClaimMode         : Manual
HATotalSlots              : 
HAUsedSlots               : 
HAAvailableSlots          : 
HASlotCpuMHz              : 
HASlotMemoryMb            : 
HASlotMemoryGB            : 
HASlotNumVCpus            : 
ParentId                  : Folder-group-h23
ParentFolder              : host
HAEnabled                 : True
HAAdmissionControlEnabled : True
HAFailoverLevel           : 1
HARestartPriority         : Low
HAIsolationResponse       : PowerOff

E.g. Creating a test file for the HA Failover Level, name the test file: “HA-FailoverLevel.Vester.ps1”.
While working on a test file the following variables also play an important role.
The variable $Title is shown during each run of Invoke-Vester and can be used to provide more information then the title of the test file.

Fig. 1

Read the rest of this entry »


About vCenter Server Folders and how to Copy them

26/01/2019

Recently, while working on a new deployment, it was determined to copy the folder structure from an existing vCenter Server to a new instance.
As the folder structure is complex and the vCenter Servers were located in separated environments, exporting and importing the folder structure seems the way to go.
Before continuing, let’s see how folders are organized in vCenter Server.

Each folder in vCenter Server has properties, which can be observed using one of the following commands:

PS> Get-Folder | Select *
PS> Get-View -ViewType Folder

In vCenter Server you can create Folders directly under the vCenter Object and under each Datacenter. Folders created under the vCenter Object will appear on each of the four tabs (“Host and Clusters”, “VMs and Templates”, “Storage” and “Networking”).
On the Datacenter level, you can create different folder structures for each of the four tabs. After creating a new Datacenter object, vCenter Server creates four hidden folders, named “host”, “network”, “datastore” and “vm”, which function as parent folders for each tab.

In the diagram (Fig. 1) I’ve tried to present an overview for a vCenter Server with two Datacenters (Datacenter1 and Datacenter2) and a few folders like “Discovered virtual machine” and ”Templates”.
On the far left is the root object which is always called “Datacenters”.
The folders marked with a red X are not visible in the vCenter GUI. Visible folders are marked with a blue folder icon. The properties “Name”, “Id” and “ParentId” are shown in the diagram. Each folder is uniquely identified with it’s “Id” and “ParentId”.

Fig. 1

Read the rest of this entry »


About Configuration Drift, Pester and Vester

29/11/2018

This topic has been on my mind for quite some time, but it was until recently, when attending a presentation, that the picture became much clearer.
In this post, I would like to share some of my thoughts.

To install and configure vSphere environments, we can use various methods, from manual, all kind of scripting, to fully automated deployments.
vSphere also comes with tools, like Host Profiles which can be helpful. After installation and initial configuration is done, we are not finished. We also want to enforce a consistent configuration, but how?

Again, Host Profiles can be useful to maintain the state of ESXi hosts, but there are some objections. Host Profiles are difficult to setup and maintain (how nice would it be, if you could export / import a Host Profile in a more user friendly .JSON format?). But more important, hosts are only a part of the environment. How about configuration of Clusters, DatastoreClusters, Virtual switches and Virtual machine properties?

Read the rest of this entry »


Hardware, firmware and drivers

10/10/2018

Because the subject is still actual, I created an updated version of this post from 2015.

A modern server is besides our favorite ESXi hypervisor loaded with all kinds of additional software, like the BIOS, firmware and drivers for items like; Baseboard management , Remote support interfaces, Storage controllers, NICs, Power Supplies, to name a few.

Some vendors provide ISO images or repositories containing the actual updates, you may run the update process and voila, ready and done.
If you want to stay in control and want some more insight in this subject, please read on.

It comes down to these four questions:

  • What hardware is in the server?
  • How to determine the current firmware and or driver?
  • Which driver and or firmware do I need?
  • How do I upgrade drivers and firmware?

Read the rest of this entry »


ESXi CLIativity – Part 3

09/09/2018

In previous post in this series, one and two, I showed you some examples how to run ESXi CLI commands on a more relaxed way with use of the PuTTY tools and some scripting.

In this post, I would like to introduce two other methods to execute ESXi CLI commands.

PowerSSH

Microsoft Windows PowerShell and VMware PowerCLI are commonly used by VMware admins. The functionality of PowerShell can be extended by adding Modules. Since PowerShell version 5 adding Modules has become very easy with the introduction of repositories (external and internal). A repository is (said irreverently) a kind of app store where you can retrieve modules. The best known repository is the PowerShell Gallery. If this is all new, the link provides information to get your started, as well as many posts about this topic.

A very handy module is Posh-SSH, created by Carlos Perez, which extend PowerShell with SSH and SCP functionality. The following commands will check for the availability of the PowerShell Gallery and installs the Posh-SSH module.

PS C:\Users> Get-PSRepository

Name      InstallationPolicy   SourceLocation
----      ------------------   --------------
PSGallery Untrusted            https://www.powershellgallery.com/api/v2/

The Get-PSRepository should return the PSGallery as one of the repositories.

Read the rest of this entry »


ESXi CLIativity – Part 2

01/07/2018

In my previous post, I showed you how to run scripts on the ESXi CLI with minimal intervention. In this episode, I will show you another example, which will also make use of PowerCLI and one of the PuTTY utilities.

The scenario; Now and then servers need all kind of upgrades; BIOS, NIC and HBA firmware to name a few. Hardware vendors usually offer multiple ways and additional tooling to perform those updates. As an example HPE provides packages, called Smart Components which can be installed from the Operating System layer, in the past limited to Windows and some Linux flavours, today also for ESXi.

Smart Components for ESXi come in the form of a .zip file, named CPxxxxxx.zip . The .zip contains an executable called: CPxxxxxx.vmexe, the firmware CPxxxxxx.vmfile, some additional .xml and .json files and a README.txt with installation instructions. Chances are that during an upgrade cycle of a cluster multiple components need a firmware upgrade, it will become clear that this is a time consuming task. So time for some automation!

Read the rest of this entry »