Get Virtualizor

Add Storage

Use the Add Storage API to define multiple storage on the virtualizor, Which will used to create vps on the node.The different type of storage can be defined in virtualizor panel such as (LVM, File, Thin LVM, Openvz, ZFS Pool, ZFS Thin, ZFS Compressed, Ceph Block Device).
Storages can be shared between the multple servers.

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETvolumesThe action specified carries out operation and returns success if the storage has been added successfullyYes
namePOSTnameName of the storageYes
pathPOSTtextPath of the StorageYes
typePOSTtextType of storageYes
seridPOSTarrayserid of node integer, for shared storage arrayYes
formatPOSTtextFormat type of storage (raw, vhd, qcow2)Yes
primary_storagePOST1/0To make storage primary pass 1 or 0Yes
oversellPOSTintMax disk space you want to Overcommit for this storage in GB'sNo
alert_thresholdPOSTintEmail will be send to admin if it crosses threshold limitNo
Lightbit project namePOSTstringwhile adding lightbits storage add project of lightbits storageNo

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
Lightbits storageLightbits Block Device path /dev/disk/by-id/uuid

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 page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list