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 c78cf3b..f3490fb 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"); |
@@ -416,13 +528,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
416 | message = "Region is going down now."; | 528 | message = "Region is going down now."; |
417 | } | 529 | } |
418 | 530 | ||
419 | m_application.SceneManager.ForEachScene( | 531 | if (requestData.ContainsKey("noticetype") |
532 | && ((string) requestData["noticetype"] == "dialog")) | ||
533 | { | ||
534 | m_application.SceneManager.ForEachScene( | ||
535 | |||
420 | delegate(Scene scene) | 536 | delegate(Scene scene) |
537 | { | ||
538 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
539 | if (dialogModule != null) | ||
540 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
541 | }); | ||
542 | } | ||
543 | else | ||
544 | { | ||
545 | if (!requestData.ContainsKey("noticetype") | ||
546 | || ((string)requestData["noticetype"] != "none")) | ||
547 | { | ||
548 | m_application.SceneManager.ForEachScene( | ||
549 | delegate(Scene scene) | ||
421 | { | 550 | { |
422 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 551 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
423 | if (dialogModule != null) | 552 | if (dialogModule != null) |
424 | dialogModule.SendGeneralAlert(message); | 553 | dialogModule.SendGeneralAlert(message); |
425 | }); | 554 | }); |
555 | } | ||
556 | } | ||
426 | 557 | ||
427 | // Perform shutdown | 558 | // Perform shutdown |
428 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 559 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |
@@ -1595,21 +1726,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1595 | 1726 | ||
1596 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1727 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1597 | { | 1728 | { |
1598 | m_log.Info("[RADMIN]: Received Query XML Administrator Request"); | ||
1599 | |||
1600 | Hashtable responseData = (Hashtable)response.Value; | 1729 | Hashtable responseData = (Hashtable)response.Value; |
1601 | Hashtable requestData = (Hashtable)request.Params[0]; | 1730 | Hashtable requestData = (Hashtable)request.Params[0]; |
1602 | 1731 | ||
1732 | int flags = 0; | ||
1733 | string text = String.Empty; | ||
1734 | int health = 0; | ||
1735 | responseData["success"] = true; | ||
1736 | |||
1603 | CheckRegionParams(requestData, responseData); | 1737 | CheckRegionParams(requestData, responseData); |
1604 | 1738 | ||
1605 | Scene scene = null; | 1739 | Scene scene = null; |
1606 | GetSceneFromRegionParams(requestData, responseData, out scene); | 1740 | try |
1607 | 1741 | { | |
1608 | int health = scene.GetHealth(); | 1742 | GetSceneFromRegionParams(requestData, responseData, out scene); |
1609 | responseData["health"] = health; | 1743 | health = scene.GetHealth(out flags, out text); |
1744 | } | ||
1745 | catch (Exception e) | ||
1746 | { | ||
1747 | responseData["error"] = null; | ||
1748 | } | ||
1610 | 1749 | ||
1611 | responseData["success"] = true; | 1750 | responseData["success"] = true; |
1612 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | 1751 | responseData["health"] = health; |
1752 | responseData["flags"] = flags; | ||
1753 | responseData["message"] = text; | ||
1613 | } | 1754 | } |
1614 | 1755 | ||
1615 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1756 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
@@ -1914,6 +2055,44 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1914 | responseData["success"] = true; | 2055 | responseData["success"] = true; |
1915 | } | 2056 | } |
1916 | 2057 | ||
2058 | private void XmlRpcRefreshSearch(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
2059 | { | ||
2060 | m_log.Info("[RADMIN]: Received Refresh Search Request"); | ||
2061 | |||
2062 | Hashtable responseData = (Hashtable)response.Value; | ||
2063 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
2064 | |||
2065 | CheckRegionParams(requestData, responseData); | ||
2066 | |||
2067 | Scene scene = null; | ||
2068 | GetSceneFromRegionParams(requestData, responseData, out scene); | ||
2069 | |||
2070 | ISearchModule searchModule = scene.RequestModuleInterface<ISearchModule>(); | ||
2071 | if (searchModule != null) | ||
2072 | { | ||
2073 | searchModule.Refresh(); | ||
2074 | responseData["success"] = true; | ||
2075 | } | ||
2076 | else | ||
2077 | { | ||
2078 | responseData["success"] = false; | ||
2079 | } | ||
2080 | |||
2081 | m_log.Info("[RADMIN]: Refresh Search Request complete"); | ||
2082 | } | ||
2083 | |||
2084 | private void XmlRpcGetOpenSimVersion(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
2085 | { | ||
2086 | m_log.Info("[RADMIN]: Received Get OpenSim Version Request"); | ||
2087 | |||
2088 | Hashtable responseData = (Hashtable)response.Value; | ||
2089 | |||
2090 | responseData["version"] = m_openSimVersion; | ||
2091 | responseData["success"] = true; | ||
2092 | |||
2093 | m_log.Info("[RADMIN]: Get OpenSim Version Request complete"); | ||
2094 | } | ||
2095 | |||
1917 | /// <summary> | 2096 | /// <summary> |
1918 | /// Parse a float with the given parameter name from a request data hash table. | 2097 | /// Parse a float with the given parameter name from a request data hash table. |
1919 | /// </summary> | 2098 | /// </summary> |