A sample perl script to create a 4x agent. This could be useful when you need to have a 4x agent to login to FSS Admin UI and you don't already have a WAMUI to create one.
Thanks Ujwol, this helped me. I will try to figure out how can I add these agents to agentgroup. If I have some problem I will update.
Just a note "!@" on line number 12 created problem, I removed it and it works.
Hi Richard,
Your current code is not optimal for creating multiple agents.
I have modified the source code to match your requirement to create multiple agents.See below :
Script: fssuiagentmultiple.pl
****************************************************************
# A sample Perl script to create multiple 4.x Agent
use Netegrity::PolicyMgtAPI;
$adminName = 'siteminder';
$adminPwd = 'siteminder';
$agentIP = '127.0.0.1';
$agentSecret = 'siteminder';
#$agentName = 'fssadminui';
@agentNames = ("agent1", "agent2", "agent3", "agent4", "agent5");
!@
$policymgtapi = Netegrity::PolicyMgtAPI->New();
$session = $policymgtapi->CreateSession($adminName, $adminPwd);
die "\nFATAL: Cannot create session. Please check admin credentials\n"
unless ($session != undef);
foreach my $i (0..4) {
if(!defined $session->GetAgent($agentNames[$i])){
print "\n\t\'$agentNames[$i]\' agent does not exist.";
}
else{
print "\n\tDeleting Agent \'$agentNames[$i]\'...";
$session->DeleteAgent($session->GetAgent($agentNames[$i]));
print "done.";
print "\n\tCreating Agent \'$agentNames[$i]\'...";
$agent = $session->CreateAgent( $agentNames[$i],
$session->GetAgentType("Web Agent"),
"4x Agent for FSS AdminUI",
$agentIP,
$agentSecret
);
if(!defined $agent) {
die "\nFATAL: Unable to create Agent \'$agentNames[$i]\'\n";
print "done\n";
Sample result :
C:\Program Files (x86)\CA\SiteMinder\CLI\bin>perl fssuiagentmultiple.pl
'agent1' agent does not exist.
Creating Agent 'agent1'...
'agent2' agent does not exist.
Creating Agent 'agent2'...
'agent3' agent does not exist.
Creating Agent 'agent3'...
'agent4' agent does not exist.
Creating Agent 'agent4'...
'agent5' agent does not exist.
Creating Agent 'agent5'...done
Hope this helps.
Let me know how it goes.
Cheers,
Ujwol
Hi Ujwol,
Thanks for sharing this script.
I am trying to create multiple agents(say more then 5) using the same script, this script works and creates 2 agents but after that perl.exe crashes. Can you please suggest if this script is wrong or there is something else I need to add so that I can create multiple agents using same script.
# A sample Perl script to create 4.x Agent
==============================================================
#creating 1st agent
$adminPwd = 'firewall';
#$agentIP = '127.0.0.1';
#$agentSecret = 'siteminder';
#$agentName = 'agent1';
if(!defined $session->GetAgent($agentName)){
print "\n\t\'$agentName\' agent does not exist.";
print "\n\tDeleting Agent \'$agentName\'...";
$session->DeleteAgent($session->GetAgent($agentName));
print "\n\tCreating Agent \'$agentName\'...";
$agent = $session->CreateAgent( $agentName,
"agent1",
die "\nFATAL: Unable to create Agent \'$agentName\'\n";
#creating 2nd agent
$agentName = 'agent2';
"agent2",
=============================================================
and further you can add same code to test.
Thank You
And you can use XPSExplorer to create 4x agent as well.