Quick and dirty PowerCLI cmdlets

I am preparing for my VCAP-DCA exam and having to automate more and more of my daily tasks within our VMware environment at work — as a result, I am using PowerCLI constantly. As I result, I thought I would share a couple quick and dirty little scripts that I have had to use lately.

Mileage will vary, but they’ve proven useful for me at work (some variables values have been edited).

Changing Network Label

> $i = 1
> $VLAN = "VLAN1012"
> while ($i -le 20) {
> $VMName = "prefix" + $i + ".site"
> Get-VM -Name $VMName | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup $VLAN -Confirm:$false | Out-Null
> $i++
> }
>

Deleting and Adding a New Disk

> $i = 1
> while ($i -le 20) {
> $VMName = "prefix" + $i + ".site"
> Get-HardDisk -VM $VMName | Remove-HardDisk -Confirm:$false | Out-Null
> New-HardDisk -VM $VMName -CapacityGB 525 -Datastore "DRSCluster1" -Confirm:$false | Out-Null
> $i++
> }
>

Changing Allocated RAM

> $i = 1
> while ($i -le 20) {
> $VMName = "prefix" + $i + ".site"
> Set-VM -VM $VMName -MemoryGB 32 -Confirm:$false | Out-Null
> $i++
> }
>

Virtualized Hadoop + Isilon HDFS Benchmark Testing

During the VMworld EMEA presentation (Tuesday October 14, 2014) , the question around performance was asked again with regards to using Isilon as the data warehouse layer and what positives and negatives are associated with leveraging Isilon as that HDFS layer. As with any benchmark or performance testing, results will vary based on the data set you have, the hardware you are leveraging and how you have the clusters configured. However, there are some things that I’ve learned over the last year and a half that are applicable on a broad scale that can show the advantages to leveraging Isilon as the HDFS layer, especially when you have very large data sets (10+ Petabytes).

There are two benchmarking tests I want to focus on for this post. The tests themselves demonstrate the necessity for understanding the workload (Hadoop job), the size of the data set, and the individual configuration settings (YARN, MapReduce, and Java) for the compute worker nodes.

Continue reading “Virtualized Hadoop + Isilon HDFS Benchmark Testing”

VCP5: Creating an iSCSI lab environment for vSphere

As I worked through the VCP5-DVC blueprint, the necessity to revisit iSCSI storage configuration and management became a key point of my study efforts. I had not used iSCSI storage before within a VMware vSphere environment, so learning how to tie it all into the infrastructure was totally new to me. In fact, the last time I had used iSCSI storage was with my previous employer 5+ years ago within a customized CentOS OpenVZ environment.

Fortunately, Google did not fail me and there were many resources readily available for teaching me how to implement iSCSI storage within a CentOS Linux virtual machine. From there it was a matter of creating a storage adapter within vCenter and exporting the iSCSI datastores to the environment.

This post will go through the steps to configure the iSCSI storage within a Linux VM, export it to vCenter and add it into the IaaS offering as a VMFS datastore. I found this extremely helpful in my preparation for the exam and in learning how to troubleshoot misconfiguration settings within the iSCSI VM — making mistakes are often the best way to learn!

Continue reading “VCP5: Creating an iSCSI lab environment for vSphere”

PowerCLI script for applying Host Profile

Encountered an issue with Auto Deploy this week where it wasn’t properly assigning the VMware License key contained within the Host Profile, so the ESXi hosts would not add themselves into the vCenter environment automatically. Looking into the issue, we only have this problem when we try to have Auto Deploy add in HP blade servers using the VSAN license key for this environment.

Anyway, it became necessary to add the hosts in manually after they each PXE booted into ESXi and apply the proper license key. From there, because we are doing everything through the slower web client for VSAN, we were going to have to apply the host profile to 80 hosts and there was no way I wanted to do that manually.

So I wrote up a quick script to handle this for us. Feel free to reuse if you find it helpful.

[string]$VCENTER = ""
[string]$USER = "administrator@vsphere.local"
[string]$PASSWD = ""
[string]$HOSTPROFILE = "vCache"

Connect-VIServer $VCENTER -User $USER -Password $PASSWORD

$i = 100
while ($i -le 120) {
  $hostname = "mraesxi" + $i " ".local.domain"
  Set-VMHost -VMHost $hostname -State "Maintenance" -Confirm:$false
  Apply-VMHostProfile -Entity $hostname -Profile $HOSTPROFILE -Confirm:$false
  Set-VMHost -VMHost $hostname -State "Connected" -Confirm:$false
  $i++
}

The script itself could likely be more efficient, especially around putting everything into maintenance mode and then apply the host profile to all the virtual machines in a parallel fashion. This was a quick hack to get around an issue we were dealing with while trying to bring online a bunch of blade chassis’ at once.

VMware Cloud Automation Center Identity Store issue

There is a known-issue (KB article) where a tenant can lose connectivity to the identity store and prevent vCAC from working properly. It is a major pain if you encounter the issue within your environment and led me to spend several hours trying to fix within my own vCAC environment that is acting as the self-service portal for Hadoop-as-a-Service.

The first thing to note is that the KB article insists this will fix the issue immediately. That was not my experience. In fact, after going through the commands of the KB article, my environment still failed to connect to the Active Directory identity store and I had to open a support case with VMware to further address the problem. Ironically the first suggestion from the support personal was to re-execute the commands an additional time. Since I had already done so twice, I was flippant in thinking it would change the result, but sure enough going through the command set an additional time (3rd in this case) resolved the issue for my environment.

For reference purposes, here is the KB article from VMware: