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