From 337a46474a1c782603c918171a7afcdb1221973c Mon Sep 17 00:00:00 2001 From: Johan Berntsson Date: Wed, 16 Jul 2008 03:04:45 +0000 Subject: Updated files for the loadbalancer web interface --- .../3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm | 100 +++++++++++++++++++++ .../3Di/RegionMonitor/MonitorGUI/htdocs/readme.txt | 21 +++++ 2 files changed, 121 insertions(+) create mode 100644 ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm create mode 100644 ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/readme.txt (limited to 'ThirdParty') diff --git a/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm b/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm new file mode 100644 index 0000000..5d9b388 --- /dev/null +++ b/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm @@ -0,0 +1,100 @@ +package XML::RPC; + +use strict; +use Carp; +use RPC::XML; +use RPC::XML::Parser; +use RPC::XML::Client; + +sub new { + my ($this, $url) = @_; + my %fields = ( + parser => new RPC::XML::Parser(), + url => $url, + ); + return bless \%fields, $this; +} + +sub receive { + my ($this, $xmldata, $handler) = @_; + my $response = undef; + eval { + my $request = $this->{parser}->parse($xmldata); + my @args = map {$_->value} @{$request->args}; + $response = $handler->($request->{name}, @args); + }; + if ($@) { + my %error = ( + "error" => "ERROR", + "message" => $@, + ); + $response = \%error; + } + if ( ref($response) eq "RPC::XML::response" ) { + return $response->as_string; + } + else { + return RPC::XML::response->new($response)->as_string; + } +} + +sub call { + my ($this, $method_name, $param) = @_; + if (!$this->{url}) { + Carp::croak("XMLRPC: url not set for calling $method_name"); + } + my $client = RPC::XML::Client->new($this->{url}); + my $request_param = undef; + my $req = undef; + if (ref $param eq "ARRAY") { + $request_param = &_make_array_param($param); + $req = RPC::XML::request->new( + $method_name, + @$request_param, + ); + } elsif (ref $param eq "HASH"){ + $request_param = &_make_hash_param($param); + $req = RPC::XML::request->new( + $method_name, + $request_param, + ); + } else { + Carp::croak("unexpected param type"); + } + my $rpc_res = undef; + eval { + $rpc_res = $client->send_request($req); + }; + if ($@) { + Carp::croak("request " . $this->{url} . "/" . $method_name . " failed. $@" ); + } + if (ref($rpc_res) eq "RPC::XML::struct") { + my %res = map { $_ => $rpc_res->{$_}->value } keys %$rpc_res; # remember good perl !! + return \%res; + } elsif (ref($rpc_res) eq "RPC::XML::string") { + return $rpc_res->value; + } else { + return undef; + } +} + +sub _make_array_param { + my $param = shift; + my @array_param = (); + foreach (@$param) { + push @array_param, RPC::XML::string->new($_); # @@@ only string type + } + return \@array_param; +} + +sub _make_hash_param { + my $param = shift; + my %hash_param = (); + foreach (keys %$param) { + $hash_param{$_} = RPC::XML::string->new($param->{$_}); # @@@ only string type + } + return RPC::XML::struct->new(\%hash_param); +} + +1; + diff --git a/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/readme.txt b/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/readme.txt new file mode 100644 index 0000000..396ba56 --- /dev/null +++ b/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/readme.txt @@ -0,0 +1,21 @@ +How to get this working on Linux/Apache: + +Create a new directory /var/www/monitor and copy all files htdocs/* files there. + +Include these lines in /etc/apache2/httpdocs +--- + + Options +ExecCGI + +AddHandler cgi-script .cgi +--- + +Restart Apache: sudo /etc/init.d/apache2 restart + +Check that the perl XML-RPC modules is available ("sudo apt-get install librcp-xml-perl" on Ubuntu) + +Edit /var/www/monitor/monitor.cgi to update the IP addresses for the Grid server (TODO: improve this) + +Start OpenSim in grid mode, use a browser to open http://localhost/monitor/monitor.cgi + + -- cgit v1.1