White Papers

50
#List only pools with enough free space
#TECH NOTE:the following commands are PS Series cmdlets
#if the volume already exists a warning will be presented
$MyPools = Get-EqlPool|where-object {$_.FreeSpaceMB -gt $MinFree}
foreach ($pool in $MyPools)
{
[int]$FreeSpace = $pool.FreeSpaceMB/1024/1024
[int]$FreeSapceMB =$pool.FreeSpaceMB
write-host $pool.StoragePoolName Free: $FreeSpace.ToString() TB
#Lets just check for for enough free space -
if ($pool.StoragePoolName -eq $PoolName){
if ($FreeSapceMB -le $MinFree){
Write-Host "This pool does not have enough free space " $PoolName
exit 86
}
}
}
################################################################################
#2. Create the New PS Series Volume
##TECH NOTE:the following command is a PS Series cmdlet
write-host "We will now create a new volume in " $PoolName " on PS Series
Group:" $GroupName
$newVolume = New-EqlVolume -VolumeName $ThisVol -VolumeSizeMB $VolUsable -
ThinProvision yes -StoragePoolName $PoolName -SnapshotBorrowingEnabled true -
GroupName $GroupName
if ($newVolume -le 0){
write-host $newVolume " Problem creating the volume"
}
#IQN and iSCSI Target will need to be retrieved before we can connect this host
###############################################################################
#IQN is the iSCSI Qualified Name - the identifier for the Host
#This is also known as the initiator in iSCSI terminology
#The iSCSI target will represent the volume on the iSCSI SAN
###############################################################################
#Windows 2003 and above
$hostn = ($env:computername)
#Next we need the iscsi initiator (host) for the iqn for new acl
#TECH NOTE:the following command is accessing the WMI api
$object = get-wmiobject -namespace root\WMI -class
MSiSCSIInitiator_MethodClass -Computer $hostn
$IQN = $object.iSCSINodeName
#3. Create the ACL from your host to the Volume for access. using the IQN from
above
Write-Host "New access enabled for " $ThisVol " to " $IQN " Host Name:" $hostn
#TECH NOTE:the following command is a PS Series cmdlet
new-EqlVolumeAcl -volumename $ThisVol -GroupName $GroupName -InitiatorName $IQN
-AclTargetType volume_and_snapshot
#Obtain the new iscsi target (the new volume)
#PS Series cmdlet to get the volume information specifically
#the iscsi target name
$MyVol = Get-EqlVolume -VolumeName $ThisVol -GroupName $GroupName
#Get the volume iscsi target name from volume information
$iTARGET=$MyVol.ISCSITargetName
#Refresh of the portal to update the initator
#TECH NOTE:the following command is using the Windows iscsicli command line
interface
Invoke-Expression ("iscsicli.exe refreshtargetportal $TargetPortal 3260")