From f7331fd46797458ab55b0104156dca19f7fb1f65 Mon Sep 17 00:00:00 2001 From: Tomas Plesnik <plesnik@ics.muni.cz> Date: Tue, 20 Mar 2012 15:32:52 +0100 Subject: [PATCH] zmena prochazeni vracenych SOAP objektu serverem --- src/warden-server/lib/WardenStatus.pm | 42 +++++++++++---------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/warden-server/lib/WardenStatus.pm b/src/warden-server/lib/WardenStatus.pm index acfe74d..4eed30f 100755 --- a/src/warden-server/lib/WardenStatus.pm +++ b/src/warden-server/lib/WardenStatus.pm @@ -38,7 +38,7 @@ use SOAP::Lite; use IO::Socket::SSL qw(debug1); use SOAP::Transport::TCP -our $VERSION = "0.1"; +our $VERSION = "0.2"; #------------------------------------------------------------------------------- # errMsg - print error message and die @@ -109,18 +109,16 @@ sub getClients my $conf_file = $etcdir . "warden-client.conf"; my ($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file) = WardenConf::loadConf($conf_file); + # call server method getClients my $response = c2s($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file, "getClients"); - # match getClients functions response - $response->match('/Envelope/Body/getClientsResponse/'); - my $i = 1; my ($client_id, $hostname, $registered, $requestor, $service, $client_type, $type, $receive_own_events, $description_tags, $ip_net_client); my @clients; - my $response_data = $response->valueof("[$i]"); - # parse returned data object - while (defined $response_data) { - # inicialization of temporal client array + # parse returned SOAP data object + my @response_list = $response->valueof('/Envelope/Body/getClientsResponse/'); + while (scalar @response_list) { + my $response_data = shift(@response_list); my @client; # parse items of one client @@ -138,10 +136,6 @@ sub getClients # push received clients from warden server into @clients which is returned @client = ("$client_id", "$hostname", "$registered", "$requestor", "$service", "$client_type", "$type", "$receive_own_events", "$description_tags", "$ip_net_client"); push (@clients,\@client); - - # go to the next received client - $i++; - $response_data = $response->valueof("[$i]"); } return @clients; } # End of getClients @@ -162,15 +156,13 @@ sub getStatus my $conf_file = $etcdir . "warden-client.conf"; my ($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file) = WardenConf::loadConf($conf_file); + # call server method getStatus my $response = c2s($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file, "getStatus"); - # match getStatus functions response - $response->match('/Envelope/Body/getStatusResponse/'); - my @status; - my $i = 1; - - # get first value from SOAP data object - my $response_data = $response->valueof("[$i]"); + # parse returned SOAP data object + my @response_list = $response->valueof('/Envelope/Body/getStatusResponse/'); + my $response_data = shift(@response_list); + # parse items of server status my $version = $response_data->{'VERSION'}; my $address = $response_data->{'ADDRESS'}; @@ -189,23 +181,23 @@ sub getStatus my $events_last_timestamp = $response_data->{'EVENTS_LAST_TIMESTAMP'}; my $clients_sum = $response_data->{'CLIENTS_SUM'}; + my @status; my @server_status = ("$version", "$address", "$port", "$logdir", "$piddir", "$vardir", "$ssl_key_file_server", "$ssl_cert_file_server", "$ssl_ca_file_server", "$facility", "$db_size", "$events_sum", "$events_last_id", "$events_first_timestamp", "$events_last_timestamp", "$clients_sum"); push(@status, \@server_status); - $i++; - $response_data = $response->valueof("[$i]"); - while (defined $response_data) { + while (scalar @response_list) { + my $response_data = shift(@response_list); my @client_status; - # parse SOAP data object + + # parse item of client status my $client_id = $response_data->{'CLIENT_ID'}; my $hostname = $response_data->{'HOSTNAME'}; my $service = $response_data->{'SERVICE'}; my $count = $response_data->{'COUNT'}; my $timestamp = $response_data->{'TIMESTAMP'}; + @client_status = ("$client_id", "$hostname", "$service", "$count", "$timestamp"); push(@status, \@client_status); - $i++; - $response_data = $response->valueof("[$i]"); } return @status; } # End of getStatus -- GitLab