Rebuild VPS

Use the Rebuild VPS API to rebuild the VPS present on your server. Rebuilding the VPS involves formatting the VPS disk and installing a new OS on the VPS. In addition to VPS ID, you need to pass in the osid for the rebuilding of the VPS. The osid can be fetched using the Template Browser API which will return the OS IDs in the “oses” array.

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETrebuildThe action specified to retrieve data after vps is rebuildYes
vpsidPOSTIntThe ID of the VPS to be rebuiltYes
osidPOSTIntThe ID of the OS TemplateYes
newpassPOSTtextThe new root passwordYes
confPOSTtextThe confirmation passwordYes
format_primaryPOST1/0If this parameter is set as one then only primary disk will be formatted of the OS. Other disks remains as it is.(Supported only for VPS(s) on KVM, PROXMOX KVM and XEN HVM)No
eu_send_rebuild_emailPOST1/0If this is set as one, an email will be sent to the VPS user after the VPS is rebuiltNo

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['vpsid'] = 51;
    $post['osid'] = 270;
    $post['newpass'] = '1234599';
    $post['conf'] = '1234599';

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

    print_r(json_encode($output));
?>

Output

{
  "title": "Rebuild Virtual Server",
  "done": 1,
  "vpses": {
    "51": {
      "vpsid": "51",
      "vps_name": "v1009",
      "uuid": "zou88fl1avyklu0s",
      "serid": "0",
      "time": "1535018665",
      "edittime": "1535123989",
      "virt": "kvm",
      "uid": "57",
      "plid": "1",
      "hostname": "test123",
      "osid": "270",
      "os_name": "centos-6.5-x86",
      "iso": "",
      "sec_iso": "",
      "boot": "cda",
      "space": "3",
      "inodes": "0",
      "ram": "1024",
      "burst": "0",
      "swap": "1024",
      "cpu": "1000",
      "cores": "2",
      "cpupin": "-1",
      "cpu_percent": "0.00",
      "bandwidth": "0",
      "network_speed": "0",
      "upload_speed": "0",
      "io": "0",
      "ubc": "a:0:{}",
      "acpi": "1",
      "apic": "1",
      "pae": "1",
      "shadow": "0",
      "vnc": "1",
      "vncport": "5902",
      "vnc_passwd": "",
      "hvm": "0",
      "suspended": "0",
      "suspend_reason": null,
      "nw_suspended": null,
      "rescue": "0",
      "band_suspend": "0",
      "tuntap": "0",
      "ppp": "0",
      "ploop": "0",
      "dns_nameserver": "a:0:{}",
      "osreinstall_limit": "0",
      "preferences": null,
      "nic_type": "virtio",
      "vif_type": "",
      "virtio": "0",
      "pv_on_hvm": "0",
      "disks": null,
      "kvm_cache": "0",
      "io_mode": "0",
      "cpu_mode": "default",
      "total_iops_sec": "0",
      "read_bytes_sec": "0",
      "write_bytes_sec": "0",
      "kvm_vga": "0",
      "acceleration": "0",
      "vnc_keymap": "en-us",
      "routing": "0",
      "mg": "",
      "used_bandwidth": "0.20",
      "cached_disk": "a:2:{s:4:\"disk\";a:3:{s:4:\"Used\";i:777580;s:9:\"Available\";i:1319572;s:4:\"Use%\";d:37.0799999999999982946974341757595539093017578125;}s:5:\"inode\";a:4:{s:6:\"Inodes\";i:131072;s:5:\"IUsed\";i:21318;s:5:\"IFree\";i:109754;s:4:\"Use%\";d:16.260000000000001563194018672220408916473388671875;}}",
      "webuzo": "0",
      "disable_ebtables": "0",
      "install_xentools": "0",
      "admin_managed": "0",
      "rdp": "1",
      "topology_sockets": "0",
      "topology_cores": "0",
      "topology_threads": "0",
      "mac": "00:16:3e:72:fe:16",
      "notes": "",
      "disable_nw_config": "0",
      "locked": "",
      "openvz_features": "",
      "speed_cap": "",
      "numa": "0",
      "bpid": "0",
      "bserid": "0",
      "timezone": null,
      "usbdevice": "N;"
    }
  },
  "ostemplates": null,
  "vps": {
    "vpsid": "51",
    "vps_name": "v1009",
    "uuid": "zou88fl1avyklu0s",
    "serid": "0",
    "time": "1535018665",
    "edittime": "1535123989",
    "virt": "kvm",
    "uid": "57",
    "plid": "1",
    "hostname": "test123",
    "osid": "270",
    "os_name": "centos-6.5-x86",
    "iso": "",
    "sec_iso": "",
    "boot": "cda",
    "space": "3",
    "inodes": "0",
    "ram": "1024",
    "burst": "0",
    "swap": "1024",
    "cpu": "1000",
    "cores": "2",
    "cpupin": "-1",
    "cpu_percent": "0.00",
    "bandwidth": "0",
    "network_speed": "0",
    "upload_speed": "0",
    "io": "0",
    "ubc": false,
    "acpi": "1",
    "apic": "1",
    "pae": "1",
    "shadow": "0",
    "vnc": "1",
    "vncport": "5902",
    "vnc_passwd": "",
    "hvm": "0",
    "suspended": "0",
    "suspend_reason": null,
    "nw_suspended": null,
    "rescue": "0",
    "band_suspend": "0",
    "tuntap": "0",
    "ppp": "0",
    "ploop": "0",
    "dns_nameserver": "a:0:{}",
    "osreinstall_limit": "0",
    "preferences": null,
    "nic_type": "virtio",
    "vif_type": "",
    "virtio": "0",
    "pv_on_hvm": "0",
    "disks": [
      {
        "did": "58",
        "disk_uuid": "da3pbqt8qgolohhk",
        "st_uuid": "ngavdbegidnbme2d",
        "vps_uuid": "zou88fl1avyklu0s",
        "path": "/dev/vg/vsv1009-da3pbqt8qgolohhk-zou88fl1avyklu0s",
        "primary": "1",
        "size": "3.000",
        "size_unit": "",
        "type": "block",
        "format": "raw",
        "num": "0",
        "rescue": "0",
        "extra": "",
        "vpsid": 51
      }
    ],
    "kvm_cache": "0",
    "io_mode": "0",
    "cpu_mode": "default",
    "total_iops_sec": "0",
    "read_bytes_sec": "0",
    "write_bytes_sec": "0",
    "kvm_vga": "0",
    "acceleration": "0",
    "vnc_keymap": "en-us",
    "routing": "0",
    "mg": "",
    "used_bandwidth": "0.20",
    "cached_disk": {
      "disk": {
        "Used": 777580,
        "Available": 1319572,
        "Use%": 37.08
      },
      "inode": {
        "Inodes": 131072,
        "IUsed": 21318,
        "IFree": 109754,
        "Use%": 16.26
      }
    },
    "webuzo": "0",
    "disable_ebtables": "0",
    "install_xentools": "0",
    "admin_managed": "0",
    "rdp": "1",
    "topology_sockets": "0",
    "topology_cores": "0",
    "topology_threads": "0",
    "mac": "00:16:3e:72:fe:16",
    "notes": "",
    "disable_nw_config": "0",
    "locked": "",
    "openvz_features": "",
    "speed_cap": "",
    "numa": "0",
    "bpid": "0",
    "bserid": "0",
    "timezone": null,
    "usbdevice": "N;",
    "pid": "0",
    "ips": [
      "10.10.100.10"
    ]
  },
  "actid": "345",
  "timenow": 1535130476,
  "time_taken": "0.167"
}
Was this helpful to you?