aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs211
1 files changed, 195 insertions, 16 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index d19b8b6..f1b59bb 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -71,6 +71,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
71 71
72 private string m_name = "RemoteAdminPlugin"; 72 private string m_name = "RemoteAdminPlugin";
73 private string m_version = "0.0"; 73 private string m_version = "0.0";
74 private string m_openSimVersion;
74 75
75 public string Version 76 public string Version
76 { 77 {
@@ -90,6 +91,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
90 91
91 public void Initialise(OpenSimBase openSim) 92 public void Initialise(OpenSimBase openSim)
92 { 93 {
94 m_openSimVersion = openSim.GetVersionText();
95
93 m_configSource = openSim.ConfigSource.Source; 96 m_configSource = openSim.ConfigSource.Source;
94 try 97 try
95 { 98 {
@@ -132,6 +135,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
132 availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); 135 availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod);
133 availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); 136 availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod);
134 availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); 137 availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod);
138 availableMethods["admin_dialog"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDialogMethod);
135 availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); 139 availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod);
136 availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); 140 availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod);
137 availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); 141 availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod);
@@ -158,6 +162,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
158 availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove); 162 availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove);
159 availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); 163 availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList);
160 164
165 // Misc
166 availableMethods["admin_refresh_search"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshSearch);
167 availableMethods["admin_get_opensim_version"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetOpenSimVersion);
168
161 // Either enable full remote functionality or just selected features 169 // Either enable full remote functionality or just selected features
162 string enabledMethods = m_config.GetString("enabled_methods", "all"); 170 string enabledMethods = m_config.GetString("enabled_methods", "all");
163 171
@@ -259,23 +267,101 @@ namespace OpenSim.ApplicationPlugins.RemoteController
259 { 267 {
260 m_log.Info("[RADMIN]: Request to restart Region."); 268 m_log.Info("[RADMIN]: Request to restart Region.");
261 269
262 CheckRegionParams(requestData, responseData);
263
264 Scene rebootedScene = null; 270 Scene rebootedScene = null;
265 GetSceneFromRegionParams(requestData, responseData, out rebootedScene); 271 bool restartAll = false;
272
273 IConfig startupConfig = m_configSource.Configs["Startup"];
274 if (startupConfig != null)
275 {
276 if (startupConfig.GetBoolean("InworldRestartShutsDown", false))
277 {
278 rebootedScene = m_application.SceneManager.CurrentOrFirstScene;
279 restartAll = true;
280 }
281 }
282
283 if (rebootedScene == null)
284 {
285 CheckRegionParams(requestData, responseData);
286
287 GetSceneFromRegionParams(requestData, responseData, out rebootedScene);
288 }
289
290 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
266 291
267 responseData["success"] = false; 292 responseData["success"] = false;
268 responseData["accepted"] = true; 293 responseData["accepted"] = true;
269 responseData["rebooting"] = true; 294 responseData["rebooting"] = true;
270 295
271 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); 296 string message;
272 if (restartModule != null) 297 List<int> times = new List<int>();
298
299 if (requestData.ContainsKey("alerts"))
273 { 300 {
274 List<int> times = new List<int> { 30, 15 }; 301 string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','});
302 if (alertTimes.Length == 1 && Convert.ToInt32(alertTimes[0]) == -1)
303 {
304 if (restartModule != null)
305 {
306 message = "Restart has been cancelled";
275 307
276 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); 308 if (requestData.ContainsKey("message"))
277 responseData["success"] = true; 309 message = requestData["message"].ToString();
310
311 restartModule.AbortRestart(message);
312
313 responseData["success"] = true;
314 responseData["rebooting"] = false;
315
316 return;
317 }
318 }
319 foreach (string a in alertTimes)
320 times.Add(Convert.ToInt32(a));
278 } 321 }
322 else
323 {
324 int timeout = 30;
325 if (requestData.ContainsKey("milliseconds"))
326 timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000;
327 while (timeout > 0)
328 {
329 times.Add(timeout);
330 if (timeout > 300)
331 timeout -= 120;
332 else if (timeout > 30)
333 timeout -= 30;
334 else
335 timeout -= 15;
336 }
337 }
338
339 message = "Region is restarting in {0}. Please save what you are doing and log out.";
340
341 if (requestData.ContainsKey("message"))
342 message = requestData["message"].ToString();
343
344 bool notice = true;
345 if (requestData.ContainsKey("noticetype")
346 && ((string)requestData["noticetype"] == "dialog"))
347 {
348 notice = false;
349 }
350
351 List<Scene> restartList;
352
353 if (restartAll)
354 restartList = m_application.SceneManager.Scenes;
355 else
356 restartList = new List<Scene>() { rebootedScene };
357
358 foreach (Scene s in m_application.SceneManager.Scenes)
359 {
360 restartModule = s.RequestModuleInterface<IRestartModule>();
361 if (restartModule != null)
362 restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
363 }
364 responseData["success"] = true;
279 } 365 }
280 catch (Exception e) 366 catch (Exception e)
281 { 367 {
@@ -312,6 +398,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
312 m_log.Info("[RADMIN]: Alert request complete"); 398 m_log.Info("[RADMIN]: Alert request complete");
313 } 399 }
314 400
401 public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
402 {
403 Hashtable responseData = (Hashtable)response.Value;
404
405 m_log.Info("[RADMIN]: Dialog request started");
406
407 Hashtable requestData = (Hashtable)request.Params[0];
408
409 string message = (string)requestData["message"];
410 string fromuuid = (string)requestData["from"];
411 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
412
413 responseData["accepted"] = true;
414 responseData["success"] = true;
415
416 m_application.SceneManager.ForEachScene(
417 delegate(Scene scene)
418 {
419 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
420 if (dialogModule != null)
421 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message);
422 });
423
424 m_log.Info("[RADMIN]: Dialog request complete");
425 }
426
315 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 427 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
316 { 428 {
317 m_log.Info("[RADMIN]: Load height maps request started"); 429 m_log.Info("[RADMIN]: Load height maps request started");
@@ -400,13 +512,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
400 message = "Region is going down now."; 512 message = "Region is going down now.";
401 } 513 }
402 514
403 m_application.SceneManager.ForEachScene( 515 if (requestData.ContainsKey("noticetype")
516 && ((string) requestData["noticetype"] == "dialog"))
517 {
518 m_application.SceneManager.ForEachScene(
519
404 delegate(Scene scene) 520 delegate(Scene scene)
521 {
522 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
523 if (dialogModule != null)
524 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
525 });
526 }
527 else
528 {
529 if (!requestData.ContainsKey("noticetype")
530 || ((string)requestData["noticetype"] != "none"))
531 {
532 m_application.SceneManager.ForEachScene(
533 delegate(Scene scene)
405 { 534 {
406 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 535 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
407 if (dialogModule != null) 536 if (dialogModule != null)
408 dialogModule.SendGeneralAlert(message); 537 dialogModule.SendGeneralAlert(message);
409 }); 538 });
539 }
540 }
410 541
411 // Perform shutdown 542 // Perform shutdown
412 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing 543 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
@@ -1578,21 +1709,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1578 1709
1579 private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1710 private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
1580 { 1711 {
1581 m_log.Info("[RADMIN]: Received Query XML Administrator Request");
1582
1583 Hashtable responseData = (Hashtable)response.Value; 1712 Hashtable responseData = (Hashtable)response.Value;
1584 Hashtable requestData = (Hashtable)request.Params[0]; 1713 Hashtable requestData = (Hashtable)request.Params[0];
1585 1714
1715 int flags = 0;
1716 string text = String.Empty;
1717 int health = 0;
1718 responseData["success"] = true;
1719
1586 CheckRegionParams(requestData, responseData); 1720 CheckRegionParams(requestData, responseData);
1587 1721
1588 Scene scene = null; 1722 Scene scene = null;
1589 GetSceneFromRegionParams(requestData, responseData, out scene); 1723 try
1590 1724 {
1591 int health = scene.GetHealth(); 1725 GetSceneFromRegionParams(requestData, responseData, out scene);
1592 responseData["health"] = health; 1726 health = scene.GetHealth(out flags, out text);
1727 }
1728 catch (Exception e)
1729 {
1730 responseData["error"] = null;
1731 }
1593 1732
1594 responseData["success"] = true; 1733 responseData["success"] = true;
1595 m_log.Info("[RADMIN]: Query XML Administrator Request complete"); 1734 responseData["health"] = health;
1735 responseData["flags"] = flags;
1736 responseData["message"] = text;
1596 } 1737 }
1597 1738
1598 private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1739 private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
@@ -1881,6 +2022,44 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1881 responseData["success"] = true; 2022 responseData["success"] = true;
1882 } 2023 }
1883 2024
2025 private void XmlRpcRefreshSearch(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
2026 {
2027 m_log.Info("[RADMIN]: Received Refresh Search Request");
2028
2029 Hashtable responseData = (Hashtable)response.Value;
2030 Hashtable requestData = (Hashtable)request.Params[0];
2031
2032 CheckRegionParams(requestData, responseData);
2033
2034 Scene scene = null;
2035 GetSceneFromRegionParams(requestData, responseData, out scene);
2036
2037 ISearchModule searchModule = scene.RequestModuleInterface<ISearchModule>();
2038 if (searchModule != null)
2039 {
2040 searchModule.Refresh();
2041 responseData["success"] = true;
2042 }
2043 else
2044 {
2045 responseData["success"] = false;
2046 }
2047
2048 m_log.Info("[RADMIN]: Refresh Search Request complete");
2049 }
2050
2051 private void XmlRpcGetOpenSimVersion(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
2052 {
2053 m_log.Info("[RADMIN]: Received Get OpenSim Version Request");
2054
2055 Hashtable responseData = (Hashtable)response.Value;
2056
2057 responseData["version"] = m_openSimVersion;
2058 responseData["success"] = true;
2059
2060 m_log.Info("[RADMIN]: Get OpenSim Version Request complete");
2061 }
2062
1884 /// <summary> 2063 /// <summary>
1885 /// Parse a float with the given parameter name from a request data hash table. 2064 /// Parse a float with the given parameter name from a request data hash table.
1886 /// </summary> 2065 /// </summary>