Unsolved
This post is more than 5 years old
4 Posts
0
1039
June 19th, 2009 12:00
Add values to GA_StringDictionary via Perl
Hello,
I am writing a program in perl that will periodically write values to a GA_StringDIctionary object in the repo. This is my first script to use the Perl API, so I apologize for my ignorance. The issue that I having is that I cannot figure out how to insert values for key pairs. I've tried a couple of things, but haven't come accross anything to do this.
my $tunnelDict = $session->create( "GA_StringDictionary::SWIFT_ConnecticityMonitor-Tunnels" );
foreach my $dTunnel (keys(%tunnels))
{
$tunnelDict->insert("key", ["$dTunnel", "$tunnels{$dTunnel}->{NotifiedTime}"]);
}
This is the closest thing that looks like what I want to do is above but this doesn't work.
Has anyone tried writing key value pairs to a GA_StringDictionary using the Perl API that could give me some guidance.
I am writing a program in perl that will periodically write values to a GA_StringDIctionary object in the repo. This is my first script to use the Perl API, so I apologize for my ignorance. The issue that I having is that I cannot figure out how to insert values for key pairs. I've tried a couple of things, but haven't come accross anything to do this.
my $tunnelDict = $session->create( "GA_StringDictionary::SWIFT_ConnecticityMonitor-Tunnels" );
foreach my $dTunnel (keys(%tunnels))
{
$tunnelDict->insert("key", ["$dTunnel", "$tunnels{$dTunnel}->{NotifiedTime}"]);
}
This is the closest thing that looks like what I want to do is above but this doesn't work.
Has anyone tried writing key value pairs to a GA_StringDictionary using the Perl API that could give me some guidance.
No Events found!
Hemulll
2 Intern
•
138 Posts
0
June 19th, 2009 22:00
I can not find the examples in perl_ref guide.
Why you not use ASL code?
Where is your key value defined ? Key should be unique.
Try to use this code, or insertElement functions page 49 in perl_ref, sorry not tested by myself
$tunnelDict->insert($dTunnel, $tunnels{$dTunnel}->{NotifiedTime});
ASL code example
foreach processor (cpuTable) {
if (defined(cpuTable[processor])) {
procObj = nodeObj->makeProcessor(string(processor));
undef(historyTable[procObj->Name])?IGNORE;
relKey = nodeObj->Name."|".processor."|";
relObj->insert(relKey, string(procObj->Name));
}
}
FredericMeunier_0588be
143 Posts
0
June 22nd, 2009 06:00
this should work:
---------------------------------------
my $session = InCharge::session->init();
my $myhash = $session->create("GA_StringDictionary", "MyHash");
$myhash->insert("key", "value");
my $value = $myhash->find("key");
print $value . "\n";
my $exists = $myhash->contains("key1");
print $exists . "\n";
$exists = $myhash->contains("key");
print $exists . "\n";
$session->detach();
---------------------------------------
what you show us in the code is :
insert( "key", [ key, value ] );
you should use:
insert( key, value );
--Fred
== Monitor your Smarts environment using APG ReportPack for Smarts health ==
Frederic Meunier
Solutions Watch4Net Inc
APG & Smarts InCharge integration
http://www.watch4net.com
g0ld2k
4 Posts
0
June 22nd, 2009 08:00
Thanks for your help, but using $obj->insert does not seem to work. I did however find another way to do it.
$tunnelDict->invoke("insert", "$dTunnel", "$tunnels{$dTunnel}->{NotifiedTime},$tunnels{$dTunnel}->{ClearedTime},$tunnels{$dTunnel}->{HostName}");
This is not the most ellegant solution but it seems to work.
Thanks for your help.
~Chris
FredericMeunier_0588be
143 Posts
0
June 22nd, 2009 10:00
This should have the exact same behavior.
$obj->invoke( "method", @args )
or
$obj->method ( @args )
is the same and works the same, except for a few methods.
--Fred