From 529dd66ed01f598696ef8d20b465b911931d6fe8 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 16 Feb 2009 02:27:34 +0000 Subject: - remove dependency on ExtensionLoader.dll (DBConnString.cs can go) - bring config system in line with other servers - add new plugin filter class which filters on ID - update AssetInventoryServer.ini file --- OpenSim/Framework/AssetInventoryConfig.cs | 146 ++++++++++++ OpenSim/Framework/PluginLoader.cs | 48 +++- .../AssetInventoryServer/AssetInventoryServer.cs | 155 ++---------- .../Extensions/DBConnString.cs | 78 ------- .../Plugins/OpenSim/OpenSimAssetStoragePlugin.cs | 11 +- .../OpenSim/OpenSimInventoryStoragePlugin.cs | 27 ++- .../AssetInventoryServerPlugins.addin.xml | 2 +- bin/AssetInventoryServer.ini.example | 260 +++++++++------------ prebuild.xml | 1 - 9 files changed, 344 insertions(+), 384 deletions(-) create mode 100644 OpenSim/Framework/AssetInventoryConfig.cs delete mode 100644 OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs diff --git a/OpenSim/Framework/AssetInventoryConfig.cs b/OpenSim/Framework/AssetInventoryConfig.cs new file mode 100644 index 0000000..9277b5e --- /dev/null +++ b/OpenSim/Framework/AssetInventoryConfig.cs @@ -0,0 +1,146 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +namespace OpenSim.Framework +{ + /// + /// AssetInventoryConfig -- For AssetInventory Server Configuration + /// + public class AssetInventoryConfig + { + private ConfigurationMember configMember; + + public const uint DefaultHttpPort = 8003; + public uint HttpPort = DefaultHttpPort; + + public string AssetStorageProvider = "OpenSimAssetStorage"; + public string AssetDatabaseConnect = String.Empty; + public string InventoryStorageProvider = "OpenSimInventoryStorage"; + public string InventoryDatabaseConnect = String.Empty; + + public string AuthenticationProvider = "NullAuthentication"; + public string AuthorizationProvider = "AuthorizeAll"; + public string MetricsProvider = "NullMetrics"; + public string Frontends = "OpenSimAssetFrontend,OpenSimInventoryFrontend"; + + public AssetInventoryConfig(string description, string filename) + { + configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true); + configMember.performConfigurationRetrieve(); + } + + public void loadConfigurationOptions() + { + configMember.addConfigurationOption("listen_port", + ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "HTTP listener port", + DefaultHttpPort.ToString(), + false); + + configMember.addConfigurationOption("asset_storage_provider", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Asset storage provider", + AssetStorageProvider, + false); + configMember.addConfigurationOption("asset_database_connect", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Asset database connection string", + AssetDatabaseConnect, + false); + configMember.addConfigurationOption("inventory_storage_provider", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Inventory storage provider", + InventoryStorageProvider, + false); + configMember.addConfigurationOption("inventory_database_connect", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Inventory database connection string", + InventoryDatabaseConnect, + false); + + configMember.addConfigurationOption("authentication_provider", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Authentication provider", + AuthenticationProvider, + false); + configMember.addConfigurationOption("authorization_provider", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Authentication provider", + AuthorizationProvider, + false); + configMember.addConfigurationOption("metrics_provider", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Metrics provider", + MetricsProvider, + false); + configMember.addConfigurationOption("frontends", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Comma-separated list of frontends", + Frontends, + false); + + } + + public bool handleIncomingConfiguration(string configuration_key, object configuration_result) + { + switch (configuration_key) + { + case "listen_port": + HttpPort = (uint) configuration_result; + break; + case "asset_storage_provider": + AssetStorageProvider = (string) configuration_result; + break; + case "asset_database_connect": + AssetDatabaseConnect = (string) configuration_result; + break; + case "inventory_storage_provider": + InventoryStorageProvider = (string) configuration_result; + break; + case "inventory_database_connect": + InventoryDatabaseConnect = (string) configuration_result; + break; + case "authentication_provider": + AuthenticationProvider = (string) configuration_result; + break; + case "authorization_provider": + AuthorizationProvider = (string) configuration_result; + break; + case "metrics_provider": + MetricsProvider = (string) configuration_result; + break; + case "frontends": + Frontends = (string) configuration_result; + break; + } + + return true; + } + } +} diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs index 15e0b9f..b586fe3 100644 --- a/OpenSim/Framework/PluginLoader.cs +++ b/OpenSim/Framework/PluginLoader.cs @@ -278,6 +278,9 @@ namespace OpenSim.Framework public class PluginExtensionNode : ExtensionNode { [NodeAttribute] + string id = ""; + + [NodeAttribute] string provider = ""; [NodeAttribute] @@ -285,6 +288,7 @@ namespace OpenSim.Framework Type typeobj; + public string ID { get { return id; } } public string Provider { get { return provider; } } public string TypeName { get { return type; } } @@ -349,7 +353,7 @@ namespace OpenSim.Framework } /// - /// Filters out which plugin to load based on its the plugin name or names given. Plugin names are contained in + /// Filters out which plugin to load based on the plugin name or names given. Plugin names are contained in /// their addin.xml /// public class PluginProviderFilter : IPluginFilter @@ -390,4 +394,46 @@ namespace OpenSim.Framework return false; } } + + /// + /// Filters plugins according to their ID. Plugin IDs are contained in their addin.xml + /// + public class PluginIdFilter : IPluginFilter + { + private string[] m_filters; + + /// + /// Constructor. + /// + /// + /// Plugin ID or IDs on which to filter. Multiple names should be separated by commas. + /// + public PluginIdFilter(string p) + { + m_filters = p.Split(','); + + for (int i = 0; i < m_filters.Length; i++) + { + m_filters[i] = m_filters[i].Trim(); + } + } + + /// + /// Apply this filter to . + /// + /// PluginExtensionNode instance to check whether it passes the filter. + /// true if the plugin's ID matches one of the filters, false otherwise. + public bool Apply (PluginExtensionNode plugin) + { + for (int i = 0; i < m_filters.Length; i++) + { + if (m_filters[i] == plugin.ID) + { + return true; + } + } + + return false; + } + } } diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs index bd05d59..f6d46e8 100644 --- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs +++ b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs @@ -32,11 +32,6 @@ using System.Collections.Generic; using System.IO; using System.Net; using System.Reflection; -using System.Security.Cryptography.X509Certificates; -using System.ServiceProcess; -using ExtensionLoader; -using ExtensionLoader.Config; -//using HttpServer; using log4net; using OpenSim.Framework; using OpenSim.Framework.Servers; @@ -44,12 +39,11 @@ using OpenSim.Framework.Console; namespace OpenSim.Grid.AssetInventoryServer { - public class AssetInventoryServer : BaseOpenSimServer//ServiceBase + public class AssetInventoryServer : BaseOpenSimServer { public const string CONFIG_FILE = "AssetInventoryServer.ini"; - //public WebServer HttpServer; - public IniConfigSource ConfigFile; + public AssetInventoryConfig ConfigFile; public IAssetStorageProvider StorageProvider; public IInventoryStorageProvider InventoryProvider; @@ -57,72 +51,39 @@ namespace OpenSim.Grid.AssetInventoryServer public IAuthorizationProvider AuthorizationProvider; public IMetricsProvider MetricsProvider; - private List frontends = new List(); - private List backends = new List(); + private List m_frontends = new List(); + private List m_backends = new List(); public AssetInventoryServer() { m_console = new ConsoleBase("Asset"); MainConsole.Instance = m_console; - //this.ServiceName = "OpenSimAssetInventoryServer"; } public bool Start() { Logger.Log.Info("Starting Asset Server"); - List extensionList = null; - int port = 0; - X509Certificate2 serverCert = null; + uint port = 0; - try { ConfigFile = new IniConfigSource(CONFIG_FILE); } + try { ConfigFile = new AssetInventoryConfig("AssetInventory Server", (Path.Combine(Util.configDir(), "AssetInventoryServer.ini"))); } catch (Exception) { Logger.Log.Error("Failed to load the config file " + CONFIG_FILE); return false; } - try - { - IConfig extensionConfig = ConfigFile.Configs["Config"]; - - // Load the port number to listen on - port = extensionConfig.GetInt("ListenPort"); - - // Load the server certificate file - string certFile = extensionConfig.GetString("SSLCertFile"); - if (!String.IsNullOrEmpty(certFile)) - serverCert = new X509Certificate2(certFile); - } - catch (Exception) - { - Logger.Log.Error("Failed to load [Config] section from " + CONFIG_FILE); - return false; - } - - try - { - // Load the extension list (and ordering) from our config file - IConfig extensionConfig = ConfigFile.Configs["Extensions"]; - extensionList = new List(extensionConfig.GetKeys()); - } - catch (Exception) - { - Logger.Log.Error("Failed to load [Extensions] section from " + CONFIG_FILE); - return false; - } - - StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider", "OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll") as IAssetStorageProvider; - backends.Add(StorageProvider); + StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider", ConfigFile.AssetStorageProvider) as IAssetStorageProvider; + m_backends.Add(StorageProvider); - InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryProvider", "OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll") as IInventoryStorageProvider; - backends.Add(InventoryProvider); + InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryProvider", ConfigFile.InventoryStorageProvider) as IInventoryStorageProvider; + m_backends.Add(InventoryProvider); - MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider", String.Empty) as IMetricsProvider; - backends.Add(MetricsProvider); + MetricsProvider = LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/MetricsProvider", ConfigFile.MetricsProvider) as IMetricsProvider; + m_backends.Add(MetricsProvider); try { - InitHttpServer(port, serverCert); + InitHttpServer(ConfigFile.HttpPort); } catch (Exception ex) { @@ -131,13 +92,13 @@ namespace OpenSim.Grid.AssetInventoryServer return false; } - frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", String.Empty)); + AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", ConfigFile.AuthenticationProvider) as IAuthenticationProvider; + m_backends.Add(AuthenticationProvider); - AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", String.Empty) as IAuthenticationProvider; - backends.Add(AuthenticationProvider); + AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", ConfigFile.AuthorizationProvider) as IAuthorizationProvider; + m_backends.Add(AuthorizationProvider); - AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", String.Empty) as IAuthorizationProvider; - backends.Add(AuthorizationProvider); + m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", ConfigFile.Frontends)); return true; } @@ -154,7 +115,7 @@ namespace OpenSim.Grid.AssetInventoryServer public override void ShutdownSpecific() { - foreach (IAssetInventoryServerPlugin plugin in frontends) + foreach (IAssetInventoryServerPlugin plugin in m_frontends) { Logger.Log.Debug("Disposing plugin " + plugin.Name); try { plugin.Dispose(); } @@ -162,7 +123,7 @@ namespace OpenSim.Grid.AssetInventoryServer { Logger.Log.ErrorFormat("Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); } } - foreach (IAssetInventoryServerPlugin plugin in backends) + foreach (IAssetInventoryServerPlugin plugin in m_backends) { Logger.Log.Debug("Disposing plugin " + plugin.Name); try { plugin.Dispose(); } @@ -174,47 +135,14 @@ namespace OpenSim.Grid.AssetInventoryServer HttpServer.Stop(); } - void InitHttpServer(int port, X509Certificate serverCert) + void InitHttpServer(uint port) { - //if (serverCert != null) - // HttpServer = new WebServer(IPAddress.Any, port, serverCert, null, false); - //else - // HttpServer = new WebServer(IPAddress.Any, port); - - //HttpServer.LogWriter = new log4netLogWriter(Logger.Log); - - //HttpServer.Set404Handler( - // delegate(IHttpClientContext client, IHttpRequest request, IHttpResponse response) - // { - // Logger.Log.Warn("Requested page was not found: " + request.Uri.PathAndQuery); - - // string notFoundString = "Page Not FoundThe requested page or method was not found"; - // byte[] buffer = System.Text.Encoding.UTF8.GetBytes(notFoundString); - // response.Body.Write(buffer, 0, buffer.Length); - // response.Status = HttpStatusCode.NotFound; - // return true; - // } - //); - - m_httpServer = new BaseHttpServer(8003); - HttpServer.Start(); + m_httpServer = new BaseHttpServer(port); + m_httpServer.Start(); Logger.Log.Info("Asset server is listening on port " + port); } - #region ServiceBase Overrides - - //protected override void OnStart(string[] args) - //{ - // Start(); - //} - //protected override void OnStop() - //{ - // Shutdown(); - //} - - #endregion - private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string provider) { PluginLoader loader = new PluginLoader(new AssetInventoryServerPluginInitialiser(this)); @@ -222,7 +150,7 @@ namespace OpenSim.Grid.AssetInventoryServer if (provider == String.Empty) loader.Add(addinPath); else - loader.Add(addinPath, new PluginProviderFilter(provider)); + loader.Add(addinPath, new PluginIdFilter(provider)); //loader.Add(addinPath, new PluginCountConstraint(1)); loader.Load(); @@ -237,7 +165,7 @@ namespace OpenSim.Grid.AssetInventoryServer if (provider == String.Empty) loader.Add(addinPath); else - loader.Add(addinPath, new PluginProviderFilter(provider)); + loader.Add(addinPath, new PluginIdFilter(provider)); //loader.Add(addinPath, new PluginCountConstraint(1)); loader.Load(); @@ -245,37 +173,4 @@ namespace OpenSim.Grid.AssetInventoryServer return loader.Plugins; } } - - //public class log4netLogWriter : ILogWriter - //{ - // ILog Log; - - // public log4netLogWriter(ILog log) - // { - // Log = log; - // } - - // public void Write(object source, LogPrio prio, string message) - // { - // switch (prio) - // { - // case LogPrio.Trace: - // case LogPrio.Debug: - // Log.DebugFormat("{0}: {1}", source, message); - // break; - // case LogPrio.Info: - // Log.InfoFormat("{0}: {1}", source, message); - // break; - // case LogPrio.Warning: - // Log.WarnFormat("{0}: {1}", source, message); - // break; - // case LogPrio.Error: - // Log.ErrorFormat("{0}: {1}", source, message); - // break; - // case LogPrio.Fatal: - // Log.FatalFormat("{0}: {1}", source, message); - // break; - // } - // } - //} } diff --git a/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs b/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs deleted file mode 100644 index 78761be..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2008 Intel Corporation - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * -- Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * -- Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * -- Neither the name of the Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Xml; -using ExtensionLoader.Config; -using MySql.Data.MySqlClient; - -namespace OpenSim.Grid.AssetInventoryServer.Extensions -{ - public static class DBConnString - { - private static string connectionString; - - /// - /// Parses the MySQL connection string out of either the asset server - /// .ini or a OpenSim-style .xml file and caches the result for future - /// requests - /// - public static string GetConnectionString(IniConfigSource configFile) - { - if (connectionString == null) - { - // Try parsing from the ini file - try - { - // Load the extension list (and ordering) from our config file - IConfig extensionConfig = configFile.Configs["MySQL"]; - connectionString = extensionConfig.GetString("database_connect", null); - } - catch (Exception) { } - - if (connectionString != null) - { - // Force MySQL's broken connection pooling off - MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(connectionString); - builder.Pooling = false; - if (String.IsNullOrEmpty(builder.Database)) - Logger.Log.Error("No database selected in the connectionString: " + connectionString); - connectionString = builder.ToString(); - } - else - { - Logger.Log.Error("Database connection string is missing, check that the database_connect line is " + - "correct and uncommented in AssetInventoryServer.ini"); - } - } - - return connectionString; - } - } -} diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs index e35092b..b7aef08 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs @@ -35,7 +35,6 @@ using MySql.Data.MySqlClient; using OpenMetaverse; using OpenMetaverse.StructuredData; using OpenSim.Framework; -using OpenSim.Grid.AssetInventoryServer.Extensions; using OpenSim.Data; namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim @@ -58,7 +57,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim metadata = null; BackendResponse ret; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect)) { IDataReader reader; @@ -104,7 +103,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim assetData = null; BackendResponse ret; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect)) { IDataReader reader; @@ -156,7 +155,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim { BackendResponse ret; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect)) { try { @@ -205,7 +204,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim { int rowCount = 0; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect)) { MySqlDataReader reader; @@ -255,7 +254,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim try { - m_assetProvider = DataPluginFactory.LoadDataPlugin("OpenSim.Data.MySQL.dll", server.ConfigFile.Configs["MySQL"].GetString("database_connect", null)); + m_assetProvider = DataPluginFactory.LoadDataPlugin("OpenSim.Data.MySQL.dll", server.ConfigFile.AssetDatabaseConnect); if (m_assetProvider == null) { Logger.Log.Error("[ASSET]: Failed to load a database plugin, server halting."); diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs index a7d2f92..0ad6c80 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs @@ -35,7 +35,6 @@ using MySql.Data.MySqlClient; using OpenMetaverse; using OpenMetaverse.StructuredData; using OpenSim.Framework; -using OpenSim.Grid.AssetInventoryServer.Extensions; using OpenSim.Data; namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim @@ -58,7 +57,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim item = null; BackendResponse ret; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { IDataReader reader; @@ -120,7 +119,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim folder = null; BackendResponse ret; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { IDataReader reader; @@ -167,7 +166,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim contents = null; BackendResponse ret; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { IDataReader reader; @@ -267,7 +266,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim if (Utils.TryGetOpenSimUUID(owner, out ownerID)) { - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { IDataReader reader; @@ -333,7 +332,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim // Fetch inventory items if (Utils.TryGetOpenSimUUID(owner, out ownerID)) { - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { IDataReader reader; @@ -405,7 +404,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim if (Utils.TryGetOpenSimUUID(owner, out ownerID)) { - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { IDataReader reader; @@ -470,7 +469,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim { BackendResponse ret; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { try { @@ -537,7 +536,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim { BackendResponse ret; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { try { @@ -593,7 +592,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim if (Utils.TryGetOpenSimUUID(owner, out ownerID)) { - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { try { @@ -639,7 +638,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim if (Utils.TryGetOpenSimUUID(owner, out ownerID)) { - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { try { @@ -685,7 +684,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim if (Utils.TryGetOpenSimUUID(owner, out ownerID)) { - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { try { @@ -739,7 +738,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim { int rowCount = 0; - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) + using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) { MySqlDataReader reader; @@ -789,7 +788,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim try { - m_inventoryProvider = DataPluginFactory.LoadDataPlugin("OpenSim.Data.MySQL.dll", server.ConfigFile.Configs["MySQL"].GetString("database_connect", null)); + m_inventoryProvider = DataPluginFactory.LoadDataPlugin("OpenSim.Data.MySQL.dll", server.ConfigFile.InventoryDatabaseConnect); if (m_inventoryProvider == null) { Logger.Log.Error("[INVENTORY]: Failed to load a database plugin, server halting."); diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml index 67c4cd2..c1e5c4d 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml @@ -8,7 +8,7 @@ - + diff --git a/bin/AssetInventoryServer.ini.example b/bin/AssetInventoryServer.ini.example index f346624..503870e 100644 --- a/bin/AssetInventoryServer.ini.example +++ b/bin/AssetInventoryServer.ini.example @@ -1,153 +1,107 @@ -[Config] - -; The port number for the asset server to listen on. If a valid SSL certificate -; file is given for SSLCertFile, the HTTPS protocol will be used. Otherwise, the -; HTTP protocol is used. -ListenPort = 8003 - -; An SSL certificate file for the server. If a valid raw certificate or PKCS#12 -; file is given the server will run in HTTPS mode. -;SSLCertFile = server.p12 - -[Extensions] - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Storage Providers -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; Simple storage is a very basic storage system for the purposes of illustrating -; a storage backend example. The assets are stored in SimpleAssets/ and -; TempAssets/ (which is deleted when the server shuts down). Metadata is -; generated for all of the files at startup and when new assets are uploaded. -;SimpleStorage - -; OpenSimMySQL storage connects to a MySQL server that has an assets table created -; by OpenSim. Open the AssetServer_Config.xml file from OpenSim and use the -; database connection string for the database_connect option in the MySQL section -; below. This backend combined with the OpenSimFrontend will allow the asset -; server to be used as a drop-in replacement for OpenSim.Grid.AssetServer.exe, -; while also allowing other frontends to run. -OpenSimMySQLStorage - -; Uses Amazon.com's Simple Storage Service (http://aws.amazon.com/s3/) to store -; asset data and metadata. This backend does not handle any data requests, as the -; data is stored remotely and metadata replies will contain the amazon.com URL -; holding the actual asset data. Your Access Key ID and Secret Access Key must be -; set in the [Amazon] section below for this backend to function. If -; UseCloudFront is true and your Amazon account has CloudFront enabled, -; CloudFront URLs will be returned in metadata instead of normal S3 URLs. -;AmazonS3Storage - -; Uses memcached (http://www.danga.com/memcached/) as a caching layer on top of -; another storage backend. If you use this, make sure you enable another storage -; provider as the actual backend, and that the MemcacheStorage line appears in -; this config file after the other storage provider. -;MemcachedStorage - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Inventory Providers -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; Simple inventory is a very basic inventory storage system for the purposes of -; illustrating an inventory backend example. The inventory is stored in -; SimpleInventory/ by creating a folder for each agent that contains all of the -; inventory items and folders serialized as XML files. -;SimpleInventory - -; OpenSimMySQL inventory connects to a MySQL server that has an inventory table -; created by OpenSim. If the OpenSimMySQLStorage backend is also being used, the -; inventory and asset tables must be stored in the same database. The -; database_connect string in the MySQL section below is used to connect to the -; database. This backend combined with the OpenSimInventoryFrontend will allow -; the server to be used as a drop-in replacement for -; OpenSim.Grid.InventoryServer.exe, while also allowing other frontends to run. -OpenSimMySQLInventory - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Authentication Providers -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; OpenID provides a direct method of authenticating with the asset server. Users -; can provide credentials and receive a session token directly from the asset -; server. The OpenIdAuth module provides a browser-based form login and an -; XML-based API, both accessible through the URL /authenticate. -;OpenIdAuth -NullAuthentication - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Authorization Providers -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; Authorize all is a dummy authorization module that allows all requests for -; metadata, data, and asset creation. Use this extension if your primary -; storage provider or front-end interface does not support authentication. -AuthorizeAll - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Metrics Providers -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; NullMetrics contains empty logging functions. Use this metrics provider if -; you want to disable metrics collection and reporting. -NullMetrics - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Frontends -;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; A simple frontend that provides three basic REST methods. /assetid/metadata -; will return the metadata for an asset (currently in LLSD format, that will -; change soon). /assetid/data will return the raw asset data with proper -; Content-Type and Content-Disposition headers to make downloading assets in a -; web browser easy. -ReferenceFrontend - -; A frontend that matches the existing OpenSim XML for transferring grid -; assets. This will allow the asset server to function as a drop-in replacement -; for OpenSim.Grid.AssetServer.exe, and can be combined with OpenSimMySQLStorage -; to provide an identical replacement or any other storage backend. -OpenSimFrontend - -; A frontend that matches the existing OpenSim XML for handling inventory -; transactions. This will allow the asset server to function as a drop-in -; replacement for OpenSim.Grid.InventoryServer.exe, and can be combined with -; OpenSimMySQLInventory to provide an identical replacement or any other -; inventory backend. -OpenSimInventoryFrontend - -; An HTML interface for browsing through the asset store -BrowseFrontend - -[MySQL] - -; Database connection string used by the OpenSim MySQL backend. If this line is -; commented out or missing, the server will look for an AssetServer_Config.xml -; in the current working directory. This file is generated by -; OpenSim.Grid.AssetServer.exe and can be used without modification. -database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;" - -[Amazon] - -; Get these values by logging in to your Amazon S3 account and going to -; https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=access-key -AccessKeyID = xxxxxxxxxxxxxxxxxxxx -SecretAccessKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - -; The bucket, or namespace, in your Amazon S3 account for storing assets in. -; Bucket names on S3 are global identifiers, and must be unique. Think up -; something clever or random. -BucketName = changeme - -; Amazon CloudFront is a Content Distribution Network for S3 stores. If this is -; set to true, AmazonS3Storage will try to locate the first available CloudFront -; distribution tied to the active S3 bucket. If no usable distribution is found, -; a new one will be created. -UseCloudFront = true - -[Memcached] - -; A comma-separated list of the memcached servers that make up your caching -; pool. Each server is a hostname or IP address, optionally followed by a -; colon and port number if the server is not listening on the default 11211 -; port. -Servers = localhost +;[Config] + +; The port number for the asset server to listen on. +listen_port = 8003 + +;[Extensions] + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Asset Storage Provider +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Simple storage is a very basic storage system for the purposes of illustrating +; a storage backend example. The assets are stored in SimpleAssets/ and +; TempAssets/ (which is deleted when the server shuts down). Metadata is +; generated for all of the files at startup and when new assets are uploaded. +;asset_storage_provider = SimpleAssetStorage + +; OpenSimMySQL storage connects to a MySQL server that has an assets table created +; by OpenSim. Open the AssetServer_Config.xml file from OpenSim and use the +; database connection string for the database_connect option in the MySQL section +; below. This backend combined with the OpenSimFrontend will allow the asset +; server to be used as a drop-in replacement for OpenSim.Grid.AssetServer.exe, +; while also allowing other frontends to run. +asset_storage_provider = OpenSimAssetStorage + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Inventory Storage Provider +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Simple inventory is a very basic inventory storage system for the purposes of +; illustrating an inventory backend example. The inventory is stored in +; SimpleInventory/ by creating a folder for each agent that contains all of the +; inventory items and folders serialized as XML files. +;inventory_asset_provider = SimpleInventoryStorage + +; OpenSimMySQL inventory connects to a MySQL server that has an inventory table +; created by OpenSim. If the OpenSimMySQLStorage backend is also being used, the +; inventory and asset tables must be stored in the same database. The +; database_connect string in the MySQL section below is used to connect to the +; database. This backend combined with the OpenSimInventoryFrontend will allow +; the server to be used as a drop-in replacement for +; OpenSim.Grid.InventoryServer.exe, while also allowing other frontends to run. +inventory_asset_provider = OpenSimInventoryStorage + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Authentication Provider +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; NullAuthentication does nothing. +authentication_provider = NullAuthentication + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Authorization Provider +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Authorize all is a dummy authorization module that allows all requests for +; metadata, data, and asset creation. Use this extension if your primary +; storage provider or front-end interface does not support authentication. +authroization_provider = AuthorizeAll + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Metrics Provider +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; NullMetrics contains empty logging functions. Use this metrics provider if +; you want to disable metrics collection and reporting. +metrics_provider = NullMetrics + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Frontends +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Specify multiple frontends as a comma-separated list. + +; ReferenceFrontend is a simple frontend that provides three basic REST +; methods. /assetid/metadata will return the metadata for an asset (currently in +; LLSD format, that will change soon). /assetid/data will return the raw asset +; data with proper Content-Type and Content-Disposition headers to make +; downloading assets in a web browser easy. + +; OpenSimAssetFrontend is a frontend that matches the existing OpenSim XML for +; transferring grid assets. This will allow the asset server to function as a +; drop-in replacement for OpenSim.Grid.AssetServer.exe, and can be combined with +; OpenSimAssetStorage to provide an identical replacement, or any other asset +; storage backend. + +; OpenSimInventoryFrontend is a frontend that matches the existing OpenSim XML +; for transferring inventory. This will allow the inventory server to function as +; a drop-in replacement for OpenSim.Grid.InventoryServer.exe, and can be combined +; with OpenSimInventoryStorage to provide an identical replacement, or any other +; inventory storage backend. +; *** NOTE: Inventory is not currently implemented. + +; BrowseFrontend is an HTML interface for browsing through the asset store. + +frontends = ReferenceFrontend,OpenSimAssetFrontend,OpenSimInventoryFrontend,BrowseFrontend + +;[MySQL] + +; Database connection string used by the OpenSim MySQL backend. If these lines +; are commented out or missing, the server will look for an +; AssetServer_Config.xml or InventoryServer_Config.xml file in the current +; working directory. These files are generated by OpenSim.Grid.AssetServer.exe +; and OpenSim.Grid.InventoryServer.exe, respectively, and can be used without +; modification. +asset_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;" +inventory_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;" diff --git a/prebuild.xml b/prebuild.xml index e63bb4f..75879d9 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -769,7 +769,6 @@ - -- cgit v1.1