Import SolusVM

Use the Import SolusVM API to get Import supported utilities.

HTTP Request

https://hostname:4085/index.php?act=import&sa=solusvm&ta=ACTION&changeserid=SERID

Parameters

NameMethodTypeDescriptionRequired
actGETtextThe action specified to retrieve data after vps is powered offYes
saGETtextThe import wizard name of which to use import functionality.Yes
taGETtextThe action of which we want the data or on which to perform import.Yes
changeseridGETintThe serid of server on which SolusVM is installed, Provide if setup is on slave server, for master server no need to pass this parameterNo

Supported “ta” Actions

ValueDescriptionReturn ParametersRequired
nodesProvide if you want to view Nodessolusvm_nodesYes
nodegroupsProvide if you want to view Node Groupssolusvm_nodegroupsYes
plansProvide if you want to view Planssolusvm_plansYes
usersProvide if you want to view Userssolusvm_usersYes
ipsProvide if you want to view IP Poolssolusvm_ipblocks
solusvm_ipblocknodes
Yes
osProvide if you want to view OS templatessolusvm_templatesYes
vpsProvide if you want to view VMssolusvm_vpsYes

Supported Import Functions

Provide the Parameters in Name column to import specific utility.

NameMethodTypeDescription“ta” Required
solusvm_ngPOSTintProvide if you want to Import Node GroupsnodegroupsYes
solusvm_plansPOSTintProvide if you want to Import PlansplansYes
solusvm_usersPOSTintProvide if you want to Import UsersusersYes
solusvm_ipsPOSTintProvide if you want to Import IPsipsYes
solusvm_osPOSTintProvide if you want to Import OSosYes
solusvm_vpsPOSTintProvide if you want to Import VPSvpsYes

If you are importing OS templates and templates have type kvm/xenhvm then you need to post additional parameters

<?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['ta'] = 'os';
    $post['changeserid'] = 3;

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

    foreach($output['solusvm_templates'] as $ok => $ov){
      foreach($ov as $virt => $os_temps){
        if($os_temps['type'] == 'openvz' || $os_temps['type'] == 'xen')continue;
        echo '$post[\''.$ok.'_'.$os_temps['templateid'].'\'] = \'VIRTUALIZOR_OS_TEMPLATE_ID\';'.PHP_EOL;
     }
   }

?>

The above code will output:
$post[‘kvm_2’] = ‘VIRTUALIZOR_OS_TEMPLATE_ID’;
$post[‘kvm_5’] = ‘VIRTUALIZOR_OS_TEMPLATE_ID’;

Replace the “VIRTUALIZOR_OS_TEMPLATE_ID” with virtualizor os template id you can get os template list using following api:
https://www.virtualizor.com/docs/admin-api/api-os-templates

Note: During replacing VIRTUALIZOR_OS_TEMPLATE_ID if solus template type is kvm then VIRTUALIZOR_OS_TEMPLATE_ID should be also of type kvm

After replacing the equivalent os ids, copy the above mentioned parameters and pass it during os template import.

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['ta'] = 'os';
    $post['changeserid'] = 3;
    $post['solusvm_os'] = 1; //Provide if you want to import
    $post['kvm_2'] = '334';//Provide if you want to import os
    $post['kvm_5'] = '334'; //Provide if you want to import os
    $output = $admin->import_solusvm($post);

    print_r(json_encode($output));

?>

Output

{
   "title":"Import",
   "solusvm_templates":{
      "xen":{
         "1":{
            "templateid":"1",
            "type":"xen",
            "catid":"0",
            "filename":"centos-7.1-x64-1.1-xen.kvm.kvm_virtio",
            "friendlyname":"centos-7.1-x64-1.1-xen.kvm.kvm_virtio",
            "description":"Xen PV template",
            "icon":"",
            "minmem":"65536",
            "status":"Active",
            "arch":"x86_64",
            "kernel":"1",
            "extra":"",
            "mediagroups":"",
            "exttype":"0",
            "rootdevice":"2",
            "clean_ssh_keys":"1",
            "_filename":"centos-7.1-x64-1.1-xen.kvm.kvm_virtio.tar.gz"
         },
         "2":{
            "templateid":"2",
            "type":"xen",
            "catid":"0",
            "filename":"centos-7.1-x64-1.1-xen.kvm.kvm_virtio",
            "friendlyname":"CentOS7.1x64XenPV",
            "description":"Xen PV template",
            "icon":"",
            "minmem":"65536",
            "status":"Active",
            "arch":"x86_64",
            "kernel":"1",
            "extra":"",
            "mediagroups":"",
            "exttype":"0",
            "rootdevice":"2",
            "clean_ssh_keys":"1",
            "_filename":"centos-7.1-x64-1.1-xen.kvm.kvm_virtio.tar.gz"
         }
      },
      "openvz":{
         "3":{
            "templateid":"3",
            "type":"openvz",
            "catid":"0",
            "filename":"centos-7-x86_64-minimal",
            "friendlyname":"CentOS 7 x64 Minimal OpenVZ6",
            "description":"OpenVZ 6 Template",
            "icon":"",
            "minmem":"65536",
            "status":"Active",
            "arch":"i386",
            "kernel":"0",
            "extra":"",
            "mediagroups":"",
            "exttype":"0",
            "rootdevice":"0",
            "clean_ssh_keys":"0",
            "_filename":"centos-7-x86_64-minimal.tar.gz"
         }
      },
      "kvm":{
         "2":{
            "templateid":"2",
            "type":"kvm",
            "filename":"linux-centos-7-x86_64-minimal-latest",
            "friendlyname":"centos-7-x86_64-minimal",
            "description":"Test",
            "status":"Active",
            "arch":"i386",
            "rootpass":"",
            "mediagroups":"2",
            "information":"",
            "diskdriver":"1",
            "changerootpass":"0",
            "part1":"1",
            "swappart":"2",
            "generation":"1",
            "networking":"0",
            "cpumodel":"1",
            "cpumatch":"1",
            "cpusockets":"1",
            "cpucores":"1",
            "cputhreads":"1",
            "cputopcheck":"0",
            "cpumatchcheck":"0",
            "cpumodelcheck":"0",
            "nosparse":"0",
            "_filename":"linux-centos-7-x86_64-minimal-latest.gz.2.solus.kvm"
         },
         "5":{
            "templateid":"5",
            "type":"kvm",
            "filename":"linux-centos-7-x86_64-minimal-latest",
            "friendlyname":"Centos7",
            "description":"wxw",
            "status":"Active",
            "arch":"i386",
            "rootpass":"password",
            "mediagroups":"",
            "information":"",
            "diskdriver":"1",
            "changerootpass":"0",
            "part1":"1",
            "swappart":"2",
            "generation":"1",
            "networking":"0",
            "cpumodel":"1",
            "cpumatch":"1",
            "cpusockets":"1",
            "cpucores":"1",
            "cputhreads":"1",
            "cputopcheck":"0",
            "cpumatchcheck":"0",
            "cpumodelcheck":"0",
            "nosparse":"0",
            "_filename":"linux-centos-7-x86_64-minimal-latest.gz.5.solus.kvm"
         }
      }
   },
   "timenow":1606883545,
   "time_taken":"0.090"
}
Was this helpful to you?