Forum Discussion
Looking for help with add_persistence_profile
All,
Looking for an example on how to add a default persistence profile to a virtual server. I see the example in the api doc, just not exactly sure how I set the profile.
add_persistence_profile(
in String [] virtual_servers,
in LocalLB__VirtualServer__VirtualServerPersistence [] [] profiles
);
Currently doing my work in powershell, but will take any language example.
Thanks.
4 Replies
- Jonathan_Scholi
Cirrostratus
Java example:
String persistenceProfile = the_persistence_you_want; LocalLBVirtualServerVirtualServerPersistence[][] persistence_profiles = new LocalLBVirtualServerVirtualServerPersistence[1][1]; LocalLBVirtualServerVirtualServerPersistence localPersistence = new LocalLBVirtualServerVirtualServerPersistence(); localPersistence.setProfile_name(persistenceProfile); localPersistence.setDefault_profile(true); persistence_profiles[0][0] = localPersistence; iControlInterfaces.getLocalLBVirtualServer().add_persistence_profile(virtualServers,persistence_profiles); - tnttobin_92979
Nimbostratus
All:
Does anyone have an example of implemting add_persistence_profile in PowerShell? This snippet below is loosely based upon this sample: https://devcentral.f5.com/wiki/iControl.PsProvisionVEForLocalDev.ashx
Example:
$Persistence = New-Object -TypeName iControl.LocalLBVirtualServerVirtualServerPersistence;
$Persistence.profile_name = "dest_addr"
$Persistence.default_profile = $true;
$Pers_ProfileA = (, $Persistence);
$Pers_ProfileAofA = (, $Pers_ProfileA);
Try {
(Get-F5.iControl).LocalLBVirtualServer.add_persistence_profile(($name, $Pers_ProfileAofA));
}
Catch {
Write-Host "Error - Adding Persistence Profile! - Exception - $_.exception" -ForegroundColor Red
}
I receive the following exception: Cannot find an overload for "add_persistence_profile" and the argument count: "1"
Any pointer would be great...I have searched all over the place and the only sample that comes close is the Java one listed here.
Thanks!
F5 Device Version: BIG-IP 10.2.1 Build 297.0 Final That looks close, but not quite there.
The function looks like this
add_persistence_profile(string [] virtual_servers, LocalLB.VirtualServer.VirtualServerPersistence [] [] profiles)
The extra parentheses around the parameters are converting the two parameters into a single array parameter.
Try changing the function call to
(Get-F5.iControl).LocalLBVirtualServer.add_persistence_profile( (, $name), $Pers_ProfileAofA);
That will convert the virtual_servers parameter into a string array, and leave the second parameter correct.
Note, I haven't tried this, but I believe it should work.
-Joe
- tnttobin_92979
Nimbostratus
After taking a fresh look today, it appears to be a syntax error that caused the iControl interface to throw an exception the lead me down the wrong path. This works now :-)
Set Source Address Affinity - so called "sticky session"
$Persistence = New-Object -TypeName iControl.LocalLBVirtualServerVirtualServerPersistence;
$Persistence.profile_name = 'source_addr'
$Persistence.default_profile = $true
$Pers_ProfileA = (, $Persistence);
$Pers_ProfileAofA = (, $Pers_ProfileA);
Write-Host "Enabling Source Address Affinity on Virtual Server `"$name`"...";
Try {
(Get-F5.iControl).LocalLBVirtualServer.add_persistence_profile($name, $Pers_ProfileAofA)
}
Catch {
Write-Host "Error - Adding Persistence Profile! - Exception - $_.exception" -ForegroundColor Red
Write-Host "Message - $_.exception.message" -ForegroundColor Red
Write-Host "Deleting VS: $name"
(Get-F5.iControl).LocalLBVirtualServer.delete_virtual_server(($name))
}
}
Else
{
Write-Host "Error - VS Name Already Exists - $name"
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
