Exemplo n.º 1
0
  @Test
  public void testAttachedStorageDomainLinks() throws Exception {
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(STORAGE_DOMAIN_ID);

    storageDomain.setDataCenter(new DataCenter());
    storageDomain.getDataCenter().setId(DATA_CENTER_ID);

    LinkHelper.addLinks(storageDomain);

    assertEquals(ATTACHED_STORAGE_DOMAIN_HREF, storageDomain.getHref());
  }
Exemplo n.º 2
0
  @Test
  public void testStorageDomainLinks() throws Exception {
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(STORAGE_DOMAIN_ID);

    storageDomain.setStorage(new HostStorage());
    storageDomain.getStorage().setPath("foo");

    LinkHelper.addLinks(storageDomain);

    assertEquals(STORAGE_DOMAIN_HREF, storageDomain.getHref());
    assertNull(storageDomain.getStorage().getHref());
  }
  @Test
  public void testAddDiskWithinStorageDomain() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpHttpHeaderExpectations("Expect", "201-created");
    setUpEntityQueryExpectations(
        VdcQueryType.GetAllDisksByVmId,
        GetAllDisksByVmIdParameters.class,
        new String[] {"VmId"},
        new Object[] {PARENT_ID},
        asList(getEntity(0)));
    setUpCreationExpectations(
        VdcActionType.AddDiskToVm,
        AddDiskToVmParameters.class,
        new String[] {"VmId", "StorageDomainId"},
        new Object[] {PARENT_ID, GUIDS[3]},
        true,
        true,
        GUIDS[2], // VM snapshot ID
        asList(GUIDS[3]),
        asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)),
        VdcQueryType.GetAllDisksByVmId,
        GetAllDisksByVmIdParameters.class,
        new String[] {"VmId"},
        new Object[] {PARENT_ID},
        asList(getEntity(0)));
    Disk model = getModel(0);
    model.setStorageDomains(new StorageDomains());
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(GUIDS[3].toString());
    model.getStorageDomains().getStorageDomains().add(storageDomain);
    model.setSize(1024 * 1024L);

    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Disk);
    verifyModel((Disk) response.getEntity(), 0);
    assertNull(((Disk) response.getEntity()).getCreationStatus());
  }