aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGridServices.GridServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices/OpenGridServices.GridServer')
-rw-r--r--OpenGridServices/OpenGridServices.GridServer/GridManager.cs589
-rw-r--r--OpenGridServices/OpenGridServices.GridServer/Main.cs271
-rw-r--r--OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj134
-rw-r--r--OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build52
-rw-r--r--OpenGridServices/OpenGridServices.GridServer/Properties/AssemblyInfo.cs33
5 files changed, 0 insertions, 1079 deletions
diff --git a/OpenGridServices/OpenGridServices.GridServer/GridManager.cs b/OpenGridServices/OpenGridServices.GridServer/GridManager.cs
deleted file mode 100644
index 45d3676..0000000
--- a/OpenGridServices/OpenGridServices.GridServer/GridManager.cs
+++ /dev/null
@@ -1,589 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using System.Reflection;
33using OpenGrid.Framework.Data;
34using OpenSim.Framework.Utilities;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Sims;
37using libsecondlife;
38using Nwc.XmlRpc;
39using System.Xml;
40
41namespace OpenGridServices.GridServer
42{
43 class GridManager
44 {
45 Dictionary<string, IGridData> _plugins = new Dictionary<string, IGridData>();
46 Dictionary<string, ILogData> _logplugins = new Dictionary<string, ILogData>();
47
48 public OpenSim.Framework.Interfaces.GridConfig config;
49
50 /// <summary>
51 /// Adds a new grid server plugin - grid servers will be requested in the order they were loaded.
52 /// </summary>
53 /// <param name="FileName">The filename to the grid server plugin DLL</param>
54 public void AddPlugin(string FileName)
55 {
56 OpenSim.Framework.Console.MainConsole.Instance.Verbose("Storage: Attempting to load " + FileName);
57 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
58
59 OpenSim.Framework.Console.MainConsole.Instance.Verbose("Storage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
60 foreach (Type pluginType in pluginAssembly.GetTypes())
61 {
62 if (!pluginType.IsAbstract)
63 {
64 // Regions go here
65 Type typeInterface = pluginType.GetInterface("IGridData", true);
66
67 if (typeInterface != null)
68 {
69 IGridData plug = (IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
70 plug.Initialise();
71 this._plugins.Add(plug.getName(), plug);
72 OpenSim.Framework.Console.MainConsole.Instance.Verbose("Storage: Added IGridData Interface");
73 }
74
75 typeInterface = null;
76
77 // Logs go here
78 typeInterface = pluginType.GetInterface("ILogData", true);
79
80 if (typeInterface != null)
81 {
82 ILogData plug = (ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
83 plug.Initialise();
84 this._logplugins.Add(plug.getName(), plug);
85 OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Storage: Added ILogData Interface");
86 }
87
88 typeInterface = null;
89 }
90 }
91
92 pluginAssembly = null;
93 }
94
95 /// <summary>
96 /// Logs a piece of information to the database
97 /// </summary>
98 /// <param name="target">What you were operating on (in grid server, this will likely be the region UUIDs)</param>
99 /// <param name="method">Which method is being called?</param>
100 /// <param name="args">What arguments are being passed?</param>
101 /// <param name="priority">How high priority is this? 1 = Max, 6 = Verbose</param>
102 /// <param name="message">The message to log</param>
103 private void logToDB(string target, string method, string args, int priority, string message)
104 {
105 foreach (KeyValuePair<string, ILogData> kvp in _logplugins)
106 {
107 try
108 {
109 kvp.Value.saveLog("Gridserver", target, method, args, priority, message);
110 }
111 catch (Exception e)
112 {
113 OpenSim.Framework.Console.MainConsole.Instance.Warn("Storage: unable to write log via " + kvp.Key);
114 }
115 }
116 }
117
118 /// <summary>
119 /// Returns a region by argument
120 /// </summary>
121 /// <param name="uuid">A UUID key of the region to return</param>
122 /// <returns>A SimProfileData for the region</returns>
123 public SimProfileData getRegion(libsecondlife.LLUUID uuid)
124 {
125 foreach(KeyValuePair<string,IGridData> kvp in _plugins) {
126 try
127 {
128 return kvp.Value.GetProfileByLLUUID(uuid);
129 }
130 catch (Exception e)
131 {
132 OpenSim.Framework.Console.MainConsole.Instance.Warn("Storage: Unable to find region " + uuid.ToStringHyphenated() + " via " + kvp.Key);
133 }
134 }
135 return null;
136 }
137
138 /// <summary>
139 /// Returns a region by argument
140 /// </summary>
141 /// <param name="uuid">A regionHandle of the region to return</param>
142 /// <returns>A SimProfileData for the region</returns>
143 public SimProfileData getRegion(ulong handle)
144 {
145 foreach (KeyValuePair<string, IGridData> kvp in _plugins)
146 {
147 try
148 {
149 return kvp.Value.GetProfileByHandle(handle);
150 }
151 catch (Exception e)
152 {
153 OpenSim.Framework.Console.MainConsole.Instance.Warn("Storage: Unable to find region " + handle.ToString() + " via " + kvp.Key);
154 }
155 }
156 return null;
157 }
158
159 public Dictionary<ulong, SimProfileData> getRegions(uint xmin, uint ymin, uint xmax, uint ymax)
160 {
161 Dictionary<ulong, SimProfileData> regions = new Dictionary<ulong, SimProfileData>();
162
163 SimProfileData[] neighbours;
164
165 foreach (KeyValuePair<string, IGridData> kvp in _plugins)
166 {
167 try
168 {
169 neighbours = kvp.Value.GetProfilesInRange(xmin, ymin, xmax, ymax);
170 foreach (SimProfileData neighbour in neighbours)
171 {
172 regions[neighbour.regionHandle] = neighbour;
173 }
174 }
175 catch (Exception e)
176 {
177 OpenSim.Framework.Console.MainConsole.Instance.Warn("Storage: Unable to query regionblock via " + kvp.Key);
178 }
179 }
180
181 return regions;
182 }
183
184 /// <summary>
185 /// Returns a XML String containing a list of the neighbouring regions
186 /// </summary>
187 /// <param name="reqhandle">The regionhandle for the center sim</param>
188 /// <returns>An XML string containing neighbour entities</returns>
189 public string GetXMLNeighbours(ulong reqhandle)
190 {
191 string response = "";
192 SimProfileData central_region = getRegion(reqhandle);
193 SimProfileData neighbour;
194 for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++)
195 {
196 if (getRegion(Util.UIntsToLong((uint)((central_region.regionLocX + x) * 256), (uint)(central_region.regionLocY + y) * 256)) != null)
197 {
198 neighbour = getRegion(Util.UIntsToLong((uint)((central_region.regionLocX + x) * 256), (uint)(central_region.regionLocY + y) * 256));
199 response += "<neighbour>";
200 response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>";
201 response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>";
202 response += "<locx>" + neighbour.regionLocX.ToString() + "</locx>";
203 response += "<locy>" + neighbour.regionLocY.ToString() + "</locy>";
204 response += "<regionhandle>" + neighbour.regionHandle.ToString() + "</regionhandle>";
205 response += "</neighbour>";
206
207 }
208 }
209 return response;
210 }
211
212 /// <summary>
213 /// Performed when a region connects to the grid server initially.
214 /// </summary>
215 /// <param name="request">The XMLRPC Request</param>
216 /// <returns>Startup parameters</returns>
217 public XmlRpcResponse XmlRpcLoginToSimulatorMethod(XmlRpcRequest request)
218 {
219 XmlRpcResponse response = new XmlRpcResponse();
220 Hashtable responseData = new Hashtable();
221 response.Value = responseData;
222
223 SimProfileData TheSim = null;
224 Hashtable requestData = (Hashtable)request.Params[0];
225
226 if (requestData.ContainsKey("UUID"))
227 {
228 TheSim = getRegion(new LLUUID((string)requestData["UUID"]));
229 logToDB((new LLUUID((string)requestData["UUID"])).ToStringHyphenated(),"XmlRpcLoginToSimulatorMethod","", 5,"Region attempting login with UUID.");
230 }
231 else if (requestData.ContainsKey("region_handle"))
232 {
233 TheSim = getRegion((ulong)Convert.ToUInt64(requestData["region_handle"]));
234 logToDB((string)requestData["region_handle"], "XmlRpcLoginToSimulatorMethod", "", 5, "Region attempting login with regionHandle.");
235 }
236 else
237 {
238 responseData["error"] = "No UUID or region_handle passed to grid server - unable to connect you";
239 return response;
240 }
241
242 if (TheSim == null)
243 {
244 responseData["error"] = "sim not found";
245 return response;
246 }
247 else
248 {
249
250 ArrayList SimNeighboursData = new ArrayList();
251
252 SimProfileData neighbour;
253 Hashtable NeighbourBlock;
254
255 bool fastMode = false; // Only compatible with MySQL right now
256
257 if (fastMode)
258 {
259 Dictionary<ulong, SimProfileData> neighbours = getRegions(TheSim.regionLocX - 1, TheSim.regionLocY - 1, TheSim.regionLocX + 1, TheSim.regionLocY + 1);
260
261 foreach (KeyValuePair<ulong, SimProfileData> aSim in neighbours)
262 {
263 NeighbourBlock = new Hashtable();
264 NeighbourBlock["sim_ip"] = aSim.Value.serverIP.ToString();
265 NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString();
266 NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString();
267 NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString();
268 NeighbourBlock["UUID"] = aSim.Value.UUID.ToString();
269
270 if (aSim.Value.UUID != TheSim.UUID)
271 SimNeighboursData.Add(NeighbourBlock);
272 }
273 }
274 else
275 {
276 for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++)
277 {
278 if (getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256)) != null)
279 {
280 neighbour = getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256));
281
282 NeighbourBlock = new Hashtable();
283 NeighbourBlock["sim_ip"] = neighbour.serverIP;
284 NeighbourBlock["sim_port"] = neighbour.serverPort.ToString();
285 NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString();
286 NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString();
287 NeighbourBlock["UUID"] = neighbour.UUID.ToString();
288
289 if (neighbour.UUID != TheSim.UUID) SimNeighboursData.Add(NeighbourBlock);
290 }
291 }
292 }
293
294 responseData["UUID"] = TheSim.UUID.ToString();
295 responseData["region_locx"] = TheSim.regionLocX.ToString();
296 responseData["region_locy"] = TheSim.regionLocY.ToString();
297 responseData["regionname"] = TheSim.regionName;
298 responseData["estate_id"] = "1";
299 responseData["neighbours"] = SimNeighboursData;
300
301 responseData["sim_ip"] = TheSim.serverIP;
302 responseData["sim_port"] = TheSim.serverPort.ToString();
303 responseData["asset_url"] = TheSim.regionAssetURI;
304 responseData["asset_sendkey"] = TheSim.regionAssetSendKey;
305 responseData["asset_recvkey"] = TheSim.regionAssetRecvKey;
306 responseData["user_url"] = TheSim.regionUserURI;
307 responseData["user_sendkey"] = TheSim.regionUserSendKey;
308 responseData["user_recvkey"] = TheSim.regionUserRecvKey;
309 responseData["authkey"] = TheSim.regionSecret;
310
311 // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap)
312 responseData["data_uri"] = TheSim.regionDataURI;
313 }
314
315 return response;
316 }
317
318 public XmlRpcResponse XmlRpcMapBlockMethod(XmlRpcRequest request)
319 {
320 int xmin=980, ymin=980, xmax=1020, ymax=1020;
321
322 Hashtable requestData = (Hashtable)request.Params[0];
323 if (requestData.ContainsKey("xmin"))
324 {
325 xmin = (Int32)requestData["xmin"];
326 }
327 if (requestData.ContainsKey("ymin"))
328 {
329 ymin = (Int32)requestData["ymin"];
330 }
331 if (requestData.ContainsKey("xmax"))
332 {
333 xmax = (Int32)requestData["xmax"];
334 }
335 if (requestData.ContainsKey("ymax"))
336 {
337 ymax = (Int32)requestData["ymax"];
338 }
339
340 XmlRpcResponse response = new XmlRpcResponse();
341 Hashtable responseData = new Hashtable();
342 response.Value = responseData;
343 IList simProfileList = new ArrayList();
344
345 bool fastMode = true; // MySQL Only
346
347 if (fastMode)
348 {
349 Dictionary<ulong, SimProfileData> neighbours = getRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax);
350
351 foreach (KeyValuePair<ulong, SimProfileData> aSim in neighbours)
352 {
353 Hashtable simProfileBlock = new Hashtable();
354 simProfileBlock["x"] = aSim.Value.regionLocX.ToString();
355 simProfileBlock["y"] = aSim.Value.regionLocY.ToString();
356 simProfileBlock["name"] = aSim.Value.regionName;
357 simProfileBlock["access"] = 21;
358 simProfileBlock["region-flags"] = 512;
359 simProfileBlock["water-height"] = 0;
360 simProfileBlock["agents"] = 1;
361 simProfileBlock["map-image-id"] = aSim.Value.regionMapTextureID.ToString();
362
363 // For Sugilite compatibility
364 simProfileBlock["regionhandle"] = aSim.Value.regionHandle.ToString();
365 simProfileBlock["sim_ip"] = aSim.Value.serverIP.ToString();
366 simProfileBlock["sim_port"] = aSim.Value.serverPort.ToString();
367 simProfileBlock["sim_uri"] = aSim.Value.serverURI.ToString();
368 simProfileBlock["uuid"] = aSim.Value.UUID.ToStringHyphenated();
369
370 simProfileList.Add(simProfileBlock);
371 }
372 OpenSim.Framework.Console.MainConsole.Instance.Verbose("World map request processed, returned " + simProfileList.Count.ToString() + " region(s) in range via FastMode");
373 }
374 else
375 {
376 SimProfileData simProfile;
377 for (int x = xmin; x < xmax; x++)
378 {
379 for (int y = ymin; y < ymax; y++)
380 {
381 simProfile = getRegion(Helpers.UIntsToLong((uint)(x * 256), (uint)(y * 256)));
382 if (simProfile != null)
383 {
384 Hashtable simProfileBlock = new Hashtable();
385 simProfileBlock["x"] = x;
386 simProfileBlock["y"] = y;
387 simProfileBlock["name"] = simProfile.regionName;
388 simProfileBlock["access"] = 0;
389 simProfileBlock["region-flags"] = 0;
390 simProfileBlock["water-height"] = 20;
391 simProfileBlock["agents"] = 1;
392 simProfileBlock["map-image-id"] = simProfile.regionMapTextureID.ToString();
393
394 // For Sugilite compatibility
395 simProfileBlock["regionhandle"] = simProfile.regionHandle.ToString();
396 simProfileBlock["sim_ip"] = simProfile.serverIP.ToString();
397 simProfileBlock["sim_port"] = simProfile.serverPort.ToString();
398 simProfileBlock["sim_uri"] = simProfile.serverURI.ToString();
399 simProfileBlock["uuid"] = simProfile.UUID.ToStringHyphenated();
400
401 simProfileList.Add(simProfileBlock);
402 }
403 }
404 }
405 OpenSim.Framework.Console.MainConsole.Instance.Verbose("World map request processed, returned " + simProfileList.Count.ToString() + " region(s) in range via Standard Mode");
406 }
407
408 responseData["sim-profiles"] = simProfileList;
409
410 return response;
411 }
412
413
414
415 /// <summary>
416 /// Performs a REST Get Operation
417 /// </summary>
418 /// <param name="request"></param>
419 /// <param name="path"></param>
420 /// <param name="param"></param>
421 /// <returns></returns>
422 public string RestGetRegionMethod(string request, string path, string param)
423 {
424 return RestGetSimMethod("", "/sims/", param);
425 }
426
427 /// <summary>
428 /// Performs a REST Set Operation
429 /// </summary>
430 /// <param name="request"></param>
431 /// <param name="path"></param>
432 /// <param name="param"></param>
433 /// <returns></returns>
434 public string RestSetRegionMethod(string request, string path, string param)
435 {
436 return RestSetSimMethod("", "/sims/", param);
437 }
438
439 /// <summary>
440 /// Returns information about a sim via a REST Request
441 /// </summary>
442 /// <param name="request"></param>
443 /// <param name="path"></param>
444 /// <param name="param"></param>
445 /// <returns>Information about the sim in XML</returns>
446 public string RestGetSimMethod(string request, string path, string param)
447 {
448 string respstring = String.Empty;
449
450 SimProfileData TheSim;
451 LLUUID UUID = new LLUUID(param);
452 TheSim = getRegion(UUID);
453
454 if (!(TheSim == null))
455 {
456 respstring = "<Root>";
457 respstring += "<authkey>" + TheSim.regionSendKey + "</authkey>";
458 respstring += "<sim>";
459 respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>";
460 respstring += "<regionname>" + TheSim.regionName + "</regionname>";
461 respstring += "<sim_ip>" + TheSim.serverIP + "</sim_ip>";
462 respstring += "<sim_port>" + TheSim.serverPort.ToString() + "</sim_port>";
463 respstring += "<region_locx>" + TheSim.regionLocX.ToString() + "</region_locx>";
464 respstring += "<region_locy>" + TheSim.regionLocY.ToString() + "</region_locy>";
465 respstring += "<estate_id>1</estate_id>";
466 respstring += "</sim>";
467 respstring += "</Root>";
468 }
469
470 return respstring;
471 }
472
473 /// <summary>
474 /// Creates or updates a sim via a REST Method Request
475 /// BROKEN with SQL Update
476 /// </summary>
477 /// <param name="request"></param>
478 /// <param name="path"></param>
479 /// <param name="param"></param>
480 /// <returns>"OK" or an error</returns>
481 public string RestSetSimMethod(string request, string path, string param)
482 {
483 Console.WriteLine("Processing region update");
484 SimProfileData TheSim;
485 TheSim = getRegion(new LLUUID(param));
486 if ((TheSim) == null)
487 {
488 TheSim = new SimProfileData();
489 LLUUID UUID = new LLUUID(param);
490 TheSim.UUID = UUID;
491 TheSim.regionRecvKey = config.SimRecvKey;
492 }
493
494 XmlDocument doc = new XmlDocument();
495 doc.LoadXml(request);
496 XmlNode rootnode = doc.FirstChild;
497 XmlNode authkeynode = rootnode.ChildNodes[0];
498 if (authkeynode.Name != "authkey")
499 {
500 return "ERROR! bad XML - expected authkey tag";
501 }
502
503 XmlNode simnode = rootnode.ChildNodes[1];
504 if (simnode.Name != "sim")
505 {
506 return "ERROR! bad XML - expected sim tag";
507 }
508
509 if (authkeynode.InnerText != TheSim.regionRecvKey)
510 {
511 return "ERROR! invalid key";
512 }
513
514 //TheSim.regionSendKey = Cfg;
515 TheSim.regionRecvKey = config.SimRecvKey;
516 TheSim.regionSendKey = config.SimSendKey;
517 TheSim.regionSecret = config.SimRecvKey;
518 TheSim.regionDataURI = "";
519 TheSim.regionAssetURI = config.DefaultAssetServer;
520 TheSim.regionAssetRecvKey = config.AssetRecvKey;
521 TheSim.regionAssetSendKey = config.AssetSendKey;
522 TheSim.regionUserURI = config.DefaultUserServer;
523 TheSim.regionUserSendKey = config.UserSendKey;
524 TheSim.regionUserRecvKey = config.UserRecvKey;
525
526
527 for (int i = 0; i < simnode.ChildNodes.Count; i++)
528 {
529 switch (simnode.ChildNodes[i].Name)
530 {
531 case "regionname":
532 TheSim.regionName = simnode.ChildNodes[i].InnerText;
533 break;
534
535 case "sim_ip":
536 TheSim.serverIP = simnode.ChildNodes[i].InnerText;
537 break;
538
539 case "sim_port":
540 TheSim.serverPort = Convert.ToUInt32(simnode.ChildNodes[i].InnerText);
541 break;
542
543 case "region_locx":
544 TheSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
545 TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256));
546 break;
547
548 case "region_locy":
549 TheSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
550 TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256));
551 break;
552 }
553 }
554
555 TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/";
556
557 bool requirePublic = false;
558
559 if (requirePublic && (TheSim.serverIP.StartsWith("172.16") || TheSim.serverIP.StartsWith("192.168") || TheSim.serverIP.StartsWith("10.") || TheSim.serverIP.StartsWith("0.") || TheSim.serverIP.StartsWith("255.")))
560 {
561 return "ERROR! Servers must register with public addresses.";
562 }
563
564 try
565 {
566 OpenSim.Framework.Console.MainConsole.Instance.Verbose("Updating / adding via " + _plugins.Count + " storage provider(s) registered.");
567 foreach (KeyValuePair<string, IGridData> kvp in _plugins)
568 {
569 try
570 {
571 kvp.Value.AddProfile(TheSim);
572 OpenSim.Framework.Console.MainConsole.Instance.Verbose("New sim added to grid (" + TheSim.regionName + ")");
573 logToDB(TheSim.UUID.ToStringHyphenated(), "RestSetSimMethod", "", 5, "Region successfully updated and connected to grid.");
574 }
575 catch (Exception e)
576 {
577 OpenSim.Framework.Console.MainConsole.Instance.Verbose("getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + e.ToString());
578 }
579 }
580 return "OK";
581 }
582 catch (Exception e)
583 {
584 return "ERROR! Could not save to database! (" + e.ToString() + ")";
585 }
586 }
587
588 }
589}
diff --git a/OpenGridServices/OpenGridServices.GridServer/Main.cs b/OpenGridServices/OpenGridServices.GridServer/Main.cs
deleted file mode 100644
index 9a7eb00..0000000
--- a/OpenGridServices/OpenGridServices.GridServer/Main.cs
+++ /dev/null
@@ -1,271 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.IO;
31using System.Text;
32using System.Timers;
33using System.Net;
34using System.Threading;
35using System.Reflection;
36using libsecondlife;
37using OpenGrid.Framework.Manager;
38using OpenSim.Framework;
39using OpenSim.Framework.Sims;
40using OpenSim.Framework.Console;
41using OpenSim.Framework.Interfaces;
42using OpenSim.Servers;
43using OpenSim.GenericConfig;
44
45namespace OpenGridServices.GridServer
46{
47 /// <summary>
48 /// </summary>
49 public class OpenGrid_Main : BaseServer, conscmd_callback
50 {
51 private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll";
52 private string GridDll = "OpenGrid.Framework.Data.MySQL.dll";
53 public GridConfig Cfg;
54
55 public static OpenGrid_Main thegrid;
56 protected IGenericConfig localXMLConfig;
57
58 public static bool setuponly;
59
60 //public LLUUID highestUUID;
61
62 // private SimProfileManager m_simProfileManager;
63
64 private GridManager m_gridManager;
65
66 private ConsoleBase m_console;
67
68 [STAThread]
69 public static void Main(string[] args)
70 {
71 if (args.Length > 0)
72 {
73 if (args[0] == "-setuponly") setuponly = true;
74 }
75 Console.WriteLine("Starting...\n");
76
77 thegrid = new OpenGrid_Main();
78 thegrid.Startup();
79
80 thegrid.Work();
81 }
82
83 private void Work()
84 {
85 while (true)
86 {
87 Thread.Sleep(5000);
88 // should flush the DB etc here
89 }
90 }
91
92 private OpenGrid_Main()
93 {
94 m_console = new ConsoleBase("opengrid-gridserver-console.log", "OpenGrid", this, false);
95 MainConsole.Instance = m_console;
96
97
98 }
99
100 public void managercallback(string cmd)
101 {
102 switch (cmd)
103 {
104 case "shutdown":
105 RunCmd("shutdown", new string[0]);
106 break;
107 }
108 }
109
110
111 public void Startup()
112 {
113 this.localXMLConfig = new XmlConfig("GridServerConfig.xml");
114 this.localXMLConfig.LoadData();
115 this.ConfigDB(this.localXMLConfig);
116 this.localXMLConfig.Close();
117
118 m_console.Verbose( "Main.cs:Startup() - Loading configuration");
119 Cfg = this.LoadConfigDll(this.ConfigDll);
120 Cfg.InitConfig();
121 if (setuponly) Environment.Exit(0);
122
123 m_console.Verbose( "Main.cs:Startup() - Connecting to Storage Server");
124 m_gridManager = new GridManager();
125 m_gridManager.AddPlugin(GridDll); // Made of win
126 m_gridManager.config = Cfg;
127
128 m_console.Verbose( "Main.cs:Startup() - Starting HTTP process");
129 BaseHttpServer httpServer = new BaseHttpServer(8001);
130 //GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback);
131
132 httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcLoginToSimulatorMethod);
133 httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod);
134
135 httpServer.AddRestHandler("GET", "/sims/", m_gridManager.RestGetSimMethod);
136 httpServer.AddRestHandler("POST", "/sims/", m_gridManager.RestSetSimMethod);
137 httpServer.AddRestHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod);
138 httpServer.AddRestHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod);
139
140
141 // lbsa71 : This code snippet taken from old http server.
142 // I have no idea what this was supposed to do - looks like an infinite recursion to me.
143 // case "regions":
144 //// DIRTY HACK ALERT
145 //Console.Notice("/regions/ accessed");
146 //TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle((ulong)Convert.ToUInt64(rest_params[1]));
147 //respstring = ParseREST("/regions/" + rest_params[1], requestBody, HTTPmethod);
148 //break;
149
150 // lbsa71 : I guess these were never used?
151 //Listener.Prefixes.Add("http://+:8001/gods/");
152 //Listener.Prefixes.Add("http://+:8001/highestuuid/");
153 //Listener.Prefixes.Add("http://+:8001/uuidblocks/");
154
155 httpServer.Start();
156
157 m_console.Verbose( "Main.cs:Startup() - Starting sim status checker");
158
159 System.Timers.Timer simCheckTimer = new System.Timers.Timer(3600000 * 3); // 3 Hours between updates.
160 simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
161 simCheckTimer.Enabled = true;
162 }
163
164 private GridConfig LoadConfigDll(string dllName)
165 {
166 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
167 GridConfig config = null;
168
169 foreach (Type pluginType in pluginAssembly.GetTypes())
170 {
171 if (pluginType.IsPublic)
172 {
173 if (!pluginType.IsAbstract)
174 {
175 Type typeInterface = pluginType.GetInterface("IGridConfig", true);
176
177 if (typeInterface != null)
178 {
179 IGridConfig plug = (IGridConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
180 config = plug.GetConfigObject();
181 break;
182 }
183
184 typeInterface = null;
185 }
186 }
187 }
188 pluginAssembly = null;
189 return config;
190 }
191
192 public void CheckSims(object sender, ElapsedEventArgs e)
193 {
194 /*
195 foreach (SimProfileBase sim in m_simProfileManager.SimProfiles.Values)
196 {
197 string SimResponse = "";
198 try
199 {
200 WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/");
201 CheckSim.Method = "GET";
202 CheckSim.ContentType = "text/plaintext";
203 CheckSim.ContentLength = 0;
204
205 StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII);
206 stOut.Write("");
207 stOut.Close();
208
209 StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream());
210 SimResponse = stIn.ReadToEnd();
211 stIn.Close();
212 }
213 catch
214 {
215 }
216
217 if (SimResponse == "OK")
218 {
219 m_simProfileManager.SimProfiles[sim.UUID].online = true;
220 }
221 else
222 {
223 m_simProfileManager.SimProfiles[sim.UUID].online = false;
224 }
225 }
226 */
227 }
228
229 public void RunCmd(string cmd, string[] cmdparams)
230 {
231 switch (cmd)
232 {
233 case "help":
234 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
235 break;
236
237 case "shutdown":
238 m_console.Close();
239 Environment.Exit(0);
240 break;
241 }
242 }
243
244 public void Show(string ShowWhat)
245 {
246 }
247
248 private void ConfigDB(IGenericConfig configData)
249 {
250 try
251 {
252 string attri = "";
253 attri = configData.GetAttribute("DataBaseProvider");
254 if (attri == "")
255 {
256 GridDll = "OpenGrid.Framework.Data.DB4o.dll";
257 configData.SetAttribute("DataBaseProvider", "OpenGrid.Framework.Data.DB4o.dll");
258 }
259 else
260 {
261 GridDll = attri;
262 }
263 configData.Commit();
264 }
265 catch (Exception e)
266 {
267
268 }
269 }
270 }
271}
diff --git a/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj b/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj
deleted file mode 100644
index 55a0e02..0000000
--- a/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.csproj
+++ /dev/null
@@ -1,134 +0,0 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{21BFC8E2-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenGridServices.GridServer</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Exe</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenGridServices.GridServer</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Db4objects.Db4o.dll" >
62 <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="libsecondlife.dll" >
66 <HintPath>..\..\bin\libsecondlife.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="OpenSim.Framework" >
70 <HintPath>OpenSim.Framework.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="OpenSim.Framework.Console" >
74 <HintPath>OpenSim.Framework.Console.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="OpenSim.GenericConfig.Xml" >
78 <HintPath>OpenSim.GenericConfig.Xml.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="OpenSim.Servers" >
82 <HintPath>OpenSim.Servers.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 <Reference Include="System" >
86 <HintPath>System.dll</HintPath>
87 <Private>False</Private>
88 </Reference>
89 <Reference Include="System.Data" >
90 <HintPath>System.Data.dll</HintPath>
91 <Private>False</Private>
92 </Reference>
93 <Reference Include="System.Xml" >
94 <HintPath>System.Xml.dll</HintPath>
95 <Private>False</Private>
96 </Reference>
97 <Reference Include="XMLRPC" >
98 <HintPath>XMLRPC.dll</HintPath>
99 <Private>False</Private>
100 </Reference>
101 </ItemGroup>
102 <ItemGroup>
103 <ProjectReference Include="..\OpenGrid.Framework.Data\OpenGrid.Framework.Data.csproj">
104 <Name>OpenGrid.Framework.Data</Name>
105 <Project>{62CDF671-0000-0000-0000-000000000000}</Project>
106 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
107 <Private>False</Private>
108 </ProjectReference>
109 <ProjectReference Include="..\OpenGrid.Framework.Manager\OpenGrid.Framework.Manager.csproj">
110 <Name>OpenGrid.Framework.Manager</Name>
111 <Project>{7924FD35-0000-0000-0000-000000000000}</Project>
112 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
113 <Private>False</Private>
114 </ProjectReference>
115 </ItemGroup>
116 <ItemGroup>
117 <Compile Include="GridManager.cs">
118 <SubType>Code</SubType>
119 </Compile>
120 <Compile Include="Main.cs">
121 <SubType>Code</SubType>
122 </Compile>
123 <Compile Include="Properties\AssemblyInfo.cs">
124 <SubType>Code</SubType>
125 </Compile>
126 </ItemGroup>
127 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
128 <PropertyGroup>
129 <PreBuildEvent>
130 </PreBuildEvent>
131 <PostBuildEvent>
132 </PostBuildEvent>
133 </PropertyGroup>
134</Project>
diff --git a/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build b/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build
deleted file mode 100644
index 60c0f85..0000000
--- a/OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build
+++ /dev/null
@@ -1,52 +0,0 @@
1<?xml version="1.0" ?>
2<project name="OpenGridServices.GridServer" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="exe" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.exe">
11 <resources prefix="OpenGridServices.GridServer" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="GridManager.cs" />
15 <include name="Main.cs" />
16 <include name="Properties/AssemblyInfo.cs" />
17 </sources>
18 <references basedir="${project::get-base-directory()}">
19 <lib>
20 <include name="${project::get-base-directory()}" />
21 <include name="${project::get-base-directory()}/${build.dir}" />
22 </lib>
23 <include name="../../bin/Db4objects.Db4o.dll" />
24 <include name="../../bin/libsecondlife.dll" />
25 <include name="../../bin/OpenGrid.Framework.Data.dll" />
26 <include name="../../bin/OpenGrid.Framework.Manager.dll" />
27 <include name="../../bin/OpenSim.Framework.dll" />
28 <include name="../../bin/OpenSim.Framework.Console.dll" />
29 <include name="../../bin/OpenSim.GenericConfig.Xml.dll" />
30 <include name="../../bin/OpenSim.Servers.dll" />
31 <include name="System.dll" />
32 <include name="System.Data.dll" />
33 <include name="System.Xml.dll" />
34 <include name="../../bin/XMLRPC.dll" />
35 </references>
36 </csc>
37 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
38 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
39 <copy todir="${project::get-base-directory()}/../../bin/">
40 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
41 <include name="*.dll"/>
42 <include name="*.exe"/>
43 </fileset>
44 </copy>
45 </target>
46 <target name="clean">
47 <delete dir="${bin.dir}" failonerror="false" />
48 <delete dir="${obj.dir}" failonerror="false" />
49 </target>
50 <target name="doc" description="Creates documentation.">
51 </target>
52</project>
diff --git a/OpenGridServices/OpenGridServices.GridServer/Properties/AssemblyInfo.cs b/OpenGridServices/OpenGridServices.GridServer/Properties/AssemblyInfo.cs
deleted file mode 100644
index 8471e6b..0000000
--- a/OpenGridServices/OpenGridServices.GridServer/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OGS-GridServer")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OGS-GridServer")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]