Libr1soft2 is a project mainly written in PHP, based on the MIT license.
PHP toolkit for working with R1soft CDP Server v2
libr1soft2 is a PHP toolkit for working with the R1soft CDP v2.0 XMLRPC API, intended for use in a larger project or just in a small script to automate some of the common tasks R1soft users do.
Since this is intended to be used in other projects, rather than as a stand-alone
tool, there is no real installation. However, due to a bug in either ZendFramework
or the R1soft XMLRPC API implementation, ZendFramework will need to be patched
with the Zend_XmlRpc_Request.php.patch file.
The bug is that the original Zend_XmlRpc_Request class will not add a
There are two basic ways to use libr1soft2:
1) Using the stand-alone R1soft_Remote object.
2) Using the full R1soft_Object object model.
For the first, usage is very simple since the R1soft_Remote is just a simple wrapper around the Zend_XmlRpc_Client_ServerProxy object. Here is an example (note that this assumes that there is an automatic class loader in use):
$server = new R1soft_Remote( 'r1soft.example.com', 'user', '12345', true );
//you can now use $server like a normal proxy object
$host = $server->host->getHostByHostname( 'host.example.com' );
//check the R1soft API documentation for the meaning of the returned array:
// http://wiki.r1soft.com/display/R1D/CDP+Server+API+Guide
$hostID = $host[0];
if( $server->host->isHostDiscoveryFinished( $hostID ) ) {
$server->backupTask->scheduleBackupTask(
true, 'backup test', $hostID, 1, true, true, true, array(), array(),
7, 0, array(), array() );
}
The object model is more complex:
$api = new R1soft_Remote( 'r1soft.example.com', 'user', '12345', true );
//get a host object
$host = new R1soft_Host( $api, 'host.example.com' );
//get it's active disk safe
$disksafe = $host->getActiveDiskSafe();
//add a new disk safe with compression level 1 and allow 5% free space before defrag
$newDisksafe = $host->addDiskSafe( 1, 5.0 );
//delete the old disk safe, any further calls on the $disksafe object will throw
// a R1soft_Object_Exception
$disksafe->delete();
//all the objects automatically inherit the methods in their namespace so
// just because a method isn't implemented directly in libr1soft2 doesn't
// mean it's not available. You can use most set/get property like methods
// as actual properties.
$user = new R1soft_User( $api );
$user->emailAddress = '[email protected]';
$host->addUser( $user->getID() );