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
Name | Method | Type | Description | Required |
---|---|---|---|---|
act | GET | text | The action specified to retrieve data after vps is powered off | Yes |
sa | GET | text | The import wizard name of which to use import functionality. | Yes |
ta | GET | text | The action of which we want the data or on which to perform import. | Yes |
changeserid | GET | int | The serid of server on which SolusVM is installed, Provide if setup is on slave server, for master server no need to pass this parameter | No |
Supported "ta" Actions
Value | Description | Return Parameters | Required |
---|---|---|---|
nodes | Provide if you want to view Nodes | solusvm_nodes | Yes |
nodegroups | Provide if you want to view Node Groups | solusvm_nodegroups | Yes |
plans | Provide if you want to view Plans | solusvm_plans | Yes |
users | Provide if you want to view Users | solusvm_users | Yes |
ips | Provide if you want to view IP Pools | solusvm_ipblocks solusvm_ipblocknodes | Yes |
os | Provide if you want to view OS templates | solusvm_templates | Yes |
vps | Provide if you want to view VMs | solusvm_vps | Yes |
Supported Import Functions
Provide the Parameters in Name column to import specific utility.
Name | Method | Type | Description | "ta" | Required |
---|---|---|---|---|---|
solusvm_ng | POST | int | Provide if you want to Import Node Groups | nodegroups | Yes |
solusvm_plans | POST | int | Provide if you want to Import Plans | plans | Yes |
solusvm_users | POST | int | Provide if you want to Import Users | users | Yes |
solusvm_ips | POST | int | Provide if you want to Import IPs | ips | Yes |
solusvm_os | POST | int | Provide if you want to Import OS | os | Yes |
solusvm_vps | POST | int | Provide if you want to Import VPS | vps | Yes |
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"
}