From dd0234f5005127c03760c2b9862ed1672f4a2e91 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 Aug 2009 05:15:25 +0100 Subject: Graft the REST console onto the grid server. Same procedure as with the user server. --- OpenSim/Framework/GridConfig.cs | 16 +++++++++++++++- OpenSim/Grid/GridServer/GridServerBase.cs | 27 +++++++++++++++++++++++++-- OpenSim/Grid/GridServer/Program.cs | 12 ++++++++++++ OpenSim/Grid/UserServer/Main.cs | 1 - prebuild.xml | 1 + 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/GridConfig.cs b/OpenSim/Framework/GridConfig.cs index a3c1032..87fd3f0 100644 --- a/OpenSim/Framework/GridConfig.cs +++ b/OpenSim/Framework/GridConfig.cs @@ -45,6 +45,8 @@ namespace OpenSim.Framework public string SimSendKey = String.Empty; public string UserRecvKey = String.Empty; public string UserSendKey = String.Empty; + public string ConsoleUser = String.Empty; + public string ConsolePass = String.Empty; public GridConfig(string description, string filename) { @@ -95,6 +97,12 @@ namespace OpenSim.Framework "Allow regions to register immediately upon grid server startup? true/false", "True", false); + m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access user name [Default: disabled]", "0", false); + + m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access password [Default: disabled]", "0", false); + } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -140,9 +148,15 @@ namespace OpenSim.Framework case "allow_region_registration": AllowRegionRegistration = (bool)configuration_result; break; + case "console_user": + ConsoleUser = (string)configuration_result; + break; + case "console_pass": + ConsolePass = (string)configuration_result; + break; } return true; } } -} \ No newline at end of file +} diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index c41a728..e3ad52a 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs @@ -31,6 +31,7 @@ using System.IO; using System.Reflection; using System.Timers; using log4net; +using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; @@ -46,6 +47,8 @@ namespace OpenSim.Grid.GridServer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected GridConfig m_config; + public string m_consoleType = "local"; + public IConfigSource m_configSource = null; public GridConfig Config { @@ -71,16 +74,36 @@ namespace OpenSim.Grid.GridServer public GridServerBase() { - m_console = new LocalConsole("Grid"); - MainConsole.Instance = m_console; } protected override void StartupSpecific() { + switch (m_consoleType) + { + case "rest": + m_console = new RemoteConsole("Grid"); + break; + case "basic": + m_console = new CommandConsole("Grid"); + break; + default: + m_console = new LocalConsole("Grid"); + break; + } + MainConsole.Instance = m_console; m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); m_log.Info("[GRID]: Starting HTTP process"); m_httpServer = new BaseHttpServer(m_config.HttpPort); + if (m_console is RemoteConsole) + { + RemoteConsole c = (RemoteConsole)m_console; + c.SetServer(m_httpServer); + IConfig netConfig = m_configSource.AddConfig("Network"); + netConfig.Set("ConsoleUser", m_config.ConsoleUser); + netConfig.Set("ConsolePass", m_config.ConsolePass); + c.ReadConfig(m_configSource); + } LoadPlugins(); diff --git a/OpenSim/Grid/GridServer/Program.cs b/OpenSim/Grid/GridServer/Program.cs index 9618b85..c7ba897 100644 --- a/OpenSim/Grid/GridServer/Program.cs +++ b/OpenSim/Grid/GridServer/Program.cs @@ -26,6 +26,7 @@ */ using log4net.Config; +using Nini.Config; namespace OpenSim.Grid.GridServer { @@ -33,10 +34,21 @@ namespace OpenSim.Grid.GridServer { public static void Main(string[] args) { + ArgvConfigSource argvSource = new ArgvConfigSource(args); + argvSource.AddSwitch("Startup", "console", "c"); + XmlConfigurator.Configure(); GridServerBase app = new GridServerBase(); + IConfig startupConfig = argvSource.Configs["Startup"]; + if (startupConfig != null) + { + app.m_consoleType = startupConfig.GetString("console", "local"); + } + + app.m_configSource = argvSource; + // if (args.Length > 0 && args[0] == "-setuponly") // { // app.Config(); diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index f47a96e..1ee53ef 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -157,7 +157,6 @@ namespace OpenSim.Grid.UserServer if (m_console is RemoteConsole) { - System.Console.WriteLine("Initialized REST console"); RemoteConsole c = (RemoteConsole)m_console; c.SetServer(m_httpServer); IConfig netConfig = m_config.AddConfig("Network"); diff --git a/prebuild.xml b/prebuild.xml index 4f110c4..216a02e 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -911,6 +911,7 @@ + -- cgit v1.1