Tuesday, January 3, 2017

VCP 6 passed

Shortly before Christmas, I took, and managed to pass the VCP6 Delta exam (2V0-621D), to further extend my VCP status by another 2 years (not really a fan of the need to do this, but ultimately the choice is do it or lose it).

Personally, I found the exam a bit tougher than the previous VCP exams. Now, whether that was because it was the Delta (and so in theory, they can concentrate on asking more detailed/specific questions, as it should focus on the changes between vSphere 5 and vSphere 6) I don’t know. It could be that as I use the VMware technologies covered by the VCP-DCV all day every day (it’s my day job), it was actually a bit tougher to then sit down and do the necessary reading (ie, the temptation to go “oh, I know this, I’m skipping it”). The risk with that of course, is that :

1) I don’t know if all - this of course, goes without saying.
2) I need to focus on the areas that I feel less confident in, or that we don’t use all day every day - resource pools are a good example of this, they’re not something we use much at all. But picking out those areas becomes more tedious.

Ultimately, that’s all just an excuse for not preparing as thoroughly as I would’ve liked, and I think I was probably a bit complacent (plus there are more “interesting” things to be working on that revising for what I think I already know - see the end of this entry for the kind of thing I mean. Still managed to pass with (what to me was) an acceptable score.

Resources used :

Well, it’s the usual kind of thing.
1) The Blueprint (I do wish they kept it as a PDF or a single file download at least, I don’t like the current presentation of it).
2) VMware documentation - as mentioned above, I struggled here, just because of the whole idea of re-reading the same stuff again - need to be wary of this, as obviously there are (significant) changes.
3) Mastering vSphere 6 - from my Safari subscription - didn’t use this as much as previous versions - again complacency on my behalf.
2) Practical work - as I said, it’s my day job, so I’m using it every day, but personally I’m poor at remembering menu options or anything like that (I just “do” tasks, I don’t think too much about the menu structure or what the labels are etc. I also try to script more and more these days, so prefer to not rely on the GUI if I can help it). So it’s a combination of my paid work, and things in the home lab.

Anyway, it’s done and dusted for a few more years, which is a relief, as there’s plenty more to work with, given the recent release of 6.5, and the associated technologies - vSAN, vROPS, vRA, Orchestrator etc. Plus I’d like to look more at NSX (may be a struggle, as I’m not a Network person), and other areas such as Openstack, AWS and Azure to name a few.

Monday, July 11, 2016

Setting QFullSampleSize and QFullThreshold by script in ESXi 5.1

[Repost of old entry that died under the weight of spam]

With ESXi 5.1, VMware have changed things a bit for Controlling LUN queue depth throttling in VMware ESX/ESXi
- see Controlling LUN queue depth throttling in VMware ESX/ESXi

Previously it was a global setting on the host, configured in the Advanced Settings - and could be checked and set using PowerCLI. eg :

To check values :

Get-VMHostAdvancedConfiguration -vmhost <host> -name Disk.QFullSampleSize
Get-VMHostAdvancedConfiguration -vmhost <host> -name Disk.QFullThreshold

To set values :

Set-VMHostAdvancedConfiguration -vmhost <host> -name Disk.QFullSampleSize -value <int>
Set-VMHostAdvancedConfiguration -vmhost <host> -name Disk.QFullThreshold -value <int>

That’s no longer the case. Now, it’s per LUN and not global. So, each LUN you present will need setting (if you use this), and on each host.

We use 3Par storage, and do set the values recommended :

QFullSampleSize = 32.
QFullThreshold = 4

The question was asked whether these settings were retained on a host that had them, and was then upgraded to 5.1. An upgrade in one of the test labs seems to indicate they’re not - all LUNs were set to 0 for these parameters.

So, I decided to try and script something. The result is below.

Basically, I read the LUN device ID from a text file (one entry per line), and then apply the change to it. The problem then is generating the text file - we have 50+ LUNs per host typically. For this, I used RV Tools , and exported the vDatastore tab, which includes the value I need - second column labelled Address. I take those values, and stick them in the text file - cumbersome, but it works.

I call the script Set3Par.sh, and chmod +x it to set the execute bit.

#!/bin/sh

usage() {
        echo "Usage : ./Set3Par.sh filename.txt"
        echo "Where filename.txt is the file with the list of naa ids, eg test.txt"
}

# File with the naa entries. One per line.
filename=$1

# Check script is invoked with correct number of arguments, ie, filename.txt
# If not, give usage details then exit.
[[ $# -ne 1 ]] && usage && exit 1

# Check if the file specified exists, if not, exit
if [ ! -f $filename ]
then
        echo "$filename does not exist. Exiting"
        exit 1
fi

# Set the values, working through the input file one line at a time.
echo "Reading in the file $filename"
cat $filename | while read line
do
        echo "Running the following ... esxcli storage core device set --device $line -q=4 -s=32"
        esxcli storage core device set --device $line -q=4 -s=32
done

echo "Completed the changes ... exiting"

How to run :
# ./Set3Par.sh
Usage : Set3Par filename.txt
Where filename.txt is list of naa ids, eg test.txt

Sample input file : (values changed for writeup purposes)
# more test.txt
naa.50002aaaaaaaaaaa
naa.50002bbbbbbbbbbb
naa.50002ccccccccccc
naa.50002ddddddddddd
naa.50002eeeeeeeeeee
#

Sample run:
# ./Set3Par.sh test.txt
Reading in the file test.txt
Running the following … esxcli storage core device set –device naa.50002aaaaaaaaaaa -q=4 -s=32
Running the following … esxcli storage core device set –device naa.50002bbbbbbbbbbb -q=4 -s=32
Running the following … esxcli storage core device set –device naa.50002ccccccccccc -q=4 -s=32
Running the following … esxcli storage core device set –device naa.50002ddddddddddd -q=4 -s=32
Running the following … esxcli storage core device set –device naa.50002eeeeeeeeeee -q=4 -s=32
Completed the changes … exiting

New vApp fails to deploy in vCloud Director with “… does not exist in our inventory, but vCenter Server claims that it does” type error.

[Repost of old entry that died under the weight of spam]

Working on a vCloud Director 5.1 proof of concept in work, ran into an issue where deploying a new vApp would fail after about a minute. Same with trying to import a template. All errors were of the type :

Folder vApp_system_25 (b220707f-7e73-401a-91b9-c74000c76a1a) does not exist in our inventory, but vCenter Server claims that it does..

I could indeed see the object in vCenter, but nothing in vCloud.

Searching around, I found this VMware communities article http://communities.vmware.com/message/2202781 It mentions “None of the cells have a vCenter proxy service running.” Checking our environment, this message was also present. The communities page indicated that it was then fixed by cleaning the QRTZ tables in the database, but no details on how. Not being a DBA, this bothers me :-)

Searching for details on how to do this led to this blog entry by Jason Boche - http://www.boche.net/blog/index.php/2011/12/16/vcloud-director-and-vcenter-proxy-service-failure/

All looked similar, so tried it on our setup, and pleasingly it fixed it. We’re running the database in MSSQL, so used the relevant script, tidied to fit our database name.

Monday, May 25, 2015

Enable or disable CBT

Implementing a new client solution recently based on vSphere 6, there was a request from our backup team to enable CBT on the VMs that were to be backed up. This basically meant around about 160 VMs from the overall solution.

Per the VMware KB article, this would entail shutting down the VM, adding the ctkEnabled parameter and then set its value to true and then Add Row, add scsi0:0.ctkEnabled, and set its value to true. Finally, power the VM back on.

To disable, again, power down the VMs.

This is a bit tedious obviously for 160 VMs, not to mention the downtime incurred for the client solution. However, in the KB article is some PowerCLI script to achieve the same end result, but without powering down the VM.

So, for ease, I took this and just put it into a simple loop to read in the list of VMs from a .txt file (1 VM per line) and make the change. It’s easy enough to have another script to disable the change and do it enmasse. Even better given the (now apparently resolved via latest patch) issue described here.

Also, there’s a one line to list out whether CBT is enabled on all the VMs in the environment.

EnableCBT.ps1

# Enable CBT on number of VMs based on .txt file
# 1 VM per line - name as per vSphere client
# Based on the code from http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1031873

$vmlist = Read-Host "Enter the name of the file with the list of VMs"

$vmname = get-content $vmlist

ForEach ($vm in (Get-VM $vmname))
{

    $vmtest = Get-vm $vm| get-view
    $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

    # enable ctk
    $vmConfigSpec.changeTrackingEnabled = $true
    $vmtest.reconfigVM($vmConfigSpec)
    $snap=New-Snapshot $vm -Name "Enable CBT"
    $snap | Remove-Snapshot -confirm:$false

}

DisableCBT.ps1

# Disable CBT on number of VMs based on .txt file
# 1 VM per line - name as per vSphere client
# Based on the code from http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1031873

$vmlist = Read-Host "Enter the name of the file with the list of VMs"

$vmname = get-content $vmlist

ForEach ($vm in (Get-VM $vmname))
{

    $vmtest = Get-vm $vm| get-view
    $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

    #disable ctk
    $vmConfigSpec.changeTrackingEnabled = $false
    $vmtest.reconfigVM($vmConfigSpec)
    $snap=New-Snapshot $vm -Name "Disable CBT"
    $snap | Remove-Snapshot -confirm:$false

}

CheckCBT.ps1

# Check CBT status on all VMs
get-vm  | Get-View | Sort Name| Select Name, @{N="CBT State";E={$_.Config.ChangeTrackingEnabled}} | ft -AutoSize

Mass creation of vDS portgroups using PowerCLI

There’s a potential project going on to migrate off of the Nexus 1000v distributed switch. One of the things that will be needed, is to create portgroups for all the existing Nexus port profiles.

Following is a simple PowerCLI script put together to help with this. It simply creates the port groups from entries in a .csv file. Nothing else is done with respect to the migration.

It’s a practical, functional script. It’s not fully featured or doing anything clever. In essence, it’s what I tend to use Powershell and PowerCLI for, getting tedious things done quickly. It’s missing the “correct” way to do things, but took 10 minutes to put together - which shows.

The core of the script is basically a couple of lines. Fleshed out with some comments, and an initial check on whether a connection has been made to the vCenter before running the script. Typically in my everyday work, I have PowerCLI connections made to the VC’s, so don’t like scripts to nag me to connect. But I’ve added a rudimentary check for this. If already connected, you’ll carry on as normal, if not connected, you’ll be prompted for the VC and the script will disconnect you at the end.

The other assumption here is that all the portgroups are going to be of type VLAN - ie, we’ve got trunked NICs, so each portgroup will need a VLAN ID set.

The script uses a .csv file that you will need to generate - this is my typical approach on these things, as I just find it easy to work with. The layout of the .csv file (ie the column name that you will need) is :

vDS - name of vDS that we want to create the portgroup on
pgName - name of the portgroup to create
NumPorts - number of ports for the portgroup
vlanID - vlanID.

Once it’s created the portgroups, it will just print out the name, number of ports, port binding and vlan configuration for every portgroup on the dVS for confirmation.

Populate-vDS-portgroup.ps1

# Check if already connected to VC or not. If not, prompt to.
if ($global:DefaultVIServer.name -eq $null) {
	$vc = Read-Host "Enter the VC to connect to"
	Connect-VIServer $vc

	Write-Host "Now connected to " -ForegroundColor Magenta
	$global:DefaultVIServer.name	

	# $wasConnected set to no - this will be used at the end to prompt 
	# whether to disconnect the session.
	$wasConnected = "no"
}
else {
	# There was already a session connected - display it and continue.
	Write-Host "Currently connected to " -ForegroundColor Magenta
	$global:DefaultVIServer.name
}

Write-Host
 
# Read in the .csv file with all the details that we'll need
# Layout (ie, column names) of the .csv is  :
# vDS - name of vDS that we want to create the portgroup on
# pgName - name of the portgroup to create
# NumPorts - number of ports for the portgroup
# vlanID - vlanID - assumption here is we've got a trunk, and each portgroup needs 
# it's own vlan ID to identify the tag
$srcFile = Read-Host "Enter the name of the .csv file to work with"
$vdsPortgroup = Import-Csv $srcFile
 
Write-Host
 
foreach ($portgroup in $vdsPortgroup){
	Get-VDSwitch $portgroup.vDS | New-VDPortgroup -name $portgroup.pgName -NumPorts $portgroup.numports -VlanId $portgroup.vlanID
}

Write-Host "`nPortgroups created. Now confirming settings" -ForegroundColor Cyan

Get-VDSwitch $portgroup.vDS | Get-VDPortgroup | select name, numports, portbinding, vlanconfiguration
 
 
# If a connection was needed to the VC at the start of the script, then prompt
# to confirm whether to disconnect the session.
if ($wasConnected -eq "no")
{
	Disconnect-VIServer $vc -confirm:$true
}

Sample output :

.Populate-vDS-Portgroups.ps1
Currently connected to
xxx.xxx.xxx.xxx

Enter the name of the .csv file to work with: dvs-test.csv

Name NumPorts PortBinding
—- ——– ———–
scriptpg1 100 Static
scriptpg2 150 Static
scriptpg3 100 Static
scriptpg4 200 Static
scriptpg5 125 Static

Portgroups created. Now confirming settings

Name : scriptpg1
NumPorts : 100
PortBinding : Static
VlanConfiguration : VLAN 500

Name : scriptpg5
NumPorts : 125
PortBinding : Static
VlanConfiguration : VLAN 504

Name : scriptpg2
NumPorts : 150
PortBinding : Static
VlanConfiguration : VLAN 501

Name : scriptpg4
NumPorts : 200
PortBinding : Static
VlanConfiguration : VLAN 503

Name : scriptpg3
NumPorts : 100
PortBinding : Static
VlanConfiguration : VLAN 502

Name : dvPortGroup
NumPorts : 128
PortBinding : Static
VlanConfiguration :

Name : CloudMgmt-vDS-DVUplinks-888
NumPorts : 2
PortBinding : Static
VlanConfiguration : VLAN Trunk [0-4094]