summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b9aa1a1)
raw | patch | inline | side by side (parent: b9aa1a1)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Jul 2008 11:25:54 +0000 (11:25 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Jul 2008 11:25:54 +0000 (11:25 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11605 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/client/events/opsi.pm | patch | blob | history |
index d32423d75398f2d607e31d891a48ae5face0807e..b0526905238f2b4245bd97c3a787fdac654123ca 100644 (file)
sub check_res {
my $res= shift;
- # TODO: We need to return the outhash!
+ # TODO: We need to return the outhash!?
my $out_hash;
if($res) {
sub opsi_get_netboot_products {
- my ($msg, $msg_hash) = @_;
- my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'source'}}[0];
- my $target = @{$msg_hash->{'target'}}[0];
- my $session_id = @{$msg_hash->{'session_id'}}[0];
- my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
- my $hostId;
+ my ($msg, $msg_hash) = @_;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+ my $session_id = @{$msg_hash->{'session_id'}}[0];
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ my $hostId;
+
+ # build return message with twisted target and source
+ my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ &add_content2xml_hash($out_hash, "session_id", $session_id);
+
+ # Get hostID if defined
+ if (defined @{$msg_hash->{'hostId'}}[0]){
+ $hostId = @{$msg_hash->{'hostId'}}[0];
+ &add_content2xml_hash($out_hash, "hostId", $hostId);
+ }
- # build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
- &add_content2xml_hash($out_hash, "session_id", $session_id);
+ if (defined $forward_to_gosa) {
+ &add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
+ }
+ &add_content2xml_hash($out_hash, "xxx", "");
+ my $xml_msg= &create_xml_string($out_hash);
- # Get hostID if defined
- if (defined @{$msg_hash->{'hostId'}}[0]){
- $hostId = @{$msg_hash->{'hostId'}}[0];
- &add_content2xml_hash($out_hash, "hostId", $hostId);
- }
+ # For hosts, only return the products that are or get installed
+ my $callobj;
+ $callobj = {
+ method => 'getNetBootProductIds_list',
+ params => [ ],
+ id => 1,
+ };
- if (defined $forward_to_gosa) {
- &add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
- }
- &add_content2xml_hash($out_hash, "xxx", "");
- my $xml_msg= &create_xml_string($out_hash);
+ my $res = $client->call($opsi_url, $callobj);
+ my %r = ();
+ for (@{$res->result}) { $r{$_} = 1 }
+
+ if (check_res($res)){
- # Authenticate
- my $callobj;
if (defined $hostId){
- $callobj = {
- method => 'getNetBootProductIds_list',
- params => [ $hostId ],
- id => 1,
- };
- } else {
- $callobj = {
- method => 'getNetBootProductIds_list',
- params => [ ],
- id => 1,
- };
- }
+ $callobj = {
+ method => 'getProductStates_hash',
+ params => [ $hostId ],
+ id => 1,
+ };
- my $res = $client->call($opsi_url, $callobj);
- if (check_res($res)){
+ my $hres = $client->call($opsi_url, $callobj);
+ if (check_res($hres)){
+ my $htmp= $hres->result->{$hostId};
+
+ # check state != not_installed or action == setup -> load and add
+ foreach my $product (@{$htmp}){
+
+ if (!defined ($r{$product->{'productId'}})){
+ next;
+ }
+
+ # Now we've a couple of hashes...
+ if ($product->{'installationStatus'} ne "not_installed" or
+ $product->{'actionRequest'} eq "setup"){
+ my $state= "<state>".$product->{'installationStatus'}."</state><action>".$product->{'actionRequest'}."</action>";
+
+ $callobj = {
+ method => 'getProduct_hash',
+ params => [ $product->{'productId'} ],
+ id => 1,
+ };
+
+ my $sres = $client->call($opsi_url, $callobj);
+ if (check_res($sres)){
+ my $tres= $sres->result;
+
+ my $name= xml_quote($tres->{'name'});
+ my $r= $product->{'productId'};
+ my $description= xml_quote($tres->{'description'});
+ $name=~ s/\//\\\//;
+ $description=~ s/\//\\\//;
+ $xml_msg=~ s/<xxx><\/xxx>/<item><ProductId>$r<\/ProductId><name><\/name><description>$description<\/description><\/item>$state<xxx><\/xxx>/;
+ }
+
+ }
+ }
+
+ }
+
+ } else {
foreach my $r (@{$res->result}) {
$callobj = {
method => 'getProduct_hash',
}
}
+
+ }
}
$xml_msg=~ s/<xxx><\/xxx>//;
if (check_res($res)){
my $result= $res->result;
foreach my $r (keys %{$result}){
- my $item= "<item><name>".xml_quote($r)."</name>";
+ my $item= "<item><id>".xml_quote($r)."</id>";
my $value= $result->{$r};
foreach my $sres (@{$value}){
}
}
+ }
$item.= "</item>";
- $xml_msg=~ s/<xxx><\/xxx>/$item<xxx><\/xxx>/;
+ $xml_msg=~ s%<xxx></xxx>%$item<xxx></xxx>%;
- }
}
}
sub opsi_get_local_products {
- my ($msg, $msg_hash) = @_;
- my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'source'}}[0];
- my $target = @{$msg_hash->{'target'}}[0];
- my $session_id = @{$msg_hash->{'session_id'}}[0];
- my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
- my $hostId;
+ my ($msg, $msg_hash) = @_;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+ my $session_id = @{$msg_hash->{'session_id'}}[0];
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ my $hostId;
+
+ # build return message with twisted target and source
+ my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ &add_content2xml_hash($out_hash, "session_id", $session_id);
+
+ # Get hostID if defined
+ if (defined @{$msg_hash->{'hostId'}}[0]){
+ $hostId = @{$msg_hash->{'hostId'}}[0];
+ &add_content2xml_hash($out_hash, "hostId", $hostId);
+ }
- # Get hostID if defined
- if (defined @{$msg_hash->{'hostId'}}[0]){
- $hostId = @{$msg_hash->{'hostId'}}[0];
- }
+ if (defined $forward_to_gosa) {
+ &add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
+ }
+ &add_content2xml_hash($out_hash, "xxx", "");
+ my $xml_msg= &create_xml_string($out_hash);
- # build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
- &add_content2xml_hash($out_hash, "session_id", $session_id);
+ # For hosts, only return the products that are or get installed
+ my $callobj;
+ $callobj = {
+ method => 'getLocalBootProductIds_list',
+ params => [ ],
+ id => 1,
+ };
- if (defined $forward_to_gosa) {
- &add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
- }
- &add_content2xml_hash($out_hash, "xxx", "");
- my $xml_msg= &create_xml_string($out_hash);
+ my $res = $client->call($opsi_url, $callobj);
+ my %r = ();
+ for (@{$res->result}) { $r{$_} = 1 }
+
+ if (check_res($res)){
- # Append hostId
- my $callobj;
if (defined $hostId){
- $callobj = {
- method => 'getLocalBootProductIds_list',
- params => [ $hostId ],
- id => 1,
- };
- } else {
- $callobj = {
- method => 'getLocalBootProductIds_list',
- params => [ ],
- id => 1,
- };
- }
+ $callobj = {
+ method => 'getProductStates_hash',
+ params => [ $hostId ],
+ id => 1,
+ };
- my $res = $client->call($opsi_url, $callobj);
- if (check_res($res)){
+ my $hres = $client->call($opsi_url, $callobj);
+ if (check_res($hres)){
+ my $htmp= $hres->result->{$hostId};
+
+ # check state != not_installed or action == setup -> load and add
+ foreach my $product (@{$htmp}){
+
+ if (!defined ($r{$product->{'productId'}})){
+ next;
+ }
+
+ # Now we've a couple of hashes...
+ if ($product->{'installationStatus'} ne "not_installed" or
+ $product->{'actionRequest'} eq "setup"){
+ my $state= "<state>".$product->{'installationStatus'}."</state><action>".$product->{'actionRequest'}."</action>";
+
+ $callobj = {
+ method => 'getProduct_hash',
+ params => [ $product->{'productId'} ],
+ id => 1,
+ };
+
+ my $sres = $client->call($opsi_url, $callobj);
+ if (check_res($sres)){
+ my $tres= $sres->result;
+
+ my $name= xml_quote($tres->{'name'});
+ my $r= $product->{'productId'};
+ my $description= xml_quote($tres->{'description'});
+ $name=~ s/\//\\\//;
+ $description=~ s/\//\\\//;
+ $xml_msg=~ s/<xxx><\/xxx>/<item><ProductId>$r<\/ProductId><name><\/name><description>$description<\/description><\/item>$state<xxx><\/xxx>/;
+ }
+
+ }
+ }
+
+ }
+
+ } else {
foreach my $r (@{$res->result}) {
$callobj = {
method => 'getProduct_hash',
if (check_res($sres)){
my $tres= $sres->result;
- my $name= $tres->{'name'};
- my $description= $tres->{'description'};
+ my $name= xml_quote($tres->{'name'});
+ my $description= xml_quote($tres->{'description'});
$name=~ s/\//\\\//;
$description=~ s/\//\\\//;
- $xml_msg=~ s/<xxx><\/xxx>/<item><id>".xml_quote($r).<\/id><name><\/name><description>".xml_quote($description)."<\/description><\/item><xxx><\/xxx>/;
+ $xml_msg=~ s/<xxx><\/xxx>/<item><ProductId>$r<\/ProductId><name><\/name><description>$description<\/description><\/item><xxx><\/xxx>/;
}
}
+
+ }
}
$xml_msg=~ s/<xxx><\/xxx>//;