Add Storage

Description

Use the Add Storage API to add storage on your server by passing the required fields to the API.

Note: Create the folder on server before adding the storage.

Parameters

Sample Code

curl --insecure -d "addstorage=1" -d "name=STORAGE_NAME" -d "path=/STORAGE_PATH" -d "type=TYPE" -d "alert=STORAGE_ALERT_PERCENT" -u "username:password" -X POST "https://hostip:2005/index.php?api=json&act=addstorage"
<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2005/index.php?api=json&act=addstorage'; 

$post = array('addstorage' => '1', 'name' => 'STORAGE_NAME', 'path' => '/STORAGE_PATH', 'type' => 'TYPE', 'alert' => 'STORAGE_ALERT_PERCENT');


// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);

// Done ?
if(!empty($res['done'])){
	print_r($res['done']);
// Error
}else{
	print_r($res['error']);
}
<?php
include_once('/usr/local/webuzo/sdk/webuzo_sdk_v2.php');
$user = 'your_user';
$pass = 'your_password';
$host = 'your_ip';

$webuzo = new Webuzo_Admin_SDK($user, $pass, $host);

$name = 'STORAGE_NAME';
$path = '/STORAGE_PATH';
$type = 'STORAGE_TYPE';
$alert = 'STORAGE_ALERT_PERCENT';

$res = $webuzo->add_storage($name, $path, $type, $alert);

// Done/Error
if(!empty($res['error'])){
	print_r($res['error']);
}else{
	print_r($res['done']);
}

?>

Output

Array ( [msg] => The storage has been saved )
Was this page helpful?