summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f4c5d56)
raw | patch | inline | side by side (parent: f4c5d56)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 28 Oct 2009 16:17:24 +0000 (16:17 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 28 Oct 2009 16:17:24 +0000 (16:17 +0000) |
* add new function _getProductStates_hash
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14678 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14678 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/server/events/opsi_com.pm | patch | blob | history |
index 2f5fdf894b1f1181113b1bd98fd5471b3e791f0a..5e423d9ff1bd01ea626bffaf90cc2005d367910d 100644 (file)
use GOSA::GosaSupportDaemon;
use Data::Dumper;
use XML::Quote qw(:all);
-use Time::HiRes qw( time );
BEGIN {}
# ----------------------------------------------------------------------------
my $licenseTyp_hash = { 'OEM'=>'', 'VOLUME'=>'', 'RETAIL'=>''};
-
-
+my ($opsi_enabled, $opsi_server, $opsi_admin, $opsi_password, $opsi_url, $opsi_client);
+my %cfg_defaults = (
+ "Opsi" => {
+ "enabled" => [\$opsi_enabled, "false"],
+ "server" => [\$opsi_server, "localhost"],
+ "admin" => [\$opsi_admin, "opsi-admin"],
+ "password" => [\$opsi_password, "secret"],
+ },
+);
+&read_configfile($main::cfg_file, %cfg_defaults);
+if ($opsi_enabled eq "true") {
+ use JSON::RPC::Client;
+ use XML::Quote qw(:all);
+ use Time::HiRes qw( time );
+ $opsi_url= "https://".$opsi_admin.":".$opsi_password."@".$opsi_server.":4447/rpc";
+ $opsi_client = new JSON::RPC::Client;
+}
# ----------------------------------------------------------------------------
# external methods handling the comunication with GOsa/GOsa-si
my $res_hash = &_parse_getSoftwareLicenseUsages($res);
# Create function result message
- my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
+ my $out_hash = &create_xml_hash("answer_$header", $main::server_address, $source);
if (exists $msg_hash->{forward_to_gosa}) { &add_content2xml_hash($out_hash, "forward_to_gosa", @{$msg_hash->{'forward_to_gosa'}}[0]); }
$out_hash->{result} = [$res_hash];
- my $endTime = Time::HiRes::time;
- my $elapsedTime = sprintf("%.4f", ($endTime - $startTime));
- &main::daemon_log("0 DEBUG: time to process gosa-si message '$header' : $elapsedTime seconds", 1034);
+ &main::daemon_log("0 DEBUG: time to process gosa-si message '$header' : ".sprintf("%.4f", (Time::HiRes::time - $startTime))." seconds", 1034);
return ( &create_xml_string($out_hash) );
}
params => [ $productId ],
id => 1,
};
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
+ #my $res = $main::opsi_client->call($main::opsi_url, $callobj);
+ my $res = $opsi_client->call($opsi_url, $callobj);
# Check Opsi error
my ($res_error, $res_error_str) = &check_opsi_res($res);
params => [ ],
id => 1,
};
- $res = $main::opsi_client->call($main::opsi_url, $callobj);
+ $res = $opsi_client->call($opsi_url, $callobj);
# Check Opsi error
($res_error, $res_error_str) = &check_opsi_res($res);
my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
if (exists $msg_hash->{forward_to_gosa}) { &add_content2xml_hash($out_hash, "forward_to_gosa", @{$msg_hash->{'forward_to_gosa'}}[0]); }
- my $endTime = Time::HiRes::time;
- my $elapsedTime = sprintf("%.4f", ($endTime - $startTime));
- &main::daemon_log("0 DEBUG: time to process gosa-si message '$header' : $elapsedTime seconds", 1034);
+ &main::daemon_log("0 DEBUG: time to process gosa-si message '$header' : ".sprintf("%.4f", (Time::HiRes::time - $startTime))." seconds", 1034);
return ( &create_xml_string($out_hash) );
}
$out_hash->{licenses} = [$res_hash];
if (exists $msg_hash->{forward_to_gosa}) { &add_content2xml_hash($out_hash, "forward_to_gosa", @{$msg_hash->{'forward_to_gosa'}}[0]); }
- my $endTime = Time::HiRes::time;
- my $elapsedTime = sprintf("%.4f", ($endTime - $startTime));
- &main::daemon_log("0 DEBUG: time to process gosa-si message '$header' : $elapsedTime seconds", 1034);
+ &main::daemon_log("0 DEBUG: time to process gosa-si message '$header' : ".sprintf("%.4f", (Time::HiRes::time - $startTime))." seconds", 1034);
return ( &create_xml_string($out_hash) );
}
};
my $startTime = Time::HiRes::time;
- my $opsiResult = $main::opsi_client->call($main::opsi_url, $callObject);
+ my $opsiResult = $opsi_client->call($opsi_url, $callObject);
my $endTime = Time::HiRes::time;
my $elapsedTime = sprintf("%.4f", ($endTime - $startTime));
return ($res->result, 0);
}
+sub _getProductStates_hash {
+ my %arg = ( 'hostId' => undef, @_ );
+
+ if (not defined $arg{hostId} ) {
+ return ("function requires hostId as parameter", 1);
+ }
+
+ my $res = &_callOpsi( method => 'getProductStates_hash', params => [$arg{hostId}]);
+ my ($res_error, $res_error_str) = &check_opsi_res($res);
+ if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
+
+ return ($res->result, 0);
+}
+
1;