aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/Framework.Manager
diff options
context:
space:
mode:
authorSean Dague2007-07-16 15:40:11 +0000
committerSean Dague2007-07-16 15:40:11 +0000
commit2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch)
treee3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Grid/Framework.Manager
parent*Trunk compiles now (diff)
downloadopensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Grid/Framework.Manager')
-rw-r--r--OpenSim/Grid/Framework.Manager/GridManagementAgent.cs276
-rw-r--r--OpenSim/Grid/Framework.Manager/GridServerManager.cs186
2 files changed, 231 insertions, 231 deletions
diff --git a/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs b/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs
index 6c916a2..989df26 100644
--- a/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs
+++ b/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs
@@ -1,138 +1,138 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections; 28using System.Collections;
29using libsecondlife; 29using libsecondlife;
30using Nwc.XmlRpc; 30using Nwc.XmlRpc;
31using OpenSim.Framework.Servers; 31using OpenSim.Framework.Servers;
32 32
33namespace OpenSim.Framework.Manager 33namespace OpenSim.Framework.Manager
34{ 34{
35 /// <summary> 35 /// <summary>
36 /// Used to pass messages to the gridserver 36 /// Used to pass messages to the gridserver
37 /// </summary> 37 /// </summary>
38 /// <param name="param">Pass this argument</param> 38 /// <param name="param">Pass this argument</param>
39 public delegate void GridManagerCallback(string param); 39 public delegate void GridManagerCallback(string param);
40 40
41 /// <summary> 41 /// <summary>
42 /// Serverside listener for grid commands 42 /// Serverside listener for grid commands
43 /// </summary> 43 /// </summary>
44 public class GridManagementAgent 44 public class GridManagementAgent
45 { 45 {
46 /// <summary> 46 /// <summary>
47 /// Passes grid server messages 47 /// Passes grid server messages
48 /// </summary> 48 /// </summary>
49 private GridManagerCallback thecallback; 49 private GridManagerCallback thecallback;
50 50
51 /// <summary> 51 /// <summary>
52 /// Security keys 52 /// Security keys
53 /// </summary> 53 /// </summary>
54 private string sendkey; 54 private string sendkey;
55 private string recvkey; 55 private string recvkey;
56 56
57 /// <summary> 57 /// <summary>
58 /// Our component type 58 /// Our component type
59 /// </summary> 59 /// </summary>
60 private string component_type; 60 private string component_type;
61 61
62 /// <summary> 62 /// <summary>
63 /// List of active sessions 63 /// List of active sessions
64 /// </summary> 64 /// </summary>
65 private static ArrayList Sessions; 65 private static ArrayList Sessions;
66 66
67 /// <summary> 67 /// <summary>
68 /// Initialises a new GridManagementAgent 68 /// Initialises a new GridManagementAgent
69 /// </summary> 69 /// </summary>
70 /// <param name="app_httpd">HTTP Daemon for this server</param> 70 /// <param name="app_httpd">HTTP Daemon for this server</param>
71 /// <param name="component_type">What component type are we?</param> 71 /// <param name="component_type">What component type are we?</param>
72 /// <param name="sendkey">Security send key</param> 72 /// <param name="sendkey">Security send key</param>
73 /// <param name="recvkey">Security recieve key</param> 73 /// <param name="recvkey">Security recieve key</param>
74 /// <param name="thecallback">Message callback</param> 74 /// <param name="thecallback">Message callback</param>
75 public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback) 75 public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback)
76 { 76 {
77 this.sendkey = sendkey; 77 this.sendkey = sendkey;
78 this.recvkey = recvkey; 78 this.recvkey = recvkey;
79 this.component_type = component_type; 79 this.component_type = component_type;
80 this.thecallback = thecallback; 80 this.thecallback = thecallback;
81 Sessions = new ArrayList(); 81 Sessions = new ArrayList();
82 82
83 app_httpd.AddXmlRPCHandler("manager_login", XmlRpcLoginMethod); 83 app_httpd.AddXmlRPCHandler("manager_login", XmlRpcLoginMethod);
84 84
85 switch (component_type) 85 switch (component_type)
86 { 86 {
87 case "gridserver": 87 case "gridserver":
88 GridServerManager.sendkey = this.sendkey; 88 GridServerManager.sendkey = this.sendkey;
89 GridServerManager.recvkey = this.recvkey; 89 GridServerManager.recvkey = this.recvkey;
90 GridServerManager.thecallback = thecallback; 90 GridServerManager.thecallback = thecallback;
91 app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod); 91 app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod);
92 break; 92 break;
93 } 93 }
94 } 94 }
95 95
96 /// <summary> 96 /// <summary>
97 /// Checks if a session exists 97 /// Checks if a session exists
98 /// </summary> 98 /// </summary>
99 /// <param name="sessionID">The session ID</param> 99 /// <param name="sessionID">The session ID</param>
100 /// <returns>Exists?</returns> 100 /// <returns>Exists?</returns>
101 public static bool SessionExists(LLUUID sessionID) 101 public static bool SessionExists(LLUUID sessionID)
102 { 102 {
103 return Sessions.Contains(sessionID); 103 return Sessions.Contains(sessionID);
104 } 104 }
105 105
106 /// <summary> 106 /// <summary>
107 /// Logs a new session to the grid manager 107 /// Logs a new session to the grid manager
108 /// </summary> 108 /// </summary>
109 /// <param name="request">the XMLRPC request</param> 109 /// <param name="request">the XMLRPC request</param>
110 /// <returns>An XMLRPC reply</returns> 110 /// <returns>An XMLRPC reply</returns>
111 public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) 111 public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
112 { 112 {
113 XmlRpcResponse response = new XmlRpcResponse(); 113 XmlRpcResponse response = new XmlRpcResponse();
114 Hashtable requestData = (Hashtable)request.Params[0]; 114 Hashtable requestData = (Hashtable)request.Params[0];
115 Hashtable responseData = new Hashtable(); 115 Hashtable responseData = new Hashtable();
116 116
117 // TODO: Switch this over to using OpenSim.Framework.Data 117 // TODO: Switch this over to using OpenSim.Framework.Data
118 if (requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret")) 118 if (requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret"))
119 { 119 {
120 response.IsFault = false; 120 response.IsFault = false;
121 LLUUID new_session = LLUUID.Random(); 121 LLUUID new_session = LLUUID.Random();
122 Sessions.Add(new_session); 122 Sessions.Add(new_session);
123 responseData["session_id"] = new_session.ToString(); 123 responseData["session_id"] = new_session.ToString();
124 responseData["msg"] = "Login OK"; 124 responseData["msg"] = "Login OK";
125 } 125 }
126 else 126 else
127 { 127 {
128 response.IsFault = true; 128 response.IsFault = true;
129 responseData["error"] = "Invalid username or password"; 129 responseData["error"] = "Invalid username or password";
130 } 130 }
131 131
132 response.Value = responseData; 132 response.Value = responseData;
133 return response; 133 return response;
134 134
135 } 135 }
136 136
137 } 137 }
138} 138}
diff --git a/OpenSim/Grid/Framework.Manager/GridServerManager.cs b/OpenSim/Grid/Framework.Manager/GridServerManager.cs
index 67cd35d..729e42b 100644
--- a/OpenSim/Grid/Framework.Manager/GridServerManager.cs
+++ b/OpenSim/Grid/Framework.Manager/GridServerManager.cs
@@ -1,93 +1,93 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections; 30using System.Collections;
31using System.Threading; 31using System.Threading;
32using libsecondlife; 32using libsecondlife;
33using Nwc.XmlRpc; 33using Nwc.XmlRpc;
34 34
35namespace OpenSim.Framework.Manager { 35namespace OpenSim.Framework.Manager {
36 36
37 /// <summary> 37 /// <summary>
38 /// A remote management system for the grid server 38 /// A remote management system for the grid server
39 /// </summary> 39 /// </summary>
40 public class GridServerManager 40 public class GridServerManager
41 { 41 {
42 /// <summary> 42 /// <summary>
43 /// Triggers events from the grid manager 43 /// Triggers events from the grid manager
44 /// </summary> 44 /// </summary>
45 public static GridManagerCallback thecallback; 45 public static GridManagerCallback thecallback;
46 46
47 /// <summary> 47 /// <summary>
48 /// Security keys 48 /// Security keys
49 /// </summary> 49 /// </summary>
50 public static string sendkey; 50 public static string sendkey;
51 public static string recvkey; 51 public static string recvkey;
52 52
53 /// <summary> 53 /// <summary>
54 /// Disconnects the grid server and shuts it down 54 /// Disconnects the grid server and shuts it down
55 /// </summary> 55 /// </summary>
56 /// <param name="request">XmlRpc Request</param> 56 /// <param name="request">XmlRpc Request</param>
57 /// <returns>An XmlRpc response containing either a "msg" or an "error"</returns> 57 /// <returns>An XmlRpc response containing either a "msg" or an "error"</returns>
58 public static XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request) 58 public static XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request)
59 { 59 {
60 XmlRpcResponse response = new XmlRpcResponse(); 60 XmlRpcResponse response = new XmlRpcResponse();
61 Hashtable requestData = (Hashtable)request.Params[0]; 61 Hashtable requestData = (Hashtable)request.Params[0];
62 Hashtable responseData = new Hashtable(); 62 Hashtable responseData = new Hashtable();
63 63
64 if(requestData.ContainsKey("session_id")) { 64 if(requestData.ContainsKey("session_id")) {
65 if(GridManagementAgent.SessionExists(new LLUUID((string)requestData["session_id"]))) { 65 if(GridManagementAgent.SessionExists(new LLUUID((string)requestData["session_id"]))) {
66 responseData["msg"]="Shutdown command accepted"; 66 responseData["msg"]="Shutdown command accepted";
67 (new Thread(new ThreadStart(ShutdownServer))).Start(); 67 (new Thread(new ThreadStart(ShutdownServer))).Start();
68 } else { 68 } else {
69 response.IsFault=true; 69 response.IsFault=true;
70 responseData["error"]="bad session ID"; 70 responseData["error"]="bad session ID";
71 } 71 }
72 } else { 72 } else {
73 response.IsFault=true; 73 response.IsFault=true;
74 responseData["error"]="no session ID"; 74 responseData["error"]="no session ID";
75 } 75 }
76 76
77 response.Value = responseData; 77 response.Value = responseData;
78 return response; 78 return response;
79 } 79 }
80 80
81 /// <summary> 81 /// <summary>
82 /// Shuts down the grid server 82 /// Shuts down the grid server
83 /// </summary> 83 /// </summary>
84 public static void ShutdownServer() 84 public static void ShutdownServer()
85 { 85 {
86 Console.WriteLine("Shutting down the grid server - recieved a grid manager request"); 86 Console.WriteLine("Shutting down the grid server - recieved a grid manager request");
87 Console.WriteLine("Terminating in three seconds..."); 87 Console.WriteLine("Terminating in three seconds...");
88 Thread.Sleep(3000); 88 Thread.Sleep(3000);
89 thecallback("shutdown"); 89 thecallback("shutdown");
90 } 90 }
91 } 91 }
92} 92}
93 93