API Add Storage

From Virtualizor Wiki
Jump to: navigation, search
This is OLD API Documentation. Click on the following link for New API Documentation
Admin API

Add Storage

Parameters Type Description
addstorage POST Flag to Add Storage
name POST Name of the Storage
serid[] POST Server Id on which storage is to created ()
path POST Path of the Storage (In case of LVM / Thin LVM the Volume Group path should be of form /dev/VG_NAME)
type. POST Type of Storage to add (file, block, openvz, thin block)
format POST Format of the Storage (raw, qcow2)
oversell POST Disk space to overcommit in GBs
alert_threshold POST If storage exceeds threshold, an email is sent to admin (in percentage)
primary_storage POST Set it as on to use storage as primary or do not define

Example Code



    $key =  'uketenhrhpunty5lhgwkcuxxxxxxxxxx';

    $pass = 'yrsofc3tg3tre7bjpfppspxxxxxxxxxx';

    $ip = 'xxx.xxx.xxx.xxx';

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

    $post['addstorage'] = 1;
    $post['name'] = 'vms';
    $post['serid[]'] = -1;
    $post['path'] = '/vms';
    $post['type'] = 'file';
    $post['format'] = 'qcow2';
    $post['oversell'] = 0;
    $post['alert_threshold'] = 90;
    $post['primary_storage'] = '';
    $output = $admin->addstorage($post);

Returns: <syntaxhighlight lang="php"> Array (

   [title] => Add Storage
   [done] => 50;
   [error] => 
   [timenow] => 1430984737
   [time_taken] => 0.056