aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 a75d10d..49fc566 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -70,6 +70,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
70 70
71 private string m_name = "RemoteAdminPlugin"; 71 private string m_name = "RemoteAdminPlugin";
72 private string m_version = "0.0"; 72 private string m_version = "0.0";
73 private string m_openSimVersion;
73 74
74 public string Version 75 public string Version
75 { 76 {
@@ -89,6 +90,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
89 90
90 public void Initialise(OpenSimBase openSim) 91 public void Initialise(OpenSimBase openSim)
91 { 92 {
93 m_openSimVersion = openSim.GetVersionText();
94
92 m_configSource = openSim.ConfigSource.Source; 95 m_configSource = openSim.ConfigSource.Source;
93 try 96 try
94 { 97 {
@@ -131,6 +134,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
131 availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); 134 availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod);
132 availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); 135 availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod);
133 availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); 136 availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod);
137 availableMethods["admin_dialog"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDialogMethod);
134 availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); 138 availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod);
135 availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); 139 availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod);
136 availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); 140 availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod);
@@ -156,6 +160,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
156 availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove); 160 availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove);
157 availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); 161 availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList);
158 162
163 // Misc
164 availableMethods["admin_refresh_search"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshSearch);
165 availableMethods["admin_get_opensim_version"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetOpenSimVersion);
166
159 // Either enable full remote functionality or just selected features 167 // Either enable full remote functionality or just selected features
160 string enabledMethods = m_config.GetString("enabled_methods", "all"); 168 string enabledMethods = m_config.GetString("enabled_methods", "all");
161 169
@@ -257,23 +265,101 @@ namespace OpenSim.ApplicationPlugins.RemoteController
257 { 265 {
258 m_log.Info("[RADMIN]: Request to restart Region."); 266 m_log.Info("[RADMIN]: Request to restart Region.");
259 267
260 CheckRegionParams(requestData, responseData);
261
262 Scene rebootedScene = null; 268 Scene rebootedScene = null;
263 GetSceneFromRegionParams(requestData, responseData, out rebootedScene); 269 bool restartAll = false;
270
271 IConfig startupConfig = m_configSource.Configs["Startup"];
272 if (startupConfig != null)
273 {
274 if (startupConfig.GetBoolean("InworldRestartShutsDown", false))
275 {
276 rebootedScene = m_application.SceneManager.CurrentOrFirstScene;
277 restartAll = true;
278 }
279 }
280
281 if (rebootedScene == null)
282 {
283 CheckRegionParams(requestData, responseData);
284
285 GetSceneFromRegionParams(requestData, responseData, out rebootedScene);
286 }
287
288 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
264 289
265 responseData["success"] = false; 290 responseData["success"] = false;
266 responseData["accepted"] = true; 291 responseData["accepted"] = true;
267 responseData["rebooting"] = true; 292 responseData["rebooting"] = true;
268 293
269 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); 294 string message;
270 if (restartModule != null) 295 List<int> times = new List<int>();
296
297 if (requestData.ContainsKey("alerts"))
271 { 298 {
272 List<int> times = new List<int> { 30, 15 }; 299 string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','});
300 if (alertTimes.Length == 1 && Convert.ToInt32(alertTimes[0]) == -1)
301 {
302 if (restartModule != null)
303 {
304 message = "Restart has been cancelled";
273 305
274 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); 306 if (requestData.ContainsKey("message"))
275 responseData["success"] = true; 307 message = requestData["message"].ToString();
308
309 restartModule.AbortRestart(message);
310
311 responseData["success"] = true;
312 responseData["rebooting"] = false;
313
314 return;
315 }
316 }
317 foreach (string a in alertTimes)
318 times.Add(Convert.ToInt32(a));
276 } 319 }
320 else
321 {
322 int timeout = 30;
323 if (requestData.ContainsKey("milliseconds"))
324 timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000;
325 while (timeout > 0)
326 {
327 times.Add(timeout);
328 if (timeout > 300)
329 timeout -= 120;
330 else if (timeout > 30)
331 timeout -= 30;
332 else
333 timeout -= 15;
334 }
335 }
336
337 message = "Region is restarting in {0}. Please save what you are doing and log out.";
338
339 if (requestData.ContainsKey("message"))
340 message = requestData["message"].ToString();
341
342 bool notice = true;
343 if (requestData.ContainsKey("noticetype")
344 && ((string)requestData["noticetype"] == "dialog"))
345 {
346 notice = false;
347 }
348
349 List<Scene> restartList;
350
351 if (restartAll)
352 restartList = m_application.SceneManager.Scenes;
353 else
354 restartList = new List<Scene>() { rebootedScene };
355
356 foreach (Scene s in m_application.SceneManager.Scenes)
357 {
358 restartModule = s.RequestModuleInterface<IRestartModule>();
359 if (restartModule != null)
360 restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
361 }
362 responseData["success"] = true;
277 } 363 }
278 catch (Exception e) 364 catch (Exception e)
279 { 365 {
@@ -310,6 +396,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
310 m_log.Info("[RADMIN]: Alert request complete"); 396 m_log.Info("[RADMIN]: Alert request complete");
311 } 397 }
312 398
399 public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
400 {
401 Hashtable responseData = (Hashtable)response.Value;
402
403 m_log.Info("[RADMIN]: Dialog request started");
404
405 Hashtable requestData = (Hashtable)request.Params[0];
406
407 string message = (string)requestData["message"];
408 string fromuuid = (string)requestData["from"];
409 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
410
411 responseData["accepted"] = true;
412 responseData["success"] = true;
413
414 m_application.SceneManager.ForEachScene(
415 delegate(Scene scene)
416 {
417 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
418 if (dialogModule != null)
419 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message);
420 });
421
422 m_log.Info("[RADMIN]: Dialog request complete");
423 }
424
313 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 425 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
314 { 426 {
315 m_log.Info("[RADMIN]: Load height maps request started"); 427 m_log.Info("[RADMIN]: Load height maps request started");
@@ -398,13 +510,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
398 message = "Region is going down now."; 510 message = "Region is going down now.";
399 } 511 }
400 512
401 m_application.SceneManager.ForEachScene( 513 if (requestData.ContainsKey("noticetype")
514 && ((string) requestData["noticetype"] == "dialog"))
515 {
516 m_application.SceneManager.ForEachScene(
517
402 delegate(Scene scene) 518 delegate(Scene scene)
519 {
520 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
521 if (dialogModule != null)
522 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
523 });
524 }
525 else
526 {
527 if (!requestData.ContainsKey("noticetype")
528 || ((string)requestData["noticetype"] != "none"))
529 {
530 m_application.SceneManager.ForEachScene(
531 delegate(Scene scene)
403 { 532 {
404 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 533 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
405 if (dialogModule != null) 534 if (dialogModule != null)
406 dialogModule.SendGeneralAlert(message); 535 dialogModule.SendGeneralAlert(message);
407 }); 536 });
537 }
538 }
408 539
409 // Perform shutdown 540 // Perform shutdown
410 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing 541 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
@@ -1576,21 +1707,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1576 1707
1577 private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1708 private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
1578 { 1709 {
1579 m_log.Info("[RADMIN]: Received Query XML Administrator Request");
1580
1581 Hashtable responseData = (Hashtable)response.Value; 1710 Hashtable responseData = (Hashtable)response.Value;
1582 Hashtable requestData = (Hashtable)request.Params[0]; 1711 Hashtable requestData = (Hashtable)request.Params[0];
1583 1712
1713 int flags = 0;
1714 string text = String.Empty;
1715 int health = 0;
1716 responseData["success"] = true;
1717
1584 CheckRegionParams(requestData, responseData); 1718 CheckRegionParams(requestData, responseData);
1585 1719
1586 Scene scene = null; 1720 Scene scene = null;
1587 GetSceneFromRegionParams(requestData, responseData, out scene); 1721 try
1588 1722 {
1589 int health = scene.GetHealth(); 1723 GetSceneFromRegionParams(requestData, responseData, out scene);
1590 responseData["health"] = health; 1724 health = scene.GetHealth(out flags, out text);
1725 }
1726 catch (Exception e)
1727 {
1728 responseData["error"] = null;
1729 }
1591 1730
1592 responseData["success"] = true; 1731 responseData["success"] = true;
1593 m_log.Info("[RADMIN]: Query XML Administrator Request complete"); 1732 responseData["health"] = health;
1733 responseData["flags"] = flags;
1734 responseData["message"] = text;
1594 } 1735 }
1595 1736
1596 private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1737 private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
@@ -1814,6 +1955,44 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1814 responseData["success"] = true; 1955 responseData["success"] = true;
1815 } 1956 }
1816 1957
1958 private void XmlRpcRefreshSearch(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
1959 {
1960 m_log.Info("[RADMIN]: Received Refresh Search Request");
1961
1962 Hashtable responseData = (Hashtable)response.Value;
1963 Hashtable requestData = (Hashtable)request.Params[0];
1964
1965 CheckRegionParams(requestData, responseData);
1966
1967 Scene scene = null;
1968 GetSceneFromRegionParams(requestData, responseData, out scene);
1969
1970 ISearchModule searchModule = scene.RequestModuleInterface<ISearchModule>();
1971 if (searchModule != null)
1972 {
1973 searchModule.Refresh();
1974 responseData["success"] = true;
1975 }
1976 else
1977 {
1978 responseData["success"] = false;
1979 }
1980
1981 m_log.Info("[RADMIN]: Refresh Search Request complete");
1982 }
1983
1984 private void XmlRpcGetOpenSimVersion(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
1985 {
1986 m_log.Info("[RADMIN]: Received Get OpenSim Version Request");
1987
1988 Hashtable responseData = (Hashtable)response.Value;
1989
1990 responseData["version"] = m_openSimVersion;
1991 responseData["success"] = true;
1992
1993 m_log.Info("[RADMIN]: Get OpenSim Version Request complete");
1994 }
1995
1817 /// <summary> 1996 /// <summary>
1818 /// Parse a float with the given parameter name from a request data hash table. 1997 /// Parse a float with the given parameter name from a request data hash table.
1819 /// </summary> 1998 /// </summary>