aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRobert Adams2014-01-19 11:03:08 -0800
committerRobert Adams2014-01-19 11:03:08 -0800
commit6fbfb47b92cf01b839208d0cc7898749306e19f4 (patch)
treeb833914d24f624662550e637b0ecabaf92d3e387
parentvarregion: add --displacement parameter to 'load oar'. (diff)
downloadopensim-SC_OLD-6fbfb47b92cf01b839208d0cc7898749306e19f4.zip
opensim-SC_OLD-6fbfb47b92cf01b839208d0cc7898749306e19f4.tar.gz
opensim-SC_OLD-6fbfb47b92cf01b839208d0cc7898749306e19f4.tar.bz2
opensim-SC_OLD-6fbfb47b92cf01b839208d0cc7898749306e19f4.tar.xz
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.
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs6
-rw-r--r--OpenSim/Region/Application/OpenSim.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs32
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs17
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs26
6 files changed, 70 insertions, 46 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 3cd6b3b..7067a62 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -1484,9 +1484,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1484 } 1484 }
1485 1485
1486 IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>(); 1486 IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>();
1487 Vector3 displacement = new Vector3(0f, 0f, 0f); 1487 Dictionary<string, object> archiveOptions = new Dictionary<string,object>();
1488 if (mergeOar) archiveOptions.Add("merge", null);
1489 if (skipAssets) archiveOptions.Add("skipAssets", null);
1488 if (archiver != null) 1490 if (archiver != null)
1489 archiver.DearchiveRegion(filename, mergeOar, skipAssets, displacement, Guid.Empty); 1491 archiver.DearchiveRegion(filename, Guid.Empty, archiveOptions);
1490 else 1492 else
1491 throw new Exception("Archiver module not present for scene"); 1493 throw new Exception("Archiver module not present for scene");
1492 1494
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index a336178..30e2b1b 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -266,11 +266,13 @@ namespace OpenSim
266 SavePrimsXml2); 266 SavePrimsXml2);
267 267
268 m_console.Commands.AddCommand("Archiving", false, "load oar", 268 m_console.Commands.AddCommand("Archiving", false, "load oar",
269 "load oar [--merge] [--skip-assets] [--displacement \"<x,y,z>\"] [<OAR path>]", 269 "load oar [--merge] [--skip-assets] [--noterrain] [--displacement \"<x,y,z>\"] [<OAR path>]",
270 "Load a region's data from an OAR archive.", 270 "Load a region's data from an OAR archive.",
271 "--merge will merge the OAR with the existing scene." + Environment.NewLine 271 "--merge will merge the OAR with the existing scene." + Environment.NewLine
272 + "--skip-assets will load the OAR but ignore the assets it contains." + Environment.NewLine 272 + "--skip-assets will load the OAR but ignore the assets it contains." + Environment.NewLine
273 + "--displacement will add this value to the position of every object loaded" + Environment.NewLine 273 + "--displacement will add this value to the position of every object loaded" + Environment.NewLine
274 + "--noterrain suppresses the loading of terrain from the oar" + Environment.NewLine
275 + "--noparcels suppresses the loading of parcels from the oar" + Environment.NewLine
274 + "The path can be either a filesystem location or a URI." 276 + "The path can be either a filesystem location or a URI."
275 + " If this is not given then the command looks for an OAR named region.oar in the current directory.", 277 + " If this is not given then the command looks for an OAR named region.oar in the current directory.",
276 LoadOar); 278 LoadOar);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index d249129..637c4a3 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -100,6 +100,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
100 protected bool m_merge; 100 protected bool m_merge;
101 101
102 /// <value> 102 /// <value>
103 /// If true, suppresses the loading of terrain from the oar file
104 /// </value>
105 protected bool m_noTerrain;
106
107 /// <value>
108 /// If true, suppresses the loading of parcels from the oar file
109 /// </value>
110 protected bool m_noParcels;
111
112 /// <value>
103 /// Should we ignore any assets when reloading the archive? 113 /// Should we ignore any assets when reloading the archive?
104 /// </value> 114 /// </value>
105 protected bool m_skipAssets; 115 protected bool m_skipAssets;
@@ -107,7 +117,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
107 /// <value> 117 /// <value>
108 /// Displacement added to each object as it is added to the world 118 /// Displacement added to each object as it is added to the world
109 /// </value> 119 /// </value>
110 protected Vector3 m_displacement = new Vector3(0f, 0f, 0f); 120 protected Vector3 m_displacement = Vector3.Zero;
111 121
112 /// <summary> 122 /// <summary>
113 /// Used to cache lookups for valid uuids. 123 /// Used to cache lookups for valid uuids.
@@ -137,7 +147,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
137 private IAssetService m_assetService = null; 147 private IAssetService m_assetService = null;
138 148
139 149
140 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId) 150 public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary<string,object>options)
141 { 151 {
142 m_rootScene = scene; 152 m_rootScene = scene;
143 153
@@ -155,10 +165,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
155 } 165 }
156 166
157 m_errorMessage = String.Empty; 167 m_errorMessage = String.Empty;
158 m_merge = merge; 168 m_merge = options.ContainsKey("merge");
159 m_skipAssets = skipAssets; 169 m_noTerrain = options.ContainsKey("noTerrain");
170 m_noParcels = options.ContainsKey("noParcels");
171 m_skipAssets = options.ContainsKey("skipAssets");
160 m_requestId = requestId; 172 m_requestId = requestId;
161 m_displacement = displacement; 173 m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero;
162 174
163 // Zero can never be a valid user id 175 // Zero can never be a valid user id
164 m_validUserUuids[UUID.Zero] = false; 176 m_validUserUuids[UUID.Zero] = false;
@@ -167,13 +179,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
167 m_assetService = m_rootScene.AssetService; 179 m_assetService = m_rootScene.AssetService;
168 } 180 }
169 181
170 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) 182 public ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionary<string, object>options)
171 { 183 {
172 m_rootScene = scene; 184 m_rootScene = scene;
173 m_loadPath = null; 185 m_loadPath = null;
174 m_loadStream = loadStream; 186 m_loadStream = loadStream;
175 m_merge = merge; 187 m_skipAssets = options.ContainsKey("skipAssets");
176 m_skipAssets = skipAssets; 188 m_merge = options.ContainsKey("merge");
177 m_requestId = requestId; 189 m_requestId = requestId;
178 190
179 // Zero can never be a valid user id 191 // Zero can never be a valid user id
@@ -249,7 +261,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
249 if ((successfulAssetRestores + failedAssetRestores) % 250 == 0) 261 if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
250 m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets..."); 262 m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets...");
251 } 263 }
252 else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) 264 else if (!m_noTerrain && !m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
253 { 265 {
254 LoadTerrain(scene, filePath, data); 266 LoadTerrain(scene, filePath, data);
255 } 267 }
@@ -257,7 +269,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
257 { 269 {
258 LoadRegionSettings(scene, filePath, data, dearchivedScenes); 270 LoadRegionSettings(scene, filePath, data, dearchivedScenes);
259 } 271 }
260 else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) 272 else if (!m_noParcels && !m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
261 { 273 {
262 sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data)); 274 sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data));
263 } 275 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index fb694de..df5b443 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -104,11 +104,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
104 { 104 {
105 bool mergeOar = false; 105 bool mergeOar = false;
106 bool skipAssets = false; 106 bool skipAssets = false;
107 bool noTerrain = false;
108 bool noParcels = false;
107 Vector3 displacement = new Vector3(0f, 0f, 0f); 109 Vector3 displacement = new Vector3(0f, 0f, 0f);
108 110
109 OptionSet options = new OptionSet(); 111 OptionSet options = new OptionSet();
110 options.Add("m|merge", delegate (string v) { mergeOar = (v != null); }); 112 options.Add("m|merge", delegate (string v) { mergeOar = (v != null); });
111 options.Add("s|skip-assets", delegate (string v) { skipAssets = (v != null); }); 113 options.Add("s|skip-assets", delegate (string v) { skipAssets = (v != null); });
114 options.Add("noterrain", delegate (string v) { noTerrain = (v != null); });
115 options.Add("noparcels", delegate (string v) { noParcels = (v != null); });
112 options.Add("displacement=", delegate (string v) { 116 options.Add("displacement=", delegate (string v) {
113 try 117 try
114 { 118 {
@@ -138,13 +142,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver
138// foreach (string param in mainParams) 142// foreach (string param in mainParams)
139// m_log.DebugFormat("GOT PARAM [{0}]", param); 143// m_log.DebugFormat("GOT PARAM [{0}]", param);
140 144
145 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
146 if (mergeOar) archiveOptions.Add("merge", null);
147 if (skipAssets) archiveOptions.Add("skipAssets", null);
148 if (noTerrain) archiveOptions.Add("noTerrain", null);
149 if (noParcels) archiveOptions.Add("noParcels", null);
150 if (displacement != Vector3.Zero) archiveOptions.Add("displacement", displacement);
151
141 if (mainParams.Count > 2) 152 if (mainParams.Count > 2)
142 { 153 {
143 DearchiveRegion(mainParams[2], mergeOar, skipAssets, displacement, Guid.Empty); 154 DearchiveRegion(mainParams[2], Guid.Empty, archiveOptions);
144 } 155 }
145 else 156 else
146 { 157 {
147 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, displacement, Guid.Empty); 158 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, Guid.Empty, archiveOptions);
148 } 159 }
149 } 160 }
150 161
@@ -214,25 +225,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
214 225
215 public void DearchiveRegion(string loadPath) 226 public void DearchiveRegion(string loadPath)
216 { 227 {
217 DearchiveRegion(loadPath, false, false, new Vector3(0f, 0f, 0f), Guid.Empty); 228 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
229 DearchiveRegion(loadPath, Guid.Empty, archiveOptions);
218 } 230 }
219 231
220 public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId) 232 public void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string,object> options)
221 { 233 {
222 m_log.InfoFormat( 234 m_log.InfoFormat(
223 "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath); 235 "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
224 236
225 new ArchiveReadRequest(Scene, loadPath, merge, skipAssets, displacement, requestId).DearchiveRegion(); 237 new ArchiveReadRequest(Scene, loadPath, requestId, options).DearchiveRegion();
226 } 238 }
227 239
228 public void DearchiveRegion(Stream loadStream) 240 public void DearchiveRegion(Stream loadStream)
229 { 241 {
230 DearchiveRegion(loadStream, false, false, new Vector3(0f, 0f, 0f), Guid.Empty); 242 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
243 DearchiveRegion(loadStream, Guid.Empty, archiveOptions);
231 } 244 }
232 245
233 public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Vector3 displacement, Guid requestId) 246 public void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string, object> options)
234 { 247 {
235 new ArchiveReadRequest(Scene, loadStream, merge, skipAssets, requestId).DearchiveRegion(); 248 new ArchiveReadRequest(Scene, loadStream, requestId, options).DearchiveRegion();
236 } 249 }
237 } 250 }
238} 251}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index c412acb..53f41f9 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -224,8 +224,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
224 224
225 byte[] data = tar.ReadEntry(out filePath, out tarEntryType); 225 byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
226 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); 226 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
227 227
228 ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); 228 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
229 ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions);
229 arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); 230 arr.LoadControlFile(filePath, data, new DearchiveScenesInfo());
230 231
231 Assert.That(arr.ControlFileLoaded, Is.True); 232 Assert.That(arr.ControlFileLoaded, Is.True);
@@ -308,8 +309,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
308 309
309 byte[] data = tar.ReadEntry(out filePath, out tarEntryType); 310 byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
310 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); 311 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
311 312
312 ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); 313 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
314 ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions);
313 arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); 315 arr.LoadControlFile(filePath, data, new DearchiveScenesInfo());
314 316
315 Assert.That(arr.ControlFileLoaded, Is.True); 317 Assert.That(arr.ControlFileLoaded, Is.True);
@@ -752,7 +754,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
752 byte[] archive = archiveWriteStream.ToArray(); 754 byte[] archive = archiveWriteStream.ToArray();
753 MemoryStream archiveReadStream = new MemoryStream(archive); 755 MemoryStream archiveReadStream = new MemoryStream(archive);
754 756
755 m_archiverModule.DearchiveRegion(archiveReadStream, true, false, new Vector3(0f, 0f, 0f), Guid.Empty); 757 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
758 archiveOptions.Add("merge", null);
759 m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions);
756 760
757 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); 761 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
758 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); 762 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
@@ -860,7 +864,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
860 byte[] data = tar.ReadEntry(out filePath, out tarEntryType); 864 byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
861 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); 865 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
862 866
863 ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); 867 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
868 ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions);
864 arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); 869 arr.LoadControlFile(filePath, data, new DearchiveScenesInfo());
865 870
866 Assert.That(arr.ControlFileLoaded, Is.True); 871 Assert.That(arr.ControlFileLoaded, Is.True);
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
index 1c00b6c..99bc87d 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
@@ -102,16 +102,11 @@ namespace OpenSim.Region.Framework.Interfaces
102 /// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event. 102 /// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
103 /// 103 ///
104 /// <param name="loadPath"></param> 104 /// <param name="loadPath"></param>
105 /// <param name="merge">
106 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
107 /// settings in the archive will be ignored.
108 /// </param>
109 /// <param name="skipAssets">
110 /// If true, the archive is loaded without loading any assets contained within it. This is useful if the
111 /// assets are already known to be present in the grid's asset service.
112 /// </param>
113 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> 105 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
114 void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId); 106 /// <param name="options">
107 /// Dictionary of options.
108 /// </param>
109 void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string,object> options);
115 110
116 /// <summary> 111 /// <summary>
117 /// Dearchive a region from a stream. This replaces the existing scene. 112 /// Dearchive a region from a stream. This replaces the existing scene.
@@ -129,15 +124,10 @@ namespace OpenSim.Region.Framework.Interfaces
129 /// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event. 124 /// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
130 /// 125 ///
131 /// <param name="loadStream"></param> 126 /// <param name="loadStream"></param>
132 /// <param name="merge">
133 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
134 /// settings in the archive will be ignored.
135 /// </param>
136 /// <param name="skipAssets">
137 /// If true, the archive is loaded without loading any assets contained within it. This is useful if the
138 /// assets are already known to be present in the grid's asset service.
139 /// </param
140 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> 127 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
141 void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Vector3 displacement, Guid requestId); 128 /// <param name="options">
129 /// Dictionary of options.
130 /// </param>
131 void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string,object> options);
142 } 132 }
143} 133}