コード例 #1
0
  @Test(enabled = false)
  public void testEditVApp() {
    VCloudDirectorApi api =
        requestsSendResponses(
            loginRequest,
            sessionResponse,
            new VcloudHttpRequestPrimer()
                .apiCommand("PUT", vAppId)
                .xmlFilePayload("/vApp/editVApp.xml", VCloudDirectorMediaType.VAPP)
                .acceptAnyMedia()
                .httpRequestBuilder()
                .build(),
            new VcloudHttpResponsePrimer()
                .xmlFilePayload("/vApp/modifiedVapp.xml", VCloudDirectorMediaType.VAPP)
                .httpResponseBuilder()
                .build());

    VApp modified = getVApp();
    modified.setName("new-name");
    modified.setDescription("New Description");

    Task expected = editVAppTask();

    assertEquals(api.getVAppApi().edit(vAppURI, modified), expected);
  }
コード例 #2
0
  /** @see VmApi#remove(String) */
  @Test(description = "DELETE /vApp/{id}")
  public void testRemoveVm() {
    // Create a temporary VApp to remove
    VApp remove = instantiateVApp();
    DeployVAppParams params =
        DeployVAppParams.builder()
            .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS))
            .notForceCustomization()
            .powerOn()
            .build();
    Task deployVApp = vAppApi.deploy(remove.getId(), params);
    assertTaskSucceedsLong(deployVApp);

    // Get the edited VApp and the Vm
    remove = vAppApi.get(remove.getId());
    List<Vm> vms = remove.getChildren().getVms();
    Vm temp = Iterables.get(vms, 0);

    // otherwise it's impossible to stop a running vApp with no vms
    if (vms.size() == 1) {
      UndeployVAppParams undeployParams = UndeployVAppParams.builder().build();
      Task shutdownVapp = vAppApi.undeploy(remove.getId(), undeployParams);
      assertTaskSucceedsLong(shutdownVapp);
    } else {
      powerOffVm(temp.getId());
    }
    // The method under test
    Task removeVm = vmApi.remove(temp.getId());
    assertTrue(retryTaskSuccess.apply(removeVm), String.format(TASK_COMPLETE_TIMELY, "removeVm"));

    Vm removed = vmApi.get(temp.getId());
    assertNull(removed, "The Vm " + temp.getName() + " should have been removed");
  }
コード例 #3
0
  public static VApp getVApp() {
    // FIXME Does not match XML
    VApp vApp =
        VApp.builder()
            .href(
                URI.create(
                    "https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be"))
            //            .link(Link.builder()
            //                     .href(URI.create())
            //                     .build())
            .build();

    //      <Link rel="power:powerOn"
    // href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/power/action/powerOn"/>
    //      <Link rel="deploy" type="application/vnd.vmware.vcloud.deployVAppParams+xml"
    // href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/action/deploy"/>
    //      <Link rel="down" type="application/vnd.vmware.vcloud.vAppNetwork+xml"
    // name="orgNet-cloudsoft-External"
    // href="https://mycloud.greenhousedata.com/api/network/2a2e2da4-446a-4ebc-a086-06df7c9570f0"/>
    //      <Link rel="down" type="application/vnd.vmware.vcloud.controlAccess+xml"
    // href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/controlAccess/"/>
    //      <Link rel="controlAccess" type="application/vnd.vmware.vcloud.controlAccess+xml"
    // href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/action/controlAccess"/>
    //      <Link rel="recompose" type="application/vnd.vmware.vcloud.recomposeVAppParams+xml"
    // href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/action/recomposeVApp"/>
    //      <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml"
    // href="https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"/>
    //      <Link rel="edit" type="application/vnd.vmware.vcloud.vApp+xml"
    // href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be"/>
    //      <Link rel="remove"
    // href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be"/>
    //      <Link rel="down" type="application/vnd.vmware.vcloud.owner+xml"
    // href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/owner"/>
    //      <Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml"
    // href="https://mycloud.greenhousedata.com/api/vApp/vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be/metadata"/>

    return vApp;
  }