diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 166 |
1 files changed, 150 insertions, 16 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index a5e56f9..202d199 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); |
@@ -257,23 +258,101 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
257 | { | 258 | { |
258 | m_log.Info("[RADMIN]: Request to restart Region."); | 259 | m_log.Info("[RADMIN]: Request to restart Region."); |
259 | 260 | ||
260 | CheckRegionParams(requestData, responseData); | ||
261 | |||
262 | Scene rebootedScene = null; | 261 | Scene rebootedScene = null; |
263 | GetSceneFromRegionParams(requestData, responseData, out rebootedScene); | 262 | bool restartAll = false; |
263 | |||
264 | IConfig startupConfig = m_configSource.Configs["Startup"]; | ||
265 | if (startupConfig != null) | ||
266 | { | ||
267 | if (startupConfig.GetBoolean("InworldRestartShutsDown", false)) | ||
268 | { | ||
269 | rebootedScene = m_application.SceneManager.CurrentOrFirstScene; | ||
270 | restartAll = true; | ||
271 | } | ||
272 | } | ||
273 | |||
274 | if (rebootedScene == null) | ||
275 | { | ||
276 | CheckRegionParams(requestData, responseData); | ||
277 | |||
278 | GetSceneFromRegionParams(requestData, responseData, out rebootedScene); | ||
279 | } | ||
280 | |||
281 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | ||
264 | 282 | ||
265 | responseData["success"] = false; | 283 | responseData["success"] = false; |
266 | responseData["accepted"] = true; | 284 | responseData["accepted"] = true; |
267 | responseData["rebooting"] = true; | 285 | responseData["rebooting"] = true; |
268 | 286 | ||
269 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | 287 | string message; |
270 | if (restartModule != null) | 288 | List<int> times = new List<int>(); |
289 | |||
290 | if (requestData.ContainsKey("alerts")) | ||
271 | { | 291 | { |
272 | List<int> times = new List<int> { 30, 15 }; | 292 | string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','}); |
293 | if (alertTimes.Length == 1 && Convert.ToInt32(alertTimes[0]) == -1) | ||
294 | { | ||
295 | if (restartModule != null) | ||
296 | { | ||
297 | message = "Restart has been cancelled"; | ||
273 | 298 | ||
274 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | 299 | if (requestData.ContainsKey("message")) |
275 | responseData["success"] = true; | 300 | message = requestData["message"].ToString(); |
301 | |||
302 | restartModule.AbortRestart(message); | ||
303 | |||
304 | responseData["success"] = true; | ||
305 | responseData["rebooting"] = false; | ||
306 | |||
307 | return; | ||
308 | } | ||
309 | } | ||
310 | foreach (string a in alertTimes) | ||
311 | times.Add(Convert.ToInt32(a)); | ||
276 | } | 312 | } |
313 | else | ||
314 | { | ||
315 | int timeout = 30; | ||
316 | if (requestData.ContainsKey("milliseconds")) | ||
317 | timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000; | ||
318 | while (timeout > 0) | ||
319 | { | ||
320 | times.Add(timeout); | ||
321 | if (timeout > 300) | ||
322 | timeout -= 120; | ||
323 | else if (timeout > 30) | ||
324 | timeout -= 30; | ||
325 | else | ||
326 | timeout -= 15; | ||
327 | } | ||
328 | } | ||
329 | |||
330 | message = "Region is restarting in {0}. Please save what you are doing and log out."; | ||
331 | |||
332 | if (requestData.ContainsKey("message")) | ||
333 | message = requestData["message"].ToString(); | ||
334 | |||
335 | bool notice = true; | ||
336 | if (requestData.ContainsKey("noticetype") | ||
337 | && ((string)requestData["noticetype"] == "dialog")) | ||
338 | { | ||
339 | notice = false; | ||
340 | } | ||
341 | |||
342 | List<Scene> restartList; | ||
343 | |||
344 | if (restartAll) | ||
345 | restartList = m_application.SceneManager.Scenes; | ||
346 | else | ||
347 | restartList = new List<Scene>() { rebootedScene }; | ||
348 | |||
349 | foreach (Scene s in m_application.SceneManager.Scenes) | ||
350 | { | ||
351 | restartModule = s.RequestModuleInterface<IRestartModule>(); | ||
352 | if (restartModule != null) | ||
353 | restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice); | ||
354 | } | ||
355 | responseData["success"] = true; | ||
277 | } | 356 | } |
278 | catch (Exception e) | 357 | catch (Exception e) |
279 | { | 358 | { |
@@ -310,6 +389,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
310 | m_log.Info("[RADMIN]: Alert request complete"); | 389 | m_log.Info("[RADMIN]: Alert request complete"); |
311 | } | 390 | } |
312 | 391 | ||
392 | public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
393 | { | ||
394 | Hashtable responseData = (Hashtable)response.Value; | ||
395 | |||
396 | m_log.Info("[RADMIN]: Dialog request started"); | ||
397 | |||
398 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
399 | |||
400 | string message = (string)requestData["message"]; | ||
401 | string fromuuid = (string)requestData["from"]; | ||
402 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
403 | |||
404 | responseData["accepted"] = true; | ||
405 | responseData["success"] = true; | ||
406 | |||
407 | m_application.SceneManager.ForEachScene( | ||
408 | delegate(Scene scene) | ||
409 | { | ||
410 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
411 | if (dialogModule != null) | ||
412 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
413 | }); | ||
414 | |||
415 | m_log.Info("[RADMIN]: Dialog request complete"); | ||
416 | } | ||
417 | |||
313 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 418 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
314 | { | 419 | { |
315 | m_log.Info("[RADMIN]: Load height maps request started"); | 420 | m_log.Info("[RADMIN]: Load height maps request started"); |
@@ -398,13 +503,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
398 | message = "Region is going down now."; | 503 | message = "Region is going down now."; |
399 | } | 504 | } |
400 | 505 | ||
401 | m_application.SceneManager.ForEachScene( | 506 | if (requestData.ContainsKey("noticetype") |
507 | && ((string) requestData["noticetype"] == "dialog")) | ||
508 | { | ||
509 | m_application.SceneManager.ForEachScene( | ||
510 | |||
402 | delegate(Scene scene) | 511 | delegate(Scene scene) |
512 | { | ||
513 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
514 | if (dialogModule != null) | ||
515 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
516 | }); | ||
517 | } | ||
518 | else | ||
519 | { | ||
520 | if (!requestData.ContainsKey("noticetype") | ||
521 | || ((string)requestData["noticetype"] != "none")) | ||
522 | { | ||
523 | m_application.SceneManager.ForEachScene( | ||
524 | delegate(Scene scene) | ||
403 | { | 525 | { |
404 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 526 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
405 | if (dialogModule != null) | 527 | if (dialogModule != null) |
406 | dialogModule.SendGeneralAlert(message); | 528 | dialogModule.SendGeneralAlert(message); |
407 | }); | 529 | }); |
530 | } | ||
531 | } | ||
408 | 532 | ||
409 | // Perform shutdown | 533 | // Perform shutdown |
410 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 534 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |
@@ -1577,21 +1701,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1577 | 1701 | ||
1578 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1702 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1579 | { | 1703 | { |
1580 | m_log.Info("[RADMIN]: Received Query XML Administrator Request"); | ||
1581 | |||
1582 | Hashtable responseData = (Hashtable)response.Value; | 1704 | Hashtable responseData = (Hashtable)response.Value; |
1583 | Hashtable requestData = (Hashtable)request.Params[0]; | 1705 | Hashtable requestData = (Hashtable)request.Params[0]; |
1584 | 1706 | ||
1707 | int flags = 0; | ||
1708 | string text = String.Empty; | ||
1709 | int health = 0; | ||
1710 | responseData["success"] = true; | ||
1711 | |||
1585 | CheckRegionParams(requestData, responseData); | 1712 | CheckRegionParams(requestData, responseData); |
1586 | 1713 | ||
1587 | Scene scene = null; | 1714 | Scene scene = null; |
1588 | GetSceneFromRegionParams(requestData, responseData, out scene); | 1715 | try |
1589 | 1716 | { | |
1590 | int health = scene.GetHealth(); | 1717 | GetSceneFromRegionParams(requestData, responseData, out scene); |
1591 | responseData["health"] = health; | 1718 | health = scene.GetHealth(out flags, out text); |
1719 | } | ||
1720 | catch (Exception e) | ||
1721 | { | ||
1722 | responseData["error"] = null; | ||
1723 | } | ||
1592 | 1724 | ||
1593 | responseData["success"] = true; | 1725 | responseData["success"] = true; |
1594 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | 1726 | responseData["health"] = health; |
1727 | responseData["flags"] = flags; | ||
1728 | responseData["message"] = text; | ||
1595 | } | 1729 | } |
1596 | 1730 | ||
1597 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1731 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |