This is some thing I have been using for some time now and might expand upon some day. Well what is it, basically it draws and populate “blade enclosures” in excel. So why have I made this – Simply put to give an overview of our fault domains, more specific cluster fault domains.
So why is this impotent at all, well we use a lot of money on redundancy – duplication every aspect of the infrastructure, we buy software like VMware(HA), F5 etc. to make sure we get the five nines, but there seems to less of a focus on blade server placement in the datacenter, as long as theirs a free bay for a blade, it going to be used.
So i created this script to get an overview how the blades were place in the enclosures in regard to the cluster the blade is in – That helps me some times realize that placement of a blade is wrong and it makes planning of server deployment easy, in order to avoid putting all our eggs in one basket.
So is this really a problem… Well it depends, if your are running 10 host it might be easy to keep track of were the host are deployed, but when you get above 25, 50 or 100+ host this is were it starts to get tricky.
Still not sure… Well think of it this way – In our enclosures theirs six PSU, the other day, one of them died and we got a new one shipped, when my colleague hot swapped the dead PSU for the new one it went ‘puuf’ (no cloud of smoke, though), and suddenly two PSU’s were dead! a fuse had died. After some troubleshooting, it was the fuse in the PDU, that had be overloaded. Lucky for us this enclosure were correctly configured and the second PSU wasn’t dead. So he removed the faulted PSU, popped in the fuse again and we were still ‘only’ one PSU down. This was a simply procedure which failed big time and the only thing that saved us was the fact that we had four power sources/PDUs. Had it gone bad what would you have lost ? do you know ? well why not give the script a go 😉
This script were made with HPs 16 bay blade enclosures in mind… Lets see if I get some time to do one for eight bay enclosures some day!
And what does is look like you ask ?
So this is a bad setup – what do you think will happen to the Citrix server running on these blades? bye bye 🙁
The above images is take from the same excel spreadsheet – see is as a hole.
And this is what it should look like – Blades are colored after which VMware cluster it belongs to and the blade name is written on the blade.
$ErrorActionPreference = "silentlycontinue"
# Create new Excel object
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add(1)
$Sheet = $Excel.WorkSheets.Item(1)
Function Create-Enclosure{
param(
[int]$row
)
# Drawing a Blade Enclosure
$Sheet.Cells.Item($row,1) = $enclosure
$Sheet.Cells.Item($row,3) = "Bay 1"
$Sheet.Cells.Item($row,4) = "Bay 2"
$Sheet.Cells.Item($row,5) = "Bay 3"
$Sheet.Cells.Item($row,6) = "Bay 4"
$Sheet.Cells.Item($row,7) = "Bay 5"
$Sheet.Cells.Item($row,8) = "Bay 6"
$Sheet.Cells.Item($row,9) = "Bay 7"
$Sheet.Cells.Item($row,10) = "Bay 8"
$row++
$Sheet.Cells.Item($row,3).Borders.Item(1).LineStyle = 1
$Sheet.Cells.Item($row,3).Borders.Item(1).Weight = 4
$Sheet.Cells.Item($row,3).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,3).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,3).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,3).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,3).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,3).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,4).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,4).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,4).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,4).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,4).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,4).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,5).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,5).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,5).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,5).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,5).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,5).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,6).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,6).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,6).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,6).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,6).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,6).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,7).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,7).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,7).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,7).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,7).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,7).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,8).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,8).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,8).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,8).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,8).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,8).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,9).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,9).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,9).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,9).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,9).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,9).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,10).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,10).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,10).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,10).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,10).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,10).Borders.Item(10).Weight = 4
$sheet.rows.item($row).rowheight = 150
$row++
$Sheet.Cells.Item($row,3).Borders.Item(1).LineStyle = 1
$Sheet.Cells.Item($row,3).Borders.Item(1).Weight = 4
$Sheet.Cells.Item($row,3).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,3).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,3).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,3).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,3).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,3).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,4).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,4).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,4).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,4).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,4).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,4).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,5).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,5).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,5).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,5).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,5).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,5).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,6).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,6).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,6).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,6).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,6).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,6).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,7).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,7).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,7).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,7).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,7).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,7).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,8).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,8).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,8).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,8).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,8).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,8).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,9).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,9).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,9).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,9).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,9).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,9).Borders.Item(10).Weight = 4
$Sheet.Cells.Item($row,10).Borders.Item(3).LineStyle = 1
$Sheet.Cells.Item($row,10).Borders.Item(3).Weight = 4
$Sheet.Cells.Item($row,10).Borders.Item(4).LineStyle = 1
$Sheet.Cells.Item($row,10).Borders.Item(4).Weight = 4
$Sheet.Cells.Item($row,10).Borders.Item(10).LineStyle = 1
$Sheet.Cells.Item($row,10).Borders.Item(10).Weight = 4
$sheet.rows.item($row).rowheight = 150
$row++
$Sheet.Cells.Item($row,3) = "Bay 9"
$Sheet.Cells.Item($row,4) = "Bay 10"
$Sheet.Cells.Item($row,5) = "Bay 11"
$Sheet.Cells.Item($row,6) = "Bay 12"
$Sheet.Cells.Item($row,7) = "Bay 13"
$Sheet.Cells.Item($row,8) = "Bay 14"
$Sheet.Cells.Item($row,9) = "Bay 15"
$Sheet.Cells.Item($row,10) = "Bay 16"
}
#PowerCli req. from here on
$Clusters = Get-Cluster | Sort
$i = 3 #Used for coloring
$j = 2 #Enclosure postition
foreach($Cluster in $Clusters){
#Set Color for each cluster
$CLColor = $i
#Write cluster name with cluster color
$Sheet.Cells.Item($i,13).Orientation = 90
$Sheet.Cells.Item($i,13).VerticalAlignment = -4108
$Sheet.Cells.Item($i,13).HorizontalAlignment = -4108
$Sheet.Cells.Item($i,13).Interior.ColorIndex = $i
$Sheet.Cells.Item($i,13) = $Cluster.name
#Get all hosts in the cluster
$VMHosts = Get-Cluster $Cluster | Get-VMHost | sort
foreach($VMhost in $VMhosts){
#Get the enclosure info from the hostname
$enclosure = $vmhost.name.split("-")[1] + "-" + $vmhost.name.split("-")[2]
#Create Enclosure if not there allready
if(!(get-variable $enclosure)){
Set-Variable $enclosure -value $j
Create-Enclosure $j
$j = $j+4
}
#Set coordinates for host placement
$y = ""
$x = ""
if(([int]($vmhost.name.split("-")[3].split(".")[0])+2) -le "10"){
$y = ([int](Get-Variable ($vmhost.name.split("-")[1] + "-" + $vmhost.name.split("-")[2])).value)+1
$x = ([int]($vmhost.name.split("-")[3].split(".")[0])+2)
}elseif(([int]($vmhost.name.split("-")[3].split(".")[0])+2) -gt "10"){
$y = ([int](Get-Variable ($vmhost.name.split("-")[1] + "-" + $vmhost.name.split("-")[2])).value)+2
$x = ([int]($vmhost.name.split("-")[3].split(".")[0])-6)
}
#Color and write hostname
$Sheet.Cells.Item($y,$x).Orientation = 90
$Sheet.Cells.Item($y,$x).VerticalAlignment = -4108
$Sheet.Cells.Item($y,$x).HorizontalAlignment = -4108
$Sheet.Cells.Item($y,$x).Interior.ColorIndex = $i
$Sheet.Cells.Item($y,$x) = $vmhost.name
}
$i++
}
#Write cluster name with cluster color
$Sheet.Cells.Item($i,13).Orientation = 90
$Sheet.Cells.Item($i,13).VerticalAlignment = -4108
$Sheet.Cells.Item($i,13).HorizontalAlignment = -4108
$Sheet.Cells.Item($i,13).Interior.ColorIndex = $i
$Sheet.Cells.Item($i,13) = "Hosts not in cluster"
#Get All host which are not in a cluster
$FreeVMHosts = get-vmhost | where {$_.parentid -notmatch "Cluster"}
foreach($FreeVMHost in $FreeVMHosts){
#Get the enclosure info from the hostname
$enclosure = $FreeVMHost.name.split("-")[1] + "-" + $FreeVMHost.name.split("-")[2]
#Create Enclosure if not there allready
if(!(get-variable $enclosure)){
Set-Variable $enclosure -value $j
Create-Enclosure $j
$j = $j+4
}
#Set coordinates for host placement
$y = ""
$x = ""
if(([int]($FreeVMHost.name.split("-")[3].split(".")[0])+2) -le "10"){
$y = ([int](Get-Variable ($FreeVMHost.name.split("-")[1] + "-" + $FreeVMHost.name.split("-")[2])).value)+1
$x = ([int]($FreeVMHost.name.split("-")[3].split(".")[0])+2)
}elseif(([int]($FreeVMHost.name.split("-")[3].split(".")[0])+2) -gt "10"){
$y = ([int](Get-Variable ($FreeVMHost.name.split("-")[1] + "-" + $FreeVMHost.name.split("-")[2])).value)+2
$x = ([int]($FreeVMHost.name.split("-")[3].split(".")[0])-6)
}
#Color and write hostname
$Sheet.Cells.Item($y,$x).Orientation = 90
$Sheet.Cells.Item($y,$x).VerticalAlignment = -4108
$Sheet.Cells.Item($y,$x).HorizontalAlignment = -4108
$Sheet.Cells.Item($y,$x).Interior.ColorIndex = $i
$Sheet.Cells.Item($y,$x) = $FreeVMHost.name
}
#Clean up removes all varibles
Get-Variable | Remove-Variable
#$sheet.SaveAs("c:\temp\test.xlsx")
One thought on “Enclosure Overview”