Using your Cloud
Once your customer account has been created, you can use your Cloud with two different methods:
Via the manager

The manager is an easy to use interface for your Cloud available here.
The manager allows you to keep an eye on your entire Cloud and your billing. You can create instances, storages and follow the status of every element of your Cloud.
By using the Cloud API
Directly in your favourite programming language, the Cloud API consolidates all the possible functions of the Cloud. Function calling is done directly via the OVH web service.
To use the OVH web services, you only need to execute them on a web connected machine via a local server or a command line.
To get detailed information on all of the API functions and data structures, go to the page Cloud API documentation
OVH provides you with the "ovhcloud" script that allows you to use all the functions of the Cloud API in an easy way.
As a first step, get the script and make it executable:
# make it executable
~$ chmod +x ovhcloud
Run the script a first time to install any necessary add-ons:
~$ Cannot load module: JSON.
Would you like to install JSON now? (yes/no):
# Install Add-ons
Once the add-ons have been installed, you have access to the loud. Run the script to have access to the documentation. You can call all of the API functions via the ovhcloud script.
Specify namespace
USAGE:
call function:
./ovhcloud [instance|storage] functionName [[-v+] [--noskip|-n] [--parameterName parameter] ...
ssh to instance:
./ovhcloud instance ssh instanceId
get help for function:
./ovhcloud [instance|storage] help [-v+] [functionName|regex]
verbosity levels:
-v - warn
-vv - debug
don't skip optional parameters:
--noskip, -n
Additional information
If you launch a command without any parameters, ovhcloud will ask you for them at each step of its execution;
login (string): nic
password (string): ***
Function login results:
$RESULT1 = {
'__class' => 'sessionType:session',
'language' => 'en',
'billingCountry' => 'UK',
'id' => 'nic-ae1e528a4a139c3640d3b47a7bf3b2eb',
'startDate' => '2011-12-07T15:33:05+01:00',
'login' => 'nic'
};
~$
Session creation and function calling preparation
This section represents an entire script to use the API Cloud features.
It connects to the web service,
Creates a user session,
Predicts the main cases of errors in the "catch{}" function.
ini_set('soap.wsdl_cache_enabled', '0');
$nicHandle = '';
$password = '[Your password received by email during your order]';
$Client = new SoapClient(
'https://ws.ovh.com/cloud/public/instance/r2/soap.wsdl',
array(
'location' => 'https://ws.ovh.com/cloud/public/instance/r2/soap.dispatcher',
)
);
$sessionClient = new SoapClient( 'https://ws.ovh.com/sessionHandler/r2/soap.wsdl',
array(
'location' => 'https://ws.ovh.com/sessionHandler/r2/soap.dispatcher',
)
);
try {
// Connection and session creation
$result = $sessionClient->login( array(
'login' => $nicHandle, 'password' => $password, 'language' => 'fr', 'multisession' => 'true',
));
// Session
$session = $result->value->id;
// Display the session results (optional)
print( 'session id : ['.$session."]\n");
// Function calling will be done here
}
// Error recovery if the Cloud API calling failed
catch (SoapFault $fault)
{
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}
// Session closing
try {
# close session
$sessionClient->logout( array( 'sessionId' => $session ));
}
catch (SoapFault $ignore) { }
?>
Function calling
As your session is already created and your script ready, you can now concentrate on function calling.
This call takes place in the "try{}" section, from the call to the return of results. In this case, the return is done via a print_r, but it is also possible to return it to a specific function that will be able to process the results the way you want.
To get detailed information on all of the API functions and data structures, go to the page Cloud API documentation
// To call a function, create the $result variable,
// then use the command:
// $Client-> Function name (
// then pass the parameters in table format
// array(
// 'sessionId' => $session,
// ...
// )
//
// For example to call the 'newinstance' function
$result = $Client->newInstance( array(
'sessionId' => $session,
'projectId' => 'your ID',
'name' => 'myInstance',
'zone' => '[Datacentre of your choice]'
'offerName' => '[Select an instance from the range: xs s l xl]',
'distributionName' => '[Choose the OS]',
'persistentDiskSize' => '[value in GB]',
'scriptUrl' => '[http://....../install.sh]',
));
// Results display
print_r( $result->value);

