Monthly Archives: February 2012

Adding and removing Equallogic ACL’s

Sometimes you may want to add or remove ESX/ESXi hosts (or HyperV of anything really) where you need to add or remove entries from the Equallogic SAN ACL.

For examples, we have about 25 volumes connected to our ESX cluster and when we replace a new host, we need to add a new entry, on all 25, and remove an entry on all 25.

So I wrote a powershell script to do the hard work. THe following code can be saved as set-eqlinitiator.ps1.

To use it, you would execute it like this:

Set-eqlInitator.ps1 "iqn.1998-01.com.vmware:myserver-2cfdfaef" remove

That would remove the supplied initiator from all the the volumes that meet the criteria. What criteria? This one:
{$_.VolumeName -like "VMFS*"}

If you want to add (rather than remove) run the same command without specifying “remove”.

All of our ESX volume start with VMFS which makes it fairly easy. You may need to change the filter depending on how you name them in your environment.

So here is the code:


param ([string]$initiator,[string]$remove)

#Check if the EQL add-in's are loaded
if (-not(get-module -name "EqlPSTools"))
	{
	Write-Host "EqlPSTools not loaded, attempting to load."
	import-module -name "C:\Program Files\EqualLogic\bin\EqlPSTools.dll"
	if (-not(get-module -name "EqlPSTools"))
		{
		Write-Host "Loading of EqlPSTools failed, script ending."
		exit
		}
	}



If ($initiator -eq "")
	{
	$initiator = Read-Host "Please enter the iSCSI initiator name:"
	}

Connect-EqlGroup 	-GroupAddress 172.16.250.20 `
					-UserName grpadmin `
					-Password PASSWORD


If ($initiator -ne "")
	{
	If ($remove -ne "remove")
		{
		get-eqlvolume | `
		where {$_.VolumeName -like "VMFS*"} | `
		New-EqlVolumeACL -UseIndex -InitiatorName $initiator -AclTargetType volume_and_snapshot
		Write-Host "added initiator $initiator"
		}
	Else
		{
		get-eqlvolume | `
		where {$_.VolumeName -like "VMFS*"} | `
		Get-EqlVolumeACL | Where {$_.InitiatorName -match $initiator} | `
		Remove-EqlVolumeACL -AclIndex {$_.index}
		Write-Host "removed initiator $initiator"
		}
	}	

Or you can grab a copy from here:
http://tinyurl.com/7t5t6ca

Advertisements

Leave a comment

Filed under Equallogic, Microsoft, Powershell, VMware