VMware Cloud Community
loneragang
Contributor
Contributor

Identify if an ESX host is Boot from San

Hi,

I am trying to find an identifier if an ESX host is running on local or remote disk, ie boot from SAN through powercli, but I can't find if there is a field for this. Does anyone know if this is something that can be reported on through this or if it is only identiable through the boot sequence?

Thanks

Gareth

Tags (2)
12 Replies
LucD
Leadership
Leadership

It looks as if the HostBootDeviceSystem might hold this information.

Can you try if the following returns the information you're after

$esx = Get-VMHost MyHost

if($esx.ExtensionData.ConfigManager.BootDeviceSystem){     $bootMgr = Get-View $esx.ExtensionData.ConfigManager.BootDeviceSystem     $devs = $bootMgr.QueryBootDevices     $devs.bootDevices     Write-Host "Current boot device" $devs.currentBootDeviceKey } else{     Write-Host "No boot device config present"
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

loneragang
Contributor
Contributor

That was the area I thought it would be if it was there, I have hosts that are boot from local disk and boot from san and this field appears empty on . I only have esx 4.0 hosts that are setup to boot from san, so cant see if it works for 3.5 or 4.1, but can say for 4.0 it doesn't seem to supply the information required

Cheers

Gareth

0 Kudos
LucD
Leadership
Leadership

I was fraid of that, but at the moment I know no other way.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
loneragang
Contributor
Contributor

I thought that might have been the case, thanks LucD

0 Kudos
DanMan3395
Enthusiast
Enthusiast

it has been YEARS since this post and I am trying the same api (.ExtensionData.ConfigManager.BootDeviceSystem) and its still blank... are we still in a place where this information cannot be checked via API directly?

0 Kudos
LucD
Leadership
Leadership

Does this work for you?

$esx = Get-VMHost MyEsx

$esxcli = Get-EsxCli -VMHost $esx -v2

$boot = $esxcli.system.boot.device.get.Invoke()

$esxcli.storage.filesystem.list.Invoke() | where {$_.Uuid -eq $boot.BootFileSystemUuid}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

DanMan3395
Enthusiast
Enthusiast

I think this would work actually. I am going to test on some of our legacy stuff and report back.

-----------------------

X:\> $esxcli.system.boot.device.get

==================

EsxCliMethodElement: get

   Methods:

   --------

   SystemBootDevice Invoke()

   string Help()

---------------

X:\> $esxcli.system.boot.device.get.Invoke()

BootFilesystemUUID BootNIC              StatelessBootNIC

------------------ -------              ----------------

                   01-00-fd-45-48-b6-60  

0 Kudos
DanMan3395
Enthusiast
Enthusiast

yep works perfectly. if no correlation its just blank.

Do you know how to reference a result like this as a Boolean for the purposes of scripting a large quantity of hosts?

I tried variation along this theme but the return value is not Boolean so it always succeeds or fails.

$temp = $esxcli



if($temp -ne $null){

Write-Host "true"

0 Kudos
LucD
Leadership
Leadership

You mean something like this?

Get-VMHost |

   ForEach-Object -Process {

   $esxcli = Get-EsxCli -VMHost $_ -v2

   $esxcli.system.boot.device.get.Invoke() |

  Select @{N = 'VMHost'; E = {$esxcli.VMHost.Name}},

   @{N = 'BootFilesystemPresent'; E = {$_.BootFilesystemUuid -ne ''}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

DanMan3395
Enthusiast
Enthusiast

lol yes that worked perfectly. The only issue is that the block I pasted below uses aliases that are beyond me. I get what you are doing but I do not know how to use select-object in this way.

Select-Object is called obviously but what does @{N = 'VMHost'; E = {$esxcli.VMHost.Name}}, translate too without this aliasing?

Select @{N = 'VMHost'; E = {$esxcli.VMHost.Name}},

   @{N = 'BootFilesystemPresent'; E = {$_.BootFilesystemUuid -ne ''}}

0 Kudos
DanMan3395
Enthusiast
Enthusiast

I bought your book, let me know what chapter covers this Smiley Wink

0 Kudos
LucD
Leadership
Leadership

Those are called 'calculated properties'.
They are basically a hash table with 2 entries, a N(ame) part and an E(xpression) part.

In the Expression part, which is a code block, you can make whatever calculation you want.

Just make sure to produce some output.

In this case I used a comparison which will produce $true or $false.

Thanks (for the book), and I think this might be covered in one of the Reporting chapters.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference