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:
- What API do you call to register the plugin? What information is needed to populate it?
- 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:
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 126.96.36.199 release.
Let’s walk through those, but first another point.
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.
You can do this all with vRealize Orchestrator too:
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.
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 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 like a FlashArray connection.
You can skip the confirmation question with -confirm:$false
Of course if you want to uninstall the plugin you can use uninstall-pfavsphereplugin: