varregion: add --noterrain and --noparcel to 'load oar'.

--noterrain suppresses the loading of the terrain from the oar.
--noparcels suppresses the loading of parcel information from the oar.
varregion
Robert Adams 2014-01-19 11:03:08 -08:00
parent dd6db72939
commit 6fbfb47b92
6 changed files with 70 additions and 46 deletions

View File

@ -1484,9 +1484,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
} }
IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>(); IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>();
Vector3 displacement = new Vector3(0f, 0f, 0f); Dictionary<string, object> archiveOptions = new Dictionary<string,object>();
if (mergeOar) archiveOptions.Add("merge", null);
if (skipAssets) archiveOptions.Add("skipAssets", null);
if (archiver != null) if (archiver != null)
archiver.DearchiveRegion(filename, mergeOar, skipAssets, displacement, Guid.Empty); archiver.DearchiveRegion(filename, Guid.Empty, archiveOptions);
else else
throw new Exception("Archiver module not present for scene"); throw new Exception("Archiver module not present for scene");

View File

@ -266,11 +266,13 @@ namespace OpenSim
SavePrimsXml2); SavePrimsXml2);
m_console.Commands.AddCommand("Archiving", false, "load oar", m_console.Commands.AddCommand("Archiving", false, "load oar",
"load oar [--merge] [--skip-assets] [--displacement \"<x,y,z>\"] [<OAR path>]", "load oar [--merge] [--skip-assets] [--noterrain] [--displacement \"<x,y,z>\"] [<OAR path>]",
"Load a region's data from an OAR archive.", "Load a region's data from an OAR archive.",
"--merge will merge the OAR with the existing scene." + Environment.NewLine "--merge will merge the OAR with the existing scene." + Environment.NewLine
+ "--skip-assets will load the OAR but ignore the assets it contains." + Environment.NewLine + "--skip-assets will load the OAR but ignore the assets it contains." + Environment.NewLine
+ "--displacement will add this value to the position of every object loaded" + Environment.NewLine + "--displacement will add this value to the position of every object loaded" + Environment.NewLine
+ "--noterrain suppresses the loading of terrain from the oar" + Environment.NewLine
+ "--noparcels suppresses the loading of parcels from the oar" + Environment.NewLine
+ "The path can be either a filesystem location or a URI." + "The path can be either a filesystem location or a URI."
+ " If this is not given then the command looks for an OAR named region.oar in the current directory.", + " If this is not given then the command looks for an OAR named region.oar in the current directory.",
LoadOar); LoadOar);

View File

@ -99,6 +99,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// </value> /// </value>
protected bool m_merge; protected bool m_merge;
/// <value>
/// If true, suppresses the loading of terrain from the oar file
/// </value>
protected bool m_noTerrain;
/// <value>
/// If true, suppresses the loading of parcels from the oar file
/// </value>
protected bool m_noParcels;
/// <value> /// <value>
/// Should we ignore any assets when reloading the archive? /// Should we ignore any assets when reloading the archive?
/// </value> /// </value>
@ -107,7 +117,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <value> /// <value>
/// Displacement added to each object as it is added to the world /// Displacement added to each object as it is added to the world
/// </value> /// </value>
protected Vector3 m_displacement = new Vector3(0f, 0f, 0f); protected Vector3 m_displacement = Vector3.Zero;
/// <summary> /// <summary>
/// Used to cache lookups for valid uuids. /// Used to cache lookups for valid uuids.
@ -137,7 +147,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
private IAssetService m_assetService = null; private IAssetService m_assetService = null;
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId) public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary<string,object>options)
{ {
m_rootScene = scene; m_rootScene = scene;
@ -155,10 +165,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
} }
m_errorMessage = String.Empty; m_errorMessage = String.Empty;
m_merge = merge; m_merge = options.ContainsKey("merge");
m_skipAssets = skipAssets; m_noTerrain = options.ContainsKey("noTerrain");
m_noParcels = options.ContainsKey("noParcels");
m_skipAssets = options.ContainsKey("skipAssets");
m_requestId = requestId; m_requestId = requestId;
m_displacement = displacement; m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero;
// Zero can never be a valid user id // Zero can never be a valid user id
m_validUserUuids[UUID.Zero] = false; m_validUserUuids[UUID.Zero] = false;
@ -167,13 +179,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_assetService = m_rootScene.AssetService; m_assetService = m_rootScene.AssetService;
} }
public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) public ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionary<string, object>options)
{ {
m_rootScene = scene; m_rootScene = scene;
m_loadPath = null; m_loadPath = null;
m_loadStream = loadStream; m_loadStream = loadStream;
m_merge = merge; m_skipAssets = options.ContainsKey("skipAssets");
m_skipAssets = skipAssets; m_merge = options.ContainsKey("merge");
m_requestId = requestId; m_requestId = requestId;
// Zero can never be a valid user id // Zero can never be a valid user id
@ -249,7 +261,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
if ((successfulAssetRestores + failedAssetRestores) % 250 == 0) if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets..."); m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets...");
} }
else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) else if (!m_noTerrain && !m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
{ {
LoadTerrain(scene, filePath, data); LoadTerrain(scene, filePath, data);
} }
@ -257,7 +269,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{ {
LoadRegionSettings(scene, filePath, data, dearchivedScenes); LoadRegionSettings(scene, filePath, data, dearchivedScenes);
} }
else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) else if (!m_noParcels && !m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
{ {
sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data)); sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data));
} }

View File

@ -104,11 +104,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{ {
bool mergeOar = false; bool mergeOar = false;
bool skipAssets = false; bool skipAssets = false;
bool noTerrain = false;
bool noParcels = false;
Vector3 displacement = new Vector3(0f, 0f, 0f); Vector3 displacement = new Vector3(0f, 0f, 0f);
OptionSet options = new OptionSet(); OptionSet options = new OptionSet();
options.Add("m|merge", delegate (string v) { mergeOar = (v != null); }); options.Add("m|merge", delegate (string v) { mergeOar = (v != null); });
options.Add("s|skip-assets", delegate (string v) { skipAssets = (v != null); }); options.Add("s|skip-assets", delegate (string v) { skipAssets = (v != null); });
options.Add("noterrain", delegate (string v) { noTerrain = (v != null); });
options.Add("noparcels", delegate (string v) { noParcels = (v != null); });
options.Add("displacement=", delegate (string v) { options.Add("displacement=", delegate (string v) {
try try
{ {
@ -138,13 +142,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// foreach (string param in mainParams) // foreach (string param in mainParams)
// m_log.DebugFormat("GOT PARAM [{0}]", param); // m_log.DebugFormat("GOT PARAM [{0}]", param);
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
if (mergeOar) archiveOptions.Add("merge", null);
if (skipAssets) archiveOptions.Add("skipAssets", null);
if (noTerrain) archiveOptions.Add("noTerrain", null);
if (noParcels) archiveOptions.Add("noParcels", null);
if (displacement != Vector3.Zero) archiveOptions.Add("displacement", displacement);
if (mainParams.Count > 2) if (mainParams.Count > 2)
{ {
DearchiveRegion(mainParams[2], mergeOar, skipAssets, displacement, Guid.Empty); DearchiveRegion(mainParams[2], Guid.Empty, archiveOptions);
} }
else else
{ {
DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, displacement, Guid.Empty); DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, Guid.Empty, archiveOptions);
} }
} }
@ -214,25 +225,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
public void DearchiveRegion(string loadPath) public void DearchiveRegion(string loadPath)
{ {
DearchiveRegion(loadPath, false, false, new Vector3(0f, 0f, 0f), Guid.Empty); Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
DearchiveRegion(loadPath, Guid.Empty, archiveOptions);
} }
public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId) public void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string,object> options)
{ {
m_log.InfoFormat( m_log.InfoFormat(
"[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath); "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
new ArchiveReadRequest(Scene, loadPath, merge, skipAssets, displacement, requestId).DearchiveRegion(); new ArchiveReadRequest(Scene, loadPath, requestId, options).DearchiveRegion();
} }
public void DearchiveRegion(Stream loadStream) public void DearchiveRegion(Stream loadStream)
{ {
DearchiveRegion(loadStream, false, false, new Vector3(0f, 0f, 0f), Guid.Empty); Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
DearchiveRegion(loadStream, Guid.Empty, archiveOptions);
} }
public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Vector3 displacement, Guid requestId) public void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string, object> options)
{ {
new ArchiveReadRequest(Scene, loadStream, merge, skipAssets, requestId).DearchiveRegion(); new ArchiveReadRequest(Scene, loadStream, requestId, options).DearchiveRegion();
} }
} }
} }

View File

@ -225,7 +225,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
byte[] data = tar.ReadEntry(out filePath, out tarEntryType); byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions);
arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); arr.LoadControlFile(filePath, data, new DearchiveScenesInfo());
Assert.That(arr.ControlFileLoaded, Is.True); Assert.That(arr.ControlFileLoaded, Is.True);
@ -309,7 +310,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
byte[] data = tar.ReadEntry(out filePath, out tarEntryType); byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions);
arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); arr.LoadControlFile(filePath, data, new DearchiveScenesInfo());
Assert.That(arr.ControlFileLoaded, Is.True); Assert.That(arr.ControlFileLoaded, Is.True);
@ -752,7 +754,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
byte[] archive = archiveWriteStream.ToArray(); byte[] archive = archiveWriteStream.ToArray();
MemoryStream archiveReadStream = new MemoryStream(archive); MemoryStream archiveReadStream = new MemoryStream(archive);
m_archiverModule.DearchiveRegion(archiveReadStream, true, false, new Vector3(0f, 0f, 0f), Guid.Empty); Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
archiveOptions.Add("merge", null);
m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions);
SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
@ -860,7 +864,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
byte[] data = tar.ReadEntry(out filePath, out tarEntryType); byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions);
arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); arr.LoadControlFile(filePath, data, new DearchiveScenesInfo());
Assert.That(arr.ControlFileLoaded, Is.True); Assert.That(arr.ControlFileLoaded, Is.True);

View File

@ -102,16 +102,11 @@ namespace OpenSim.Region.Framework.Interfaces
/// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event. /// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
/// ///
/// <param name="loadPath"></param> /// <param name="loadPath"></param>
/// <param name="merge">
/// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
/// settings in the archive will be ignored.
/// </param>
/// <param name="skipAssets">
/// If true, the archive is loaded without loading any assets contained within it. This is useful if the
/// assets are already known to be present in the grid's asset service.
/// </param>
/// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId); /// <param name="options">
/// Dictionary of options.
/// </param>
void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string,object> options);
/// <summary> /// <summary>
/// Dearchive a region from a stream. This replaces the existing scene. /// Dearchive a region from a stream. This replaces the existing scene.
@ -129,15 +124,10 @@ namespace OpenSim.Region.Framework.Interfaces
/// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event. /// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
/// ///
/// <param name="loadStream"></param> /// <param name="loadStream"></param>
/// <param name="merge">
/// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
/// settings in the archive will be ignored.
/// </param>
/// <param name="skipAssets">
/// If true, the archive is loaded without loading any assets contained within it. This is useful if the
/// assets are already known to be present in the grid's asset service.
/// </param
/// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Vector3 displacement, Guid requestId); /// <param name="options">
/// Dictionary of options.
/// </param>
void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string,object> options);
} }
} }