summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 09ccb1f)
raw | patch | inline | side by side (parent: 09ccb1f)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 25 Nov 2009 10:49:11 +0000 (10:49 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 25 Nov 2009 10:49:11 +0000 (10:49 +0000) |
* version dependency to GosaSupportDaemon
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14837 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14837 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/modules/GosaSupportDaemon.pm | patch | blob | history | |
gosa-si/server/events/opsi_com.pm | patch | blob | history | |
gosa-si/tests/client.php | patch | blob | history |
index 3cc769ba846e6dbe2ff53a7390588c5be7051516..7d769c08ad6ff4e302a900203e214f955cb2b16c 100644 (file)
use Crypt::Rijndael;
use Digest::MD5 qw(md5 md5_hex md5_base64);
use MIME::Base64;
+use XML::Quote qw(:all);
use XML::Simple;
use Data::Dumper;
use Net::DNS;
} elsif ( ref $content eq "ARRAY") {
$s .= &_transformArrayToString($tag, $content);
} else {
- $s .= "<$tag>".$content."</$tag>";
+ $content = defined $content ? $content : "";
+ $s .= "<$tag>".&xml_quote($content)."</$tag>";
}
}
return $s;
if (ref $content eq "HASH") {
$s .= "<$tag>".&_transformHashToString($content)."</$tag>";
} else {
- $s .= "<$tag>$content</$tag>";
+ $content = defined $content ? $content : "";
+ $s .= "<$tag>".&xml_quote($content)."</$tag>";
}
}
return $s;
index 98b21712c4042a1f4a169fc1471dfb2dd19334d1..c049ea0da3e31e510a686c0e7c1a21148860f44e 100644 (file)
"opsi_modify_client",
"opsi_add_product_to_client",
"opsi_del_product_from_client",
- "opsi_createLicensePool",
- "opsi_deleteLicensePool",
- "opsi_createLicense",
- "opsi_assignSoftwareLicenseToHost",
- "opsi_unassignSoftwareLicenseFromHost",
- "opsi_unassignAllSoftwareLicensesFromHost",
- "opsi_getSoftwareLicense_hash",
- "opsi_getLicensePool_hash",
- "opsi_getSoftwareLicenseUsages",
- "opsi_getSoftwareLicenseUsagesForProductId",
- "opsi_getLicensePools_listOfHashes",
- "opsi_getLicenseInformationForProduct",
- "opsi_getPool",
- "opsi_getAllSoftwareLicenses",
- "opsi_removeLicense",
- "opsi_getReservedLicenses",
- "opsi_boundHostToLicense",
- "opsi_unboundHostFromLicense",
- "opsi_test",
+ "opsi_createLicensePool",
+ "opsi_deleteLicensePool",
+ "opsi_createLicense",
+ "opsi_assignSoftwareLicenseToHost",
+ "opsi_unassignSoftwareLicenseFromHost",
+ "opsi_unassignAllSoftwareLicensesFromHost",
+ "opsi_getSoftwareLicense_hash",
+ "opsi_getLicensePool_hash",
+ "opsi_getSoftwareLicenseUsages",
+ "opsi_getSoftwareLicenseUsagesForProductId",
+ "opsi_getLicensePools_listOfHashes",
+ "opsi_getLicenseInformationForProduct",
+ "opsi_getPool",
+ "opsi_getAllSoftwareLicenses",
+ "opsi_removeLicense",
+ "opsi_getReservedLicenses",
+ "opsi_boundHostToLicense",
+ "opsi_unboundHostFromLicense",
+ "opsi_get_full_product_host_information",
+ "opsi_test",
);
@EXPORT = @events;
use Time::HiRes qw( time );
$opsi_url= "https://".$opsi_admin.":".$opsi_password."@".$opsi_server.":4447/rpc";
$opsi_client = new JSON::RPC::Client;
+
+ # Check version dependencies
+ eval { &myXmlHashToString(); };
+ if ($@ ) {
+ die "\nThe version of the Opsi plugin you want to use requires a newer version of GosaSupportDaemon. Please update your GOsa-SI or deactivate the Opsi plugin.\n";
+ }
}
# ----------------------------------------------------------------------------
if ($err){
return &_giveErrorFeedback($msg_hash, "cannot fetch licensePoolId for given productId : ".$res, $session_id);
}
-
- my $licensePoolId;
+ my $licensePoolId = $res; # We assume that there is only one pool for each productID!!!
# Fetch softwareLiceceUsages for licensePoolId
($res, $err) = &_getSoftwareLicenseUsages_listOfHashes('licensePoolId'=>$licensePoolId);
if ($err){
return &_giveErrorFeedback($msg_hash, "cannot fetch software licenses from license pool : ".$res, $session_id);
}
-
# Parse Opsi result
my $res_hash = &_parse_getSoftwareLicenseUsages($res);
return ( &create_xml_string($out_hash) );
}
+
+################################
+# @brief Returns a list of values for a given host. Values: priority, onceScript, licenseRequired, packageVersion, productVersion, advice, setupScript, windowsSoftwareIds, installationStatus, pxeConfigTemplate, name, creationTimestamp, alwaysScript, productId, description, properties, actionRequest, uninstallScript, action, updateScript and productClassNames
+# @param hostId Opsi hostId
+sub opsi_get_full_product_host_information {
+ my $startTime = Time::HiRes::time;
+ my ($msg, $msg_hash, $session_id) = @_;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+
+ my ($res, $err) = &_get_full_product_host_information( hostId=>@{$msg_hash->{'hostId'}}[0]);
+ if ($err) {
+ return &_giveErrorFeedback($msg_hash, "cannot fetch full_product_host_information from Opsi server : ".$res, $session_id);
+ }
+
+ my $out_hash = &main::create_xml_hash("answer_$header", $main::server_address, $source);
+ $out_hash->{hit} = $res;
+ if (exists $msg_hash->{forward_to_gosa}) { &add_content2xml_hash($out_hash, "forward_to_gosa", @{$msg_hash->{'forward_to_gosa'}}[0]); }
+
+ &main::daemon_log("0 DEBUG: time to process gosa-si message '$header' : ".sprintf("%.4f", (Time::HiRes::time - $startTime))." seconds", 1034);
+ return ( &myXmlHashToString($out_hash) );
+}
+
+
sub opsi_test {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
my $source = @{$msg_hash->{'source'}}[0];
my $pram1 = @{$msg_hash->{'productId'}}[0];
-print STDERR Dumper $pram1;
# Fetch infos from Opsi server
my $callobj = {
};
my $res = $main::opsi_client->call($main::opsi_url, $callobj);
- print STDERR Dumper $res;
return ();
}
return ($res->result, 0);
}
+sub _get_full_product_host_information {
+ my %arg = ( 'hostId' => undef, @_ );
-################################
-# @brief Get all host information for a specific host.
-# @param msg - STRING - xml message with hostId tag
-# @param msg_hash - HASHREF - message information parsed into a hash
-# @param session_id - INTEGER - POE session id of the processing of this message
-# @return out_msg - STRING - feedback to GOsa in success and error case
-sub opsi_get_full_product_host_information {
- my $startTime = Time::HiRes::time;
- my ($msg, $msg_hash, $session_id) = @_;
- my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'source'}}[0];
- my $target = @{$msg_hash->{'target'}}[0];
- my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
- my $hostId;
- my $xml_msg;
+ if (not defined $arg{hostId}) {
+ return ("function requires hostId as parameter", 1);
+ }
-# $callobj = {
-# method => 'getFullProductHostInformation_list',
-# params => [ $hostId ],
-# id => 1,
-# };
-# my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-# print STDERR "===================================================================\n";
-# print STDERR Dumper $res;
-# print STDERR "===================================================================\n";
+ my $res = &_callOpsi( method => 'getFullProductHostInformation_list', 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;
index c1c21443bbcad13e631dcd916a5512f982c02e82..84c5d701a586e3159b259861cb5857f3cb50e721 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
#$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsages</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><hostId>krakenarme.intranet.gonicus.de</hostId></xml>";
#$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsages</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId></xml>";
#$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsages</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target></xml>";
- $data = "<xml><header>gosa_opsi_getSoftwareLicenseUsagesForProductId</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><productId>firefox</productId></xml>";
+ #$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsagesForProductId</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><productId>firefox</productId></xml>";
#$data = "<xml><header>gosa_opsi_getSoftwareLicense_hash</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><softwareLicenseId>l_2009-09-22_09:50:58_0</softwareLicenseId></xml>";
#$data = "<xml><header>gosa_opsi_getAllSoftwareLicenses</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target></xml>";
+ $data = "<xml><header>gosa_opsi_get_full_product_host_information</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><hostId>linux-cl-2.intranet.gonicus.de</hostId></xml>";
##############################
# periodical jobs