Installing the Pure Storage vSphere Plugin with PowerShell

A common question I hear is “can I install the Pure vSphere Plugin via PowerShell?” and my answer has been up until now, “sorry no :(”

But I was asked it twice last week and I decided to actually think about it? Why couldn’t it be automated? Just because we host in in the FlashArray and it is normally installed via our GUI? That GUI has to be executing code to do the install.

Installing a vSphere plugin is really two steps. First registering the plugin as an extension (this says what the plugin is, what version, etc). And then actually installing the plugin files to the vCenter. In a normal situation, someone logs into our GUI, connect to the vCenter and then runs the “install” which is really just registering the extension. In that registered extension, there is a link to where the plugin files can be downloaded from. This is step 2. At some point after registration, the vSphere Client downloads the files. In the Flash version, it happened the next time you logged in (this is why logging in took so long the first time you logged in after installing plugin). In the HTML-5 vSphere Client, this happens in the background, so there is no delay in logging in.

Okay. So there are two hurdles to doing this:

  1. What API do you call to register the plugin? What information is needed to populate it?
  2. Once the plugin is installed where is the plugin? Where do I tell vSphere to download from?

The first problem was easy to solve. There is an API method in ExtensionManager called updateExtension() and registerExtension(). These respectively update a plugin and register a new one.

In PowerCLI, (once you’ve connected to vCenter) you can get this fairly easily:

$services = Get-view 'ServiceInstance'
$extensionMgr  = Get-view $services.Content.ExtensionManager
#to update:
$extensionMgr.UpdateExtension($extensionSpec)
#to install new:
$extensionMgr.RegisterExtension($extensionSpec)

How to build the extension spec will of course vary between every vendors plugins, but the key part is registering the download location. Which is problem #2.

So on the FlashArray, we host the plugin on the array controllers, and someone can login to the GUI (or CLI) and run the installation. That process registers the extension and the download URL is that arrays management IP and the plugin zip. Will look like this:

https://10.21.202.101/download/purestorage-vsphere-plugin.zip?version=4.0.0

Nothing special about this. So what I did is bypassed the GUI and just rewrote it in PowerShell.

In the module I manage (PureStorage.FlashArray.VMware) I added two new cmdlets, Install-PfavSpherePlugin and Get-PfavSpherePlugin in the 1.2.1.0 release.

Let’s walk through those, but first another point.

Cloud-hosted Plugin

We are working on changing how the plugin is offered and delivered, but I made a small step in improving this process. As it stands, if you want a new plugin installed, you have to open a case with Pure support and we load the latest plugin on your array, and then you can push it to your various vCenters. Not the greatest system–which is what we are changing. But the full implementation of the change is still in the future.

So what I did is host the latest plugin versions on an S3 bucket, that is publicly accessible. So If you want the latest plugin, you do not even need to get it loaded on your array. Just run the cmdlet! I will post the latest versions of the plugins there as they release.

Get-PfavSpherePlugin

This tells you what plugins you have on an array, or what is out there hosted.

If you just run it without any parameters, you will only get what is on the cloud.

Of course, if your organization does not let you route out to this URL over 443, then it will return nothing.

Or you can pass in FlashArray connections, or IPs, or domain names. In this case, it will query the arrays for what versions they have. This will return the versions on those arrays and the ones on the cloud.

If you have connected arrays using new-pfaconnection, it will pick those up and query those arrays too

Also, there are two switch parameters. HTML and Flash. This will allow you to only return arrays that have that type of plugin:

Lastly, version. If you want to see who has what version, enter in the version.

Install-PfavSpherePlugin

Install-PfavSpherePlugin actually installs the plugin.

Here is its behavior:

  • Defaults to installing the release on the cloud. Unless you specify a particular source
  • Defaults to installing the HTML-5 plugin, unless you specify -flash
  • Requires confirmation. So it will interactively ask you if you want to install. This will tell you the existing version on your vCenter (if there is one) what version and type it wants to install/upgrade. You can bypass this with the -confirm:$false parameter.
  • It will block installation on vCenter 5.x, I haven’t tested it, and nor do I plan to
  • It will block installation of the HTML-5 plugin on any vCenter earlier than 6.5–we only support it with vCenter 6.5+
  • If the same or newer version of that type (flash or HTML) plugin is installed, it will fail.

In my vCenter, I do not have any plugins installed:

So, I run the following:

connect-viserver -Server test-vc -Credential $creds
Install-PfavSpherePlugin

The cmdlet returns the extension object, so you can store it, or out-null if you don’t need it.

And you will see it download:

Ready to use!

So the cmdlet has very similar options to the other one, specify the plugin type (-html or -flash) or the version (-version). It can also take in specific sources (FlashArray connections, FlashArray FQDNs or IPs).

9 thoughts on “Installing the Pure Storage vSphere Plugin with PowerShell”

  1. Hi Cody, unfortunately I cant get to the S3 storage (network policies) but I was able to download the zip off network. Is there away to install the plug in from that download without trying to download the file?

    Thanks!

    1. So you have two options:
      -Have support load it to your FlashArray (open a support ticket and ask for the latest plugin to be loaded) and then just install it from the FlashArray GUI
      -Or you can host the zip file on some internal object store or web server (an HTTPS link) and manually edit the PowerShell with the new URL and also hardcode the version. You just need to be careful with this method, so don’t try it first with a production vCenter. I have been toying with updating the module to support this, but haven’t had the request yet so I haven’t.

      Let me know which you want to do. If you want the latter option, I can write a blog post on how to do it.

      1. Actually, our security group just opened up some rules for me so I was able to run the script… ran into a different error… but thats something I need to investigate now.

        “Install-PfavSpherePlugin : Exception calling “RegisterExtension” with “1” argument(s): “A specified parameter was not
        correct: extension.key””

        1. Oh I know why you hit this error. I’m in customer meetings all day, but I think this is a simple fix on my part. Has to do with the way it failed to download the first time

          1. Hi Cody,

            In the 6.7 flash client I hit check for new plugins and it completed the install and I can now access the plugin from html 5. So from our perspective we are all good. Thanks for all your help!

          2. I suspect when the network pipe opened up the “check for new plugins” process re-engaged the vSphere Client to re-attempt the plugin download and it went through. A restart of the vSphere UI (or time itself) would have resolved this too. The latest release of vSphere 6.7 are better at polling for this too

  2. Hi Cody,

    I guess it depends on the follow question I have. So what we ran into is that we have an old vcenter that has the flash plug in (which is what loaded on our array) but we are setting up a new vcenter and need the html 5 plugin. If we do the first option and have the latest plugin loaded, would we still be able to run the flash plugin on our old vcenter? If so I think we will go that route, if not that the second option you presented would work for us.

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.