// TODO insufficient permissions to test
  @Test(description = "PUT /admin/vdc/{id}", enabled = false)
  public void testEditVdc() throws Exception {
    String origName = lazyGetVdc().getName();
    String newName = name("a");
    Exception exception = null;

    AdminVdc vdc = AdminVdc.builder().name(newName).build();

    try {
      Task task = vdcApi.edit(vdcUrn, vdc);
      assertTaskSucceeds(task);

      AdminVdc modified = vdcApi.get(vdcUrn);
      assertEquals(modified.getName(), newName);

      // parent type
      Checks.checkAdminVdc(vdc);
    } catch (Exception e) {
      exception = e;
    } finally {
      try {
        AdminVdc restorableVdc = AdminVdc.builder().name(origName).build();
        Task task = vdcApi.edit(vdcUrn, restorableVdc);
        assertTaskSucceeds(task);
      } catch (Exception e) {
        if (exception != null) {
          logger.warn(e, "Error resetting adminVdc.name; rethrowing original test exception...");
          throw exception;
        } else {
          throw e;
        }
      }
    }
  }
Beispiel #2
0
  public static void checkAdminVdc(AdminVdc vdc) {
    // optional
    // NOTE isThinProvision cannot be checked
    // NOTE usesFastProvisioning cannot be checked
    if (vdc.getResourceGuaranteedMemory() != null) {
      // TODO: between 0 and 1 inc.
    }
    if (vdc.getResourceGuaranteedCpu() != null) {
      // TODO: between 0 and 1 inc.
    }
    if (vdc.getVCpuInMhz() != null) {
      assertTrue(
          vdc.getVCpuInMhz() >= 0,
          String.format(OBJ_FIELD_GTE_0, "Vdc", "cCpuInMhz", vdc.getVCpuInMhz()));
    }
    if (vdc.getNetworkPoolReference() != null) {
      checkReferenceType(vdc.getNetworkPoolReference());
    }
    if (vdc.getProviderVdcReference() != null) {
      checkReferenceType(vdc.getProviderVdcReference());
    }

    // parent type
    checkVdc(vdc);
  }
Beispiel #3
0
 public T fromAdminVdc(AdminVdc in) {
   return fromVdc(in)
       .resourceGuaranteedMemory(in.getResourceGuaranteedMemory())
       .resourceGuaranteedCpu(in.getResourceGuaranteedCpu())
       .vCpuInMhz(in.getVCpuInMhz())
       .isThinProvision(in.isThinProvision())
       .networkPoolReference(in.getNetworkPoolReference())
       .providerVdcReference(in.getProviderVdcReference())
       .usesFastProvisioning(in.usesFastProvisioning());
 }