Plugin manager generic result for use by command line or rest interface
parent
3c03418e06
commit
40828910e7
|
@ -29,6 +29,7 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Linq;
|
||||||
using OpenSim.Server.Base;
|
using OpenSim.Server.Base;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
@ -130,12 +131,15 @@ namespace OpenSim.Services.IntegrationService
|
||||||
|
|
||||||
#region console handlers
|
#region console handlers
|
||||||
// Handle our console commands
|
// Handle our console commands
|
||||||
|
//
|
||||||
|
// Install plugin from registered repository
|
||||||
private void HandleConsoleInstallPlugin(string module, string[] cmd)
|
private void HandleConsoleInstallPlugin(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output(m_PluginManager.InstallPlugin(cmd));
|
MainConsole.Instance.Output(m_PluginManager.InstallPlugin(cmd));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove installed plugin
|
||||||
private void HandleConsoleUnInstallPlugin(string module, string[] cmd)
|
private void HandleConsoleUnInstallPlugin(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
if (cmd.Length == 2)
|
if (cmd.Length == 2)
|
||||||
|
@ -145,18 +149,36 @@ namespace OpenSim.Services.IntegrationService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check installed plugins **not working
|
||||||
private void HandleConsoleCheckInstalledPlugin(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List installed plugins
|
||||||
private void HandleConsoleListInstalledPlugin(string module, string[] cmd)
|
private void HandleConsoleListInstalledPlugin(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
m_PluginManager.ListInstalledAddins();
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
m_PluginManager.ListInstalledAddins(out result);
|
||||||
|
|
||||||
|
ArrayList s = new ArrayList();
|
||||||
|
s.AddRange(result.Keys);
|
||||||
|
s.Sort();
|
||||||
|
|
||||||
|
foreach (string k in s)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
|
||||||
|
bool enabled = (bool)plugin["enabled"];
|
||||||
|
MainConsole.Instance.OutputFormat("{0}) {1} {2} rev. {3}",
|
||||||
|
k,
|
||||||
|
enabled == true ? "[ ]" : "[X]",
|
||||||
|
plugin["name"], plugin["version"]);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List available plugins on registered repositories
|
||||||
private void HandleConsoleListAvailablePlugin(string module, string[] cmd)
|
private void HandleConsoleListAvailablePlugin(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
ArrayList list = m_PluginManager.ListAvailable();
|
ArrayList list = m_PluginManager.ListAvailable();
|
||||||
|
@ -166,18 +188,21 @@ namespace OpenSim.Services.IntegrationService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List available updates **not ready
|
||||||
private void HandleConsoleListUpdates(string module, string[] cmd)
|
private void HandleConsoleListUpdates(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
m_PluginManager.ListUpdates();
|
m_PluginManager.ListUpdates();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update plugin **not ready
|
||||||
private void HandleConsoleUpdatePlugin(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register repository
|
||||||
private void HandleConsoleAddRepo(string module, string[] cmd)
|
private void HandleConsoleAddRepo(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
if ( cmd.Length == 3)
|
if ( cmd.Length == 3)
|
||||||
|
@ -187,12 +212,14 @@ namespace OpenSim.Services.IntegrationService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get repository status **not working
|
||||||
private void HandleConsoleGetRepo(string module, string[] cmd)
|
private void HandleConsoleGetRepo(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
m_PluginManager.GetRepository();
|
m_PluginManager.GetRepository();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove registered repository
|
||||||
private void HandleConsoleRemoveRepo(string module, string[] cmd)
|
private void HandleConsoleRemoveRepo(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
if (cmd.Length == 3)
|
if (cmd.Length == 3)
|
||||||
|
@ -200,7 +227,7 @@ namespace OpenSim.Services.IntegrationService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable repo
|
// Enable repository
|
||||||
private void HandleConsoleEnableRepo(string module, string[] cmd)
|
private void HandleConsoleEnableRepo(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
m_PluginManager.EnableRepository(cmd);
|
m_PluginManager.EnableRepository(cmd);
|
||||||
|
@ -249,33 +276,6 @@ namespace OpenSim.Services.IntegrationService
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// #region web handlers
|
|
||||||
// public byte[] HandleWebListPlugins(OSDMap request)
|
|
||||||
// {
|
|
||||||
// return Ux.FailureResult("Not Implemented");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public byte[] HandleWebPluginInfo(OSDMap request)
|
|
||||||
// {
|
|
||||||
// return Ux.FailureResult("Not Implemented");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public byte[] HandleWebListAvailablePlugins(OSDMap request)
|
|
||||||
// {
|
|
||||||
// return Ux.FailureResult("Not Implemented");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public byte[] HandleWebInstallPlugin(OSDMap request)
|
|
||||||
// {
|
|
||||||
// return Ux.FailureResult("Not Implemented");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public byte[] HandleWebUnInstallPlugin(OSDMap request)
|
|
||||||
// {
|
|
||||||
// return Ux.FailureResult("Not Implemented");
|
|
||||||
// }
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
#region IIntegrationService implementation
|
#region IIntegrationService implementation
|
||||||
public byte[] HandleWebListRepositories (OSDMap request)
|
public byte[] HandleWebListRepositories (OSDMap request)
|
||||||
{
|
{
|
||||||
|
@ -304,7 +304,10 @@ namespace OpenSim.Services.IntegrationService
|
||||||
|
|
||||||
public byte[] HandleWebListPlugins(OSDMap request)
|
public byte[] HandleWebListPlugins(OSDMap request)
|
||||||
{
|
{
|
||||||
return Ux.FailureResult("Not Implemented");
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
m_PluginManager.ListInstalledAddins(out result);
|
||||||
|
string json = LitJson.JsonMapper.ToJson(result);
|
||||||
|
return Ux.DocToBytes(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] HandleWebPluginInfo (OSDMap request)
|
public byte[] HandleWebPluginInfo (OSDMap request)
|
||||||
|
|
|
@ -101,6 +101,11 @@ namespace OpenSim.Services.IntegrationService
|
||||||
{
|
{
|
||||||
return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(doc));
|
return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(doc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] DocToBytes(string json)
|
||||||
|
{
|
||||||
|
return Encoding.UTF8.GetBytes(json);
|
||||||
|
}
|
||||||
#endregion web utils
|
#endregion web utils
|
||||||
|
|
||||||
#region config utils
|
#region config utils
|
||||||
|
|
|
@ -35,7 +35,6 @@ using Mono.Addins;
|
||||||
using Mono.Addins.Setup;
|
using Mono.Addins.Setup;
|
||||||
using Mono.Addins.Description;
|
using Mono.Addins.Description;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
using Ux = OpenSim.Services.IntegrationService.IUtils;
|
using Ux = OpenSim.Services.IntegrationService.IUtils;
|
||||||
|
|
||||||
namespace OpenSim.Services.IntegrationService
|
namespace OpenSim.Services.IntegrationService
|
||||||
|
@ -78,9 +77,13 @@ namespace OpenSim.Services.IntegrationService
|
||||||
|
|
||||||
ResolveDependencies(ps, pack, out toUninstall, out unresolved);
|
ResolveDependencies(ps, pack, out toUninstall, out unresolved);
|
||||||
|
|
||||||
|
// Attempt to install the plugin disabled
|
||||||
if (Install(ps, pack) == true)
|
if (Install(ps, pack) == true)
|
||||||
{
|
{
|
||||||
m_Registry.Update(ps);
|
m_Registry.Update(ps);
|
||||||
|
Addin addin = m_Registry.GetAddin(aentry.Addin.Id);
|
||||||
|
m_Registry.DisableAddin(addin.Id);
|
||||||
|
addin.Enabled = false;
|
||||||
return "Install";
|
return "Install";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -116,20 +119,26 @@ namespace OpenSim.Services.IntegrationService
|
||||||
}
|
}
|
||||||
|
|
||||||
// List instaled addins
|
// List instaled addins
|
||||||
public void ListInstalledAddins()
|
public void ListInstalledAddins(out Dictionary<string, object> result)
|
||||||
{
|
{
|
||||||
Addin[] addins = GetSortedAddinList("IntegrationPlugin");
|
Dictionary<string, object> res = new Dictionary<string, object>();
|
||||||
|
|
||||||
MainConsole.Instance.Output("Installed Plugins");
|
Addin[] addins = GetSortedAddinList("IntegrationPlugin");
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (Addin addin in addins)
|
foreach (Addin addin in addins)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.OutputFormat("{0}) {1} {2} rev. {3}", count.ToString(),
|
Dictionary<string, object> r = new Dictionary<string, object>();
|
||||||
addin.Enabled == false ? "[X]" : "[ ]",
|
r["enabled"] = addin.Enabled == true ? true : false;
|
||||||
addin.Name, addin.Version );
|
r["name"] = addin.LocalId;
|
||||||
|
r["version"] = addin.Version;
|
||||||
|
|
||||||
|
res.Add(count.ToString(), r);
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = res;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue