diff options
author | MW | 2007-05-26 13:40:19 +0000 |
---|---|---|
committer | MW | 2007-05-26 13:40:19 +0000 |
commit | 3436961bb5c01d659d09be134368f4f69460cef9 (patch) | |
tree | 3753ba4d7818df2a6bce0bbe863ff033cdfd568a /OpenGridServices/OpenGrid.Framework.Manager | |
download | opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.zip opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.gz opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.bz2 opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.xz |
Start of rewrite 5279!
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Manager')
5 files changed, 281 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..f4483fb --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs | |||
@@ -0,0 +1,76 @@ | |||
1 | using Nwc.XmlRpc; | ||
2 | using OpenSim.Framework; | ||
3 | using OpenSim.Servers; | ||
4 | using System.Collections; | ||
5 | using System.Collections.Generic; | ||
6 | using libsecondlife; | ||
7 | |||
8 | namespace OpenGrid.Framework.Manager | ||
9 | { | ||
10 | |||
11 | public delegate void GridManagerCallback(string param); | ||
12 | |||
13 | public class GridManagementAgent | ||
14 | { | ||
15 | |||
16 | private GridManagerCallback thecallback; | ||
17 | private string sendkey; | ||
18 | private string recvkey; | ||
19 | private string component_type; | ||
20 | |||
21 | private static ArrayList Sessions; | ||
22 | |||
23 | public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback) | ||
24 | { | ||
25 | this.sendkey = sendkey; | ||
26 | this.recvkey = recvkey; | ||
27 | this.component_type = component_type; | ||
28 | this.thecallback = thecallback; | ||
29 | Sessions = new ArrayList(); | ||
30 | |||
31 | app_httpd.AddXmlRPCHandler("manager_login", XmlRpcLoginMethod); | ||
32 | |||
33 | switch (component_type) | ||
34 | { | ||
35 | case "gridserver": | ||
36 | GridServerManager.sendkey = this.sendkey; | ||
37 | GridServerManager.recvkey = this.recvkey; | ||
38 | GridServerManager.thecallback = thecallback; | ||
39 | app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod); | ||
40 | break; | ||
41 | } | ||
42 | } | ||
43 | |||
44 | public static bool SessionExists(LLUUID sessionID) | ||
45 | { | ||
46 | return Sessions.Contains(sessionID); | ||
47 | } | ||
48 | |||
49 | public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
50 | { | ||
51 | XmlRpcResponse response = new XmlRpcResponse(); | ||
52 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
53 | Hashtable responseData = new Hashtable(); | ||
54 | |||
55 | // TODO: Switch this over to using OpenGrid.Framework.Data | ||
56 | if (requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret")) | ||
57 | { | ||
58 | response.IsFault = false; | ||
59 | LLUUID new_session = LLUUID.Random(); | ||
60 | Sessions.Add(new_session); | ||
61 | responseData["session_id"] = new_session.ToString(); | ||
62 | responseData["msg"] = "Login OK"; | ||
63 | } | ||
64 | else | ||
65 | { | ||
66 | response.IsFault = true; | ||
67 | responseData["error"] = "Invalid username or password"; | ||
68 | } | ||
69 | |||
70 | response.Value = responseData; | ||
71 | return response; | ||
72 | |||
73 | } | ||
74 | |||
75 | } | ||
76 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs b/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs new file mode 100644 index 0000000..7ebf66a --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs | |||
@@ -0,0 +1,50 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using Nwc.XmlRpc; | ||
5 | using System.Threading; | ||
6 | using libsecondlife; | ||
7 | |||
8 | namespace OpenGrid.Framework.Manager { | ||
9 | |||
10 | public class GridServerManager | ||
11 | { | ||
12 | public static GridManagerCallback thecallback; | ||
13 | |||
14 | public static string sendkey; | ||
15 | public static string recvkey; | ||
16 | |||
17 | public static XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request) | ||
18 | { | ||
19 | XmlRpcResponse response = new XmlRpcResponse(); | ||
20 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
21 | Hashtable responseData = new Hashtable(); | ||
22 | |||
23 | if(requestData.ContainsKey("session_id")) { | ||
24 | if(GridManagementAgent.SessionExists(new LLUUID((string)requestData["session_id"]))) { | ||
25 | responseData["msg"]="Shutdown command accepted"; | ||
26 | (new Thread(new ThreadStart(ZOMGServerIsNowTerminallyIll))).Start(); | ||
27 | } else { | ||
28 | response.IsFault=true; | ||
29 | responseData["error"]="bad session ID"; | ||
30 | } | ||
31 | } else { | ||
32 | response.IsFault=true; | ||
33 | responseData["error"]="no session ID"; | ||
34 | } | ||
35 | |||
36 | response.Value = responseData; | ||
37 | return response; | ||
38 | } | ||
39 | |||
40 | // Brought to by late-night coding | ||
41 | public static void ZOMGServerIsNowTerminallyIll() | ||
42 | { | ||
43 | Console.WriteLine("ZOMG! THIS SERVER IS TERMINALLY ILL - WE GOT A SHUTDOWN REQUEST FROM A GRID MANAGER!!!!"); | ||
44 | Console.WriteLine("We have 3 seconds to live..."); | ||
45 | Thread.Sleep(3000); | ||
46 | thecallback("shutdown"); | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | |||
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..ea7548a --- /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" > | ||
66 | <HintPath>OpenSim.Framework.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="OpenSim.Servers" > | ||
70 | <HintPath>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..d47d65d --- /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\opensim15-07\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> | ||