VMware Cloud Community
srlawton
Contributor
Contributor
Jump to solution

Installing driver vib with get-esxcli

I am fairly new to PowerShell and PowerCLI, so this may be a simple question, but I have searched around and cannot find a clear example that shows me what to do. I am running 5.0 GA ESXi, vCenter, and PowerCLI.

I want to install a network driver via Powercli in the same manner I would if I ssh directly to the host, i.e.

esxcli software vib install -v /vib_file_path/vib_file_name = what in Powercli?

I have created the object as outlined in the docs, and run down the tree using the Get-Member commandlet, so I know what I need is in

$esxcli.software.vib.install()

But I do not understand what options / invocation method is required to get the command to complete. When I run this with no options, i get the usage:

TypeNameOfValue     : VMware.VimAutomation.ViCore.Util10Ps.EsxCliExtensionMethod
OverloadDefinitions : {vim.EsxCLI.software.vib.install.InstallationResult install(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string proxy, string[] vibname, string[] viburl)}
MemberType          : CodeMethod
Value               : vim.EsxCLI.software.vib.install.InstallationResult install(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string proxy, string[] vibname, string[] viburl)
Name                : install
IsInstance          : True

I am assuming that each of the pairs of brackets is a parameter, so I need give the command 3 options:

$esxcli.software.vib.install($1, $2, $3)

I have tried using a variation of these values, but the error I  get is the same:

PowerCLI C:\> $test.software.vib.install($null, "net-ixgbe-3.4.23-1OEM.500.0.0.406165.x86_64.vib", "/store/")


The remote server returned an error: (500) Internal Server Error.
At line:1 char:27
+ $test.software.vib.install <<<< ($null, "net-ixgbe-3.4.23-1OEM.500.0.0.406165.x86_64.vib", "/store/")
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodInvocationException

Anybody see what i am doing wrong?

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I'm afraid there are a few more parameters, like the message indicates

string[] depot

boolean dryrun

boolean force

boolean maintenancemode

boolean noliveinstall

boolean nosigcheck

string proxy

string[]  vibname

string[] viburl

These correspond exactly with the parameters described in the ESXCLI command.

These are all positional parameters, so if there is a parameter you don't need, you still will have to pass something in that position.

$esxcli.software.vib.install($null,$true,$false,$true,$true,$false,$null,"net-ixgbe-3.4.23-1OEM.500.0.0.406165.x86_64.vib", "/store/")

This, or something similar, should do the trick.


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

View solution in original post

Reply
0 Kudos
13 Replies
LucD
Leadership
Leadership
Jump to solution

I'm afraid there are a few more parameters, like the message indicates

string[] depot

boolean dryrun

boolean force

boolean maintenancemode

boolean noliveinstall

boolean nosigcheck

string proxy

string[]  vibname

string[] viburl

These correspond exactly with the parameters described in the ESXCLI command.

These are all positional parameters, so if there is a parameter you don't need, you still will have to pass something in that position.

$esxcli.software.vib.install($null,$true,$false,$true,$true,$false,$null,"net-ixgbe-3.4.23-1OEM.500.0.0.406165.x86_64.vib", "/store/")

This, or something similar, should do the trick.


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

Reply
0 Kudos
VMwareDeveloper
Contributor
Contributor
Jump to solution

Can someone confirm if this works ?

Reply
0 Kudos
srlawton
Contributor
Contributor
Jump to solution

I tried following the advice above, but still could not get my hosts to respond correctly. I finally dropped trying to run get-esxcli, and just used plink in my powershell script to ssh into the host, and run the esxcli install command in the busybox shell. Here is my script.

# Script to call plink and run a command via ssh directly on a host
# Requires that the Putty install directory be listed in the path statement
# Requires that PowerCLI be connected to each host individually.
# Assumes the driver.vib file has been uploaded to the local data store of the host.
# Assumes that the local datastore containing the vib driver file has "local" somewhere in the name.

#ESX Host login information
$user="root"
$pswd="password"

$ESXHost = Get-VMHost | Sort Name | ForEach {
      #Find the local datastore via name
      $DataStore = $_ | Get-Datastore | where{$_.Name -match "local"}
      #Build host DataStore path
      $DSPath = "/vmfs/volumes/$Datastore"
      #Get the hostname for plink to use
      $ID = % {$_.Name}
      #Use the PowerCLI drive provider to find the latest driver vib uploaded to the host
      $VIB = ls vmstores:\$ID@443\ha-datacenter\$DataStore\*.vib | sort LastWriteTime | select -last 1 | % {$_.Name}
      #Output what we found to make sure it is correct
      write-host $ID
      write-host $VIB
      #Build the ESX shell command we need to run to install the drivers
      $remoteCommand = "esxcli software vib install -v " + $DSPath + "/" + $VIB
      #Output what we built to make sure it is correct
      write-host $remoteCommand

      #Place host into Maintenance Mode
      If ($_.ConnectionState -notmatch "Maintenance"){$_ | Set-VMHost -State Maintenance}

      #Run the plink command
      $msg = plink -v -batch -pw $pswd $user@$ID $remoteCommand
      #output the plink results
      write-host $msg

      #Restart Host   
      $_ | Restart-VMHost -Confirm:$false
}

There are several short cuts I am taking because I have a very focused group of hosts with a strict host config that I control when I bring up a new server.

You may not have ssh enabled, for instance, or the same username and password on each of your hosts.

Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Why don't you use the Install-VMHostPatch cmdlet to install the driver? This seems much easier to me.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
srlawton
Contributor
Contributor
Jump to solution

I looked at using the Install-VMHostPatch cmdlet, but that requires the driver be built in patch form, i.e. the vib file with the metadata.zip. Often I only have access to the vib itself, so the esxcli software vib install command is my best option. 

Reply
0 Kudos
VMwareDeveloper
Contributor
Contributor
Jump to solution

Thanks everyone for the suggestions. I have resorted to using Install-VMHostPatch for now. One limitation there is that there is no equivalent uinstall like a vib.remove .. So if I try the vib.remove I see the following error -- which leads me to believe that the powerCLI functionality has not been plumbed properly to the actual esxcli functionality ..

PowerCLI C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> (Get-EsxCli -V
MHost mesx3.xxx.yyy.com).software.vib.remove($true,$true,$true,$true,"
test-vib")
Missing required parameter --vibname
At line:1 char:69
+ (Get-EsxCli -VMHost mesx3.xxx.yyy.com).software.vib.remove <<<< ($t
rue,$true,$true,$true,"test-vib")
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodInvocationExceptioncyclnane01 291 >

Looks like the vibname is not even getting passed to the invocation ..

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

There is indeed a problem in the Get-EsxCli when trying to use the 'remove' method.

But Alan shows the way around this in his Removing the vCD Agent from hosts post.

You have connect to the ESX(i) server instead of the vCenter.


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

Reply
0 Kudos
twoton
Enthusiast
Enthusiast
Jump to solution

I was able to use the method suggested by LucD.  Since I was installing a Cisco vib for a nexus 1kv using a depot URL, my code looked like below:

$esxcli= Get-Esxcli -vmHost hostname.example.com

$ciscovibpath="/vmfs/volumes/datastore/Cisco_bootbank_cisco-vem-v152-esx_4.2.1.2.1.1a.0-3.0.1.vib"

$esxcli.software.vib.install($null,$null,$null,$null,$null,$null,$null,$null,$ciscovibpath)

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Thanks for sharing that.


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

Reply
0 Kudos
srlawton
Contributor
Contributor
Jump to solution


Using twoton's example of LucD's answer, I was able to modify my script and get my vibs to install without resorting to ssh. Thank you both.

Comparing the 2 methods, my ssh script seems to be faster, though that may be because I am getting more feedback messages.  

Reply
0 Kudos
haripetrov
Contributor
Contributor
Jump to solution

Here is a simple script which can save a lot of time:

$hosts = Get-Cluster "Public Cluster" | Get-VMHost

foreach($vihost in $hosts){

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

$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")

}

P.S. Please, have in mind that when you have a vib file you have to specify "string[] viburl" and leave "string[]  vibname" empty (the example provided by LucD is not entirely correct).

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I stand corrected, I didn't know that Smiley Happy


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

Reply
0 Kudos
haripetrov
Contributor
Contributor
Jump to solution

Neither do I.
I spent several minutes to figured out that and I thought it would be a good idea if I share this here. Smiley Happy

I don't know if this is the right place but: also there is another interesting fact: "boolean maintenancemode" doesn't work (I set it to $true). I put two hosts in maintenance mode but the script above patched all hosts in the cluster without skipping the hosts which are not in maintenance mode. The version of the vCenter Server is "vCenter Server 5.1 Update 2a", ESXi "ESXi 5.1 Patch 5" (all hosts), PowerCLI 5.8 Release 1 (I also tried with PowerCLI 5.1 Release 1).

I would like to express my gratitude here for the information you have shared.

This information saved me a couple of hours.

Reply
0 Kudos