Unsolved
This post is more than 5 years old
5 Posts
0
1637
October 16th, 2009 04:00
Unable to insert Criteria for SelectiveGroups in using perl API
Hello all,
I'am working on a script to adding automatically Selectivegroups to SAM.
To do that I'm using the perl API. Everything is working except the insertion of criteria (filters).
I've tried a lot of methods but I don't understand why it doesn't work.
Behind my script :
#!/usr/bin/perl
use InCharge::session;
use InCharge::object;
use Data::Dumper;
$DEBUG=1;
#
#Connexion à un DM
#conToSAM(broker,DM,username,password);
#
sub conToDM(){
$session=InCharge::session->new(
broker=>$_[0],
domain=>$_[1],
username=>$_[2],
password=>$_[3]
);
}
#
#Deconnexion du DM
#discoToDM();
#
sub discoToDM(){
$session->detach();
}
#
#
#
sub createGroup(){
$session->create("SelectiveGroup","HGRP-".$_[0]);
$obj=$session->object("SelectiveGroup","HGRP-".$_[0]);
open(RAA,"/opt/aqos/lco/scripts/regions/".$_[0]."_sousregions.txt")||die("marche pas");
$i=0;
@buffer="";
while( ){
$buffer[$i]=$_;
$i++;
}
close(RAA);
open(RAA2,"/opt/aqos/lco/scripts/regions/".$_[0]."_sousregionsNumber.txt")||die("marche pas");
$l=0;
@bufferNumber="";
while( ){
$bufferNumber[$l]=$_;
$l++;
}
close(RAA2);
@childs="";
@childstocreate="";
@selects="";
for $org (0..$#buffer){
$childs[$org]="SelectiveGroup::HGRP-".$_[0]."/".$buffer[$org];
$childstocreate[$org]="HGRP-".$_[0]."/".$buffer[$org];
$selects[$org]="ICF_GroupSelector::S-HGRP-".$_[0]."/".$buffer[$org];
}
chomp(@childs);
chomp(@childstocreate);
chomp(@selects);
for $or (0..$#childs){
print "create : ".$childstocreate[$or]."\n";
$session->create("SelectiveGroup",$childstocreate[$or]);
$session->create("ICF_GroupSelector","S-".$childstocreate[$or]);
}
$obj->put("IsTopLevel",1);
$obj->put("Description",$_[0].": 1");
$obj->put("DisplayName",$_[0]);
$obj->put("Generation",1);
$obj->insertElement("MemberOf","HierarchicalGroupManager::ICS-HierarchicalGroupManager");
$obj->put("TargetClass","UnitaryComputerSystem");
$obj->insertElement("ChildGroups",@childs);
$obj->insertElement("Selects",@selects);
####TEST###
$obj2=$session->object("SelectiveGroup","HGRP-RAA/URCAM d'Auvergne");
$obj2->put("DisplayName","URCAM d'Auvergne");
$obj2->put("Description","URCAM d'Auvergne : 63X");
$obj2->put("Generation",10);
$obj2->put("TargetClass","UnitaryComputerSystem");
$obj3=$session->object("ICF_GroupSelector","S-HGRP-RAA/URCAM d'Auvergne");
$obj3->put("SelectedBy","SelectiveGroup::HGRP-RAA");
$obj3->put("ChildGroup","SelectiveGroup::HGRP-RAA/URCAM d'Auvergne");
$obj3->put("Priority",0);
###HERE IS MY PROBLEM###
####BEGIN######
@name = ("Name","BB-*");
@vendor = ("Vendor","CISCO");
@criteria = ( \@name, \@vendor );
%criteria2=("Vendor"=>"CISCO","Name"=>"BB*");
%name3 = (Name=>"BB-*");
%vendor3 = (Vendor=>"CISCO");
%criteria3 = ( \@name, \@vendor );
$obj3->insertElement("criteria",@criteria);
#####END######
}
&conToDM("55.18.4.81","SUP-NAT-SAM","admin","changeme");
&createGroup("RAA");
&discoToDM();
##################
I obtain two errors depending the code I use :
[6] Unknown argument (internal type 'Name') for InCharge primitive 'insertElement_P', stopped at /opt/aqos/lco/scripts/tmp.pl line 104
[6] Reference to 2-element array expected for argument to InCharge primitive 'insertElement_P', stopped at /opt/aqos/lco/scripts/tmp.pl line 104
the first one when I use the line : $obj3->insertElement("criteria",\@criteria);
and the second one with $obj3->insertElement("criteria",@criteria);
The script is launched with : /opt/InCharge7/SAM/smarts/bin/sm_perl /opt/aqos/lco/scripts/tmp.pl
I hope my explanation and my english are good.
By advance, thank you
I'am working on a script to adding automatically Selectivegroups to SAM.
To do that I'm using the perl API. Everything is working except the insertion of criteria (filters).
I've tried a lot of methods but I don't understand why it doesn't work.
Behind my script :
#!/usr/bin/perl
use InCharge::session;
use InCharge::object;
use Data::Dumper;
$DEBUG=1;
#
#Connexion à un DM
#conToSAM(broker,DM,username,password);
#
sub conToDM(){
$session=InCharge::session->new(
broker=>$_[0],
domain=>$_[1],
username=>$_[2],
password=>$_[3]
);
}
#
#Deconnexion du DM
#discoToDM();
#
sub discoToDM(){
$session->detach();
}
#
#
#
sub createGroup(){
$session->create("SelectiveGroup","HGRP-".$_[0]);
$obj=$session->object("SelectiveGroup","HGRP-".$_[0]);
open(RAA,"/opt/aqos/lco/scripts/regions/".$_[0]."_sousregions.txt")||die("marche pas");
$i=0;
@buffer="";
while( ){
$buffer[$i]=$_;
$i++;
}
close(RAA);
open(RAA2,"/opt/aqos/lco/scripts/regions/".$_[0]."_sousregionsNumber.txt")||die("marche pas");
$l=0;
@bufferNumber="";
while( ){
$bufferNumber[$l]=$_;
$l++;
}
close(RAA2);
@childs="";
@childstocreate="";
@selects="";
for $org (0..$#buffer){
$childs[$org]="SelectiveGroup::HGRP-".$_[0]."/".$buffer[$org];
$childstocreate[$org]="HGRP-".$_[0]."/".$buffer[$org];
$selects[$org]="ICF_GroupSelector::S-HGRP-".$_[0]."/".$buffer[$org];
}
chomp(@childs);
chomp(@childstocreate);
chomp(@selects);
for $or (0..$#childs){
print "create : ".$childstocreate[$or]."\n";
$session->create("SelectiveGroup",$childstocreate[$or]);
$session->create("ICF_GroupSelector","S-".$childstocreate[$or]);
}
$obj->put("IsTopLevel",1);
$obj->put("Description",$_[0].": 1");
$obj->put("DisplayName",$_[0]);
$obj->put("Generation",1);
$obj->insertElement("MemberOf","HierarchicalGroupManager::ICS-HierarchicalGroupManager");
$obj->put("TargetClass","UnitaryComputerSystem");
$obj->insertElement("ChildGroups",@childs);
$obj->insertElement("Selects",@selects);
####TEST###
$obj2=$session->object("SelectiveGroup","HGRP-RAA/URCAM d'Auvergne");
$obj2->put("DisplayName","URCAM d'Auvergne");
$obj2->put("Description","URCAM d'Auvergne : 63X");
$obj2->put("Generation",10);
$obj2->put("TargetClass","UnitaryComputerSystem");
$obj3=$session->object("ICF_GroupSelector","S-HGRP-RAA/URCAM d'Auvergne");
$obj3->put("SelectedBy","SelectiveGroup::HGRP-RAA");
$obj3->put("ChildGroup","SelectiveGroup::HGRP-RAA/URCAM d'Auvergne");
$obj3->put("Priority",0);
###HERE IS MY PROBLEM###
####BEGIN######
@name = ("Name","BB-*");
@vendor = ("Vendor","CISCO");
@criteria = ( \@name, \@vendor );
%criteria2=("Vendor"=>"CISCO","Name"=>"BB*");
%name3 = (Name=>"BB-*");
%vendor3 = (Vendor=>"CISCO");
%criteria3 = ( \@name, \@vendor );
$obj3->insertElement("criteria",@criteria);
#####END######
}
&conToDM("55.18.4.81","SUP-NAT-SAM","admin","changeme");
&createGroup("RAA");
&discoToDM();
##################
I obtain two errors depending the code I use :
[6] Unknown argument (internal type 'Name') for InCharge primitive 'insertElement_P', stopped at /opt/aqos/lco/scripts/tmp.pl line 104
[6] Reference to 2-element array expected for argument to InCharge primitive 'insertElement_P', stopped at /opt/aqos/lco/scripts/tmp.pl line 104
the first one when I use the line : $obj3->insertElement("criteria",\@criteria);
and the second one with $obj3->insertElement("criteria",@criteria);
The script is launched with : /opt/InCharge7/SAM/smarts/bin/sm_perl /opt/aqos/lco/scripts/tmp.pl
I hope my explanation and my english are good.
By advance, thank you
No Events found!
commarla
5 Posts
0
October 20th, 2009 02:00
$obj2=$session->object("ICF_GroupSelector","S-HGRP-TopGroup/SousGroupe");
@bla=[["STRING","Location"],["STRING","CC"]];
$obj2->put("criteria",\@bla);
that's all
Bye.
tomas_nekolny
13 Posts
0
November 20th, 2009 03:00
Hello,
I need to do the exact thing in ASL and I am not able to figure out the syntax. Do not you know how to do the same thing in ASL please?
Thank you very much.
Tom
tomas_nekolny
13 Posts
0
November 20th, 2009 05:00
Figured it out
But lost some two hours with it. Did not know that the "table" in the criteria is not a "table" property but "list" property
Here is the solution if someone needs that:
ASL:
insertValues=list();
selHandle= object("ICF_GroupSelector","S-HGRP-TopGroup/Grouptest");
insertValues=list(„Location“,“CC“);
selHandle->criteria+=insertValues;
Bye T.
commarla
5 Posts
0
November 20th, 2009 05:00
Hello,
I'm sorry I never do that in asl.
What kind of errors have you got?
Regards,
Laurent.
commarla
5 Posts
0
November 20th, 2009 07:00
well done
Bye
tomas_nekolny
13 Posts
0
November 24th, 2009 01:00
Hi again,
any idea how to regroup the server from ASL/Perl/dmctl? Can not find the right command.
Thank you,
T.
Message was edited by: Tomas Nekolny Sorry, just found it :) groupHandle->regroup(); :)
commarla
5 Posts
0
November 24th, 2009 02:00
Hi
In perl :
$obj=$session->object("SelectiveGroup","HGRP-TEST");
$obj->regroup();
Regards,
Ce message a été modifié par: commarla Ok I've just seen your update :)