RemoteAdmin

From OpenSimulator

Revision as of 01:24, 27 July 2009 by Svanleeuwen (Talk | contribs)

Jump to: navigation, search


Caution ! The RemoteAdmin feature is unsecured at this time. For testing uses only.

How to Setup the Remote Admin

Setup OpenSim

First you should enable the remote admin interface to do so just add the following lines to your OpenSim.ini file:

[RemoteAdmin]
enabled = true
access_password = secret

Example in C# .NET

This example needs the Nwc.XmlRpc library, located in your OpenSim bin folder.

public void CreateUser(Uri url, string adminPassword, string firstName, string lastName, string password, string email, int regionX, int regionY)
{
    var address = Dns.GetHostEntry(url.DnsSafeHost).AddressList[0];
    var l = new List<object>();
    var ht = new Hashtable();
    ht["password"] = adminPassword;
    ht["user_firstname"] = firstName;
    ht["user_lastname"] = lastName;
    ht["user_password"] = password;
    ht["user_email"] = email;
    ht["start_region_x"] = regionX;
    ht["start_region_y"] = regionY;
    var parameters = new List<Hashtable> { ht };
    var rpc = new XmlRpcRequest("admin_create_user", parameters);
    rpc.Invoke(url.ToString());
}

[Test]
public void NativeUserRegistrationTest()
{
    CreateUser(new Uri("http://yourgrid.com:9000/"), "secret", "Test2", "user2", "apassword", "email@address.com", 0, 0);
}

Example in Python

# Author  : DrScofield 
# Source  : http://xyzzyxyzzy.net/2008/01/23/using-pythons-xmlrpclib-with-opensim/
# License : BSD License

#!/usr/bin/python  
import xmlrpclib  
  
# XML-RPC URL (http_listener_port)  
gridServerURL = ‘http://127.0.0.1:9000′  
   
# instantiate server object  
gridServer = xmlrpclib.Server(gridServerURL)  
  
# invoke admin_alert: requires password and message  
gridServer.admin_broadcast({’password’: ’secret’,   ‘message’: ‘the answer is 42′})

RemoteAdmin executable for Windows

The RemoteAdmin executable for Windows is a command line tool based on the RemoteAdmin PHP Class.

Downloads and documentation on the RemoteAdmin Executable webpage

Example in PHP

This example needs the RemoteAdmin PHP Class file available here.

<?php
 
// Author  : Olish Newman
// Source  : http://code.google.com/p/opensimtools/wiki/RemoteAdminPHPClass
// Licence : BSD License
 
// Including the RemoteAdmin PHP class. It can be downloaded from the link above.
include('RemoteAdmin.php');
 
// Instantiate the class with parameters identical to the Python example above
$myRemoteAdmin = new RemoteAdmin('127.0.0.1', 9000, 'secret');
 
// Invoke admin_broadcast
$parameters = array('message' => 'the answer is 42');
$myRemoteAdmin->SendCommand('admin_broadcast', $parameters);
 
// Invoke admin_shutdown (example for use without parameters)
$myRemoteAdmin->SendCommand('admin_shutdown');
 
// Invoke admin_create_user (multiple parameters)
$parameters = array('user_firstname' => 'Ruth', 'user_lastname' => 'OpenSim', 'user_password' => 'MyPassword', 'start_region_x' => '1000', 'start_region_y' => '1000');
$myRemoteAdmin->SendCommand('admin_create_user', $parameters);
?>

Note: This script does not appear to work for create user because it tries to pass the start region x and y as a string when the RemoteAdmin needs a string. The class needs to be edited to pass it as a number or edit the remoteadmin source to convert the string to a unsigned int.

Another example in PHP5, using CURL.

//This is the slightly modified RPC-class of the BSD-licensed WiXTD webportal
<?php
class RemotePC {
 
	function __construct() {
        $this->serveruri = "http://myhost";
        $this->serverport ="9000";
        $this->password ="foobar";
	}
 
	function call($command,$parameters) {
        $parameters['password'] = $this->password;
	$request = xmlrpc_encode_request($command, $parameters);
	$ch = curl_init();
	curl_setopt( $ch, CURLOPT_URL, $this->serveruri);
	curl_setopt( $ch, CURLOPT_PORT, $this->serverport]);	
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt ( $ch, CURLOPT_POSTFIELDS, $request);
	curl_setopt ( $ch, CURLOPT_TIMEOUT, 5);	
	$result = curl_exec($ch);
	curl_close($ch); 
	return xmlrpc_decode($result);
	}
}
?>


Example in Perl

Because the OpenSim internal web server just accepts HTTP/1.0 requests, it's worth to give a perl example. It's not a daily thing to do HTTP/1.0 within the LWP environment. You can get the Perl example here.

RemoteAdmin Commands

Name Status Description Parameters
admin_create_region Create a new region region_name, region_id (optional), region_master_first, region_master_last, region_master_uuid (optional), region_master_password, listen_ip, listen_port (integer), external_address, region_x (integer), region_y (integer), persist (optional)
admin_delete_region Delete a region region_name
admin_modify_region Modify a region region_name, region_id (optional), public, enable_voice
admin_region_query Query the 'health' of a region region_uuid or region_name
admin_shutdown Shut down the simulator shutdown (optional, expects 'delayed'), milliseconds
admin_broadcast Send a general alert message
admin_restart Restart Region regionid
admin_load_heightmap Load Height Map filename, regionid
admin_create_user Create a new user user_firstname, user_lastname, user_password, start_region_x, start_region_y
admin_create_user_email Create a new user (alias for admin_create_user) user_firstname, user_lastname, user_password, start_region_x, start_region_y
admin_exists_user Check whether a certain user account exists user_firstname, user_lastname
admin_update_user Update the password/home of a user account user_firstname, user_lastname, user_password, start_region_x, start_region_y
admin_load_xml Execute the Load XML command filename, region_uuid (or region_name), xml_version
admin_save_xml Execute the Save XML command filename, region_uuid (or region_name), xml_version
admin_load_oar Load a saved OAR file into a region filename, region_uuid (or region_name)
admin_save_oar Saved an OAR file of a regions contents filename, region_uuid (or region_name)
admin_region_query Query the 'health' of a region region_uuid or region_name
admin_acl_list Retrieve a list of users who can access the region region_uuid or region_name
admin_acl_clear Clear the access list for the region region_uuid or region_name
admin_acl_add Add a list of users to the access control list region_uuid or region_name, users
admin_acl_remove Remove a list of users from the access control list region_uuid or region_name, users

Credits

Thanks to DrScofield for the Python Script Sources : http://xyzzyxyzzy.net/2008/01/23/using-pythons-xmlrpclib-with-opensim/

Personal tools
General
About This Wiki