VMmanager 6: Administrator guide

How to import a VM to VMmanager?

ISPSystem

You can import a virtual machine (VM) created with QEMU-KVM virtualization technology into the VMmanager platform. Import is possible only for VMs with one disk.

If the VM to be imported is in RAW format, it should be converted to Qcow2 format first. Read about VM disk formats in Storage types.

If the disk of the VM being imported is in Ceph, create a Ceph storage in VMmanager and connect it to the cluster. Read more about creating Ceph in Configuring Ceph RBD, about connecting a storage in Managing cluster storages.

Note

The following actions cannot be performed on imported VMs:

  • change the password with VMmanager tools;
  • automatically add and delete IP addresses;
  • automatically change the disk partition.

To import a VM:

  1. On the server with VMmanager:

    1. Log into VMmanager with administrator's permissions:

      curl -X POST 'https://domain.com/auth/v3/auth' -d '{"email": "admin_email", "password": "admin_pass"}'

      domain.com — domain name of the server with VMmanager

      admin_email — VMmanager administrator's email

      admin_pass — VMmanager administrator's password

      In response, you will get the message in the form:

      Response in JSON
      {
      "expires_at":"2020-03-30 10:24:21",
      "id":2,
      "session":"544EA22F56A1416A8A1CEFD0"
      }

      Save the value of the session id from the received response.

    2. Execute the command to create the VM:

      curl -k -H 'Cookie: ses6=<session>' -H 'isp-box-instance: true' -H 'x-xsrf-token: <session>' -X POST  "https://domain.com/vm/v3/host" -d '{"name":"<vm_name>", "cluster":<cluster_id>, "storage":<storage_id>, "account":<user_id>, "domain": "vm.example.com", "os": <os_id>, "password":"<vm_password>", "ram_mib":<ram_value>, "hdd_mib": <disk_value>, "cpu_number":<cpu_quantity>, "ip_addr": {"name": "<ip_address>", "ip_pool":<pool_id>, "ip_network": <network_id>}}'

      <session> — session id

      domain.com — domain name of the server with VMmanager

      <vmname> — VM name

      <cluster_id> — cluster id

      <user_id > — id of the VM owner user

      <storage_id> — storage id. If you need to move a VM with a disk in Ceph, select the Ceph storage.

      vm.example.com — domain name of the VM

      <os_id> — id of NoOS template for installing a VM without an operating system

      <vm_password> — random password to the VM. The value of this parameter will not change the password of the imported VM

      <ram_value> — RAM allocated for the VM (MB)

      <disk_value> — VM disk size (MB)

      <cpu_quantity> — CPU quantity for the VM

      <ip_address> — VM IP address

      <pool_id> — id of the pool from which the IP address will be assigned

      <network_id> — id of the physical network from which the IP address will be assigned

      Example of command
      curl -k -H 'Cookie: ses6=6258704D423C0F26E862B' -H 'isp-box-instance: true' -H 'x-xsrf-token: 6258704D423C0F26E862B' -X POST  "https://vm6.domain.com/vm/v3/host" -d '{"name":"test-solus", "cluster":1, "account":3, "domain": "test-solus.example.com", "os": 24, "password":"qwerty", "ram_mib":512, "hdd_mib": 20480, "cpu_number":1, "ip_addr": {"name": "172.31.214.42", "ip_pool":1, "ip_network": 2}}'
    3. Stop the created VM: Virtual machines → select the VM →  menu → StopStop.
    1. Create the VM with the required parameters: Virtual machinesCreate a VM. In the Operating system field, select NoOS. If you need to move a VM with a disk in Ceph, select the Ceph storage.
    2. Stop the created VM: Virtual machines → select the VM →  menu → StopStop.
  2. On the server with the VM being imported:
    1. Turn the VM off.
    2. Prepare the VM disk: 

      1. Convert the VM disk to Qcow2 format:

        Example of command
        qemu-img convert -f raw -O qcow2 path_to_vm/vm_raw vm_qcow

        path_to_vm/vm_raw — path and name of the source VM file in RAW format

        vm_qcow — output file name in Qcow2 format

      2. Copy the VM file in Qcow2 format to the VMmanager cluster node.
      1. Connect to the Ceph monitor server with the source VM and export its disk:

        Example of command
        rbd export pool-1/vm_disk /tmp/vm_output.raw

        pool-1 — Сeph pool name

        vm_disk — VM disk name

        /tmp/vm_output.raw — path and file name for RAW export

      2. Move the VM disk to the Ceph monitor server used by VMmanager.
  3. Import the VM into VMmanager:

    1. Copy the VM file to the storage directory:

      Example of command
      cp vm_qcow /vm/<vm_id>_<vm_name>

      /vm — VMstorage directory

      <vm_id>_<vm_name> — the name of a VM file containing the VM id and name. For example, for the VM with id 12 and the name test-solus, the file name must be 12_test-solus

    1. Convert the VM file to RAW format and copy it to the LVM storage:

      qemu-img convert -f qcow2 -O raw vm_qcow /dev/mapper/<vm_id>_<vm_name>

      /dev/mapper/ — path to the LVM disk

      <vm_id>_<vm_name> — the name of a VM file containing the VM id and name. For example, for the VM with id 12 and the name test-solus, the file name must be 12_test-solus.

    On the Ceph monitor server used by VMmanager:

    1. Delete the disk of the created VM:

      Example of command
      rbd rm pool-1/1234_vm_name

      pool-1 — name of the Сeph pool used by the platform

      1234_vm_name — VM disk name

    2. Import the disk of the source VM:

      Example of command
      rbd import vm_output.raw pool-1/1234_vm_name

      vm_output.raw — source VM file name

      pool-1 — name of the Сeph pool used by the platform

      1234_vm_name — VM disk name

  4. Start the imported VM: Virtual machines → select the VM →  menu → StartStart.
  5. If necessary, connect to the VM via VNC and change its network settings.
Thank you for your feedback!
Was the article useful?
Tell us why not:

it does not match the title

it was hard to understand

I didn't find the answer

recommendations from the article did not help

other

Tell us what you didn't like in the article: