aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
diff options
context:
space:
mode:
authorMic Bowman2013-07-31 11:27:35 -0700
committerMic Bowman2013-07-31 11:27:35 -0700
commit64f2dc778ad7a080ba89a1077da538c011c7c934 (patch)
tree963b456d229b7b986b8f8a6ce251e52774de474d /OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
parentAvoid another null ref opportunity. (diff)
downloadopensim-SC-64f2dc778ad7a080ba89a1077da538c011c7c934.zip
opensim-SC-64f2dc778ad7a080ba89a1077da538c011c7c934.tar.gz
opensim-SC-64f2dc778ad7a080ba89a1077da538c011c7c934.tar.bz2
opensim-SC-64f2dc778ad7a080ba89a1077da538c011c7c934.tar.xz
A pretty major restructuring of the simian method invocations in order to
service access capabilities. In conjunction with the corresponding Simian updates, this enables explicit per-simulator capability-based access to grid services. That enables grid owners to add or revoke access to the grid on a simulator by simulator basis.
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs114
1 files changed, 114 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
index 847319c..a4dd36c 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
@@ -26,8 +26,122 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30using System.Collections.Specialized;
31using System.Reflection;
32
33using log4net;
29using Mono.Addins; 34using Mono.Addins;
30using Nini.Config; 35using Nini.Config;
31 36
37using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces;
41using OpenMetaverse;
42using OpenMetaverse.StructuredData;
43
32[assembly: Addin("SimianGrid", "1.0")] 44[assembly: Addin("SimianGrid", "1.0")]
33[assembly: AddinDependency("OpenSim", "0.5")] 45[assembly: AddinDependency("OpenSim", "0.5")]
46
47namespace OpenSim.Services.Connectors.SimianGrid
48{
49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")]
50 public class SimianGrid : ISharedRegionModule
51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 private IConfig m_config = null;
55 private bool m_enabled = true;
56
57 private String m_simianURL;
58
59#region IRegionModule Members
60
61 public string Name
62 {
63 get { return this.GetType().Name; }
64 }
65
66
67 public void Initialise(IConfigSource config)
68 {
69 try
70 {
71 m_config = config.Configs["SimianGrid"];
72
73 if (m_config != null)
74 {
75 m_simianURL = m_config.GetString("SimianServiceURL");
76 if (String.IsNullOrEmpty(m_simianURL))
77 m_log.ErrorFormat("[SimianGrid] service URL is not defined");
78
79 InitialiseSimCap();
80 SimulatorCapability = SimulatorCapability.Trim();
81 m_log.WarnFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability);
82 }
83 }
84 catch (Exception e)
85 {
86 m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
87 return;
88 }
89 }
90
91 public void PostInitialise() { }
92 public void Close() { }
93 public void AddRegion(Scene scene) { }
94 public void RemoveRegion(Scene scene) { }
95 public void RegionLoaded(Scene scene) { }
96
97 public Type ReplaceableInterface
98 {
99 get { return null; }
100 }
101
102 ///<summary>
103 /// Try a variety of methods for finding the simian simulator capability; first check the
104 /// configuration itself, then look for a file that contains the cap, then finally look
105 /// for an environment variable that contains it.
106 ///</summary>
107 private void InitialiseSimCap()
108 {
109 if (m_config.Contains("SimulatorCapability"))
110 {
111 SimulatorCapability = m_config.GetString("SimulatorCapability");
112 return;
113 }
114
115 if (m_config.Contains("SimulatorCapabilityFile"))
116 {
117 String filename = m_config.GetString("SimulatorCapabilityFile");
118 if (System.IO.File.Exists(filename))
119 {
120 SimulatorCapability = System.IO.File.ReadAllText(filename);
121 return;
122 }
123 }
124
125 if (m_config.Contains("SimulatorCapabilityVariable"))
126 {
127 String envname = m_config.GetString("SimulatorCapabilityVariable");
128 String envvalue = System.Environment.GetEnvironmentVariable(envname);
129 if (envvalue != null)
130 {
131 SimulatorCapability = envvalue;
132 return;
133 }
134 }
135
136 m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability");
137 }
138
139#endregion
140 public static String SimulatorCapability = UUID.Zero.ToString();
141 public static OSDMap PostToService(string url, NameValueCollection data)
142 {
143 data["cap"] = SimulatorCapability;
144 return WebUtil.PostToService(url, data);
145 }
146 }
147}