diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 211 |
1 files changed, 195 insertions, 16 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 3abf40b..729667c 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); |
@@ -159,6 +163,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
159 | availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); | 163 | availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); |
160 | availableMethods["admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload); | 164 | availableMethods["admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload); |
161 | 165 | ||
166 | // Misc | ||
167 | availableMethods["admin_refresh_search"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshSearch); | ||
168 | availableMethods["admin_get_opensim_version"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetOpenSimVersion); | ||
169 | |||
162 | // Either enable full remote functionality or just selected features | 170 | // Either enable full remote functionality or just selected features |
163 | string enabledMethods = m_config.GetString("enabled_methods", "all"); | 171 | string enabledMethods = m_config.GetString("enabled_methods", "all"); |
164 | 172 | ||
@@ -260,23 +268,101 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
260 | { | 268 | { |
261 | m_log.Info("[RADMIN]: Request to restart Region."); | 269 | m_log.Info("[RADMIN]: Request to restart Region."); |
262 | 270 | ||
263 | CheckRegionParams(requestData, responseData); | ||
264 | |||
265 | Scene rebootedScene = null; | 271 | Scene rebootedScene = null; |
266 | GetSceneFromRegionParams(requestData, responseData, out rebootedScene); | 272 | bool restartAll = false; |
273 | |||
274 | IConfig startupConfig = m_configSource.Configs["Startup"]; | ||
275 | if (startupConfig != null) | ||
276 | { | ||
277 | if (startupConfig.GetBoolean("InworldRestartShutsDown", false)) | ||
278 | { | ||
279 | rebootedScene = m_application.SceneManager.CurrentOrFirstScene; | ||
280 | restartAll = true; | ||
281 | } | ||
282 | } | ||
283 | |||
284 | if (rebootedScene == null) | ||
285 | { | ||
286 | CheckRegionParams(requestData, responseData); | ||
287 | |||
288 | GetSceneFromRegionParams(requestData, responseData, out rebootedScene); | ||
289 | } | ||
290 | |||
291 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | ||
267 | 292 | ||
268 | responseData["success"] = false; | 293 | responseData["success"] = false; |
269 | responseData["accepted"] = true; | 294 | responseData["accepted"] = true; |
270 | responseData["rebooting"] = true; | 295 | responseData["rebooting"] = true; |
271 | 296 | ||
272 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | 297 | string message; |
273 | if (restartModule != null) | 298 | List<int> times = new List<int>(); |
299 | |||
300 | if (requestData.ContainsKey("alerts")) | ||
274 | { | 301 | { |
275 | List<int> times = new List<int> { 30, 15 }; | 302 | string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','}); |
303 | if (alertTimes.Length == 1 && Convert.ToInt32(alertTimes[0]) == -1) | ||
304 | { | ||
305 | if (restartModule != null) | ||
306 | { | ||
307 | message = "Restart has been cancelled"; | ||
276 | 308 | ||
277 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | 309 | if (requestData.ContainsKey("message")) |
278 | responseData["success"] = true; | 310 | message = requestData["message"].ToString(); |
311 | |||
312 | restartModule.AbortRestart(message); | ||
313 | |||
314 | responseData["success"] = true; | ||
315 | responseData["rebooting"] = false; | ||
316 | |||
317 | return; | ||
318 | } | ||
319 | } | ||
320 | foreach (string a in alertTimes) | ||
321 | times.Add(Convert.ToInt32(a)); | ||
279 | } | 322 | } |
323 | else | ||
324 | { | ||
325 | int timeout = 30; | ||
326 | if (requestData.ContainsKey("milliseconds")) | ||
327 | timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000; | ||
328 | while (timeout > 0) | ||
329 | { | ||
330 | times.Add(timeout); | ||
331 | if (timeout > 300) | ||
332 | timeout -= 120; | ||
333 | else if (timeout > 30) | ||
334 | timeout -= 30; | ||
335 | else | ||
336 | timeout -= 15; | ||
337 | } | ||
338 | } | ||
339 | |||
340 | message = "Region is restarting in {0}. Please save what you are doing and log out."; | ||
341 | |||
342 | if (requestData.ContainsKey("message")) | ||
343 | message = requestData["message"].ToString(); | ||
344 | |||
345 | bool notice = true; | ||
346 | if (requestData.ContainsKey("noticetype") | ||
347 | && ((string)requestData["noticetype"] == "dialog")) | ||
348 | { | ||
349 | notice = false; | ||
350 | } | ||
351 | |||
352 | List<Scene> restartList; | ||
353 | |||
354 | if (restartAll) | ||
355 | restartList = m_application.SceneManager.Scenes; | ||
356 | else | ||
357 | restartList = new List<Scene>() { rebootedScene }; | ||
358 | |||
359 | foreach (Scene s in m_application.SceneManager.Scenes) | ||
360 | { | ||
361 | restartModule = s.RequestModuleInterface<IRestartModule>(); | ||
362 | if (restartModule != null) | ||
363 | restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice); | ||
364 | } | ||
365 | responseData["success"] = true; | ||
280 | } | 366 | } |
281 | catch (Exception e) | 367 | catch (Exception e) |
282 | { | 368 | { |
@@ -313,6 +399,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
313 | m_log.Info("[RADMIN]: Alert request complete"); | 399 | m_log.Info("[RADMIN]: Alert request complete"); |
314 | } | 400 | } |
315 | 401 | ||
402 | public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
403 | { | ||
404 | Hashtable responseData = (Hashtable)response.Value; | ||
405 | |||
406 | m_log.Info("[RADMIN]: Dialog request started"); | ||
407 | |||
408 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
409 | |||
410 | string message = (string)requestData["message"]; | ||
411 | string fromuuid = (string)requestData["from"]; | ||
412 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
413 | |||
414 | responseData["accepted"] = true; | ||
415 | responseData["success"] = true; | ||
416 | |||
417 | m_application.SceneManager.ForEachScene( | ||
418 | delegate(Scene scene) | ||
419 | { | ||
420 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
421 | if (dialogModule != null) | ||
422 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
423 | }); | ||
424 | |||
425 | m_log.Info("[RADMIN]: Dialog request complete"); | ||
426 | } | ||
427 | |||
316 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 428 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
317 | { | 429 | { |
318 | m_log.Info("[RADMIN]: Load height maps request started"); | 430 | m_log.Info("[RADMIN]: Load height maps request started"); |
@@ -401,13 +513,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
401 | message = "Region is going down now."; | 513 | message = "Region is going down now."; |
402 | } | 514 | } |
403 | 515 | ||
404 | m_application.SceneManager.ForEachScene( | 516 | if (requestData.ContainsKey("noticetype") |
517 | && ((string) requestData["noticetype"] == "dialog")) | ||
518 | { | ||
519 | m_application.SceneManager.ForEachScene( | ||
520 | |||
405 | delegate(Scene scene) | 521 | delegate(Scene scene) |
522 | { | ||
523 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
524 | if (dialogModule != null) | ||
525 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
526 | }); | ||
527 | } | ||
528 | else | ||
529 | { | ||
530 | if (!requestData.ContainsKey("noticetype") | ||
531 | || ((string)requestData["noticetype"] != "none")) | ||
532 | { | ||
533 | m_application.SceneManager.ForEachScene( | ||
534 | delegate(Scene scene) | ||
406 | { | 535 | { |
407 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 536 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
408 | if (dialogModule != null) | 537 | if (dialogModule != null) |
409 | dialogModule.SendGeneralAlert(message); | 538 | dialogModule.SendGeneralAlert(message); |
410 | }); | 539 | }); |
540 | } | ||
541 | } | ||
411 | 542 | ||
412 | // Perform shutdown | 543 | // Perform shutdown |
413 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 544 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |
@@ -1580,21 +1711,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1580 | 1711 | ||
1581 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1712 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1582 | { | 1713 | { |
1583 | m_log.Info("[RADMIN]: Received Query XML Administrator Request"); | ||
1584 | |||
1585 | Hashtable responseData = (Hashtable)response.Value; | 1714 | Hashtable responseData = (Hashtable)response.Value; |
1586 | Hashtable requestData = (Hashtable)request.Params[0]; | 1715 | Hashtable requestData = (Hashtable)request.Params[0]; |
1587 | 1716 | ||
1717 | int flags = 0; | ||
1718 | string text = String.Empty; | ||
1719 | int health = 0; | ||
1720 | responseData["success"] = true; | ||
1721 | |||
1588 | CheckRegionParams(requestData, responseData); | 1722 | CheckRegionParams(requestData, responseData); |
1589 | 1723 | ||
1590 | Scene scene = null; | 1724 | Scene scene = null; |
1591 | GetSceneFromRegionParams(requestData, responseData, out scene); | 1725 | try |
1592 | 1726 | { | |
1593 | int health = scene.GetHealth(); | 1727 | GetSceneFromRegionParams(requestData, responseData, out scene); |
1594 | responseData["health"] = health; | 1728 | health = scene.GetHealth(out flags, out text); |
1729 | } | ||
1730 | catch (Exception e) | ||
1731 | { | ||
1732 | responseData["error"] = null; | ||
1733 | } | ||
1595 | 1734 | ||
1596 | responseData["success"] = true; | 1735 | responseData["success"] = true; |
1597 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | 1736 | responseData["health"] = health; |
1737 | responseData["flags"] = flags; | ||
1738 | responseData["message"] = text; | ||
1598 | } | 1739 | } |
1599 | 1740 | ||
1600 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1741 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
@@ -1899,6 +2040,44 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1899 | responseData["success"] = true; | 2040 | responseData["success"] = true; |
1900 | } | 2041 | } |
1901 | 2042 | ||
2043 | private void XmlRpcRefreshSearch(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
2044 | { | ||
2045 | m_log.Info("[RADMIN]: Received Refresh Search Request"); | ||
2046 | |||
2047 | Hashtable responseData = (Hashtable)response.Value; | ||
2048 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
2049 | |||
2050 | CheckRegionParams(requestData, responseData); | ||
2051 | |||
2052 | Scene scene = null; | ||
2053 | GetSceneFromRegionParams(requestData, responseData, out scene); | ||
2054 | |||
2055 | ISearchModule searchModule = scene.RequestModuleInterface<ISearchModule>(); | ||
2056 | if (searchModule != null) | ||
2057 | { | ||
2058 | searchModule.Refresh(); | ||
2059 | responseData["success"] = true; | ||
2060 | } | ||
2061 | else | ||
2062 | { | ||
2063 | responseData["success"] = false; | ||
2064 | } | ||
2065 | |||
2066 | m_log.Info("[RADMIN]: Refresh Search Request complete"); | ||
2067 | } | ||
2068 | |||
2069 | private void XmlRpcGetOpenSimVersion(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
2070 | { | ||
2071 | m_log.Info("[RADMIN]: Received Get OpenSim Version Request"); | ||
2072 | |||
2073 | Hashtable responseData = (Hashtable)response.Value; | ||
2074 | |||
2075 | responseData["version"] = m_openSimVersion; | ||
2076 | responseData["success"] = true; | ||
2077 | |||
2078 | m_log.Info("[RADMIN]: Get OpenSim Version Request complete"); | ||
2079 | } | ||
2080 | |||
1902 | /// <summary> | 2081 | /// <summary> |
1903 | /// Parse a float with the given parameter name from a request data hash table. | 2082 | /// Parse a float with the given parameter name from a request data hash table. |
1904 | /// </summary> | 2083 | /// </summary> |