From: Dr Scofield <hud@zurich.ibm.com>
the attached patch set is centered around RemoteAdminPlugin and focuses mainly on making it more robust (i.e. more parameter checking and better error reporting) but also we've re-implemented the LoadTerrain stuff that got disabled during the terrain code reworking: * missing PostInitialize() calls on region modules that were loaded for regions created via RemoteAdmin's CreateRegion XmlRpc call * re-implements RemoteAdmin's LoadTerrain XmlRpc call (probably lost during the TerrainModule rework) * adds lots more parameter checking and error reporting to RemoteAdmin * adds a read-only property to RegionApplicationBase so that we can access the CommsManager * adds Exceptions to TerrainModule so that we get better error case feedback (and can report more meaningful errors in turn) * adds a CheckForTerrainUpdate() call to TerrainModule.LoadFromFile() to make terrain changes effective * adds TryGetCurrentScene(LLUUID) to SceneManager so that we can retrieve Scenes not only by name but also by LLUUID cheers, dr scofield0.6.0-stable
parent
a0b8c46ef3
commit
bf1580fba4
|
@ -38,6 +38,7 @@ using Nwc.XmlRpc;
|
|||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.Modules.Terrain;
|
||||
|
||||
[assembly : Addin]
|
||||
[assembly : AddinDependency("OpenSim", "0.5")]
|
||||
|
@ -88,6 +89,9 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
LLUUID regionID = new LLUUID((string) requestData["regionID"]);
|
||||
|
||||
Hashtable responseData = new Hashtable();
|
||||
|
||||
m_log.Info("[RADMIN]: Request to restart Region.");
|
||||
|
||||
if (requiredPassword != String.Empty &&
|
||||
(!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
|
||||
{
|
||||
|
@ -119,24 +123,30 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
{
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable requestData = (Hashtable) request.Params[0];
|
||||
|
||||
Hashtable responseData = new Hashtable();
|
||||
if (requiredPassword != String.Empty &&
|
||||
(!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
|
||||
{
|
||||
responseData["accepted"] = "false";
|
||||
response.Value = responseData;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
try {
|
||||
checkStringParameters(request, new string[] { "password", "message" });
|
||||
|
||||
if (requiredPassword != String.Empty &&
|
||||
(!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
|
||||
throw new Exception("wrong password");
|
||||
|
||||
string message = (string) requestData["message"];
|
||||
m_log.Info("[RADMIN]: Broadcasting: " + message);
|
||||
m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
|
||||
|
||||
responseData["accepted"] = "true";
|
||||
response.Value = responseData;
|
||||
|
||||
m_app.SceneManager.SendGeneralMessage(message);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message);
|
||||
m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString());
|
||||
responseData["accepted"] = "false";
|
||||
response.Value = responseData;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
@ -146,35 +156,48 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
|
||||
Hashtable responseData = new Hashtable();
|
||||
if (requiredPassword != String.Empty &&
|
||||
(!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
|
||||
m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString());
|
||||
foreach (string k in requestData.Keys)
|
||||
{
|
||||
responseData["accepted"] = "false";
|
||||
response.Value = responseData;
|
||||
m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}",
|
||||
k, (string)requestData[k], ((string)requestData[k]).Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Hashtable responseData = new Hashtable();
|
||||
try {
|
||||
checkStringParameters(request, new string[] { "password", "filename", "regionid"});
|
||||
|
||||
if (requiredPassword != String.Empty &&
|
||||
(!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
|
||||
throw new Exception("wrong password");
|
||||
|
||||
string file = (string)requestData["filename"];
|
||||
LLUUID regionID = LLUUID.Parse((string)requestData["regionid"]);
|
||||
m_log.Info("[RADMIN]: Terrain Loading: " + file);
|
||||
LLUUID regionID = (string) requestData["regionid"];
|
||||
m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file);
|
||||
|
||||
responseData["accepted"] = "true";
|
||||
|
||||
Scene region = null;
|
||||
|
||||
if (m_app.SceneManager.TryGetScene(regionID, out region))
|
||||
{
|
||||
//region.LoadWorldMap(file);
|
||||
responseData["success"] = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
responseData["success"] = "false";
|
||||
responseData["error"] = "1: Unable to get a scene with that name.";
|
||||
}
|
||||
if (!m_app.SceneManager.TryGetScene(regionID, out region))
|
||||
throw new Exception("1: unable to get a scene with that name");
|
||||
|
||||
ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
|
||||
if (null == terrainModule) throw new Exception("terrain module not available");
|
||||
terrainModule.LoadFromFile(file);
|
||||
|
||||
responseData["success"] = "true";
|
||||
|
||||
response.Value = responseData;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[RADMIN] Terrain Loading: failed: {0}", e.Message);
|
||||
m_log.DebugFormat("[RADMIN] Terrain Loading: failed: {0}", e.ToString());
|
||||
|
||||
responseData["success"] = "false";
|
||||
responseData["error"] = e.Message;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
@ -185,37 +208,32 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable requestData = (Hashtable) request.Params[0];
|
||||
Hashtable responseData = new Hashtable();
|
||||
if (requiredPassword != String.Empty &&
|
||||
(!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
|
||||
{
|
||||
responseData["accepted"] = "false";
|
||||
|
||||
try {
|
||||
checkStringParameters(request, new string[] { "password", "shutdown" });
|
||||
checkIntegerParams(request, new string[] { "milliseconds"});
|
||||
|
||||
if (requiredPassword != String.Empty &&
|
||||
(!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
|
||||
throw new Exception("wrong password");
|
||||
|
||||
responseData["accepted"] = "true";
|
||||
response.Value = responseData;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if ((string) requestData["shutdown"] == "delayed")
|
||||
{
|
||||
int timeout = (Int32) requestData["milliseconds"];
|
||||
|
||||
responseData["accepted"] = "true";
|
||||
response.Value = responseData;
|
||||
|
||||
m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int) (timeout/1000)).ToString() +
|
||||
" second(s). Please save what you are doing and log out.");
|
||||
|
||||
|
||||
// Perform shutdown
|
||||
Timer shutdownTimer = new Timer(timeout); // Wait before firing
|
||||
shutdownTimer.AutoReset = false;
|
||||
shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
|
||||
shutdownTimer.Start();
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responseData["accepted"] = "true";
|
||||
response.Value = responseData;
|
||||
|
||||
m_app.SceneManager.SendGeneralMessage("Region is going down now.");
|
||||
|
||||
// Perform shutdown
|
||||
|
@ -223,10 +241,18 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
shutdownTimer.AutoReset = false;
|
||||
shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
|
||||
shutdownTimer.Start();
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[RADMIN] Shutdown: failed: {0}", e.Message);
|
||||
m_log.DebugFormat("[RADMIN] Shutdown: failed: {0}", e.ToString());
|
||||
|
||||
responseData["accepted"] = "false";
|
||||
responseData["error"] = e.Message;
|
||||
|
||||
response.Value = responseData;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -401,7 +427,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
region.SaveRegionToFile("dynamic region", regionConfigPath);
|
||||
}
|
||||
|
||||
m_app.CreateRegion(region, true);
|
||||
m_app.CreateRegion(region);
|
||||
|
||||
responseData["success"] = "true";
|
||||
responseData["region_name"] = region.RegionName;
|
||||
|
@ -484,8 +510,10 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]);
|
||||
uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]);
|
||||
|
||||
// FIXME: need to check whether "firstname lastname"
|
||||
// already exists!
|
||||
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
|
||||
if (null != userProfile)
|
||||
throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname));
|
||||
|
||||
LLUUID userID = m_app.CreateUser(firstname, lastname, passwd, regX, regY);
|
||||
|
||||
if (userID == LLUUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}",
|
||||
|
@ -523,22 +551,34 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
try
|
||||
{
|
||||
// check completeness
|
||||
foreach (string p in new string[] { "password", "region_name", "filename" })
|
||||
foreach (string p in new string[] { "password", "filename" })
|
||||
{
|
||||
if (!requestData.Contains(p))
|
||||
throw new Exception(String.Format("missing parameter {0}", p));
|
||||
if (String.IsNullOrEmpty((string)requestData[p]))
|
||||
throw new Exception(String.Format("parameter {0} is empty"));
|
||||
}
|
||||
|
||||
// check password
|
||||
if (!String.IsNullOrEmpty(requiredPassword) &&
|
||||
(string)requestData["password"] != requiredPassword) throw new Exception("wrong password");
|
||||
|
||||
string region_name = (string)requestData["region_name"];
|
||||
string filename = (string)requestData["filename"];
|
||||
|
||||
if (!m_app.SceneManager.TrySetCurrentScene(region_name))
|
||||
throw new Exception(String.Format("failed to switch to region {0}", region_name));
|
||||
m_log.InfoFormat("[RADMIN] Switched to region {0}");
|
||||
string filename = (string)requestData["filename"];
|
||||
if (requestData.Contains("region_uuid"))
|
||||
{
|
||||
LLUUID region_uuid = (string)requestData["region_uuid"];
|
||||
if (!m_app.SceneManager.TrySetCurrentScene(region_uuid))
|
||||
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
|
||||
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
|
||||
}
|
||||
else if (requestData.Contains("region_name"))
|
||||
{
|
||||
string region_name = (string)requestData["region_name"];
|
||||
if (!m_app.SceneManager.TrySetCurrentScene(region_name))
|
||||
throw new Exception(String.Format("failed to switch to region {0}", region_name));
|
||||
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
|
||||
}
|
||||
else throw new Exception("neither region_name nor region_uuid given");
|
||||
|
||||
responseData["switched"] = "true";
|
||||
|
||||
|
@ -550,7 +590,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
|||
catch (Exception e)
|
||||
{
|
||||
m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message);
|
||||
m_log.DebugFormat("[RADMIN] LoadXML {0}: {1}", e.ToString());
|
||||
m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString());
|
||||
|
||||
responseData["loaded"] = "false";
|
||||
responseData["switched"] = "false";
|
||||
|
|
|
@ -44,6 +44,10 @@ namespace OpenSim.Region.Capabilities
|
|||
private uint m_httpListenerPort;
|
||||
|
||||
/// <summary></summary>
|
||||
/// CapsHandlers is a cap handler container but also takes
|
||||
/// care of adding and removing cap handlers to and from the
|
||||
/// supplied BaseHttpServer.
|
||||
/// </summary>
|
||||
/// <param name="httpListener">base HTTP server</param>
|
||||
/// <param name="httpListenerHostname">host name of the HTTP
|
||||
/// server</param>
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace OpenSim.Framework.RegionLoader.Filesystem
|
|||
|
||||
if (configFiles.Length == 0)
|
||||
{
|
||||
new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "default.xml"),false);
|
||||
new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "default.xml"), false);
|
||||
configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
|
||||
}
|
||||
|
||||
|
|
|
@ -462,7 +462,28 @@ namespace OpenSim
|
|||
/// <param name="regionInfo"></param>
|
||||
/// <param name="portadd_flag"></param>
|
||||
/// <returns></returns>
|
||||
public UDPServer CreateRegion(RegionInfo regionInfo, bool portadd_flag)
|
||||
public UDPServer CreateRegion(RegionInfo regionInfo, bool portadd_flag) {
|
||||
return CreateRegion(regionInfo, portadd_flag, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute the region creation process. This includes setting up scene infrastructure.
|
||||
/// </summary>
|
||||
/// <param name="regionInfo"></param>
|
||||
/// <param name="portadd_flag"></param>
|
||||
/// <returns></returns>
|
||||
public UDPServer CreateRegion(RegionInfo regionInfo) {
|
||||
return CreateRegion(regionInfo, false, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute the region creation process. This includes setting up scene infrastructure.
|
||||
/// </summary>
|
||||
/// <param name="regionInfo"></param>
|
||||
/// <param name="portadd_flag"></param>
|
||||
/// <param name="do_post_init"></param>
|
||||
/// <returns></returns>
|
||||
public UDPServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init)
|
||||
{
|
||||
int port = regionInfo.InternalEndPoint.Port;
|
||||
|
||||
|
@ -487,7 +508,7 @@ namespace OpenSim
|
|||
|
||||
m_log.Info("[MODULES]: Loading Region's modules");
|
||||
|
||||
m_moduleLoader.PickupModules(scene, ".");
|
||||
List<IRegionModule> modules = m_moduleLoader.PickupModules(scene, ".");
|
||||
//m_moduleLoader.PickupModules(scene, "ScriptEngines");
|
||||
//m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene);
|
||||
|
||||
|
@ -536,6 +557,14 @@ namespace OpenSim
|
|||
m_regionData.Add(regionInfo);
|
||||
udpServer.ServerListener();
|
||||
|
||||
if (do_post_init)
|
||||
{
|
||||
foreach (IRegionModule module in modules)
|
||||
{
|
||||
module.PostInitialise();
|
||||
}
|
||||
}
|
||||
|
||||
return udpServer;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ namespace OpenSim.Region.ClientStack
|
|||
protected uint m_httpServerPort;
|
||||
|
||||
protected CommunicationsManager m_commsManager;
|
||||
public CommunicationsManager CommunicationsManager {
|
||||
get { return m_commsManager; }
|
||||
}
|
||||
|
||||
protected SceneManager m_sceneManager = new SceneManager();
|
||||
|
||||
|
|
|
@ -62,14 +62,16 @@ namespace OpenSim.Region.Environment
|
|||
}
|
||||
}
|
||||
|
||||
public void PickupModules(Scene scene, string moduleDir)
|
||||
public List<IRegionModule> PickupModules(Scene scene, string moduleDir)
|
||||
{
|
||||
DirectoryInfo dir = new DirectoryInfo(moduleDir);
|
||||
List<IRegionModule> modules = new List<IRegionModule>();
|
||||
|
||||
foreach (FileInfo fileInfo in dir.GetFiles("*.dll"))
|
||||
{
|
||||
LoadRegionModules(fileInfo.FullName, scene);
|
||||
modules.AddRange(LoadRegionModules(fileInfo.FullName, scene));
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
public void LoadDefaultSharedModules()
|
||||
|
@ -190,9 +192,10 @@ namespace OpenSim.Region.Environment
|
|||
}
|
||||
}
|
||||
|
||||
public void LoadRegionModules(string dllName, Scene scene)
|
||||
public List<IRegionModule> LoadRegionModules(string dllName, Scene scene)
|
||||
{
|
||||
IRegionModule[] modules = LoadModules(dllName);
|
||||
List<IRegionModule> initializedModules = new List<IRegionModule>();
|
||||
|
||||
if (modules.Length > 0)
|
||||
{
|
||||
|
@ -203,6 +206,7 @@ namespace OpenSim.Region.Environment
|
|||
{
|
||||
m_log.InfoFormat("[MODULES]: [{0}]: Initializing.", module.Name);
|
||||
InitializeModule(module, scene);
|
||||
initializedModules.Add(module);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -211,6 +215,7 @@ namespace OpenSim.Region.Environment
|
|||
}
|
||||
}
|
||||
}
|
||||
return initializedModules;
|
||||
}
|
||||
|
||||
public void LoadRegionModule(string dllName, string moduleName, Scene scene)
|
||||
|
|
|
@ -178,20 +178,24 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
|||
{
|
||||
m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value +
|
||||
" parser does not support file loading. (May be save only)");
|
||||
return;
|
||||
throw new Exception(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value));
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
m_log.Error(
|
||||
"[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)");
|
||||
return;
|
||||
throw new Exception(String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access",
|
||||
filename));
|
||||
}
|
||||
}
|
||||
CheckForTerrainUpdates();
|
||||
m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format.");
|
||||
throw new Exception(String.Format("unable to load heightmap from file {0}: no loader available for that format",
|
||||
filename));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -214,6 +218,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
|||
catch (NotImplementedException)
|
||||
{
|
||||
m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented.");
|
||||
throw new Exception(String.Format("unable to save heightmap: {0}: saving of this file format not implemented"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -250,6 +250,22 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public bool TrySetCurrentScene(LLUUID regionID)
|
||||
{
|
||||
Console.WriteLine("Searching for Region: '{0}'", regionID.ToString());
|
||||
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.RegionInfo.RegionID == regionID)
|
||||
{
|
||||
m_currentScene = scene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetScene(string regionName, out Scene scene)
|
||||
{
|
||||
foreach (Scene mscene in m_localScenes)
|
||||
|
|
Loading…
Reference in New Issue