This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added docs and support for simplified shutdown and restart XMLRPC calls.

  • Loading branch information...
kf6kjg committed Dec 4, 2017
1 parent 283fa06 commit 93c6982796e037500b8c5ad5d266f15364308210
@@ -118,6 +118,8 @@ public void Dispose()
private ulong countdownTimeEnd;
private Scene rebootedScene;
private Timer shutdownCounter;
// Region.Restart(string sessionid, optional string regionid = ACTIVE_REGION)
private object RegionRestartHandler(IList args, IPEndPoint remoteClient)
{
m_admin.CheckSessionValid(new UUID((string)args[0]));
@@ -127,16 +129,41 @@ private object RegionRestartHandler(IList args, IPEndPoint remoteClient)
throw new Exception("remote shutdown already in progress");
}
var regionID = new UUID(Convert.ToString(args[1]));
string regionIDInput = "";
if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
throw new Exception("region not found");
// Make the region ID optional.
regionIDInput = Convert.ToString(args[1]); // There's more in the args than what's passed, so this might not be the ID much less a UUID!.
countdownTimeEnd = 1; // Mark a shutdown in progress.
rebootedScene.Restart(30);
return true;
if (regionIDInput.Length > 0)
{
UUID regionID;
try
{
regionID = new UUID(regionIDInput);
if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene)) // It is a UUID, see if that's an active region.
throw new Exception("region not found");
}
catch (FormatException) // Not a UUID, use the active region.
{
rebootedScene = m_app.SceneManager.CurrentOrFirstScene;
}
}
else
{
rebootedScene = m_app.SceneManager.CurrentOrFirstScene;
}
if (rebootedScene != null)
{
countdownTimeEnd = 1; // Mark a shutdown in progress.
rebootedScene.Restart(30);
return true;
}
throw new Exception("no active region");
}
// Region.Shutdown(string sessionid, optional string regionid, optional int delay)
public object RegionShutdownHandler(IList args, IPEndPoint remoteClient)
{
m_admin.CheckSessionValid(new UUID((string)args[0]));
@@ -146,15 +173,47 @@ public object RegionShutdownHandler(IList args, IPEndPoint remoteClient)
throw new Exception("remote shutdown already in progress");
}
if (countdownTimeEnd > 0)
{
throw new Exception("remote shutdown already in progress");
}
string regionIDInput = "";
int delay = 30;
// Make the region ID and delay optional. Though if both are sepcified they have to be in order of ID then delay.
// Note that there are always more entries in the args array than were sent.
if (args[1] is Int32) // Delay was provided.
{
delay = Math.Max(0, Convert.ToInt32(args[1]));
// And region ID is not expected.
}
else if (args[1] is String) // Region ID was provided.
{
regionIDInput = Convert.ToString(args[1]);
// Try for both entries.
if (args.Count >= 3 && args[2] is Int32)
{
delay = Math.Max(0, Convert.ToInt32(args[2]));
}
// else Only the region ID was specified.
}
try
{
string message;
var regionID = new UUID(Convert.ToString(args[1]));
int delay = Math.Max(0, Convert.ToInt32(args[2]));
if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
throw new Exception("Region not found");
if (regionIDInput.Length > 0)
{
var regionID = new UUID(regionIDInput);
if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
throw new Exception("Region not found");
}
else
{
rebootedScene = m_app.SceneManager.CurrentOrFirstScene;
}
message = GenerateShutdownMessage(delay);
@@ -149,7 +149,7 @@
},
"response": [
{
"id": "93cce335-56d0-439d-ab2d-bc42247dcfc9",
"id": "16cb3a46-3e64-4cfb-8109-6b2b41e92074",
"name": "ExampleLogin",
"originalRequest": {
"url": "http://localhost:9991/xmlrpc/RemoteAdmin",
@@ -326,7 +326,7 @@
},
"response": [
{
"id": "b23f8b80-f983-49b0-961f-aeb97c83caa5",
"id": "f6ad291d-89cf-4d98-8d5e-7123e00c3a04",
"name": "ExampleLogin",
"originalRequest": {
"url": "http://localhost:9991/xmlrpc/RemoteAdmin",
@@ -503,7 +503,7 @@
},
"response": [
{
"id": "8b4e579b-c537-4ce8-a0f1-be7089e3813f",
"id": "b81ceaa7-5bb4-45e8-b404-c92e115787a4",
"name": "ExampleLogin",
"originalRequest": {
"url": "http://localhost:9991/xmlrpc/RemoteAdmin",
@@ -623,7 +623,7 @@
},
"response": [
{
"id": "74ee02e5-af9a-4c94-a06f-e7bb82b57017",
"id": "06b67a3f-de08-4f8e-861d-11e70f959a8b",
"name": "ExampleLogin",
"originalRequest": {
"url": "http://localhost:9991/xmlrpc/RemoteAdmin",
@@ -740,6 +740,26 @@
},
"response": []
},
{
"name": "XMLRPC Region Server Restart (active region, default timeout)",
"request": {
"url": "{{PROTOCOL}}://{{REGION_URL}}:{{REGION_PORT}}/xmlrpc/RemoteAdmin",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "text/xml",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "<?xml version=\"1.0\"?>\n<methodCall>\n <methodName>Region.Restart</methodName>\n <params>\n <param>\n <value><string>{{rpc_login_key}}</string></value>\n </param>\n </params>\n</methodCall>"
},
"description": ""
},
"response": []
},
{
"name": "XMLRPC Region Server Restart (specified region, default timeout)",
"request": {
@@ -760,6 +780,66 @@
},
"response": []
},
{
"name": "XMLRPC Region Server Shutdown (active region, default timeout)",
"request": {
"url": "{{PROTOCOL}}://{{REGION_URL}}:{{REGION_PORT}}/xmlrpc/RemoteAdmin",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "text/xml",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "<?xml version=\"1.0\"?>\n<methodCall>\n <methodName>Region.Shutdown</methodName>\n <params>\n <param>\n <value><string>{{rpc_login_key}}</string></value>\n </param>\n </params>\n</methodCall>"
},
"description": ""
},
"response": []
},
{
"name": "XMLRPC Region Server Shutdown (active region, 10 sec)",
"request": {
"url": "{{PROTOCOL}}://{{REGION_URL}}:{{REGION_PORT}}/xmlrpc/RemoteAdmin",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "text/xml",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "<?xml version=\"1.0\"?>\n<methodCall>\n <methodName>Region.Shutdown</methodName>\n <params>\n <param>\n <value><string>{{rpc_login_key}}</string></value>\n </param>\n <param><!-- Time to wait until shut down, alerting users every minute. -->\n <value><int>10</int><!-- seconds --></value>\n </param>\n </params>\n</methodCall>"
},
"description": ""
},
"response": []
},
{
"name": "XMLRPC Region Server Shutdown (specified region, default timeout)",
"request": {
"url": "{{PROTOCOL}}://{{REGION_URL}}:{{REGION_PORT}}/xmlrpc/RemoteAdmin",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "text/xml",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "<?xml version=\"1.0\"?>\n<methodCall>\n <methodName>Region.Shutdown</methodName>\n <params>\n <param>\n <value><string>{{rpc_login_key}}</string></value>\n </param>\n <param><!-- UUID of region on server. -->\n <value><string>1337886a-bdd6-4b2e-bede-d3d3bb1184a9</string></value>\n </param>\n </params>\n</methodCall>"
},
"description": ""
},
"response": []
},
{
"name": "XMLRPC Region Server Shutdown (specified region, 10 sec)",
"request": {
@@ -960,7 +1040,7 @@
},
"response": [
{
"id": "57dab8fe-5248-4c19-9bef-203317c22123",
"id": "e0c4ba39-dff3-4352-85de-779544774536",
"name": "ExampleLogin",
"originalRequest": {
"url": "http://localhost:9991/xmlrpc/RemoteAdmin",
@@ -265,18 +265,39 @@ paths:
# * session.login_with_password(string username, string password)
# * session.logout(string sessionID)
# * Console.Command(string sessionID, string command)
### Region methods:
# * Region.SendAlert(string sessionID, string regionName, string message)
# * Region.Restart(string sessionID, string regionUUID) - restarts in 30 seconds.
# * Region.Shutdown(string sessionid, string regionUUID, int delayInSeconds)
# * Region.Backup(string sessionid, string regionName, string fileName, boolean storeAssets)
# * Region.Restore(string sessionid, string regionName, string fileName, boolean allowUserReassignment, boolean skipErrorGroups)
# * Region.SaveOAR(string sessionid, string regionName, string fileName, boolean storeAssets)
# * Region.LoadOAR(string sessionid, string regionName, string fileName, boolean allowUserReassignment, boolean skipErrorGroups)
# * Region.ChangeParcelFlags(string sessionid, string regionName, string enable["","enable"], int mask)
# * Region.SendAlert(string sessionID, string message) - send on active region.
# * Region.SendAlert(string sessionID, string regionName, string message) - send on specified region.
# * Region.Restart(string sessionID) - restarts active region in 30 seconds.
# * Region.Restart(string sessionID, string regionUUID) - restarts specified region on server in 30 seconds.
# * Region.Shutdown(string sessionid) - shutdown active region in 30 seconds.
# * Region.Shutdown(string sessionid, int delayInSeconds) - shutdown active region.
# * Region.Shutdown(string sessionid, string regionUUID) - shutdown specified region on server region in 30 seconds.
# * Region.Shutdown(string sessionid, string regionUUID, int delayInSeconds) - shutdown specified region on server region.
# * Region.Backup(string sessionid, string fileName, boolean storeAssets) - backup active region.
# * Region.Backup(string sessionid, string regionName, string fileName, boolean storeAssets) - backup specified region.
# * Region.Restore(string sessionid, string fileName, boolean allowUserReassignment, boolean skipErrorGroups) - restore active region.
# * Region.Restore(string sessionid, string regionName, string fileName, boolean allowUserReassignment, boolean skipErrorGroups) - restore specified region.
# * Region.SaveOAR(string sessionid, string fileName, boolean storeAssets) - save from active region.
# * Region.SaveOAR(string sessionid, string regionName, string fileName, boolean storeAssets) - save from specified region.
# * Region.LoadOAR(string sessionid, string fileName, boolean allowUserReassignment, boolean skipErrorGroups) - load into active region.
# * Region.LoadOAR(string sessionid, string regionName, string fileName, boolean allowUserReassignment, boolean skipErrorGroups) - load into specified region.
# * Region.ChangeParcelFlags(string sessionid, string enable["","enable"], int mask) - change flags for parcel on active region.
# * Region.ChangeParcelFlags(string sessionid, string regionName, string enable["","enable"], int mask) - change flags for parcel on specified region.
### Grid server methods
# * GridService.Shutdown(string sessionid, int delayInSeconds)
### Messaging server methods
# * MessagingService.Shutdown(string sessionid, int delayInSeconds)
### User server methods
# * UserService.Shutdown(string sessionid, int delayInSeconds)

0 comments on commit 93c6982

Please sign in to comment.