aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/Framework.Manager
diff options
context:
space:
mode:
authorMW2007-06-27 15:28:52 +0000
committerMW2007-06-27 15:28:52 +0000
commit646bbbc84b8010e0dacbeed5342cdb045f46cc49 (patch)
tree770b34d19855363c3c113ab9a0af9a56d821d887 /OpenSim/Grid/Framework.Manager
downloadopensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.zip
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.gz
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.bz2
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.xz
Some work on restructuring the namespaces / project names. Note this doesn't compile yet as not all the code has been changed to use the new namespaces. Am committing it now for feedback on the namespaces.
Diffstat (limited to 'OpenSim/Grid/Framework.Manager')
-rw-r--r--OpenSim/Grid/Framework.Manager/GridManagementAgent.cs140
-rw-r--r--OpenSim/Grid/Framework.Manager/GridServerManager.cs94
-rw-r--r--OpenSim/Grid/Framework.Manager/OpenSim.Grid.Framework.Manager.csproj99
-rw-r--r--OpenSim/Grid/Framework.Manager/OpenSim.Grid.Framework.Manager.csproj.user12
4 files changed, 345 insertions, 0 deletions
diff --git a/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs b/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs
new file mode 100644
index 0000000..dfc572a
--- /dev/null
+++ b/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs
@@ -0,0 +1,140 @@
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 Nwc.XmlRpc;
29using OpenSim.Framework;
30using OpenSim.Servers;
31using System.Collections;
32using System.Collections.Generic;
33using libsecondlife;
34
35namespace OpenGrid.Framework.Manager
36{
37 /// <summary>
38 /// Used to pass messages to the gridserver
39 /// </summary>
40 /// <param name="param">Pass this argument</param>
41 public delegate void GridManagerCallback(string param);
42
43 /// <summary>
44 /// Serverside listener for grid commands
45 /// </summary>
46 public class GridManagementAgent
47 {
48 /// <summary>
49 /// Passes grid server messages
50 /// </summary>
51 private GridManagerCallback thecallback;
52
53 /// <summary>
54 /// Security keys
55 /// </summary>
56 private string sendkey;
57 private string recvkey;
58
59 /// <summary>
60 /// Our component type
61 /// </summary>
62 private string component_type;
63
64 /// <summary>
65 /// List of active sessions
66 /// </summary>
67 private static ArrayList Sessions;
68
69 /// <summary>
70 /// Initialises a new GridManagementAgent
71 /// </summary>
72 /// <param name="app_httpd">HTTP Daemon for this server</param>
73 /// <param name="component_type">What component type are we?</param>
74 /// <param name="sendkey">Security send key</param>
75 /// <param name="recvkey">Security recieve key</param>
76 /// <param name="thecallback">Message callback</param>
77 public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback)
78 {
79 this.sendkey = sendkey;
80 this.recvkey = recvkey;
81 this.component_type = component_type;
82 this.thecallback = thecallback;
83 Sessions = new ArrayList();
84
85 app_httpd.AddXmlRPCHandler("manager_login", XmlRpcLoginMethod);
86
87 switch (component_type)
88 {
89 case "gridserver":
90 GridServerManager.sendkey = this.sendkey;
91 GridServerManager.recvkey = this.recvkey;
92 GridServerManager.thecallback = thecallback;
93 app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod);
94 break;
95 }
96 }
97
98 /// <summary>
99 /// Checks if a session exists
100 /// </summary>
101 /// <param name="sessionID">The session ID</param>
102 /// <returns>Exists?</returns>
103 public static bool SessionExists(LLUUID sessionID)
104 {
105 return Sessions.Contains(sessionID);
106 }
107
108 /// <summary>
109 /// Logs a new session to the grid manager
110 /// </summary>
111 /// <param name="request">the XMLRPC request</param>
112 /// <returns>An XMLRPC reply</returns>
113 public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
114 {
115 XmlRpcResponse response = new XmlRpcResponse();
116 Hashtable requestData = (Hashtable)request.Params[0];
117 Hashtable responseData = new Hashtable();
118
119 // TODO: Switch this over to using OpenGrid.Framework.Data
120 if (requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret"))
121 {
122 response.IsFault = false;
123 LLUUID new_session = LLUUID.Random();
124 Sessions.Add(new_session);
125 responseData["session_id"] = new_session.ToString();
126 responseData["msg"] = "Login OK";
127 }
128 else
129 {
130 response.IsFault = true;
131 responseData["error"] = "Invalid username or password";
132 }
133
134 response.Value = responseData;
135 return response;
136
137 }
138
139 }
140}
diff --git a/OpenSim/Grid/Framework.Manager/GridServerManager.cs b/OpenSim/Grid/Framework.Manager/GridServerManager.cs
new file mode 100644
index 0000000..e276556
--- /dev/null
+++ b/OpenSim/Grid/Framework.Manager/GridServerManager.cs
@@ -0,0 +1,94 @@
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.Collections;
31using System.Collections.Generic;
32using Nwc.XmlRpc;
33using System.Threading;
34using libsecondlife;
35
36namespace OpenGrid.Framework.Manager {
37
38 /// <summary>
39 /// A remote management system for the grid server
40 /// </summary>
41 public class GridServerManager
42 {
43 /// <summary>
44 /// Triggers events from the grid manager
45 /// </summary>
46 public static GridManagerCallback thecallback;
47
48 /// <summary>
49 /// Security keys
50 /// </summary>
51 public static string sendkey;
52 public static string recvkey;
53
54 /// <summary>
55 /// Disconnects the grid server and shuts it down
56 /// </summary>
57 /// <param name="request">XmlRpc Request</param>
58 /// <returns>An XmlRpc response containing either a "msg" or an "error"</returns>
59 public static XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request)
60 {
61 XmlRpcResponse response = new XmlRpcResponse();
62 Hashtable requestData = (Hashtable)request.Params[0];
63 Hashtable responseData = new Hashtable();
64
65 if(requestData.ContainsKey("session_id")) {
66 if(GridManagementAgent.SessionExists(new LLUUID((string)requestData["session_id"]))) {
67 responseData["msg"]="Shutdown command accepted";
68 (new Thread(new ThreadStart(ShutdownServer))).Start();
69 } else {
70 response.IsFault=true;
71 responseData["error"]="bad session ID";
72 }
73 } else {
74 response.IsFault=true;
75 responseData["error"]="no session ID";
76 }
77
78 response.Value = responseData;
79 return response;
80 }
81
82 /// <summary>
83 /// Shuts down the grid server
84 /// </summary>
85 public static void ShutdownServer()
86 {
87 Console.WriteLine("Shutting down the grid server - recieved a grid manager request");
88 Console.WriteLine("Terminating in three seconds...");
89 Thread.Sleep(3000);
90 thecallback("shutdown");
91 }
92 }
93}
94
diff --git a/OpenSim/Grid/Framework.Manager/OpenSim.Grid.Framework.Manager.csproj b/OpenSim/Grid/Framework.Manager/OpenSim.Grid.Framework.Manager.csproj
new file mode 100644
index 0000000..9a98ff4
--- /dev/null
+++ b/OpenSim/Grid/Framework.Manager/OpenSim.Grid.Framework.Manager.csproj
@@ -0,0 +1,99 @@
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>{4B7BFD1C-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>OpenSim.Grid.Framework.Manager</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Grid.Framework.Manager</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="libsecondlife.dll" >
62 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="OpenSim.Framework" >
66 <HintPath>OpenSim.Framework.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="OpenSim.Framework.Servers" >
70 <HintPath>OpenSim.Framework.Servers.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System" >
74 <HintPath>System.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="XMLRPC.dll" >
78 <HintPath>..\..\..\bin\XMLRPC.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 </ItemGroup>
82 <ItemGroup>
83 </ItemGroup>
84 <ItemGroup>
85 <Compile Include="GridManagementAgent.cs">
86 <SubType>Code</SubType>
87 </Compile>
88 <Compile Include="GridServerManager.cs">
89 <SubType>Code</SubType>
90 </Compile>
91 </ItemGroup>
92 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
93 <PropertyGroup>
94 <PreBuildEvent>
95 </PreBuildEvent>
96 <PostBuildEvent>
97 </PostBuildEvent>
98 </PropertyGroup>
99</Project>
diff --git a/OpenSim/Grid/Framework.Manager/OpenSim.Grid.Framework.Manager.csproj.user b/OpenSim/Grid/Framework.Manager/OpenSim.Grid.Framework.Manager.csproj.user
new file mode 100644
index 0000000..6841907
--- /dev/null
+++ b/OpenSim/Grid/Framework.Manager/OpenSim.Grid.Framework.Manager.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-06\NameSpaceChanges\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>