From: cajus Date: Mon, 7 Jul 2008 16:35:13 +0000 (+0000) Subject: Finalized set properties X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e6553f96557a33c13aab01341e13776ebfdcafd4;p=gosa.git Finalized set properties git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11548 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/client/events/opsi.pm b/gosa-si/client/events/opsi.pm index 3ce4cb33a..6f8bbfdb6 100644 --- a/gosa-si/client/events/opsi.pm +++ b/gosa-si/client/events/opsi.pm @@ -221,31 +221,51 @@ sub opsi_set_product_properties { 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 $productId = @{$msg_hash->{'ProductId'}}[0]; my $hostId; - # Get hostID if defined - if (defined @{$msg_hash->{'hostId'}}[0]){ - $hostId = @{$msg_hash->{'hostId'}}[0]; - } - # 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); + &add_content2xml_hash($out_hash, "ProductId", $productId); + + # Get hostID if defined + if (defined @{$msg_hash->{'hostId'}}[0]){ + $hostId = @{$msg_hash->{'hostId'}}[0]; + &add_content2xml_hash($out_hash, "hostId", $hostId); + } if (defined $forward_to_gosa) { &add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); } -# Params += objectId ='hostId' + # Find properties + foreach my $item (@{$msg_hash->{'item'}}){ + # JSON Query + my $callobj; -# Produkt -# Property -# Wert -# ntfs-restore-image -# -# askbeforeinst -# false -# + if (defined $hostId){ + $callobj = { + method => 'setProductProperty', + params => [ $productId, $item->{'name'}[0], $item->{'value'}[0], $hostId ], + id => 1, + }; + } else { + $callobj = { + method => 'setProductProperty', + params => [ $productId, $item->{'name'}[0], $item->{'value'}[0] ], + id => 1, + }; + } + + my $res = $client->call($opsi_url, $callobj); + + if (!check_res($res)){ + &main::daemon_log("ERROR: no communication failed while setting '".$item->{'name'}[0]."': ".$res->error_message, 1); + &add_content2xml_hash($out_hash, "error", $$res->error_message); + } + + } # return message return &create_xml_string($out_hash);