Phew that title is a mouthful. Sorry about that. But at least you know what I’m gonna talk about here. Nothing particularly profound, but obviously something every customer must do. I’ve been on a solid PowerShell kick as of late so why not put pen to paper here.
So whether you are using VVols or VMFS (or gross: RDMs) you need to do a bit of prep work to get things up and running. I will likely write a post on doing this with the vSphere Client Plugin, but for now let’s focus on doing it with PowerShell.
So step one is to install the PowerShell module that will help you. This is hosted on the PowerShell Gallery, so it is fairly simple to install:
install-module PureStorage.FlashArray.VMware
If you already have it installed, don’t forget to pull the latest version:
update-module PureStorage.FlashArray.VMware
Prep Work
Next step is to connect to your vCenter with PowerCLI (I am assuming you already have this installed, if not, run: Install-Module VMware.PowerCLI).
connect-viserver -Server <my vCenter> -credential (get-credential)
Then we need to connect to our FlashArray. We can use New-PfaConnection for this.
$flasharray = new-pfaConnection -endpoint <FlashArray FQDN/IP> -credentials (Get-Credential) -ignoreCertificateError -nonDefaultArray
My new cluster looks like this:
On a FlashArray we want to create a “host” object for each ESXi server. A FlashArray host is a collection of initiators that represent a physical server. Furthermore, (as best practices dictate) we should create a “host group” that corresponds to the VMware cluster. All of the hosts for the servers in that cluster should be in the FlashArray host group.
As you can see on my FlashArray, I neither have a host group for the “Cupertino” cluster, nor hosts for esxi-11 or esxi-12.
The last thing is to store our cluster in an object. My cluster is “Cupertino”:
$cluster = Get-Cluster <cluster name>
So let’s do it!
Create a New Host Group
There are a few relevant cmdlets for hosts and host groups. Let’s focus on the host group ones for now:
- Get-PfaHostGroupFromVcCluster. This looks to see if a host group exists on a FlashArray for a given cluster.
- New-PfaHostGroupFromVcCluster. This creates a new host group and its hosts for a given cluster.
Both of these take in two things, a cluster and a FlashArray connection. So first let’s verify that a host group does not exist:
Just as we thought. Not there. So let’s create it.
The New-PfaHostGroupFromVcCluster cmdlet takes in the same things as the other (cluster and FlashArray connection) but also one of two other options. -iSCSI or -FC. This indicates if we should configure the host and FlashArray for iSCSI or FC. In this environment it is iSCSI.
What this cmdlet does is the following:
- Iterates though each ESXi host in the cluster
- If iSCSI, it will check the host for a software iSCSI adapter. If it does not exist, it will create it. Then, it adds the FlashArray iSCSI targets to the ESXi host and sets our best practices (LoginTimeout to 30 seconds and disables DelayedAck). If any or all of this already done, it will silently skip that entire host or setting.
- If FibreChannel, nothing is done on the host.
- It then goes to the FlashArray and creates a FlashArray host using the network name of the ESXi host. Then it will add the identified initiators to the new host. For FC, it will add all WWNs. For iSCSI it will add the IQN of the software adapter. This cmdlet DOES NOT support hardware iSCSI. If the FlashArray version is Purity 5.0 or later, it will set the ESXi host personality. If the FlashArray host already exists, it will skip it this whole step.
- It will then repeat step 2-4 for each host.
- Lastly, it will create a new host group and put the new hosts into it. If one of the hosts somehow is in a different host group already, this will fail.
- It will then return the host group information.
Okay so the operation:
New-PfaHostGroupfromVcCluster -flasharray $flasharray -iscsi -cluster $cluster
The host group is created and the hosts are added
The hosts have their initiators and the ESXi host personality is set:
Adding a Host
Okay so what if later I add a host? Well the simplest option is to rerun the above command:
New-PfaHostGroupfromVcCluster -flasharray $flasharray -iscsi -cluster $cluster
I have a third host. So the above workflow will find a host is not configured/added and add it: