summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5e8fb58)
raw | patch | inline | side by side (parent: 5e8fb58)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 13 Oct 2009 10:20:48 +0000 (10:20 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 13 Oct 2009 10:20:48 +0000 (10:20 +0000) |
* gosa-si-server: writes micro seconds to log too
* opsi_com: refactoring, opsi calls are in a seperate function now
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14590 594d385d-05f5-0310-b6e9-bd551577e9d8
* opsi_com: refactoring, opsi calls are in a seperate function now
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14590 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history | |
gosa-si/server/events/opsi_com.pm | patch | blob | history | |
gosa-si/tests/client.php | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 7b1a5569b8e2b1822344cce134106065910582c7..bc28f7482ab3d61142594fb03f28b0446baad808 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
use XML::Simple;
use Data::Dumper;
use Sys::Syslog qw( :DEFAULT setlogsock);
-use Time::HiRes qw( usleep);
+use Time::HiRes qw( usleep clock_gettime );
use Cwd;
use File::Spec;
use File::Basename;
use Net::LDAP;
use Net::LDAP::Util qw(:escape);
+
# revision number of server and program name
my $server_headURL;
my $server_revision;
$monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday;
$year+=1900;
-
+ # Microseconds since epoch
+ my $microSeconds = sprintf("%.2f", clock_gettime ( 'CLOCK_REALTIME' ));
+ $microSeconds =~ s/^\d*(.\d\d)$/$1/;
+
# Build log message and write it to log file and commandline
chomp($msg);
- my $log_msg = "$month $monthday $hours:$minutes:$seconds $prg $msg\n";
+ my $log_msg = "$month $monthday $hours:$minutes:$seconds$microSeconds $prg $msg\n";
flock(LOG_HANDLE, LOCK_EX);
seek(LOG_HANDLE, 0, 2);
print LOG_HANDLE $log_msg;
module=>$module,
sessionid=>$session_id,
} );
-
+ $kernel->yield('watch_for_next_tasks');
}
# target is own address with forward_to_gosa-tag pointing at myself -> forward to gosa
sessionid=>$session_id,
} );
$done = 1;
+ $kernel->yield('watch_for_next_tasks');
}
$kernel->yield('register_at_foreign_servers');
$kernel->yield('create_fai_server_db', $fai_server_tn );
$kernel->yield('create_fai_release_db', $fai_release_tn );
- $kernel->yield('watch_for_next_tasks');
$kernel->sig(USR1 => "sig_handler");
$kernel->sig(USR2 => "recreate_packages_db");
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
my $sql = "DELETE FROM $incoming_tn WHERE id=$message_id";
my $res = $incoming_db->exec_statement($sql);
}
-
- $kernel->delay_set('watch_for_next_tasks', 1);
}
},
InlineStates => {
msg_to_decrypt => \&msg_to_decrypt,
+ watch_for_next_tasks => \&watch_for_next_tasks,
next_task => \&next_task,
task_result => \&handle_task_result,
task_done => \&handle_task_done,
task_result => \&handle_task_result,
task_done => \&handle_task_done,
task_debug => \&handle_task_debug,
- watch_for_next_tasks => \&watch_for_next_tasks,
watch_for_new_messages => \&watch_for_new_messages,
watch_for_delivery_messages => \&watch_for_delivery_messages,
watch_for_done_messages => \&watch_for_done_messages,
index 48ab4e2ffae5cc24b3a6d088be6e5bc5f84a3daa..abd23984e5658f25bf973f60e85bc17ae009d092 100644 (file)
use GOSA::GosaSupportDaemon;
use Data::Dumper;
use XML::Quote qw(:all);
+use Time::HiRes qw( time );
BEGIN {}
# ----------------------------------------------------------------------------
-# S U B R O U T I N E S
+# external methods handling the comunication with GOsa/GOsa-si
# ----------------------------------------------------------------------------
method => 'setProductActionRequest',
params => [ $productId, $hostId, "setup" ],
id => 1, };
-
my $res = $main::opsi_client->call($main::opsi_url, $callobj);
+
if (&check_opsi_res($res)) { return ( (caller(0))[3]." : ".$_, 1 ); };
- # return message
return ( &create_xml_string($out_hash) );
}
# @param
#
sub opsi_getPool {
+ my $startTime = Time::HiRes::time;
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
my $source = @{$msg_hash->{'source'}}[0];
}
$out_hash->{licenses} = [$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);
return ( &create_xml_string($out_hash) );
}
}
+# ----------------------------------------------------------------------------
+# internal methods handling the comunication with Opsi
+# ----------------------------------------------------------------------------
+
+sub _callOpsi {
+ my %arg = ('method'=>undef, 'params'=>[], 'id'=>1, @_);
+
+ my $callObject = {
+ method => $arg{method},
+ params => $arg{params},
+ id => $arg{id},
+ };
+
+ my $startTime = Time::HiRes::time;
+ my $opsiResult = $main::opsi_client->call($main::opsi_url, $callObject);
+ my $endTime = Time::HiRes::time;
+ my $elapsedTime = sprintf("%.4f", ($endTime - $startTime));
+
+ &main::daemon_log("0 DEBUG: time to process opsi call '$arg{method}' : $elapsedTime seconds", 1034);
+ return $opsiResult;
+}
sub _getLicensePool_hash {
- my %arg = (
- 'licensePoolId' => undef,
- @_,
- );
+ my %arg = ( 'licensePoolId' => undef, @_ );
if (not defined $arg{licensePoolId} ) {
return ("function requires licensePoolId as parameter", 1);
}
- # Fetch pool infos from Opsi server
- my $callobj = {
- method => 'getLicensePool_hash',
- params => [ $arg{licensePoolId} ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-
- # Check Opsi error
+ my $res = &_callOpsi( method => 'getLicensePool_hash', params =>[$arg{licensePoolId}], id => 1 );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
}
sub _getSoftwareLicenses_listOfHashes {
- # Fetch licenses associated to the given pool
- my $callobj = {
- method => 'getSoftwareLicenses_listOfHashes',
- params => [ ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-
- # Check Opsi error
+
+ my $res = &_callOpsi( method => 'getSoftwareLicenses_listOfHashes' );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
}
sub _getSoftwareLicenseUsages_listOfHashes {
- my %arg = (
- 'hostId' => "",
- 'licensePoolId' => "",
- @_,
- );
-
- # Fetch pool infos from Opsi server
- my $callobj = {
- method => 'getSoftwareLicenseUsages_listOfHashes',
- params => [ $arg{hostId}, $arg{licensePoolId} ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
+ my %arg = ( 'hostId' => "", 'licensePoolId' => "", @_ );
- # Check Opsi error
+ my $res = &_callOpsi( method=>'getSoftwareLicenseUsages_listOfHashes', params=>[ $arg{hostId}, $arg{licensePoolId} ] );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
}
sub _removeSoftwareLicenseFromLicensePool {
- my %arg = (
- 'softwareLicenseId' => undef,
- 'licensePoolId' => undef,
- @_,
- );
+ my %arg = ( 'softwareLicenseId' => undef, 'licensePoolId' => undef, @_ );
if (not defined $arg{softwareLicenseId} ) {
return ("function requires softwareLicenseId as parameter", 1);
return ("function requires licensePoolId as parameter", 1);
}
- # Remove software license from license pool
- my $callobj = {
- method => 'removeSoftwareLicenseFromLicensePool',
- params => [ $arg{softwareLicenseId}, $arg{licensePoolId} ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-
- # Check Opsi error
+ my $res = &_callOpsi( method=>'removeSoftwareLicenseFromLicensePool', params=>[ $arg{softwareLicenseId}, $arg{licensePoolId} ] );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
}
sub _deleteSoftwareLicense {
- my %arg = (
- 'softwareLicenseId' => undef,
- 'removeFromPools' => "false",
- @_,
- );
+ my %arg = ( 'softwareLicenseId' => undef, 'removeFromPools' => "false", @_ );
if (not defined $arg{softwareLicenseId} ) {
return ("function requires softwareLicenseId as parameter", 1);
$removeFromPools = "removeFromPools";
}
- # Fetch
- my $callobj = {
- method => 'deleteSoftwareLicense',
- params => [ $arg{softwareLicenseId}, $removeFromPools ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-
- # Check Opsi error
+ my $res = &_callOpsi( method=>'deleteSoftwareLicense', params=>[ $arg{softwareLicenseId}, $removeFromPools ] );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
}
sub _getLicensePoolId {
- my %arg = (
- 'productId' => undef,
- @_,
- );
+ my %arg = ( 'productId' => undef, @_ );
if (not defined $arg{productId} ) {
return ("function requires productId as parameter", 1);
}
- my $callobj = {
- method => 'getLicensePoolId',
- params => [ $arg{productId} ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-
- # Check Opsi error
+ my $res = &_callOpsi( method => 'getLicensePoolId', params => [ $arg{productId} ] );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
}
sub _getLicenseContract_hash {
- my %arg = (
- 'licenseContractId' => undef,
- @_,
- );
+ my %arg = ( 'licenseContractId' => undef, @_ );
if (not defined $arg{licenseContractId} ) {
return ("function requires licenseContractId as parameter", 1);
}
- my $callobj = {
- method => 'getLicenseContract_hash',
- params => [ $arg{licenseContractId} ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-
- # Check Opsi error
+ my $res = &_callOpsi( method => 'getLicenseContract_hash', params => [ $arg{licenseContractId} ] );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
'notificationDate' => undef,
'expirationDate' => undef,
'notes' => undef,
- @_,
- );
-
- # Create license contract at Opsi server
- my $callobj = {
- method => 'createLicenseContract',
- params => [ $arg{licenseContractId}, $arg{partner}, $arg{conclusionDate}, $arg{notificationDate}, $arg{expirationDate}, $arg{notes} ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
+ @_ );
- # Check Opsi error
+ my $res = &_callOpsi( method => 'createLicenseContract',
+ params => [ $arg{licenseContractId}, $arg{partner}, $arg{conclusionDate}, $arg{notificationDate}, $arg{expirationDate}, $arg{notes} ],
+ );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
'maxInstallations' => undef,
'boundToHost' => undef,
'expirationDate' => undef,
- @_,
- );
+ @_ );
- my $callobj = {
- method => 'createSoftwareLicense',
+ my $res = &_callOpsi( method => 'createSoftwareLicense',
params => [ $arg{softwareLicenseId}, $arg{licenseContractId}, $arg{licenseType}, $arg{maxInstallations}, $arg{boundToHost}, $arg{expirationDate} ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-
- # Check Opsi error
+ );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
'softwareLicenseId' => undef,
'licensePoolId' => undef,
'licenseKey' => undef,
- @_,
- );
+ @_ );
if (not defined $arg{softwareLicenseId} ) {
return ("function requires softwareLicenseId as parameter", 1);
return ("function requires licensePoolId as parameter", 1);
}
- # Add software license to license pool
- my $callobj = {
- method => 'addSoftwareLicenseToLicensePool',
- params => [ $arg{softwareLicenseId}, $arg{licensePoolId}, $arg{licenseKey} ],
- id => 1,
- };
- my $res = $main::opsi_client->call($main::opsi_url, $callobj);
-
- # Check Opsi error
+ my $res = &_callOpsi( method => 'addSoftwareLicenseToLicensePool', params => [ $arg{softwareLicenseId}, $arg{licensePoolId}, $arg{licenseKey} ] );
my ($res_error, $res_error_str) = &check_opsi_res($res);
if ($res_error){ return ( (caller(0))[3]." : ".$res_error_str, 1 ); }
index f01246d9ebffef2860422c38ad033ea01e5e6c88..7ecf664d664b71cc03d188ea24b530041165fc15 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
require_once("../../gosa-core/include/class_socketClient.inc");
error_reporting(E_ALL);
-$zahl= 1;
+function microtime_float()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+
+$zahl= 10;
for($count = 1; $count <= $zahl; $count++)
{
#$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_getPool</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId></xml>";
+ $data = "<xml><header>gosa_opsi_getPool</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId></xml>";
#$data = "<xml><header>gosa_opsi_removeLicense</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId><softwareLicenseId>l_2009-09-22_14:06:11</softwareLicenseId></xml>";
#$data = "<xml><header>gosa_opsi_boundHostToLicense</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><softwareLicenseId>andisLizenz</softwareLicenseId><hostId>krakenarme.intranet.gonicus.de</hostId></xml>";
#$data = "<xml><header>gosa_opsi_unboundHostFromLicense</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><softwareLicenseId>andisLizenz</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_getAllSoftwareLicenses</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target></xml>";
##############################
#$data = "<xml> <header>gosa_trigger_reload_syslog_config</header> <source>GOSA</source> <target>GOSA</target> <macaddress>00:0C:29:4C:4B:0C</macaddress> </xml>";
+ $time_start = microtime_float();
$sock->write($data);
$answer = "nothing";
$answer = $sock->read();
-
echo "$count: $answer\n";
$sock->close();
+
+ $time_end = microtime_float();
+ $time = $time_end - $time_start;
+ echo "Processing time: $time seconds\n";
+
}else{
echo "... FAILED!\n";
}