summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e824252)
raw | patch | inline | side by side (parent: e824252)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 6 Aug 2008 13:33:34 +0000 (13:33 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 6 Aug 2008 13:33:34 +0000 (13:33 +0000) |
* bugfix: check_opsi_res
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12162 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12162 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index a2eaf89a15f2a5b79d5739ad2c298682c5427586..dcf3b063f5f081d96c97d005e8bcbe392be31e4d 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
}
-sub check_opsi_res {
- my $res= shift;
- if($res) {
- if ($res->is_error) {
- &main::daemon_log("ERROR: opsi configed communication failed: ".$res->error_message, 1);
- } else {
- return 1;
- }
- } else {
- &main::daemon_log("ERROR: opsi configed communication failed: ".$opsi_client->status_line, 1);
- }
- return 0;
-}
-
-
sub watch_for_done_jobs {
#CHECK: $heap for what?
my ($kernel,$heap) = @_[KERNEL, HEAP];
};
my $hres = $opsi_client->call($opsi_url, $callobj);
+ my ($hres_err, $hres_err_string) = &check_opsi_res($hres);
if (&check_opsi_res($hres)) {
my $htmp= $hres->result->{$hostId};
index f0998cfe37575eae466f6ec24a38c1df87ce7524..c10a0e46f5d19f03f12017b6974ea30b1f9104eb 100644 (file)
"run_as",
"inform_all_other_si_server",
"read_configfile",
+ "check_opsi_res",
);
@EXPORT = @functions;
use strict;
}
+sub check_opsi_res {
+ my $res= shift;
+
+ if($res) {
+ if ($res->is_error) {
+ my $error_string;
+ if (ref $res->error_message eq "HASH") {
+ $error_string = $res->error_message->{'message'};
+ } else {
+ $error_string = $res->error_message;
+ }
+ return 1, $error_string;
+ }
+ } else {
+ return 1, $main::opsi_client->status_line;
+ }
+ return 0;
+}
+
+
1;
index e38f7c495202e3588f71ed4cf243d00663c0e57d..d0acd00cddce00ee84a3df15ff26902bfda6d392 100644 (file)
# TODO: check dependencies later on?
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
}
params => [ $productId, $hostId, "setup" ],
id => 1, };
+
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
- &main::daemon_log("ERROR: cannot add product: ".$sres->error_message, 1);
- &add_content2xml_hash($out_hash, "error", $sres->error_message);
+ my ($sres_err, $sres_err_string) = &check_opsi_res($sres);
+ if ($sres_err){
+ &main::daemon_log("$session_id ERROR: cannot add product: ".$sres_err_string, 1);
+ &add_content2xml_hash($out_hash, "error", $sres_err_string);
}
# return message
my ($hostId, $productId);
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
}
# id => 1, };
#
#my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- #if (&main::check_opsi_res($sres)){
- # &main::daemon_log("ERROR: cannot perform dependency check: ".$res->error_message, 1);
- # &add_content2xml_hash($out_hash, "error", $res->error_message);
+ #my ($sres_err, $sres_err_string) = &check_opsi_res($sres);
+ #if ($sres_err){
+ # &main::daemon_log("ERROR: cannot perform dependency check: ".$sres_err_string, 1);
+ # &add_content2xml_hash($out_hash, "error", $sres_err_string);
# return ( &create_xml_string($out_hash) );
#}
id => 1, };
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
- &main::daemon_log("ERROR: cannot get product action list: ".$sres->error_message, 1);
- &add_content2xml_hash($out_hash, "error", $sres->error_message);
+ my ($sres_err, $sres_err_string) = &check_opsi_res($sres);
+ if ($sres_err){
+ &main::daemon_log("$session_id ERROR: cannot get product action list: ".$sres_err_string, 1);
+ &add_content2xml_hash($out_hash, "error", $sres_err_string);
return ( &create_xml_string($out_hash) );
}
my $uninst_possible= 0;
}
}
if (!$uninst_possible){
- &main::daemon_log("ERROR: cannot uninstall product", 1);
+ &main::daemon_log("$session_id ERROR: cannot uninstall product", 1);
&add_content2xml_hash($out_hash, "error", "product is not uninstallable");
return ( &create_xml_string($out_hash) );
}
id => 1, };
$sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
- &main::daemon_log("ERROR: cannot delete product: ".$sres->error_message, 1);
- &add_content2xml_hash($out_hash, "error", $sres->error_message);
+ my ($sres_err, $sres_err_string) = &check_opsi_res($sres);
+ if ($sres_err){
+ &main::daemon_log("$session_id ERROR: cannot delete product: ".$sres_err_string, 1);
+ &add_content2xml_hash($out_hash, "error", $sres_err_string);
return ( &create_xml_string($out_hash) );
}
my $hostId;
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
}
if (defined @{$msg_hash->{'ip'}}[0]){
$ip = @{$msg_hash->{'ip'}}[0];
}
- if (defined @{$msg_hash->{'mac'}}[0]){
- $mac = @{$msg_hash->{'mac'}}[0];
+ if (defined @{$msg_hash->{'macaddress'}}[0]){
+ $mac = @{$msg_hash->{'macaddress'}}[0];
}
my $callobj;
$callobj = {
- method => 'createclient',
+ method => 'createClient',
params => [ $name, $domain, $description, $notes, $ip, $mac ],
id => 1,
};
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
- &main::daemon_log("ERROR: cannot create client: ".$sres->error_message, 1);
- &add_content2xml_hash($out_hash, "error", $sres->error_message);
+ my ($sres_err, $sres_err_string) = &check_opsi_res($sres);
+ if ($sres_err){
+ &main::daemon_log("$session_id ERROR: cannot create client: ".$sres_err_string, 1);
+ &add_content2xml_hash($out_hash, "error", $sres_err_string);
}
# return message
my $hostId;
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
}
id => 1,
};
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
- &main::daemon_log("ERROR: cannot set description: ".$sres->error_message, 1);
- &add_content2xml_hash($out_hash, "error", $sres->error_message);
+ my ($sres_err, $sres_err_string) = &check_opsi_res($sres);
+ if ($sres_err){
+ &main::daemon_log("ERROR: cannot set description: ".$sres_err_string, 1);
+ &add_content2xml_hash($out_hash, "error", $sres_err_string);
return ( &create_xml_string($out_hash) );
}
}
id => 1,
};
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
- &main::daemon_log("ERROR: cannot set notes: ".$sres->error_message, 1);
- &add_content2xml_hash($out_hash, "error", $sres->error_message);
+ my ($sres_err, $sres_err_string) = &check_opsi_res($sres);
+ if ($sres_err){
+ &main::daemon_log("ERROR: cannot set notes: ".$sres_err_string, 1);
+ &add_content2xml_hash($out_hash, "error", $sres_err_string);
return ( &create_xml_string($out_hash) );
}
}
id => 1,
};
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
- &main::daemon_log("ERROR: cannot set mac address: ".$sres->error_message, 1);
- &add_content2xml_hash($out_hash, "error", $sres->error_message);
+ my ($sres_err, $sres_err_string) = &check_opsi_res($sres);
+ if ($sres_err){
+ &main::daemon_log("ERROR: cannot set mac address: ".$sres_err_string, 1);
+ &add_content2xml_hash($out_hash, "error", $sres_err_string);
return ( &create_xml_string($out_hash) );
}
}
my $hostId;
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
}
my %r = ();
for (@{$res->result}) { $r{$_} = 1 }
- if (&main::check_opsi_res($res)){
+ if (&check_opsi_res($res)){
if (defined $hostId){
$callobj = {
};
my $hres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($hres)){
+ if (&check_opsi_res($hres)){
my $htmp= $hres->result->{$hostId};
# check state != not_installed or action == setup -> load and add
};
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
+ if (&check_opsi_res($sres)){
my $tres= $sres->result;
my $name= xml_quote($tres->{'name'});
};
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
+ if (&check_opsi_res($sres)){
my $tres= $sres->result;
my $name= xml_quote($tres->{'name'});
my $hostId;
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
# Get hostID if defined
if (defined @{$msg_hash->{'hostId'}}[0]){
id => 1,
};
my $res = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($res)){
+ if (&check_opsi_res($res)){
foreach my $action (@{$res->result}){
&add_content2xml_hash($out_hash, "action", $action);
}
$res = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($res)){
+ if (&check_opsi_res($res)){
my $r= $res->result;
foreach my $key (keys %{$r}) {
my $item= "<item>";
my $hostId;
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
&add_content2xml_hash($out_hash, "ProductId", $productId);
# Get hostID if defined
}
my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-
- if (!&main::check_opsi_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);
+ my ($res_err, $res_err_string) = &check_opsi_res($res);
+# TODO : This error message sounds strange
+ if ($res_err){
+ &man::daemon_log("$session_id ERROR: no communication failed while setting '".$item->{'name'}[0]."': ".$res_err_string, 1);
+ &add_content2xml_hash($out_hash, "error", $res_err_string);
}
}
my $hostId = @{$msg_hash->{'hostId'}}[0];
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
};
my $res = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($res)){
+ if (&check_opsi_res($res)){
my $result= $res->result;
foreach my $r (keys %{$result}){
my $item= "<item><id>".xml_quote($r)."</id>";
my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
};
my $res = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($res)){
+ if (&check_opsi_res($res)){
foreach my $host (@{$res->result}){
my $item= "<item><name>".$host->{'hostId'}."</name>";
my $hostId = @{$msg_hash->{'hostId'}}[0];
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
};
my $res = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($res)){
+ if (&check_opsi_res($res)){
my $result= $res->result;
}
my $hostId;
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
# Get hostID if defined
if (defined @{$msg_hash->{'hostId'}}[0]){
my %r = ();
for (@{$res->result}) { $r{$_} = 1 }
- if (&main::check_opsi_res($res)){
+ if (&check_opsi_res($res)){
if (defined $hostId){
$callobj = {
};
my $hres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($hres)){
+ if (&check_opsi_res($hres)){
my $htmp= $hres->result->{$hostId};
# check state != not_installed or action == setup -> load and add
};
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
+ if (&check_opsi_res($sres)){
my $tres= $sres->result;
my $name= xml_quote($tres->{'name'});
};
my $sres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($sres)){
+ if (&check_opsi_res($sres)){
my $tres= $sres->result;
my $name= xml_quote($tres->{'name'});
my $hostId = @{$msg_hash->{'hostId'}}[0];
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
# Set parameters in opsi
if (not $error) {
# build return message with twisted target and source
- my $out_hash = &main::create_xml_hash("answer_$header", $target, $source);
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (defined $forward_to_gosa) {
&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa);
};
my $hres = $main::opsi_client->call($main::opsi_url, $callobj);
- if (&main::check_opsi_res($hres)){
+ if (&check_opsi_res($hres)){
my $htmp= $hres->result->{$hostId};
# check state != not_installed or action == setup -> load and add
id => 1,
};
my $res = $main::opsi_client->call($main::opsi_url, $callobj);
- if (!&main::check_opsi_res($res)){
+ if (!&check_opsi_res($res)){
&main::daemon_log("ERROR: cannot set product action request for $hostId!", 1);
} else {
&main::daemon_log("INFO: requesting 'setup' for '".$product->{'productId'}."' on $hostId", 1);
index 62b0a6648ed2740fb64335dee7cb5892dc94efcb..11368f7a8434ad625bf2b5333a7e1e3664105621 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
# Install Opsi client
$data = "<xml> <header>job_opsi_install_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>limux-cl-2.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e5</macaddress> </xml>";
+ # Add Opsi client
+ $data = "<xml> <header>gosa_opsi_add_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>limux-cl-1.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e6</macaddress> <description>Test halt</description> </xml>";
+
+ # Add product to Opsi client
+
+ # Delete product from Opsi client
#########################
# Mailqueue communication