aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Common/Communications/GridInfoService.cs125
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs4
-rw-r--r--OpenSim/Grid/UserServer/Main.cs7
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs7
4 files changed, 141 insertions, 2 deletions
diff --git a/OpenSim/Common/Communications/GridInfoService.cs b/OpenSim/Common/Communications/GridInfoService.cs
new file mode 100644
index 0000000..f8208ad
--- /dev/null
+++ b/OpenSim/Common/Communications/GridInfoService.cs
@@ -0,0 +1,125 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.IO;
31using System.Reflection;
32using System.Text;
33using log4net;
34using Nini.Config;
35using Nwc.XmlRpc;
36using OpenSim.Framework.Servers;
37using OpenSim.Framework;
38
39namespace OpenSim.Common.Communications
40{
41 public class GridInfoService
42 {
43 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
45 private Hashtable _info = new Hashtable();
46
47 /// <summary>
48 /// Instantiate a GridInfoService object.
49 /// </summary>
50 /// <param name="configPath">path to config path containing
51 /// grid information</param>
52 /// <remarks>
53 /// GridInfoService uses the [GridInfo] section of the
54 /// standard OpenSim.ini file --- which is not optimal, but
55 /// anything else requires a general redesign of the config
56 /// system.
57 /// </remarks>
58 public GridInfoService(string configPath)
59 {
60 _info["platform"] = "OpenSim";
61 if (File.Exists(configPath))
62 {
63 try
64 {
65 IConfigSource _configSource = new IniConfigSource(configPath);
66 IConfig startupCfg = _configSource.Configs["Startup"];
67 IConfig gridCfg = _configSource.Configs["GridInfo"];
68
69 if (!startupCfg.GetBoolean("gridmode", false))
70 _info["mode"] = "standalone";
71 else
72 _info["mode"] = "grid";
73
74 foreach (string k in gridCfg.GetKeys())
75 {
76 _info[k] = gridCfg.GetString(k);
77 }
78 }
79 catch (Exception)
80 {
81 _log.DebugFormat("[GridInfoService] cannot get grid info from {0}, using minimal defaults", configPath);
82 }
83 }
84 _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count);
85 }
86
87 /// <summary>
88 /// Default constructor, uses OpenSim.ini.
89 /// </summary>
90 public GridInfoService() : this(Path.Combine(Util.configDir(), "OpenSim.ini"))
91 {
92 }
93
94 public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request)
95 {
96 XmlRpcResponse response = new XmlRpcResponse();
97 Hashtable responseData = new Hashtable();
98
99 _log.Info("[GridInfo]: Request for grid info");
100
101 foreach (string k in _info.Keys)
102 {
103 responseData[k] = _info[k];
104 }
105 response.Value = responseData;
106
107 return response;
108 }
109
110 public string RestGetGridInfoMethod(string request, string path, string param,
111 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
112 {
113 StringBuilder sb = new StringBuilder();
114
115 sb.Append("<gridinfo>\n");
116 foreach (string k in _info.Keys)
117 {
118 sb.AppendFormat("<{0}>{1}</{0}>\n", k, _info[k]);
119 }
120 sb.Append("</gridinfo>\n");
121
122 return sb.ToString();
123 }
124 }
125}
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 4dc5994..f8b4ccb 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -88,7 +88,7 @@ namespace OpenSim.Framework.Servers
88 { 88 {
89 if (!m_streamHandlers.ContainsKey(handlerKey)) 89 if (!m_streamHandlers.ContainsKey(handlerKey))
90 { 90 {
91 //m_log.DebugFormat("[BASE HTTP SERVER]: Adding handler key {0}", handlerKey); 91 // m_log.DebugFormat("[BASE HTTP SERVER]: Adding handler key {0}", handlerKey);
92 m_streamHandlers.Add(handlerKey, handler); 92 m_streamHandlers.Add(handlerKey, handler);
93 } 93 }
94 } 94 }
@@ -195,7 +195,7 @@ namespace OpenSim.Framework.Servers
195 string path = request.RawUrl; 195 string path = request.RawUrl;
196 string handlerKey = GetHandlerKey(request.HttpMethod, path); 196 string handlerKey = GetHandlerKey(request.HttpMethod, path);
197 197
198 //m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path); 198 // m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path);
199 199
200 if (TryGetStreamHandler(handlerKey, out requestHandler)) 200 if (TryGetStreamHandler(handlerKey, out requestHandler))
201 { 201 {
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 1338d68..a9b4a4f 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -39,6 +39,7 @@ using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Statistics; 41using OpenSim.Framework.Statistics;
42using OpenSim.Common.Communications;
42using OpenSim.Grid.Communications.OGS1; 43using OpenSim.Grid.Communications.OGS1;
43 44
44namespace OpenSim.Grid.UserServer 45namespace OpenSim.Grid.UserServer
@@ -53,6 +54,7 @@ namespace OpenSim.Grid.UserServer
53 54
54 public UserManager m_userManager; 55 public UserManager m_userManager;
55 public UserLoginService m_loginService; 56 public UserLoginService m_loginService;
57 public GridInfoService m_gridInfoService;
56 public MessageServersConnector m_messagesService; 58 public MessageServersConnector m_messagesService;
57 protected IInterServiceInventoryServices m_interServiceInventoryService; 59 protected IInterServiceInventoryServices m_interServiceInventoryService;
58 60
@@ -100,6 +102,8 @@ namespace OpenSim.Grid.UserServer
100 m_userManager._config = Cfg; 102 m_userManager._config = Cfg;
101 m_userManager.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); 103 m_userManager.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect);
102 104
105 m_gridInfoService = new GridInfoService();
106
103 m_interServiceInventoryService = new OGS1InterServiceInventoryService(m_userManager._config.InventoryUrl); 107 m_interServiceInventoryService = new OGS1InterServiceInventoryService(m_userManager._config.InventoryUrl);
104 108
105 m_loginService = new UserLoginService( 109 m_loginService = new UserLoginService(
@@ -148,6 +152,9 @@ namespace OpenSim.Grid.UserServer
148 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion); 152 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
149 m_httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer); 153 m_httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer);
150 154
155 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod));
156 m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
157
151 158
152 m_httpServer.AddStreamHandler( 159 m_httpServer.AddStreamHandler(
153 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); 160 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 6889a61..c2d30e4 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -40,6 +40,7 @@ using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
41using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
42using OpenSim.Framework.Statistics; 42using OpenSim.Framework.Statistics;
43using OpenSim.Common.Communications;
43using OpenSim.Region.ClientStack; 44using OpenSim.Region.ClientStack;
44using OpenSim.Region.Communications.Local; 45using OpenSim.Region.Communications.Local;
45using OpenSim.Region.Communications.OGS1; 46using OpenSim.Region.Communications.OGS1;
@@ -79,6 +80,7 @@ namespace OpenSim
79 public bool m_see_into_region_from_neighbor; 80 public bool m_see_into_region_from_neighbor;
80 81
81 protected LocalLoginService m_loginService; 82 protected LocalLoginService m_loginService;
83 protected GridInfoService m_gridInfoService;
82 84
83 protected string m_storageDll; 85 protected string m_storageDll;
84 protected string m_clientstackDll; 86 protected string m_clientstackDll;
@@ -382,6 +384,11 @@ namespace OpenSim
382 // Provides the LLSD login 384 // Provides the LLSD login
383 m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod); 385 m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
384 386
387 // provide grid info
388 m_gridInfoService = new GridInfoService();
389 m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
390 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod));
391
385 CreateAccount = localComms.doCreate; 392 CreateAccount = localComms.doCreate;
386 } 393 }
387 else 394 else