adds support to delete a region completely and offers that

functionality via the console command "delete-region" and also via
RemoteAdminPlugin.

minor typo fix.
0.6.0-stable
Dr Scofield 2008-09-18 15:44:05 +00:00
parent 232d1af663
commit 03f246d6fe
6 changed files with 118 additions and 23 deletions

View File

@ -86,6 +86,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
m_httpd = openSim.HttpServer; m_httpd = openSim.HttpServer;
m_httpd.AddXmlRPCHandler("admin_create_region", XmlRpcCreateRegionMethod); m_httpd.AddXmlRPCHandler("admin_create_region", XmlRpcCreateRegionMethod);
m_httpd.AddXmlRPCHandler("admin_delete_region", XmlRpcDeleteRegionMethod);
m_httpd.AddXmlRPCHandler("admin_shutdown", XmlRpcShutdownMethod); m_httpd.AddXmlRPCHandler("admin_shutdown", XmlRpcShutdownMethod);
m_httpd.AddXmlRPCHandler("admin_broadcast", XmlRpcAlertMethod); m_httpd.AddXmlRPCHandler("admin_broadcast", XmlRpcAlertMethod);
m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod); m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod);
@ -344,8 +345,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
/// <description>internal port (integer)</description></item> /// <description>internal port (integer)</description></item>
/// <item><term>external_address</term> /// <item><term>external_address</term>
/// <description>external IP address</description></item> /// <description>external IP address</description></item>
/// <item><term>datastore</term>
/// <description>datastore parameter (?)</description></item>
/// <item><term>persist</term> /// <item><term>persist</term>
/// <description>if true, persist the region info /// <description>if true, persist the region info
/// ('true' or 'false')</description></item> /// ('true' or 'false')</description></item>
@ -378,7 +377,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
"region_master_first", "region_master_last", "region_master_first", "region_master_last",
"region_master_password", "region_master_password",
"listen_ip", "external_address"}); "listen_ip", "external_address"});
checkIntegerParams(request, new string[] { "region_x", "region_y", "listen_port"}); checkIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"});
// check password // check password
if (!String.IsNullOrEmpty(requiredPassword) && if (!String.IsNullOrEmpty(requiredPassword) &&
@ -390,7 +389,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (requestData.ContainsKey("region_id") && if (requestData.ContainsKey("region_id") &&
!String.IsNullOrEmpty((string)requestData["region_id"])) !String.IsNullOrEmpty((string)requestData["region_id"]))
{ {
regionID = (string) requestData["region_id"]; regionID = (string)requestData["region_id"];
if (m_app.SceneManager.TryGetScene(regionID, out scene)) if (m_app.SceneManager.TryGetScene(regionID, out scene))
throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>",
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
@ -492,6 +491,68 @@ namespace OpenSim.ApplicationPlugins.RemoteController
return response; return response;
} }
/// <summary>
/// Delete a new region.
/// <summary>
/// <param name="request">incoming XML RPC request</param>
/// <remarks>
/// XmlRpcCreateRegionMethod takes the following XMLRPC
/// parameters
/// <list type="table">
/// <listheader><term>parameter name</term><description>description</description></listheader>
/// <item><term>password</term>
/// <description>admin password as set in OpenSim.ini</description></item>
/// <item><term>region_name</term>
/// <description>desired region name</description></item>
/// <item><term>region_id</term>
/// <description>(optional) desired region UUID</description></item>
/// </list>
///
/// XmlRpcCreateRegionMethod returns
/// <list type="table">
/// <listheader><term>name</term><description>description</description></listheader>
/// <item><term>success</term>
/// <description>true or false</description></item>
/// <item><term>error</term>
/// <description>error message if success is false</description></item>
/// </list>
/// </remarks>
public XmlRpcResponse XmlRpcDeleteRegionMethod(XmlRpcRequest request)
{
m_log.Info("[RADMIN]: DeleteRegion: new request");
XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable();
try {
Hashtable requestData = (Hashtable) request.Params[0];
checkStringParameters(request, new string[] {"password", "region_name"});
Scene scene = null;
string regionName = (string)requestData["region_name"];
if (!m_app.SceneManager.TryGetScene(regionName, out scene))
throw new Exception(String.Format("region \"{0}\" does not exist", regionName));
m_app.RemoveRegion(scene, true);
responseData["success"] = "true";
responseData["region_name"] = regionName;
response.Value = responseData;
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0}", e.Message);
m_log.DebugFormat("[RADMIN] DeleteRegion: failed {0}", e.ToString());
responseData["success"] = "false";
responseData["error"] = e.Message;
response.Value = responseData;
}
return response;
}
/// <summary> /// <summary>
/// Create a new user account. /// Create a new user account.
/// <summary> /// <summary>

View File

@ -30,7 +30,6 @@ using System.Collections;
using OpenMetaverse; using OpenMetaverse;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenMetaverse;
namespace OpenSim.Data namespace OpenSim.Data
{ {

View File

@ -196,6 +196,7 @@ namespace OpenSim.Framework
public bool commFailTF = false; public bool commFailTF = false;
public ConfigurationMember configMember; public ConfigurationMember configMember;
public string DataStore = String.Empty; public string DataStore = String.Empty;
public string RegionFile = String.Empty;
public bool isSandbox = false; public bool isSandbox = false;
private EstateSettings m_estateSettings; private EstateSettings m_estateSettings;
private RegionSettings m_regionSettings; private RegionSettings m_regionSettings;
@ -221,6 +222,7 @@ namespace OpenSim.Framework
configMember = configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig); new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig);
configMember.performConfigurationRetrieve(); configMember.performConfigurationRetrieve();
RegionFile = filename;
} }
public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig) public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig)
@ -364,6 +366,7 @@ namespace OpenSim.Framework
configMember = new ConfigurationMember(filename, description, loadConfigurationOptionsFromMe, configMember = new ConfigurationMember(filename, description, loadConfigurationOptionsFromMe,
ignoreIncomingConfiguration, false); ignoreIncomingConfiguration, false);
configMember.performConfigurationRetrieve(); configMember.performConfigurationRetrieve();
RegionFile = filename;
} }
public void loadConfigurationOptionsFromMe() public void loadConfigurationOptionsFromMe()

View File

@ -311,22 +311,23 @@ namespace OpenSim
break; break;
case "remove-region": case "remove-region":
string regName = CombineParams(cmdparams, 0); string regRemoveName = CombineParams(cmdparams, 0);
Scene removeScene;
if (m_sceneManager.TryGetScene(regRemoveName, out removeScene))
RemoveRegion(removeScene, false);
else
m_console.Error("no region with that name");
break;
case "delete-region":
string regDeleteName = CombineParams(cmdparams, 0);
Scene killScene; Scene killScene;
if (m_sceneManager.TryGetScene(regName, out killScene)) if (m_sceneManager.TryGetScene(regDeleteName, out killScene))
{ RemoveRegion(killScene, true);
// only need to check this if we are not at the else
// root level m_console.Error("no region with that name");
if ((m_sceneManager.CurrentScene != null) &&
(m_sceneManager.CurrentScene.RegionInfo.RegionID == killScene.RegionInfo.RegionID))
{
m_sceneManager.TrySetCurrentScene("..");
}
m_regionData.Remove(killScene.RegionInfo);
m_sceneManager.CloseScene(killScene);
}
break; break;
case "restart": case "restart":
@ -610,6 +611,7 @@ namespace OpenSim
m_console.Notice("force-update - force an update of prims in the scene"); m_console.Notice("force-update - force an update of prims in the scene");
m_console.Notice("restart - disconnects all clients and restarts the sims in the instance."); m_console.Notice("restart - disconnects all clients and restarts the sims in the instance.");
m_console.Notice("remove-region [name] - remove a region"); m_console.Notice("remove-region [name] - remove a region");
m_console.Notice("delete-region [name] - delete a region");
m_console.Notice("load-xml [filename] - load prims from XML (DEPRECATED)"); m_console.Notice("load-xml [filename] - load prims from XML (DEPRECATED)");
m_console.Notice("save-xml [filename] - save prims to XML (DEPRECATED)"); m_console.Notice("save-xml [filename] - save prims to XML (DEPRECATED)");
m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format"); m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format");

View File

@ -589,6 +589,37 @@ namespace OpenSim
return clientServer; return clientServer;
} }
public void RemoveRegion(Scene scene, bool cleanup)
{
// only need to check this if we are not at the
// root level
if ((m_sceneManager.CurrentScene != null) &&
(m_sceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID))
{
m_sceneManager.TrySetCurrentScene("..");
}
scene.DeleteAllSceneObjects();
m_regionData.Remove(scene.RegionInfo);
m_sceneManager.CloseScene(scene);
if (!cleanup)
return;
if (!String.IsNullOrEmpty(scene.RegionInfo.RegionFile))
{
File.Delete(scene.RegionInfo.RegionFile);
m_log.InfoFormat("[OPENSIM MAIN] deleting region file \"{0}\"", scene.RegionInfo.RegionFile);
}
}
public void RemoveRegion(string name, bool cleanUp)
{
Scene target;
if (m_sceneManager.TryGetScene(name, out target))
RemoveRegion(target, cleanUp);
}
protected override StorageManager CreateStorageManager(string connectionstring, string estateconnectionstring) protected override StorageManager CreateStorageManager(string connectionstring, string estateconnectionstring)
{ {
return new StorageManager(m_storageDll, connectionstring, estateconnectionstring); return new StorageManager(m_storageDll, connectionstring, estateconnectionstring);

View File

@ -624,7 +624,7 @@ namespace OpenSim.Region.Environment.Scenes
// close the inner scene // close the inner scene
m_innerScene.Close(); m_innerScene.Close();
// De-register with region communications (events cleanup) // De-register with region communications (events cleanup)
UnRegisterReginWithComms(); UnRegisterRegionWithComms();
// Shut down all non shared modules. // Shut down all non shared modules.
foreach (IRegionModule module in Modules.Values) foreach (IRegionModule module in Modules.Values)
@ -1775,10 +1775,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns>true if the object was in the scene, false if it was not</returns> /// <returns>true if the object was in the scene, false if it was not</returns>
public bool UnlinkSceneObject(UUID uuid, bool resultOfLinkingObjects) public bool UnlinkSceneObject(UUID uuid, bool resultOfLinkingObjects)
{ {
if (m_innerScene.DeleteSceneObject(uuid,resultOfLinkingObjects)) if (m_innerScene.DeleteSceneObject(uuid, resultOfLinkingObjects))
{ {
m_storageManager.DataStore.RemoveObject(uuid, m_regInfo.RegionID); m_storageManager.DataStore.RemoveObject(uuid, m_regInfo.RegionID);
return true; return true;
} }
@ -2568,7 +2567,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public void UnRegisterReginWithComms() public void UnRegisterRegionWithComms()
{ {
m_sceneGridService.KiPrimitive -= SendKiPrimitive; m_sceneGridService.KiPrimitive -= SendKiPrimitive;
m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;