Exemplo n.º 1
0
  @Test
  public void test() throws ApiSenderException {
    PrimaryStorageInventory local = deployer.primaryStorages.get("local");
    VmInstanceInventory vm1 = deployer.vms.get("TestVm");
    VmInstanceInventory vm2 = deployer.vms.get("TestVm1");
    DiskOfferingInventory dof = deployer.diskOfferings.get("TestDiskOffering1");
    VolumeInventory data = api.createDataVolume("data", dof.getUuid());
    data = api.attachVolumeToVm(vm1.getUuid(), data.getUuid());
    data = api.detachVolumeFromVm(data.getUuid());

    List<VmInstanceInventory> vms = api.getDataVolumeCandidateVmForAttaching(data.getUuid());
    Assert.assertEquals(1, vms.size());

    api.localStorageMigrateVolume(data.getUuid(), vm2.getHostUuid(), null);

    vms = api.getDataVolumeCandidateVmForAttaching(data.getUuid());
    Assert.assertEquals(1, vms.size());
    Assert.assertEquals(vm2.getUuid(), vms.get(0).getUuid());

    List<VolumeInventory> vols = api.getVmAttachableVolume(vm2.getUuid());
    Assert.assertEquals(1, vols.size());
    Assert.assertEquals(data.getUuid(), vols.get(0).getUuid());

    vols = api.getVmAttachableVolume(vm1.getUuid());
    Assert.assertEquals(0, vols.size());

    api.localStorageMigrateVolume(data.getUuid(), vm1.getHostUuid(), null);

    vols = api.getVmAttachableVolume(vm1.getUuid());
    Assert.assertEquals(1, vols.size());
    Assert.assertEquals(data.getUuid(), vols.get(0).getUuid());

    vols = api.getVmAttachableVolume(vm2.getUuid());
    Assert.assertEquals(0, vols.size());
  }
Exemplo n.º 2
0
  @Test
  public void test() throws ApiSenderException {
    DiskOfferingInventory dinv = new DiskOfferingInventory();
    dinv.setDiskSize(SizeUnit.GIGABYTE.toByte(10));
    dinv.setName("Test");
    dinv.setDescription("Test");
    dinv = api.addDiskOffering(dinv);

    VolumeInventory vinv = api.createDataVolume("TestData", dinv.getUuid());
    Assert.assertEquals(VolumeStatus.NotInstantiated.toString(), vinv.getStatus());
    Assert.assertEquals(VolumeType.Data.toString(), vinv.getType());
    Assert.assertFalse(vinv.isAttached());

    api.deleteDataVolume(vinv.getUuid());
    VolumeVO vo = dbf.findByUuid(vinv.getUuid(), VolumeVO.class);
    Assert.assertNull(vo);
  }