From 54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Sat, 7 Feb 2009 12:25:39 +0000
Subject: Replace the console for all OpenSim apps with a new console featuring
command line editing, context sensitive help (press ? at any time), command
line history, a new plugin command system and new appender features thet let
you type while the console is scrolling. Seamlessly integrates the ICommander
interfaces.
---
OpenSim/Grid/AssetServer/Main.cs | 6 +-
OpenSim/Grid/GridServer/GridServerBase.cs | 63 +++++++++++----------
OpenSim/Grid/InventoryServer/Main.cs | 21 ++++---
OpenSim/Grid/MessagingServer/Main.cs | 42 +++++++-------
OpenSim/Grid/UserServer/Main.cs | 94 +++++++++++++++++++++++--------
5 files changed, 138 insertions(+), 88 deletions(-)
(limited to 'OpenSim/Grid')
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
index 060c473..c71e53f 100644
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Grid.AssetServer
///
/// An asset server
///
- public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback
+ public class OpenAsset_Main : BaseOpenSimServer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -76,7 +76,7 @@ namespace OpenSim.Grid.AssetServer
public OpenAsset_Main()
{
- m_console = new ConsoleBase("Asset", this);
+ m_console = new ConsoleBase("Asset");
MainConsole.Instance = m_console;
}
@@ -99,6 +99,8 @@ namespace OpenSim.Grid.AssetServer
AddHttpHandlers();
m_httpServer.Start();
+
+ base.StartupSpecific();
}
protected void AddHttpHandlers()
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs
index 68edbd2..3fb07b5 100644
--- a/OpenSim/Grid/GridServer/GridServerBase.cs
+++ b/OpenSim/Grid/GridServer/GridServerBase.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Grid.GridServer
{
///
///
- public class GridServerBase : BaseOpenSimServer, conscmd_callback
+ public class GridServerBase : BaseOpenSimServer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -59,43 +59,34 @@ namespace OpenSim.Grid.GridServer
public GridServerBase()
{
- m_console = new ConsoleBase("Grid", this);
+ m_console = new ConsoleBase("Grid");
MainConsole.Instance = m_console;
}
- public override void RunCmd(string cmd, string[] cmdparams)
+ private void HandleRegistration(string module, string[] cmd)
{
- base.RunCmd(cmd, cmdparams);
-
- switch (cmd)
+ switch (cmd[0])
{
- case "disable-reg":
- m_config.AllowRegionRegistration = false;
- m_log.Info("Region registration disabled");
- break;
- case "enable-reg":
- m_config.AllowRegionRegistration = true;
- m_log.Info("Region registration enabled");
- break;
+ case "enable":
+ m_config.AllowRegionRegistration = true;
+ m_log.Info("Region registration enabled");
+ break;
+ case "disable":
+ m_config.AllowRegionRegistration = false;
+ m_log.Info("Region registration disabled");
+ break;
}
}
-
- public override void Show(string[] showParams)
- {
- base.Show(showParams);
- switch (showParams[0])
+ private void HandleShowStatus(string module, string[] cmd)
+ {
+ if (m_config.AllowRegionRegistration)
{
- case "status":
- if (m_config.AllowRegionRegistration)
- {
- m_log.Info("Region registration enabled.");
- }
- else
- {
- m_log.Info("Region registration disabled.");
- }
- break;
+ m_log.Info("Region registration enabled.");
+ }
+ else
+ {
+ m_log.Info("Region registration disabled.");
}
}
@@ -120,6 +111,20 @@ namespace OpenSim.Grid.GridServer
// Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
// simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
// simCheckTimer.Enabled = true;
+
+ base.StartupSpecific();
+
+ m_console.Commands.AddCommand("gridserver", "enable registration",
+ "enable registration",
+ "Enable new regions to register", HandleRegistration);
+
+ m_console.Commands.AddCommand("gridserver", "disable registration",
+ "disable registration",
+ "Disable registering new regions", HandleRegistration);
+
+ m_console.Commands.AddCommand("gridserver", "show status",
+ "show status",
+ "Show registration status", HandleShowStatus);
}
protected void AddHttpHandlers()
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
index 81a6a03..4727f6e 100644
--- a/OpenSim/Grid/InventoryServer/Main.cs
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -38,7 +38,7 @@ using OpenSim.Framework.Servers;
namespace OpenSim.Grid.InventoryServer
{
- public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback
+ public class OpenInventory_Main : BaseOpenSimServer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -58,7 +58,7 @@ namespace OpenSim.Grid.InventoryServer
public OpenInventory_Main()
{
- m_console = new ConsoleBase("Inventory", this);
+ m_console = new ConsoleBase("Inventory");
MainConsole.Instance = m_console;
}
@@ -77,6 +77,12 @@ namespace OpenSim.Grid.InventoryServer
m_httpServer.Start();
m_log.Info("[" + LogName + "]: Started HTTP server");
+
+ base.StartupSpecific();
+
+ m_console.Commands.AddCommand("inventoryserver", "add user",
+ "add user",
+ "Add a random user inventory", HandleAddUser);
}
protected void AddHttpHandlers()
@@ -146,16 +152,9 @@ namespace OpenSim.Grid.InventoryServer
}
}
- public override void RunCmd(string cmd, string[] cmdparams)
+ private void HandleAddUser(string module, string[] args)
{
- base.RunCmd(cmd, cmdparams);
-
- switch (cmd)
- {
- case "add-user":
- m_inventoryService.CreateUsersInventory(UUID.Random().Guid);
- break;
- }
+ m_inventoryService.CreateUsersInventory(UUID.Random().Guid);
}
}
}
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs
index e83da7a..9b7e731 100644
--- a/OpenSim/Grid/MessagingServer/Main.cs
+++ b/OpenSim/Grid/MessagingServer/Main.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Grid.MessagingServer
{
///
///
- public class OpenMessage_Main : BaseOpenSimServer, conscmd_callback
+ public class OpenMessage_Main : BaseOpenSimServer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -64,7 +64,7 @@ namespace OpenSim.Grid.MessagingServer
public OpenMessage_Main()
{
- m_console = new ConsoleBase("Messaging", this);
+ m_console = new ConsoleBase("Messaging");
MainConsole.Instance = m_console;
}
@@ -124,6 +124,16 @@ namespace OpenSim.Grid.MessagingServer
registerWithUserServer();
m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete");
+
+ base.StartupSpecific();
+
+ m_console.Commands.AddCommand("messageserver", "clear cache",
+ "clear cache",
+ "Clear presence cache", HandleClearCache);
+
+ m_console.Commands.AddCommand("messageserver", "register",
+ "register",
+ "Re-register with user server(s)", HandleRegister);
}
public void do_create(string what)
@@ -154,29 +164,17 @@ namespace OpenSim.Grid.MessagingServer
}
}
- public override void RunCmd(string cmd, string[] cmdparams)
+ private void HandleClearCache(string module, string[] cmd)
{
- base.RunCmd(cmd, cmdparams);
-
- switch (cmd)
- {
- case "clear-cache":
- int entries = msgsvc.ClearRegionCache();
- m_console.Notice("Region cache cleared! Cleared " + entries.ToString() + " entries");
- break;
- case "register":
- deregisterFromUserServer();
- registerWithUserServer();
- break;
- }
+ int entries = msgsvc.ClearRegionCache();
+ m_console.Notice("Region cache cleared! Cleared " +
+ entries.ToString() + " entries");
}
-
- protected override void ShowHelp(string[] helpArgs)
+
+ private void HandleRegister(string module, string[] cmd)
{
- base.ShowHelp(helpArgs);
-
- m_console.Notice("clear-cache - Clears region cache. Should be done when regions change position. The region cache gets stale after a while.");
- m_console.Notice("register - (Re-)registers with user-server. This might be necessary if the userserver crashed/restarted");
+ deregisterFromUserServer();
+ registerWithUserServer();
}
public override void ShutdownSpecific()
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index be26ab3..0b0bee1 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Grid.UserServer
///
/// Grid user server main class
///
- public class OpenUser_Main : BaseOpenSimServer, conscmd_callback
+ public class OpenUser_Main : BaseOpenSimServer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -73,7 +73,7 @@ namespace OpenSim.Grid.UserServer
public OpenUser_Main()
{
- m_console = new ConsoleBase("User", this);
+ m_console = new ConsoleBase("User");
MainConsole.Instance = m_console;
}
@@ -119,6 +119,37 @@ namespace OpenSim.Grid.UserServer
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
AddHttpHandlers();
m_httpServer.Start();
+
+ base.StartupSpecific();
+
+ m_console.Commands.AddCommand("userserver", "create user",
+ "create user [ [ [ [email]]]]",
+ "Create a new user account", RunCommand);
+
+ m_console.Commands.AddCommand("userserver", "reset user password",
+ "reset user password [ [ []]]",
+ "Reset a user's password", RunCommand);
+
+ m_console.Commands.AddCommand("userserver", "login level",
+ "login level ",
+ "Set the minimum user level to log in", HandleLoginCommand);
+
+ m_console.Commands.AddCommand("userserver", "login reset",
+ "login reset",
+ "Reset the login level to allow all users",
+ HandleLoginCommand);
+
+ m_console.Commands.AddCommand("userserver", "login text",
+ "login text ",
+ "Set the text users will see on login", HandleLoginCommand);
+
+ m_console.Commands.AddCommand("userserver", "test-inventory",
+ "test-inventory",
+ "Perform a test inventory transaction", RunCommand);
+
+ m_console.Commands.AddCommand("userserver", "logoff-user",
+ "logoff-user ",
+ "Log off a named user", RunCommand);
}
///
@@ -301,39 +332,54 @@ namespace OpenSim.Grid.UserServer
m_userManager.ResetUserPassword(firstName, lastName, newPassword);
}
- public override void RunCmd(string cmd, string[] cmdparams)
+ private void HandleLoginCommand(string module, string[] cmd)
{
- base.RunCmd(cmd, cmdparams);
- switch (cmd)
+ string subcommand = cmd[1];
+
+ switch (subcommand)
{
- case "create":
- do_create(cmdparams);
- break;
-
- case "reset":
- Reset(cmdparams);
- break;
-
-
- case "login-level":
- // Set the minimal level to allow login
- // Usefull to allow grid update without worrying about users.
- // or fixing critical issue
- if (cmdparams.Length == 1)
+ case "level":
+ // Set the minimal level to allow login
+ // Useful to allow grid update without worrying about users.
+ // or fixing critical issues
+ //
+ if (cmd.Length > 2)
{
- int level = Convert.ToInt32(cmdparams[0]);
+ int level = Convert.ToInt32(cmd[2]);
m_loginService.setloginlevel(level);
}
break;
- case "login-reset":
+ case "reset":
m_loginService.setloginlevel(0);
break;
- case "login-text":
- if (cmdparams.Length == 1)
+ case "text":
+ if (cmd.Length > 2)
{
- m_loginService.setwelcometext(cmdparams[0]);
+ m_loginService.setwelcometext(cmd[2]);
}
break;
+ }
+ }
+
+ public void RunCommand(string module, string[] cmd)
+ {
+ List args = new List(cmd);
+ string command = cmd[0];
+
+ args.RemoveAt(0);
+
+ string[] cmdparams = args.ToArray();
+
+ switch (command)
+ {
+ case "create":
+ do_create(cmdparams);
+ break;
+
+ case "reset":
+ Reset(cmdparams);
+ break;
+
case "test-inventory":
// RestObjectPosterResponse> requester = new RestObjectPosterResponse>();
--
cgit v1.1