Allow the reading of ini files instead of xml files when reading region

definitions from the file system
0.6.6-post-fixes
Melanie Thielker 2009-06-25 15:48:54 +00:00
parent 934b291f59
commit d9528bd06e
2 changed files with 139 additions and 50 deletions

View File

@ -238,15 +238,48 @@ namespace OpenSim.Framework
// access the same database server. Since estate settings are lodaed // access the same database server. Since estate settings are lodaed
// from there, that should be sufficient for full remote administration // from there, that should be sufficient for full remote administration
public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource) // File based loading
//
public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource) : this(description, filename, skipConsoleConfig, configSource, String.Empty)
{
}
public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource, string configName)
{ {
// m_configSource = configSource; // m_configSource = configSource;
if (filename.ToLower().EndsWith(".ini"))
{
IConfigSource source = new IniConfigSource(filename);
ReadNiniConfig(source, configName);
return;
}
try
{
// This will throw if it's not legal Nini XML format
// and thereby toss it to the legacy loader
//
IConfigSource xmlsource = new XmlConfigSource(filename);
ReadNiniConfig(xmlsource, configName);
return;
}
catch (Exception)
{
}
configMember = configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig); new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig);
configMember.performConfigurationRetrieve(); configMember.performConfigurationRetrieve();
RegionFile = filename; RegionFile = filename;
} }
// The web loader uses this
//
public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig, IConfigSource configSource) public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig, IConfigSource configSource)
{ {
// m_configSource = configSource; // m_configSource = configSource;
@ -355,53 +388,92 @@ namespace OpenSim.Framework
m_internalEndPoint = tmpEPE; m_internalEndPoint = tmpEPE;
} }
//not in use, should swap to nini though. private void ReadNiniConfig(IConfigSource source, string name)
public void LoadFromNiniSource(IConfigSource source)
{ {
LoadFromNiniSource(source, "RegionInfo"); if (name == String.Empty)
} name = source.Configs[0].Name;
//not in use, should swap to nini though. if (source.Configs[name] == null)
public void LoadFromNiniSource(IConfigSource source, string sectionName) throw new Exception("Config name does not exist");
{
string errorMessage = String.Empty;
RegionID = new UUID(source.Configs[sectionName].GetString("Region_ID", UUID.Random().ToString()));
RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test");
m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000"));
m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000"));
// this.DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db");
string ipAddress = source.Configs[sectionName].GetString("internal_ip_address", "0.0.0.0"); IConfig config = source.Configs[name];
IPAddress ipAddressResult;
if (IPAddress.TryParse(ipAddress, out ipAddressResult))
{
m_internalEndPoint = new IPEndPoint(ipAddressResult, 0);
}
else
{
errorMessage = "needs an IP Address (IPAddress)";
}
m_internalEndPoint.Port =
source.Configs[sectionName].GetInt("internal_ip_port", (int) ConfigSettings.DefaultRegionHttpPort);
string externalHost = source.Configs[sectionName].GetString("external_host_name", "127.0.0.1"); // UUID
if (externalHost != "SYSTEMIP") //
{ string regionUUID = config.GetString("RegionUUID", string.Empty);
m_externalHostName = externalHost;
} if (regionUUID == String.Empty)
else throw new Exception("A region UUID is required");
{
RegionID = new UUID(regionUUID);
originRegionID = RegionID; // What IS this?!
// Region name
//
RegionName = name;
// Region location
//
string location = config.GetString("Location", String.Empty);
if (location == String.Empty)
throw new Exception("Location is required");
string[] locationElements = location.Split(new char[] {','});
m_regionLocX = Convert.ToUInt32(locationElements[0]);
m_regionLocY = Convert.ToUInt32(locationElements[1]);
// Datastore
//
DataStore = config.GetString("Datastore", String.Empty);
// Internal IP
//
IPAddress address = IPAddress.Parse(config.GetString("InternalAddress", "127.0.0.1"));
int port = config.GetInt("InternalPort", 9000);
m_internalEndPoint = new IPEndPoint(address, port);
m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
// External IP
//
string externalName = config.GetString("ExternalHostName", "SYSTEMIP");
if (externalName == "SYSTEMIP")
m_externalHostName = Util.GetLocalHost().ToString(); m_externalHostName = Util.GetLocalHost().ToString();
} else
m_externalHostName = externalName;
MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test");
MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User");
MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test");
if (errorMessage != String.Empty) // Master avatar cruft
{ //
// a error string masterAvatarUUID = config.GetString("MasterAvatarUUID", UUID.Zero.ToString());
} MasterAvatarAssignedUUID = new UUID(masterAvatarUUID);
MasterAvatarFirstName = config.GetString("MasterAvatarFirstName", String.Empty);
MasterAvatarLastName = config.GetString("MasterAvatarLastName", String.Empty);
MasterAvatarSandboxPassword = config.GetString("MasterAvatarSandboxPassword", String.Empty);
// Prim stuff
//
m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 256);
m_physPrimMax = config.GetInt("PhysicalPrimMax", 10);
m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);
m_objectCapacity = config.GetInt("MaxPrims", 15000);
// Multi-tenancy
//
ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
} }
public bool ignoreIncomingConfiguration(string configuration_key, object configuration_result) public bool ignoreIncomingConfiguration(string configuration_key, object configuration_result)

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using Nini.Config; using Nini.Config;
@ -60,21 +61,37 @@ namespace OpenSim.Framework.RegionLoader.Filesystem
} }
string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
if (configFiles.Length == 0) if (configFiles.Length == 0 && iniFiles.Length == 0)
{ {
new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "default.xml"), false, m_configSource); new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "default.xml"), false, m_configSource);
configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
} }
RegionInfo[] regionInfos = new RegionInfo[configFiles.Length]; List<RegionInfo> regionInfos = new List<RegionInfo>();
for (int i = 0; i < configFiles.Length; i++)
int i = 0;
foreach (string file in iniFiles)
{ {
RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i], false, m_configSource); IConfigSource source = new IniConfigSource(file);
regionInfos[i] = regionInfo;
foreach (IConfig config in source.Configs)
{
RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name);
regionInfos.Add(regionInfo);
i++;
}
} }
return regionInfos; foreach (string file in configFiles)
{
RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource);
regionInfos.Add(regionInfo);
i++;
}
return regionInfos.ToArray();
} }
} }
} }