Forum Discussion
Richard_Milner-
Aug 16, 2012Nimbostratus
Thanks for the responses, it's really nice to see active forum support for these things. Here's my Pool creation script in case it helps anyone out:
-------------------------------------------------------------------------
function Create-Pool()
Check whether a Pool exists, create it if required.
The following arguments are expected to be arrays: $MemberIPList $MemberPortList $HealthMonitorList
-------------------------------------------------------------------------
{
Param([string] $poolName, [string] $LBMethod, [String[]] $MemberIPList, [String[]] $MemberPortList, [String[]] $HealthMonitorList )
$PoolArray = @()
$PoolArray = (Get-F5.iControl).LocalLBPool.get_list()
If ($PoolArray -contains $poolName) {
Write-Host "Pool: $poolName already exists" -ForegroundColor Cyan
} Else {
try {
$IPPortDefList = New-Object -TypeName iControl.CommonIPPortDefinition[] $MemberIPList.Count;
for($i=0; $i -lt $MemberIPList.Count; $i++) {
$IPPortDefList[$i] = New-Object -TypeName iControl.CommonIPPortDefinition;
$IPPortDefList[$i].address = $MemberIPList[$i];
$IPPortDefList[$i].port = $MemberPortList[$i];
}
(Get-F5.iControl).LocalLBPool.create( (,$poolName), (,$LBMethod), (,$IPPortDefList) );
Write-Host "Created Pool: $poolName" -ForegroundColor Green
$monitor_association = New-Object -TypeName iControl.LocalLBPoolMonitorAssociation;
$monitor_association.pool_name = $poolName;
$monitor_association.monitor_rule = New-Object -TypeName iControl.LocalLBMonitorRule;
$monitor_association.monitor_rule.type = "MONITOR_RULE_TYPE_AND_LIST";
$monitor_association.monitor_rule.quorum = 1;
$monitor_association.monitor_rule.monitor_templates = $HealthMonitorList;
$monitor_associations = (, $monitor_association);
(Get-F5.iControl).LocalLBPool.set_monitor_association( $monitor_associations );
Write-Host "Assigned monitors to Pool `"$PoolName`"..." -ForegroundColor Green
} Catch {
Write-Host "There was an exception thrown creating Pool: $profileName" -ForegroundColor Red
$Error[0]
}
}
}