@Test
  public void test() throws ApiSenderException {
    VmInstanceInventory vm = deployer.vms.get("TestVm");
    api.stopVmInstance(vm.getUuid());
    PrimaryStorageInventory local = deployer.primaryStorages.get("local");

    VolumeSnapshotInventory sp = api.createSnapshot(vm.getRootVolumeUuid());
    Assert.assertFalse(kconfig.snapshotCmds.isEmpty());
    LocalStorageResourceRefVO ref = dbf.findByUuid(sp.getUuid(), LocalStorageResourceRefVO.class);
    Assert.assertNotNull(ref);
    Assert.assertEquals(vm.getHostUuid(), ref.getHostUuid());

    sp = api.createSnapshot(vm.getRootVolumeUuid());
    ref = dbf.findByUuid(sp.getUuid(), LocalStorageResourceRefVO.class);
    Assert.assertNotNull(ref);
    Assert.assertEquals(vm.getHostUuid(), ref.getHostUuid());

    sp = api.createSnapshot(vm.getRootVolumeUuid());
    ref = dbf.findByUuid(sp.getUuid(), LocalStorageResourceRefVO.class);
    Assert.assertNotNull(ref);
    Assert.assertEquals(vm.getHostUuid(), ref.getHostUuid());

    PrimaryStorageVO localvo = dbf.findByUuid(local.getUuid(), PrimaryStorageVO.class);
    long avail = localvo.getCapacity().getAvailableCapacity();

    ImageInventory img = api.createTemplateFromSnapshot(sp.getUuid());
    Assert.assertTrue(img.getSize() != 0);

    localvo = dbf.findByUuid(local.getUuid(), PrimaryStorageVO.class);
    Assert.assertEquals(avail, localvo.getCapacity().getAvailableCapacity());
  }
  @Test
  public void test() throws ApiSenderException {
    VmInstanceInventory vm = deployer.vms.get("TestVm");
    api.stopVmInstance(vm.getUuid());
    String rootVolumeUuid = vm.getRootVolumeUuid();
    VolumeVO vol = dbf.findByUuid(rootVolumeUuid, VolumeVO.class);

    BackupStorageInventory sftp = deployer.backupStorages.get("sftp");
    ImageInventory image =
        api.createTemplateFromRootVolume("testImage", rootVolumeUuid, (List) null);
    Assert.assertEquals(sftp.getUuid(), image.getBackupStorageRefs().get(0).getBackupStorageUuid());
    Assert.assertEquals(ImageStatus.Ready.toString(), image.getStatus());
    Assert.assertEquals(vol.getSize(), image.getSize());
    Assert.assertEquals(String.format("volume://%s", vol.getUuid()), image.getUrl());

    ImageVO ivo = dbf.findByUuid(image.getUuid(), ImageVO.class);
    Assert.assertNotNull(ivo);
  }