API IP to Pool

From Virtualizor Wiki
Jump to: navigation, search

Add an IP to pool

Parameters Description
submitip Confirmation to add the IPs
iptype 4 for IPv4, 6 for IPv6
ips An array containing ips
macs An array containing mac addresses
ips6 An array containing IPv6 addresses
firstip First IP of the range if there are multiple IPs
lastip Last IP of the range if there are multiple IPs
ipv6_1 The first field of the Ipv6 address
ipv6_2 The second field of the Ipv6 address
ipv6_3 The third field of the Ipv6 address
ipv6_4 The fourth field of the Ipv6 address
ipv6_5 The fifth field of the Ipv6 address
ipv6_6 The sixth field of the Ipv6 address
ippid The IP Pool id
ipv6_num The number of Ipv6 addresses
ip_serid The server id in which the pool exists

Example Code

<?php

    require_once('admin.php');

    $key =  'uketenhrhpunty5lhgwkcuxxxxxxxxxx';

    $pass = 'yrsofc3tg3tre7bjpfppspxxxxxxxxxx';

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

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

    $post = array();
    $post['submitip'] = 1;
    $post['iptype']  = 4;
    $post['ips']     = array('');
    $post['macs']    = array('');
    $post['ips6']    = array(array('','','','','','','',''));
    $post['firstip'] = '192.168.1.221';
    $post['lastip']  = '192.168.1.224';
    $post['ipv6_1']  = '';
    $post['ipv6_2']  = '';
    $post['ipv6_3']  = '';
    $post['ipv6_4']  = '';
    $post['ipv6_5']  = '';
    $post['ipv6_6']  = '';
    $post['ipv6_num']= '50';
    $post['ippid']   = '259';
    $post['ip_serid']= '0';

    $output = $admin->addips($post);
    print_r($output);
?>

Returns:

Array
(
    [title] => Add IP
    [done] => Array
        (
            [range] => Array
                (
                    [3796] => 192.168.1.221
                    [3797] => 192.168.1.222
                    [3798] => 192.168.1.223
                    [3799] => 192.168.1.224
                )

            [done] => 1
        )

    [timenow] => 1402915286
    [time_taken] => 0.018
)