Archive for the ‘Virtualisation’ Category


To celebrate the passing of my “VMware Certified Professional – Datacenter Virtualization” exam this week my lovely sister made me a Monster VM* cake and I thought it would be nice to bring this into the office so my colleagues could all try a slice!

This slideshow requires JavaScript.

*What’s a Monster VM? Good question. Monster VM is a term used in the virtualisation world for a very high specification virtual machine which a few years ago would have been impossible to create virtually but with the latest advancements in this technology we can have VMs that can meet even the most demanding workloads, these are the Monster VMs. Monster VM can often be seen at events such as VMworld as in the below pictures.

 

Interestingly my sister got more praise than me, oh well you cannot win them all :)

My CTO also blogged about my success which you can read here. Thanks Tref!

Regards,

jfrmilner


This week I have been tasked with assisting a storage engineer while he replaces a couple of Fibre Channel switches. My task was simple, check the HBAs for any “Dead” paths (See below screen shot for an example) across all the ESX hosts every hour for a weekend. We have a fair few VMHosts so this gave me the opportunity to use PowerCLI (Think PowerShell with a VMware snapin).

It didn’t take long at all to knock up a little script that can report on path states, this is what I came up with:

$VMHosts = Get-VMHost  | ? { $_.ConnectionState -eq "Connected" } | Sort-Object -Property Name
$results= @()

foreach ($VMHost in $VMHosts) {
Get-VMHostStorage -RescanAllHba -VMHost $VMHost | Out-Null
[ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "FibreChannel"

	foreach ($HBA in $HBAs) {
    $pathState = $HBA | Get-ScsiLun | Get-ScsiLunPath | Group-Object -Property state
    $pathStateActive = $pathState | ? { $_.Name -eq "Active"}
    $pathStateDead = $pathState | ? { $_.Name -eq "Dead"}
    $pathStateStandby = $pathState | ? { $_.Name -eq "Standby"}
    $results += "{0},{1},{2},{3},{4},{5}" -f $VMHost.Name, $HBA.Device, $VMHost.Parent, [INT]$pathStateActive.Count, [INT]$pathStateDead.Count, [INT]$pathStateStandby.Count
    }

}
ConvertFrom-Csv -Header "VMHost","HBA","Cluster","Active","Dead","Standby" -InputObject $results | Ft -AutoSize

The output is pretty simple but does the job:

VMHost                            HBA    Cluster        Active Dead Standby
------                            ---    -------        ------ ---- -------
d1-vmesx-001.*************.uk    vmhba2 Cluster05      40     0    24
d1-vmesx-001.*************.uk    vmhba3 Cluster05      40     0    24
d2-vmesx-001.****************.uk vmhba2 Cluster02      98     0    80
d2-vmesx-001.****************.uk vmhba3 Cluster02      96     0    80
d2-vmesx-011.****************.uk vmhba2 Cluster03      76     0    88
d2-vmesx-011.****************.uk vmhba3 Cluster03      75     0    85
d2-vmesx-012.****************.uk vmhba2 Cluster03      76     0    88
d2-vmesx-012.****************.uk vmhba3 Cluster03      75     0    85
d2-vmesx-013.****************.uk vmhba1 Cluster03      83     0    85
d2-vmesx-013.****************.uk vmhba2 Cluster03      83     0    85
d2-vmesx-014.****************.uk vmhba1 Cluster03      83     0    85
d2-vmesx-014.****************.uk vmhba2 Cluster03      83     0    85
d2-vmesx-015.****************.uk vmhba1 Cluster03      83     0    85
d2-vmesx-015.****************.uk vmhba2 Cluster03      83     0    85
d2-vmesx-016.****************.uk vmhba1 Cluster03      83     0    85
d2-vmesx-016.****************.uk vmhba2 Cluster03      83     0    85
d2-vmesx-017.****************.uk vmhba1 MSCS Cluster01 44     0    308
d2-vmesx-017.****************.uk vmhba2 MSCS Cluster01 44     0    308
d2-vmesx-018.****************.uk vmhba1 MSCS Cluster01 44     0    308
d2-vmesx-018.****************.uk vmhba2 MSCS Cluster01 44     0    308
d2-vmesx-019.****************.uk vmhba1 Cluster04      68     0    52
d2-vmesx-019.****************.uk vmhba2 Cluster04      68     0    52
d2-vmesx-021.****************.uk vmhba1 Cluster04      68     0    52
d2-vmesx-021.****************.uk vmhba2 Cluster04      68     0    52

If you wanted to work with this information further then I would suggest creating a custom object and populating the properties with Add-Member instead of doing the format string method above, I just did that as it’s quick. Well this is my first PowerCLI script, I hope to share some more.

Bye for now.

jfrmilner


I had a situation where I needed to enable the Virtualisation Technology (VT) across a bunch of Dell servers and then install the Hyper-V role. It turned out to be much simpler than I originally thought thanks in part to PowerShell remoting and Dells omconfig.

Dell give you the option to change BIOS configuration from the command line, for example to enable the CPU VT:


omconfig chassis biossetup attribute=cpuvt setting=enabled

In addition to the above I would also need to install the Hyper-V role:

Import-Module ServerManager ; Add-WindowsFeature Hyper-V

This can be combined into a PowerShell remote command like so ($allServers is an array of all the server host names I want to execute the command against):

icm -ComputerName $allServers -ScriptBlock { omconfig chassis biossetup attribute=cpuvt setting=enabled ; Import-Module ServerManager ; Add-WindowsFeature Hyper-V }

Next I needed to create a software virtual switch, for this I used a script from

http://blogs.technet.com/b/virtualization/archive/2008/05/26/hyper-v-wmi-using-powershell-scripts-part-5.aspx :

$VirtualSwitchService = get-wmiobject -class "Msvm_VirtualSwitchManagementService" -namespace "root\virtualization"
$ReturnObject = $VirtualSwitchService.CreateSwitch([guid]::NewGuid().ToString(), "DELL NETWORK TEAM - Virtual Network", "1024","")

#Create New Virtual Switch
$CreatedSwitch = [WMI]$ReturnObject.CreatedVirtualSwitch

#Create Internal Switch Port
$ReturnObject = $VirtualSwitchService.CreateSwitchPort($CreatedSwitch, [guid]::NewGuid().ToString(), "InternalSwitchPort", "")
$InternalSwitchPort = [WMI]$ReturnObject.CreatedSwitchPort

#Create External Switch Port
$ReturnObject = $VirtualSwitchService.CreateSwitchPort($CreatedSwitch, [guid]::NewGuid().ToString(), "ExternalSwitchPort", "")
$ExternalSwitchPort = [WMI]$ReturnObject.CreatedSwitchPort

$ExternalNic = get-wmiobject -namespace "root\virtualization" -Query "Select * From Msvm_ExternalEthernetPort WHERE IsBound=False" | ? { $_.Name -eq 'BASP Virtual Adapter'}

#Call SetupSwitch
$Job = $VirtualSwitchService.SetupSwitch($ExternalSwitchPort, $InternalSwitchPort, $ExternalNic, [guid]::NewGuid().ToString(), "InternalEthernetPort")
while (([WMI]$Job.Job.JobState -eq 2) -or ([WMI]$Job.Job.JobState -eq 3) -or ([WMI]$Job.Job.JobState -eq 4)) {Start-Sleep -m 100}
[WMI]$Job.Job

And finally reboot them all (they actually reboot twice as part of the Hypervisor installtion):

icm -ComputerName $allServers -ScriptBlock { Restart-Computer -Force }

With the above I managed to enable and install Hyper-V across 70 severs simultaneously with less than a couple of hours of effort, nice!

Kind Regards,

jfrmilner