diff options
Re-imported OpenGridServices from trunk
Diffstat (limited to '')
5 files changed, 389 insertions, 0 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs b/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs new file mode 100644 index 0000000..dfc572a --- /dev/null +++ b/OpenGridServices/OpenGrid.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 | */ | ||
28 | using Nwc.XmlRpc; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenSim.Servers; | ||
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | ||
33 | using libsecondlife; | ||
34 | |||
35 | namespace 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/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs b/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs new file mode 100644 index 0000000..d665ab4 --- /dev/null +++ b/OpenGridServices/OpenGrid.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 | |||
29 | using System; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using Nwc.XmlRpc; | ||
33 | using System.Threading; | ||
34 | using libsecondlife; | ||
35 | |||
36 | namespace 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/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj b/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj new file mode 100644 index 0000000..dad56cb --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.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>{7924FD35-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>OpenGrid.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>OpenGrid.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="System" > | ||
62 | <HintPath>System.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="OpenSim.Framework.dll" > | ||
66 | <HintPath>..\..\bin\OpenSim.Framework.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="OpenSim.Servers.dll" > | ||
70 | <HintPath>..\..\bin\OpenSim.Servers.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | <Reference Include="libsecondlife.dll" > | ||
74 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | ||
75 | <Private>False</Private> | ||
76 | </Reference> | ||
77 | <Reference Include="XMLRPC" > | ||
78 | <HintPath>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/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj.user b/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj.user new file mode 100644 index 0000000..1b6b14d --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.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\opensim26-05\trunk\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> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build b/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build new file mode 100644 index 0000000..f8cc80e --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build | |||
@@ -0,0 +1,44 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenGrid.Framework.Manager" 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="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenGrid.Framework.Manager" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="GridManagementAgent.cs" /> | ||
15 | <include name="GridServerManager.cs" /> | ||
16 | </sources> | ||
17 | <references basedir="${project::get-base-directory()}"> | ||
18 | <lib> | ||
19 | <include name="${project::get-base-directory()}" /> | ||
20 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
21 | </lib> | ||
22 | <include name="System.dll" /> | ||
23 | <include name="../../bin/OpenSim.Framework.dll" /> | ||
24 | <include name="../../bin/OpenSim.Servers.dll" /> | ||
25 | <include name="../../bin/libsecondlife.dll" /> | ||
26 | <include name="../../bin/XMLRPC.dll" /> | ||
27 | </references> | ||
28 | </csc> | ||
29 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
30 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
31 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
32 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
33 | <include name="*.dll"/> | ||
34 | <include name="*.exe"/> | ||
35 | </fileset> | ||
36 | </copy> | ||
37 | </target> | ||
38 | <target name="clean"> | ||
39 | <delete dir="${bin.dir}" failonerror="false" /> | ||
40 | <delete dir="${obj.dir}" failonerror="false" /> | ||
41 | </target> | ||
42 | <target name="doc" description="Creates documentation."> | ||
43 | </target> | ||
44 | </project> | ||