diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 105 |
1 files changed, 92 insertions, 13 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 0a262fb..2930753 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -131,6 +131,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
131 | availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); | 131 | availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); |
132 | availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); | 132 | availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); |
133 | availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); | 133 | availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); |
134 | availableMethods["admin_dialog"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDialogMethod); | ||
134 | availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); | 135 | availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); |
135 | availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); | 136 | availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); |
136 | availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); | 137 | availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); |
@@ -270,12 +271,48 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
270 | 271 | ||
271 | responseData["rebooting"] = true; | 272 | responseData["rebooting"] = true; |
272 | 273 | ||
274 | string message; | ||
275 | List<int> times = new List<int>(); | ||
276 | |||
277 | if (requestData.ContainsKey("alerts")) | ||
278 | { | ||
279 | string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','}); | ||
280 | foreach (string a in alertTimes) | ||
281 | times.Add(Convert.ToInt32(a)); | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | int timeout = 30; | ||
286 | if (requestData.ContainsKey("milliseconds")) | ||
287 | timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000; | ||
288 | while (timeout > 0) | ||
289 | { | ||
290 | times.Add(timeout); | ||
291 | if (timeout > 300) | ||
292 | timeout -= 120; | ||
293 | else if (timeout > 30) | ||
294 | timeout -= 30; | ||
295 | else | ||
296 | timeout -= 15; | ||
297 | } | ||
298 | } | ||
299 | |||
300 | message = "Region is restarting in {0}. Please save what you are doing and log out."; | ||
301 | |||
302 | if (requestData.ContainsKey("message")) | ||
303 | message = requestData["message"].ToString(); | ||
304 | |||
305 | bool notice = true; | ||
306 | if (requestData.ContainsKey("noticetype") | ||
307 | && ((string)requestData["noticetype"] == "dialog")) | ||
308 | { | ||
309 | notice = false; | ||
310 | } | ||
311 | |||
273 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | 312 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); |
274 | if (restartModule != null) | 313 | if (restartModule != null) |
275 | { | 314 | { |
276 | List<int> times = new List<int> { 30, 15 }; | 315 | restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice); |
277 | |||
278 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | ||
279 | responseData["success"] = true; | 316 | responseData["success"] = true; |
280 | } | 317 | } |
281 | } | 318 | } |
@@ -314,6 +351,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
314 | m_log.Info("[RADMIN]: Alert request complete"); | 351 | m_log.Info("[RADMIN]: Alert request complete"); |
315 | } | 352 | } |
316 | 353 | ||
354 | public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
355 | { | ||
356 | Hashtable responseData = (Hashtable)response.Value; | ||
357 | |||
358 | m_log.Info("[RADMIN]: Dialog request started"); | ||
359 | |||
360 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
361 | |||
362 | string message = (string)requestData["message"]; | ||
363 | string fromuuid = (string)requestData["from"]; | ||
364 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
365 | |||
366 | responseData["accepted"] = true; | ||
367 | responseData["success"] = true; | ||
368 | |||
369 | m_application.SceneManager.ForEachScene( | ||
370 | delegate(Scene scene) | ||
371 | { | ||
372 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
373 | if (dialogModule != null) | ||
374 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
375 | }); | ||
376 | |||
377 | m_log.Info("[RADMIN]: Dialog request complete"); | ||
378 | } | ||
379 | |||
317 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 380 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
318 | { | 381 | { |
319 | m_log.Info("[RADMIN]: Load height maps request started"); | 382 | m_log.Info("[RADMIN]: Load height maps request started"); |
@@ -403,13 +466,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
403 | message = "Region is going down now."; | 466 | message = "Region is going down now."; |
404 | } | 467 | } |
405 | 468 | ||
406 | m_application.SceneManager.ForEachScene( | 469 | if (requestData.ContainsKey("noticetype") |
470 | && ((string) requestData["noticetype"] == "dialog")) | ||
471 | { | ||
472 | m_application.SceneManager.ForEachScene( | ||
473 | |||
407 | delegate(Scene scene) | 474 | delegate(Scene scene) |
475 | { | ||
476 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
477 | if (dialogModule != null) | ||
478 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
479 | }); | ||
480 | } | ||
481 | else | ||
482 | { | ||
483 | if (!requestData.ContainsKey("noticetype") | ||
484 | || ((string)requestData["noticetype"] != "none")) | ||
485 | { | ||
486 | m_application.SceneManager.ForEachScene( | ||
487 | delegate(Scene scene) | ||
408 | { | 488 | { |
409 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 489 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
410 | if (dialogModule != null) | 490 | if (dialogModule != null) |
411 | dialogModule.SendGeneralAlert(message); | 491 | dialogModule.SendGeneralAlert(message); |
412 | }); | 492 | }); |
493 | } | ||
494 | } | ||
413 | 495 | ||
414 | // Perform shutdown | 496 | // Perform shutdown |
415 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 497 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |
@@ -1642,8 +1724,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1642 | 1724 | ||
1643 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1725 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1644 | { | 1726 | { |
1645 | m_log.Info("[RADMIN]: Received Query XML Administrator Request"); | ||
1646 | |||
1647 | Hashtable responseData = (Hashtable)response.Value; | 1727 | Hashtable responseData = (Hashtable)response.Value; |
1648 | Hashtable requestData = (Hashtable)request.Params[0]; | 1728 | Hashtable requestData = (Hashtable)request.Params[0]; |
1649 | 1729 | ||
@@ -1654,16 +1734,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1654 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | 1734 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; |
1655 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | 1735 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) |
1656 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | 1736 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); |
1657 | |||
1658 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
1659 | } | 1737 | } |
1660 | else if (requestData.Contains("region_name")) | 1738 | else if (requestData.Contains("region_name")) |
1661 | { | 1739 | { |
1662 | string region_name = (string) requestData["region_name"]; | 1740 | string region_name = (string) requestData["region_name"]; |
1663 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | 1741 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) |
1664 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | 1742 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); |
1665 | |||
1666 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
1667 | } | 1743 | } |
1668 | else | 1744 | else |
1669 | { | 1745 | { |
@@ -1671,10 +1747,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1671 | } | 1747 | } |
1672 | 1748 | ||
1673 | Scene scene = m_application.SceneManager.CurrentScene; | 1749 | Scene scene = m_application.SceneManager.CurrentScene; |
1674 | int health = scene.GetHealth(); | ||
1675 | responseData["health"] = health; | ||
1676 | 1750 | ||
1677 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | 1751 | int flags; |
1752 | string text; | ||
1753 | int health = scene.GetHealth(out flags, out text); | ||
1754 | responseData["health"] = health; | ||
1755 | responseData["flags"] = flags; | ||
1756 | responseData["message"] = text; | ||
1678 | } | 1757 | } |
1679 | 1758 | ||
1680 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1759 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |