VMware Cloud Community
vin01
Expert
Expert
Jump to solution

update esxi using esxcli.software.vib.install

Hi

I need to update 100 Esxi 5.x build hosts to 5.1_update03

Tried below steps

1)uploaded "update-from-esxi5.1-5.1_update03.zip" file to all hosts datastore -- through script.

2)tried to install by ssh to a host as below command it works perfectly.

esxcli software vib install -d "/vmfs/volumes/Datastore/DirectoryName/PatchName.zip"

But i failed using powercli, Can someone correct me on below code.

Used Code:

$hosts = Get-VMHost 10.50.37.31

foreach($vihost in $hosts){

$uuid=$vihost |Get-Datastore |?{$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1|Select @{n="UUID"; e={$_.ExtensionData.Info.Vmfs.Uuid}}

  $esxcli = get-vmhost $vihost | Get-EsxCli

$esxcli.software.vib.install("/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip",$false,$true,$true,$false,$false)

#$esxcli.software.vib.install($null,$false,$false,$false,$false,$true,$null,$null,'/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip')

#$esxcli.software.vib.update($null,$false,$false,$false,$false,$true,$null,$null,"/vmfs/volumes/*datastore*/scsi-fnic-1.6.0.5-1OEM.500.0.0.472560.x86_64.vib")

}

Error :

Message:  [MetadataDownloadError];

InnerText:  [MetadataDownloadError] Could not download from depot at

zip:/vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}/update-from-esxi5.1-5.1_update03.zip?index.xml, skipping

(('zip:/vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}/update-from-esxi5.1-5.1_update03.zip?index.xml', '', "Error extracting

index.xml from /vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}/update-from-esxi5.1-5.1_update03.zip: [Errno 2] No such file or

directory: '/vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}/update-from-esxi5.1-5.1_update03.zip'")) url =

zip:/vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}/update-from-esxi5.1-5.1_update03.zip?index.xml Please refer to the log file

for more details.EsxCLI.CLIFault.summary

At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vibinstall.ps1:16 char:3

+ $esxcli.software.vib.install("/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_upda ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (:) [], ViError

    + FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViError

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

Message:  [VibDownloadError];

InnerText:  [VibDownloadError] ('/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip', '', "[Errno 4] IOError: <urlopen error [Errno 2]

No such file or directory: '/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip'>") url =

/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip Please refer to the log file for more details.EsxCLI.CLIFault.summary

At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vibinstall.ps1:18 char:3

+ $esxcli.software.vib.install($null,$false,$false,$false,$false,$true,$null,$nu ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (:) [], ViError

    + FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViError

Regards Vineeth.K
0 Kudos
1 Solution

Accepted Solutions
MKguy
Virtuoso
Virtuoso
Jump to solution

There is the --force or -f switch, see the documentation:

https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vcli.ref.doc_50%2Fesxcli_software.h...

The syntax should look like this:

$esxcli.software.vib.update(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string proxy, string[] vibname, string[] viburl)

You did this: $esxcli.software.vib.install("/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip",$false,$true,$true,$false,$false)

In ESXi shell terms this translates to force and ignore the maintenance mode requirement, both of which are not recommended:

esxcli software vib install --depot /vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip --force --maintenance-mode

What you should do however is just entering maintenance mode and execute:

esxcli software vib update --depot /vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip

So the PowerCLI command should look like this: (Again, don't forget to put the host into maintenance mode prior to this):

$esxcli.software.vib.update("/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip",$false,$false,$false,$false,$false,$null,$null,$null)

Omitting all the other unspecified parameters might work too.

Note: behavior or flags might have changed in esxcli between different versions. Compare the ESXi host versions where it works and where it doesn't, and see what options an esxcli software vib update expects. If this causes any errors

-- http://alpacapowered.wordpress.com

View solution in original post

0 Kudos
14 Replies
Wh33ly
Hot Shot
Hot Shot
Jump to solution

Try this:

$esxcli.software.vib.install("/vmfs/volumes/$uuid.uuid/update-from-esxi5.1-5.1_update03.zip",$false,$true,$true,$false,$false) 

0 Kudos
vin01
Expert
Expert
Jump to solution

no that's not working:smileyconfused:

Error

Message:  [MetadataDownloadError];

InnerText:  [MetadataDownloadError] Could not download from depot at

zip:/vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}.uuid/update-from-esxi5.1-5.1_update03.zip?index.xml, skipping

(('zip:/vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}.uuid/update-from-esxi5.1-5.1_update03.zip?index.xml', '', "Error extracting

index.xml from /vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}.uuid/update-from-esxi5.1-5.1_update03.zip: [Errno 2] No such file

or directory: '/vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}.uuid/update-from-esxi5.1-5.1_update03.zip'"))        url =

zip:/vmfs/volumes/@{UUID=514f1a00-17e89090-4207-e41f1390d694}.uuid/update-from-esxi5.1-5.1_update03.zip?index.xml Please refer to the log

file for more details.EsxCLI.CLIFault.summary

At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vibinstall.ps1:16 char:3

+   $esxcli.software.vib.install("/vmfs/volumes/$uuid.uuid/update-from-esxi5.1-5.1 ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (:) [], ViError

    + FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViError

Regards Vineeth.K
0 Kudos
MKguy
Virtuoso
Virtuoso
Jump to solution

Change the 3rd line to this, which should do the trick:

$uuid = ($vihost |Get-Datastore | ? {$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1).ExtensionData.Info.Vmfs.Uuid

-- http://alpacapowered.wordpress.com
0 Kudos
vin01
Expert
Expert
Jump to solution

No luck still same error..Not Sure where i am missing

Used Code :

$hosts = Get-VMHost 10.50.37.31

foreach($vihost in $hosts){

# $uuid=$vihost |Get-Datastore |?{$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1|Select @{n="UUID"; e={$_.ExtensionData.Info.Vmfs.Uuid}}

$uuid = ($vihost |Get-Datastore | ? {$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1).ExtensionData.Info.Vmfs.Uuid

 

  $esxcli = get-vmhost $vihost | Get-EsxCli

 

  $esxcli.software.vib.install("/vmfs/volumes/$uuid.uuid/update-from-esxi5.1-5.1_update03.zip",$false,$true,$true,$false,$false)

  #$esxcli.software.vib.install($null,$false,$false,$false,$false,$true,$null,$null,'/vmfs/volumes/$uuid.uuid/update-from-esxi5.1-5.1_update03.zip')

#$esxcli.software.vib.update($null,$false,$false,$false,$false,$true,$null,$null,"/vmfs/volumes/*datastore*/scsi-fnic-1.6.0.5-1OEM.500.0.0.472560.x86_64.vib")

}

Error:

Message:  [MetadataDownloadError];

InnerText:  [MetadataDownloadError] Could not download from depot at

zip:/vmfs/volumes/514f1a00-17e89090-4207-e41f1390d694.uuid/update-from-esxi5.1-5.1_update03.zip?index.xml, skipping

(('zip:/vmfs/volumes/514f1a00-17e89090-4207-e41f1390d694.uuid/update-from-esxi5.1-5.1_update03.zip?index.xml', '', "Error extracting

index.xml from /vmfs/volumes/514f1a00-17e89090-4207-e41f1390d694.uuid/update-from-esxi5.1-5.1_update03.zip: [Errno 2] No such file or

directory: '/vmfs/volumes/514f1a00-17e89090-4207-e41f1390d694.uuid/update-from-esxi5.1-5.1_update03.zip'"))        url =

zip:/vmfs/volumes/514f1a00-17e89090-4207-e41f1390d694.uuid/update-from-esxi5.1-5.1_update03.zip?index.xml Please refer to the log file for

more details.EsxCLI.CLIFault.summary

At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vibinstall.ps1:18 char:3

+   $esxcli.software.vib.install("/vmfs/volumes/$uuid.uuid/update-from-esxi5.1-5.1 ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (:) [], ViError

    + FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViError

Regards Vineeth.K
0 Kudos
MKguy
Virtuoso
Virtuoso
Jump to solution

You have to use it with your original code from your first post and not with the volumes/$uuid.uuid/update- version that came up here.

-- http://alpacapowered.wordpress.com
0 Kudos
vin01
Expert
Expert
Jump to solution

Tried both but still same error.Now i tried to change the code as below but its showing new error.

$hosts = Get-VMHost 10.50.37.31

foreach($vihost in $hosts){

$dspath = ($vihost |Get-Datastore | ? {$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1).ExtensionData.info.url

# $uuid=$vihost |Get-Datastore |?{$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1|Select @{n="UUID"; e={$_.ExtensionData.Info.Vmfs.Uuid}}

# $uuid = ($vihost |Get-Datastore | ? {$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1).ExtensionData.Info.Vmfs.Uuid

 

  $esxcli = get-vmhost $vihost | Get-EsxCli

 

  $esxcli.software.vib.install("$dspath update-from-esxi5.1-5.1_update03.zip",$false,$true,$true,$false,$false)

 

  #$esxcli.software.vib.install($null,$false,$false,$false,$false,$true,$null,$null,'$dspath/update-from-esxi5.1-5.1_update03.zip')

#$esxcli.software.vib.update($null,$false,$false,$false,$false,$true,$null,$null,"/vmfs/volumes/*datastore*/VMware_locker_tools-light_5.1.0-2.44.2191751.vib")

}

Error :

Message:  [ValueError];

InnerText:  [ValueError] Only server local file path is supported for offline bundles.

(ds:///vmfs/volumes/514f1a00-17e89090-4207-e41f1390d694/ /update-from-esxi5.1-5.1_update03.zip) seem to be remote URIs. Please refer to the

log file for more details.EsxCLI.CLIFault.summary

At line:13 char:3

+   $esxcli.software.vib.install("$dspath /update-from-esxi5.1-5.1_update03.zip",$ ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (:) [], ViError

    + FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViError

Regards Vineeth.K
0 Kudos
MKguy
Virtuoso
Virtuoso
Jump to solution

The new error is because it returns a string with a datastore URL instead of a "local" path, i.e. something like ds:///vmfs/volumes/[...]

You can remove the ds:// prefix from the string with something like $dspath.Substring(5) but it should work with what I provided earlier too. Did you check the exact resulting path and that your Select -first 1 statement actually selects the correct datastore?

PS D:\> $vihost = Get-VMHost -Name esxihostname.goes.here

PS D:\> $uuid = ($vihost |Get-Datastore | ? {$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1).ExtensionData.Info.Vmfs.Uuid

PS D:\> "/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip"

/vmfs/volumes/523afae4-6a4506c3-cf7f-10604bb3ace8/update-from-esxi5.1-5.1_update03.zip

Is that returning the correct path to the file on the correct datastore?

You can also just use the datastore name instead of the VMFS UUID to make it more obvious where you're heading:

$hosts = Get-VMHost 10.50.37.31 

foreach($vihost in $hosts){

  $ds = ($vihost |Get-Datastore | ? {$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1).Name

  $path = "/vmfs/volumes/$ds/update-from-esxi5.1-5.1_update03.zip"

  $esxcli = get-vmhost $vihost | Get-EsxCli 

  $esxcli.software.vib.install($path,$false,$true,$true,$false,$false)

}

-- http://alpacapowered.wordpress.com
0 Kudos
vin01
Expert
Expert
Jump to solution

Thanks MKguy..Its my mistake I am trying to get vmhost which of standalone it doesn't contains datastore with multiple host access so its pointing to some other datastore.Now I tried with other hosts which are in cluster that works.But for some hosts in output is showing Dry run only

Used Code :

$hosts = Get-VMHost 10.50.37.27

foreach($vihost in $hosts){

$uuid=($vihost |Get-Datastore |?{$_.ExtensionData.Summary.MultipleHostAccess -eq $false} |select -First 1).ExtensionData.Info.Vmfs.Uuid

#$uuid = ($vihost |Get-Datastore "*datastore*" |select -First 1).ExtensionData.Info.Vmfs.Uuid

 

$esxcli = get-vmhost $vihost | Get-EsxCli

Write-Host  -Object "Updating Esxi version on $vihost"

 

$esxcli.software.vib.install("/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip",$false,$true,$true,$false,$false)

}

Output :

===

Host 1

Message        : The update completed successfully, but the system needs to be rebooted for the changes to be effective.

RebootRequired : true

VIBsInstalled  : {VMware_bootbank_esx-base_5.1.0-3.50.2323236, VMware_bootbank_esx-tboot_5.1.0-2.23.1483097,

                 VMware_bootbank_misc-drivers_5.1.0-3.50.2323236, VMware_bootbank_net-e1000e_1.1.2-3vmw.510.2.23.1483097...}

VIBsRemoved    : {Cisco_bootbank_net-enic_2.1.2.50-1OEM.500.0.0.472560, VMware_bootbank_esx-base_5.1.0-1.22.1472666,

                 VMware_bootbank_esx-tboot_5.1.0-0.0.799733, VMware_bootbank_misc-drivers_5.1.0-1.20.1312873...}

VIBsSkipped    : {VMware_bootbank_ata-pata-amd_0.3.10-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-atiixp_0.4.6-4vmw.510.0.0.799733,

                 VMware_bootbank_ata-pata-cmd64x_0.2.5-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-hpt3x2n_0.3.4-3vmw.510.0.0.799733...}

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

Host 2

==========

Message        : Dryrun only, host not changed. The following installers will be applied: [BootBankInstaller, LockerInstaller]

RebootRequired : true

VIBsInstalled  : {VMware_bootbank_ata-pata-amd_0.3.10-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-atiixp_0.4.6-4vmw.510.0.0.799733,

                 VMware_bootbank_ata-pata-cmd64x_0.2.5-3vmw.510.0.0.799733, VMware_bootbank_ata-pata-hpt3x2n_0.3.4-3vmw.510.0.0.799733...}

VIBsRemoved    : {Emulex_bootbank_scsi-lpfc820_8.2.2.121.45-1OEM.500.0.0.472560, VMware_bootbank_ata-pata-amd_0.3.10-3vmw.500.0.0.469512,

                 VMware_bootbank_ata-pata-atiixp_0.4.6-3vmw.500.0.0.469512, VMware_bootbank_ata-pata-cmd64x_0.2.5-3vmw.500.0.0.469512...}

VIBsSkipped    :

But when I tried by ssh to the server and executed

esxcli software vib install -d "/vmfs/volumes/50c97d9d-fb383900-4bd2-00151752c641/update-from-esxi5.1-5.1_update03.zip"

its installed sucessfully

Regards Vineeth.K
MKguy
Virtuoso
Virtuoso
Jump to solution

I'm not sure why it works in an SSH session and does a dry run when using the same command on the same host, but here are some guesses:

Did you make sure the host was in maintenance mode at that time when you executed the PowerCLI code?

Check the logfile in /var/log/esxupdate.log after executing the PowerCLI code.

Have you tried the force option too?

Also you should really use the esxcli software vib update command instead of install to apply patches. Using install might downgrade or remove packages entirely:

VMware KB: Installing patches on an ESXi 5.x host from the command line

Using the update command is the recommended method for patch application. Using this command applies all of the newer contents in a patch, including all security fixes. Contents of the patch that are a lower revision than the existing packages on the system are not applied.

Using the install command overwrites the existing packages in the system with contents of the patch you are installing, including installing new packages and removing old packages. The install command may downgrade packages on the system and should be used with caution. If required, the install command can be used to downgrade a system (only for image profiles) when the --allow-downgrade flag is set.

Caution: The install method has the possibility of overwriting existing drivers. If you are using 3rd party ESXi images, VMware recommends using the update method to prevent an unbootable state.

-- http://alpacapowered.wordpress.com
vin01
Expert
Expert
Jump to solution

None of the hosts which i executed in the script are in maintenance mode.I ll go through the logs and post here.

OK i will give a try with esxcli software vib update

how force update

What is dry run can you elaborate  please.

Regards Vineeth.K
0 Kudos
MKguy
Virtuoso
Virtuoso
Jump to solution

None of the hosts which i executed in the script are in maintenance mode.

Whoa there, you should always place your hosts into maintenance mode before applying any patches, no matter what way. Actually the patch metadata for packages like esx-base states maintenance mode as a mandatory requirement and should enforce that. No idea why some of your hosts apparently didn't enforce it. Make sure you set your hosts into maintenance mode first!

What is dry run can you elaborate  please.

A dry run is just a "what if" scenario that doesn't take any actions, it just tells you what it would do.

-- http://alpacapowered.wordpress.com
0 Kudos
vin01
Expert
Expert
Jump to solution

Ok Thanks got it..But i aware that host should be in maintenance mode but when i tried using ssh it worked successfully that's why i tried using powercli.

One question How to force update..

Regards Vineeth.K
0 Kudos
MKguy
Virtuoso
Virtuoso
Jump to solution

There is the --force or -f switch, see the documentation:

https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vcli.ref.doc_50%2Fesxcli_software.h...

The syntax should look like this:

$esxcli.software.vib.update(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string proxy, string[] vibname, string[] viburl)

You did this: $esxcli.software.vib.install("/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip",$false,$true,$true,$false,$false)

In ESXi shell terms this translates to force and ignore the maintenance mode requirement, both of which are not recommended:

esxcli software vib install --depot /vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip --force --maintenance-mode

What you should do however is just entering maintenance mode and execute:

esxcli software vib update --depot /vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip

So the PowerCLI command should look like this: (Again, don't forget to put the host into maintenance mode prior to this):

$esxcli.software.vib.update("/vmfs/volumes/$uuid/update-from-esxi5.1-5.1_update03.zip",$false,$false,$false,$false,$false,$null,$null,$null)

Omitting all the other unspecified parameters might work too.

Note: behavior or flags might have changed in esxcli between different versions. Compare the ESXi host versions where it works and where it doesn't, and see what options an esxcli software vib update expects. If this causes any errors

-- http://alpacapowered.wordpress.com
0 Kudos
vin01
Expert
Expert
Jump to solution

Thanks that working perfectly.

Kept host in maintenance mode

Rebooted the host

Executed the above code

Regards Vineeth.K
0 Kudos