Add volume

Use Add Volume API to create new volume on your server.

This function is for cloud user

HTTP Request

https://hostname:4083/index.php?act=volume

Parameters

ParametersTypeValueDescription
actGETvolumeThe action will create volume for a particular vps and user
volnamePOSTtextSpecify the name of the volume to be created.
vps_selPOSTIntVpsid for which volume is to be created.
vol_sizePOSTintSize of the volume that is to be created.
formatPOSTtextFormat for volume ext4 or xfs.
attach_volPOSTIntpass 1 to create and attach and 0 to just create it.
mntpointPOSTtextMountpoint to mount volume inside vps

Sample Code

PHP

<?php
    require_once('/usr/local/virtualizor/sdk/enduser.php');

    $key =  'your_api_key';
    $pass = 'your_api_pass';
    $ip = 'host_ip';

    $admin = new Virtualizor_Enduser_API($ip, $key, $pass);

    $post = array();
    $post['vol_size'] = '2'; 
    $post['vps_sel'] = '143'; 
    $post['format'] = 'ext4'; 
    $post['attach_vol'] = '1'; 
    $post['mntpoint'] = '/mnt'; 
    $post['volname'] = 'enduer'; 

    $output = $admin->add_volume($post);

    print_r(json_encode($output));
?>

Curl

curl -k -X POST -d "addvolume=1&vol_size=2&vps_sel=143&format=ext4&attach_vol=0&volname=sec" 
-L "https://hostname:4083/index.php?act=volume
&api=json&apikey=your_api_key
&apipass=your_api_pass"

 Output


Array
(
    [done] => Volume creation task is started in background
    [msg] => Volume creation task is started in background
    [goto] => act=volume
)
Was this page helpful?