diff options
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Manager')
5 files changed, 282 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..e43ce87 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs | |||
@@ -0,0 +1,71 @@ | |||
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 | public delegate void GridManagerCallback(string param); | ||
11 | |||
12 | public class GridManagementAgent { | ||
13 | |||
14 | private GridManagerCallback thecallback; | ||
15 | private string sendkey; | ||
16 | private string recvkey; | ||
17 | private string component_type; | ||
18 | |||
19 | private static ArrayList Sessions; | ||
20 | |||
21 | public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback) | ||
22 | { | ||
23 | this.sendkey=sendkey; | ||
24 | this.recvkey=recvkey; | ||
25 | this.component_type=component_type; | ||
26 | this.thecallback=thecallback; | ||
27 | Sessions = new ArrayList(); | ||
28 | |||
29 | app_httpd.AddXmlRPCHandler("manager_login",XmlRpcLoginMethod); | ||
30 | |||
31 | switch(component_type) | ||
32 | { | ||
33 | case "gridserver": | ||
34 | GridServerManager.sendkey=this.sendkey; | ||
35 | GridServerManager.recvkey=this.recvkey; | ||
36 | GridServerManager.thecallback=thecallback; | ||
37 | app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod); | ||
38 | break; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | public static bool SessionExists(LLUUID sessionID) | ||
43 | { | ||
44 | return Sessions.Contains(sessionID); | ||
45 | } | ||
46 | |||
47 | public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
48 | { | ||
49 | XmlRpcResponse response = new XmlRpcResponse(); | ||
50 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
51 | Hashtable responseData = new Hashtable(); | ||
52 | |||
53 | // TODO: Switch this over to using OpenGrid.Framework.Data | ||
54 | if( requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret")) { | ||
55 | response.IsFault=false; | ||
56 | LLUUID new_session=LLUUID.Random(); | ||
57 | Sessions.Add(new_session); | ||
58 | responseData["session_id"]=new_session.ToString(); | ||
59 | responseData["msg"]="Login OK"; | ||
60 | } else { | ||
61 | response.IsFault=true; | ||
62 | responseData["error"]="Invalid username or password"; | ||
63 | } | ||
64 | |||
65 | response.Value = responseData; | ||
66 | return response; | ||
67 | |||
68 | } | ||
69 | |||
70 | } | ||
71 | } | ||
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..3122633 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj | |||
@@ -0,0 +1,105 @@ | |||
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="libsecondlife.dll" > | ||
66 | <HintPath>..\bin\libsecondlife.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | </ItemGroup> | ||
70 | <ItemGroup> | ||
71 | <ProjectReference Include="..\OpenSim.Framework\OpenSim.Framework.csproj"> | ||
72 | <Name>OpenSim.Framework</Name> | ||
73 | <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> | ||
74 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
75 | <Private>False</Private> | ||
76 | </ProjectReference> | ||
77 | <ProjectReference Include="..\OpenSim.Servers\OpenSim.Servers.csproj"> | ||
78 | <Name>OpenSim.Servers</Name> | ||
79 | <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project> | ||
80 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
81 | <Private>False</Private> | ||
82 | </ProjectReference> | ||
83 | <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj"> | ||
84 | <Name>XMLRPC</Name> | ||
85 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> | ||
86 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
87 | <Private>False</Private> | ||
88 | </ProjectReference> | ||
89 | </ItemGroup> | ||
90 | <ItemGroup> | ||
91 | <Compile Include="GridManagementAgent.cs"> | ||
92 | <SubType>Code</SubType> | ||
93 | </Compile> | ||
94 | <Compile Include="GridServerManager.cs"> | ||
95 | <SubType>Code</SubType> | ||
96 | </Compile> | ||
97 | </ItemGroup> | ||
98 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
99 | <PropertyGroup> | ||
100 | <PreBuildEvent> | ||
101 | </PreBuildEvent> | ||
102 | <PostBuildEvent> | ||
103 | </PostBuildEvent> | ||
104 | </PropertyGroup> | ||
105 | </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..daee3bf --- /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> | ||