diff options
author | Johan Berntsson | 2008-07-16 03:04:45 +0000 |
---|---|---|
committer | Johan Berntsson | 2008-07-16 03:04:45 +0000 |
commit | 337a46474a1c782603c918171a7afcdb1221973c (patch) | |
tree | 56a9a92a53e2050c0f8d168d125f94c1994cde4f | |
parent | Fix issue 1582. The maximum allowable length for a string passed to SimChat i... (diff) | |
download | opensim-SC-337a46474a1c782603c918171a7afcdb1221973c.zip opensim-SC-337a46474a1c782603c918171a7afcdb1221973c.tar.gz opensim-SC-337a46474a1c782603c918171a7afcdb1221973c.tar.bz2 opensim-SC-337a46474a1c782603c918171a7afcdb1221973c.tar.xz |
Updated files for the loadbalancer web interface
Diffstat (limited to '')
-rw-r--r-- | ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm | 100 | ||||
-rw-r--r-- | ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/readme.txt | 21 |
2 files changed, 121 insertions, 0 deletions
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 @@ | |||
1 | package XML::RPC; | ||
2 | |||
3 | use strict; | ||
4 | use Carp; | ||
5 | use RPC::XML; | ||
6 | use RPC::XML::Parser; | ||
7 | use RPC::XML::Client; | ||
8 | |||
9 | sub new { | ||
10 | my ($this, $url) = @_; | ||
11 | my %fields = ( | ||
12 | parser => new RPC::XML::Parser(), | ||
13 | url => $url, | ||
14 | ); | ||
15 | return bless \%fields, $this; | ||
16 | } | ||
17 | |||
18 | sub receive { | ||
19 | my ($this, $xmldata, $handler) = @_; | ||
20 | my $response = undef; | ||
21 | eval { | ||
22 | my $request = $this->{parser}->parse($xmldata); | ||
23 | my @args = map {$_->value} @{$request->args}; | ||
24 | $response = $handler->($request->{name}, @args); | ||
25 | }; | ||
26 | if ($@) { | ||
27 | my %error = ( | ||
28 | "error" => "ERROR", | ||
29 | "message" => $@, | ||
30 | ); | ||
31 | $response = \%error; | ||
32 | } | ||
33 | if ( ref($response) eq "RPC::XML::response" ) { | ||
34 | return $response->as_string; | ||
35 | } | ||
36 | else { | ||
37 | return RPC::XML::response->new($response)->as_string; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | sub call { | ||
42 | my ($this, $method_name, $param) = @_; | ||
43 | if (!$this->{url}) { | ||
44 | Carp::croak("XMLRPC: url not set for calling $method_name"); | ||
45 | } | ||
46 | my $client = RPC::XML::Client->new($this->{url}); | ||
47 | my $request_param = undef; | ||
48 | my $req = undef; | ||
49 | if (ref $param eq "ARRAY") { | ||
50 | $request_param = &_make_array_param($param); | ||
51 | $req = RPC::XML::request->new( | ||
52 | $method_name, | ||
53 | @$request_param, | ||
54 | ); | ||
55 | } elsif (ref $param eq "HASH"){ | ||
56 | $request_param = &_make_hash_param($param); | ||
57 | $req = RPC::XML::request->new( | ||
58 | $method_name, | ||
59 | $request_param, | ||
60 | ); | ||
61 | } else { | ||
62 | Carp::croak("unexpected param type"); | ||
63 | } | ||
64 | my $rpc_res = undef; | ||
65 | eval { | ||
66 | $rpc_res = $client->send_request($req); | ||
67 | }; | ||
68 | if ($@) { | ||
69 | Carp::croak("request " . $this->{url} . "/" . $method_name . " failed. $@" ); | ||
70 | } | ||
71 | if (ref($rpc_res) eq "RPC::XML::struct") { | ||
72 | my %res = map { $_ => $rpc_res->{$_}->value } keys %$rpc_res; # remember good perl !! | ||
73 | return \%res; | ||
74 | } elsif (ref($rpc_res) eq "RPC::XML::string") { | ||
75 | return $rpc_res->value; | ||
76 | } else { | ||
77 | return undef; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | sub _make_array_param { | ||
82 | my $param = shift; | ||
83 | my @array_param = (); | ||
84 | foreach (@$param) { | ||
85 | push @array_param, RPC::XML::string->new($_); # @@@ only string type | ||
86 | } | ||
87 | return \@array_param; | ||
88 | } | ||
89 | |||
90 | sub _make_hash_param { | ||
91 | my $param = shift; | ||
92 | my %hash_param = (); | ||
93 | foreach (keys %$param) { | ||
94 | $hash_param{$_} = RPC::XML::string->new($param->{$_}); # @@@ only string type | ||
95 | } | ||
96 | return RPC::XML::struct->new(\%hash_param); | ||
97 | } | ||
98 | |||
99 | 1; | ||
100 | |||
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 @@ | |||
1 | How to get this working on Linux/Apache: | ||
2 | |||
3 | Create a new directory /var/www/monitor and copy all files htdocs/* files there. | ||
4 | |||
5 | Include these lines in /etc/apache2/httpdocs | ||
6 | --- | ||
7 | <Directory /var/www/monitor> | ||
8 | Options +ExecCGI | ||
9 | </Directory> | ||
10 | AddHandler cgi-script .cgi | ||
11 | --- | ||
12 | |||
13 | Restart Apache: sudo /etc/init.d/apache2 restart | ||
14 | |||
15 | Check that the perl XML-RPC modules is available ("sudo apt-get install librcp-xml-perl" on Ubuntu) | ||
16 | |||
17 | Edit /var/www/monitor/monitor.cgi to update the IP addresses for the Grid server (TODO: improve this) | ||
18 | |||
19 | Start OpenSim in grid mode, use a browser to open http://localhost/monitor/monitor.cgi | ||
20 | |||
21 | |||