Add Storage

Use the Add Storage API to add storage space information which will be used for the creation of vps. You can set the type, format etc using this API. You can define multiple storage per physical node. Virtualizor supports multiple types of storage viz “LVM based storage”, “File based storage”, “ZFS storage”, “Thin LVM based storage”, “Ceph Block storage” and “Ceph File System”. The API response will contain “done” as the storage ID on successful addition of the storage information.

The partition/volume for the storage should be present on the server before the API call is made. If there are multiple storages then atleast one storage should be made primary storage.

For more information, please refer this Add Storage guide.

HTTP Request

https://hostname:4085/index.php?act=addstorage

Parameters

NameMethodValueDescriptionRequired
actGETaddstorageThe action specified carries out operation and returns success if the storage has been added successfullyYes
namePOSTnameName of the StorageYes
seridPOSTarrayServer ID on which storage exist, array for shared storageYes
pathPOSTtextPath of the Storage, as defined in Storage type availableYes
typePOSTtextType of Storage to add (file, block, openvz, thin block, zfs block, zfs thin block, zfs block compressed, zfs thin block compressed, ceph block)Yes
formatPOSTtextFormat of the Storage (raw, qcow2, vhd). Not required for OpenVz, ZFS Thin Compressed and Ceph Block DeviceYes
oversellPOSTIntDisk space to overcommit in GBsNo
alert_thresholdPOSTIntIf storage exceeds threshold, an email is sent to admin (in percentage)No
primary_storagePOST1/01 to use storage as primaryNo

Storage type available

NamePath
LVMVolume Group path /dev/VG_NAME
FileAbsolute path /FileStorage
OpenVZAbsolute path /vz
Thin LVMThin Volume Group path /dev/VGName/THINPOOLNAME
ZFS PoolZFS Volume Group path /dev/zvol/YOUR_POOLNAME
ZFS ThinZFS Volume Group path /dev/zvol/YOUR_POOLNAME
ZFS CompressedZFS Volume Group path /dev/zvol/YOUR_POOLNAME
ZFS Thin CompressedZFS Volume Group path /dev/zvol/YOUR_POOLNAME
Ceph Block DeviceCeph Block Device path /dev/rbd/CEPH_POOLNAME

Sample Code

<?php

    require_once('/usr/local/virtualizor/sdk/admin.php');

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

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

    $post = array();
    $post['name'] = 'Test Storage';
    $post['serid'] = 0;
    $post['path'] = '/dev/vg/thin_pool';
    $post['type'] = 'thin block';
    $post['format'] = 'raw';

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

    print_r(json_encode($output));
?>

Output

{
    "title": "Add Storage",
    "done": "2",
    "timenow": 1535562728,
    "time_taken": "0.303"
}
Was this helpful to you?