Have some commands working

Still rough, but making some progress.
integration
BlueWall 2012-04-06 19:22:34 -04:00
parent 1aab096a83
commit 90a2296983
3 changed files with 170 additions and 73 deletions

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using OpenSim.Server.Base; using OpenSim.Server.Base;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
@ -61,142 +62,155 @@ namespace OpenSim.Services.IntegrationService
{ {
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"install", "install \"plugin name\"", "Install plugin from repository", "install", "install \"plugin name\"", "Install plugin from repository",
HandleInstallPlugin); HandleConsoleInstallPlugin);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"uninstall", "uninstall \"plugin name\"", "Remove plugin from repository", "uninstall", "uninstall \"plugin name\"", "Remove plugin from repository",
HandleUnInstallPlugin); HandleConsoleUnInstallPlugin);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"check installed", "check installed \"plugin name=\"","Check installed plugin", "check installed", "check installed \"plugin name=\"","Check installed plugin",
HandleCheckInstalledPlugin); HandleConsoleCheckInstalledPlugin);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"list installed", "list installed \"plugin name=\"","List install plugins", "list installed", "list installed \"plugin name=\"","List install plugins",
HandleListInstalledPlugin); HandleConsoleListInstalledPlugin);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"list available", "list available \"plugin name=\"","List available plugins", "list available", "list available \"plugin name=\"","List available plugins",
HandleListAvailablePlugin); HandleConsoleListAvailablePlugin);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"list updates", "list updates","List availble updates", "list updates", "list updates","List availble updates",
HandleListUpdates); HandleConsoleListUpdates);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"update", "update \"plugin name=\"","Update the plugin", "update", "update \"plugin name=\"","Update the plugin",
HandleUpdatePlugin); HandleConsoleUpdatePlugin);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"add repo", "add repo \"url\"","Add repository", "add repo", "add repo \"url\"","Add repository",
HandleAddRepo); HandleConsoleAddRepo);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"get repo", "get repo \"url\"", "Sync with a registered repository", "get repo", "get repo \"url\"", "Sync with a registered repository",
HandleGetRepo); HandleConsoleGetRepo);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"remove repo", "remove repo \"[url | index]\"","Remove registered repository", "remove repo", "remove repo \"[url | index]\"","Remove registered repository",
HandleRemoveRepo); HandleConsoleRemoveRepo);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"enable repo", "enable repo \"[url | index]\"","Enable registered repository", "enable repo", "enable repo \"[url | index]\"","Enable registered repository",
HandleEnableRepo); HandleConsoleEnableRepo);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"disable repo", "disable repo \"[url | index]\"","Disable registered repository", "disable repo", "disable repo \"[url | index]\"","Disable registered repository",
HandleDisableRepo); HandleConsoleDisableRepo);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"list repos", "list repos","List registered repositories", "list repos", "list repos","List registered repositories",
HandleListRepos); HandleConsoleListRepos);
MainConsole.Instance.Commands.AddCommand("Integration", true, MainConsole.Instance.Commands.AddCommand("Integration", true,
"show info", "show info \"plugin name\"","Show detailed information for plugin", "show info", "show info \"plugin name\"","Show detailed information for plugin",
HandleShowAddinInfo); HandleConsoleShowAddinInfo);
} }
#region console handlers #region console handlers
private void HandleInstallPlugin(string module, string[] cmd) private void HandleConsoleInstallPlugin(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.Install()); MainConsole.Instance.Output(m_PluginManager.InstallPlugin(cmd));
return; return;
} }
private void HandleUnInstallPlugin(string module, string[] cmd) private void HandleConsoleUnInstallPlugin(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.UnInstall()); if (cmd.Length == 2)
{
m_PluginManager.UnInstall(cmd);
}
return; return;
} }
private void HandleCheckInstalledPlugin(string module, string[] cmd) private void HandleConsoleCheckInstalledPlugin(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.CheckInstalled()); MainConsole.Instance.Output(m_PluginManager.CheckInstalled());
return; return;
} }
private void HandleListInstalledPlugin(string module, string[] cmd) private void HandleConsoleListInstalledPlugin(string module, string[] cmd)
{ {
m_PluginManager.ListInstalledAddins(); m_PluginManager.ListInstalledAddins();
return; return;
} }
private void HandleListAvailablePlugin(string module, string[] cmd) private void HandleConsoleListAvailablePlugin(string module, string[] cmd)
{ {
m_PluginManager.ListAvailable(); ArrayList list = m_PluginManager.ListAvailable();
foreach (string entry in list)
MainConsole.Instance.Output(entry);
return; return;
} }
private void HandleListUpdates(string module, string[] cmd) private void HandleConsoleListUpdates(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.ListUpdates()); MainConsole.Instance.Output(m_PluginManager.ListUpdates());
return; return;
} }
private void HandleUpdatePlugin(string module, string[] cmd) private void HandleConsoleUpdatePlugin(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.Update()); MainConsole.Instance.Output(m_PluginManager.Update());
return; return;
} }
private void HandleAddRepo(string module, string[] cmd) private void HandleConsoleAddRepo(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.AddRepository()); if ( cmd.Length == 3)
{
m_PluginManager.AddRepository(cmd);
}
return; return;
} }
private void HandleGetRepo(string module, string[] cmd) private void HandleConsoleGetRepo(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.GetRepository()); MainConsole.Instance.Output(m_PluginManager.GetRepository());
return; return;
} }
private void HandleRemoveRepo(string module, string[] cmd) private void HandleConsoleRemoveRepo(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.RemoveRepository()); MainConsole.Instance.Output(m_PluginManager.RemoveRepository(cmd));
return; return;
} }
private void HandleEnableRepo(string module, string[] cmd) private void HandleConsoleEnableRepo(string module, string[] cmd)
{ {
m_PluginManager.EnableRepository(cmd); m_PluginManager.EnableRepository(cmd);
return; return;
} }
private void HandleDisableRepo(string module, string[] cmd) private void HandleConsoleDisableRepo(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.DisableRepository()); m_PluginManager.DisableRepository(cmd);
return; return;
} }
private void HandleListRepos(string module, string[] cmd) private void HandleConsoleListRepos(string module, string[] cmd)
{ {
m_PluginManager.ListRepositories(); ArrayList list = m_PluginManager.ListRepositories();
foreach (string entry in list)
MainConsole.Instance.Output(entry);
return; return;
} }
private void HandleShowAddinInfo(string module, string[] cmd) private void HandleConsoleShowAddinInfo(string module, string[] cmd)
{ {
if ( cmd.Length < 2 ) if ( cmd.Length < 2 )
{ {

View File

@ -77,8 +77,8 @@ namespace OpenSim.Services.IntegrationService
// defaults to the ./bin directory // defaults to the ./bin directory
string RegistryLocation = serverConfig.GetString("PluginRegistryLocation", string RegistryLocation = serverConfig.GetString("PluginRegistryLocation",
"."); ".");
AddinRegistry registry = new AddinRegistry(RegistryLocation, ".");
m_PluginManager = new PluginManager(RegistryLocation); m_PluginManager = new PluginManager(registry);
// Deal with files only for now - will add url/environment later // Deal with files only for now - will add url/environment later
m_IntegrationConfigLoc = serverConfig.GetString("IntegrationConfig", String.Empty); m_IntegrationConfigLoc = serverConfig.GetString("IntegrationConfig", String.Empty);

View File

@ -26,33 +26,69 @@
*/ */
using System; using System;
using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Mono.Addins; using Mono.Addins;
using Mono.Addins.Setup; using Mono.Addins.Setup;
using Mono.Addins.Description;
using OpenSim.Framework; using OpenSim.Framework;
namespace OpenSim.Services.IntegrationService namespace OpenSim.Services.IntegrationService
{ {
// This will maintain the plugin repositories and plugins // This will maintain the plugin repositories and plugins
public class PluginManager public class PluginManager : SetupService
{ {
protected AddinRegistry m_Registry; protected AddinRegistry m_Registry;
protected SetupService m_Service; // protected SetupService m_Service;
public PluginManager(string registry_path) internal PluginManager( AddinRegistry r): base (r)
{ {
m_Registry = new AddinRegistry(registry_path); m_Registry = r;
m_Service = new SetupService(m_Registry);
} }
public string Install() // public PluginManager(string registry_path)
// {
// m_Registry = new AddinRegistry(registry_path);
// m_Service = new SetupService(m_Registry);
// }
//
public string InstallPlugin(string[] args)
{ {
return "Install"; PackageCollection pack = new PackageCollection();
PackageCollection toUninstall;
DependencyCollection unresolved;
IProgressStatus ps = new ConsoleProgressStatus(true);
string name = Addin.GetIdName(args[1]);
string version = Addin.GetIdVersion(args[1]);
AddinRepositoryEntry[] aentry = Repositories.GetAvailableAddin(name, version);
foreach (AddinRepositoryEntry ae in aentry)
{
Package p = Package.FromRepository(ae);
pack.Add(p);
}
ResolveDependencies(ps, pack, out toUninstall, out unresolved);
if(Install(ps, pack) == true)
return "Install";
else
return "Bomb";
} }
public string UnInstall() public void UnInstall(string[] args)
{ {
return "UnInstall"; IProgressStatus ps = new ConsoleProgressStatus(true);
Addin addin = m_Registry.GetAddin(args[1]);
Uninstall(ps, addin.Id);
return;
} }
public string CheckInstalled() public string CheckInstalled()
@ -67,21 +103,24 @@ namespace OpenSim.Services.IntegrationService
MainConsole.Instance.Output("Installed Plugins"); MainConsole.Instance.Output("Installed Plugins");
foreach (Addin addin in list) foreach (Addin addin in list)
{ {
MainConsole.Instance.Output(" - " + addin.Name + " " + addin.Version); MainConsole.Instance.OutputFormat("* {0} rev. {1}", addin.Name, addin.Version);
} }
return; return;
} }
public void ListAvailable() public ArrayList ListAvailable()
{ {
MainConsole.Instance.Output("Available Plugins"); AddinRepositoryEntry[] addins = Repositories.GetAvailableAddins ();
AddinRepositoryEntry[] addins = m_Service.Repositories.GetAvailableAddins (); ArrayList list = new ArrayList();
// foreach (PackageRepositoryEntry addin in addins)
foreach (AddinRepositoryEntry addin in addins) foreach (AddinRepositoryEntry addin in addins)
{ {
MainConsole.Instance.OutputFormat("{0} - {1} ",addin.Addin.Name, addin.RepositoryName ); StringBuilder sb = new StringBuilder();
sb.Append(String.Format("{0} rev. {1}, repo {2}", addin.Addin.Id, addin.Addin.Version, addin.RepositoryUrl));
list.Add(sb.ToString());
} }
return list;
} }
public string ListUpdates() public string ListUpdates()
@ -94,8 +133,9 @@ namespace OpenSim.Services.IntegrationService
return "Update"; return "Update";
} }
public string AddRepository() public string AddRepository(string[] args)
{ {
Repositories.RegisterRepository(null, args[2].ToString(), true);
return "AddRepository"; return "AddRepository";
} }
@ -104,24 +144,14 @@ namespace OpenSim.Services.IntegrationService
return "GetRepository"; return "GetRepository";
} }
public string RemoveRepository() public string RemoveRepository(string[] args)
{ {
return "RemoveRepository"; return "RemoveRepository";
} }
public string EnableRepository(string[] args) public void EnableRepository(string[] args)
{ {
return "Test"; AddinRepository[] reps = Repositories.GetRepositories();
}
public string DisableRepository()
{
return DisableRepository();
}
public void ListRepositories()
{
AddinRepository[] reps = m_Service.Repositories.GetRepositories();
Array.Sort (reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); Array.Sort (reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
if (reps.Length == 0) if (reps.Length == 0)
{ {
@ -129,20 +159,73 @@ namespace OpenSim.Services.IntegrationService
return; return;
} }
int n = 0; int n = Convert.ToInt16(args[2]);
MainConsole.Instance.Output("Registered Repositories"); if (n > (reps.Length -1))
{
MainConsole.Instance.Output("Selection out of range");
return;
}
AddinRepository rep = reps[n];
//return "TEST";
Repositories.SetRepositoryEnabled(rep.Url, true);
return;
//return DisableRepository();
}
public void DisableRepository(string[] args)
{
AddinRepository[] reps = Repositories.GetRepositories();
Array.Sort (reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
if (reps.Length == 0)
{
MainConsole.Instance.Output("No repositories have been registered.");
return;
}
int n = Convert.ToInt16(args[2]);
if (n > (reps.Length -1))
{
MainConsole.Instance.Output("Selection out of range");
return;
}
AddinRepository rep = reps[n];
//return "TEST";
Repositories.SetRepositoryEnabled(rep.Url, false);
return;
//return DisableRepository();
}
public ArrayList ListRepositories()
{
AddinRepository[] reps = Repositories.GetRepositories();
Array.Sort (reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
if (reps.Length == 0)
{
MainConsole.Instance.Output("No repositories have been registered.");
return null;
}
ArrayList list = new ArrayList();
int n = 0;
foreach (AddinRepository rep in reps) foreach (AddinRepository rep in reps)
{ {
string num = n.ToString (); StringBuilder sb = new StringBuilder();
MainConsole.Instance.Output(num + ") ");
sb.AppendFormat("{0}) ", n.ToString());
if (!rep.Enabled) if (!rep.Enabled)
MainConsole.Instance.Output("(Disabled) "); sb.AppendFormat("(Disabled) ");
MainConsole.Instance.Output(rep.Title); sb.AppendFormat("{0}", rep.Title);
if (rep.Title != rep.Url) if (rep.Title != rep.Url)
MainConsole.Instance.Output(new string (' ', num.Length + 2) + rep.Url); sb.AppendFormat("{0}", rep.Url);
list.Add(sb.ToString());
n++; n++;
} }
return list;
} }
public void UpdateRegistry() public void UpdateRegistry()