Package org.jclouds.vcloud.director.v1_5.features

Examples of org.jclouds.vcloud.director.v1_5.features.VAppApi


      vApp = vAppApi.get(vApp.getId()); // reload, so it has the VMs
      List<Vm> vms = vApp.getChildren().getVms();
      Set<URI> vmHrefs = toHrefs(vms);

      // Method under test: do the query
      QueryResultRecords queryResult = queryApi.vmsQueryAll();
      Set<URI> hrefs = toHrefs(queryResult);

      assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class);
      assertTrue(hrefs.containsAll(vmHrefs), "VMs query result should include vms " + vmHrefs + "; but only has "
               + hrefs);
View Full Code Here


  @Test(description = "GET /vms/query?filter", dependsOnMethods = { "testQueryAllVms" })
  public void testQueryAllVmsWithFilter() {
    List<Vm> vms = vApp.getChildren().getVms();
    Set<URI> vmHrefs = toHrefs(vms);

    QueryResultRecords queryResult = queryApi.vmsQuery(String.format(
        "containerName==%s", vApp.getName()));
    Set<URI> hrefs = toHrefs(queryResult);

    assertRecordTypes(queryResult,
        Arrays.asList(VCloudDirectorMediaType.VM, null),
View Full Code Here

        message);
  }

   @Test(description = "GET /mediaList/query")
   public void testQueryAllMedia() {
      QueryResultRecords queryResult = queryApi.mediaListQueryAll();

      assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultMediaRecord.class);
   }
View Full Code Here

   }

   @Test(description = "GET /mediaList/query?filter")
   public void testQueryMediaWithFilter() {
      String mediaName = "abc";
      QueryResultRecords queryResult = queryApi.mediaListQuery(String.format("name==%s", mediaName));

      assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultMediaRecord.class);
   }
View Full Code Here

      return params;
   }

   public static GuestCustomizationSection getGuestCustomizationSection() {
      GuestCustomizationSection section = GuestCustomizationSection.builder()
            .build();

      return section;
   }
View Full Code Here

            .httpRequestBuilder().build(),
         new VcloudHttpResponsePrimer()
            .xmlFilePayload("/vApp/getLeaseSettingsSection.xml", VCloudDirectorMediaType.LEASE_SETTINGS_SECTION)
            .httpResponseBuilder().build());

      LeaseSettingsSection expected = getLeaseSettingsSection();

      assertEquals(api.getVAppApi().getLeaseSettingsSection(vAppURI), expected);
   }
View Full Code Here

            .httpRequestBuilder().build(),
         new VcloudHttpResponsePrimer()
            .xmlFilePayload("/vApp/editLeaseSettingsSectionTask.xml", VCloudDirectorMediaType.TASK)
            .httpResponseBuilder().build());

      LeaseSettingsSection section = getLeaseSettingsSection().toBuilder()
            .build();

    Task expected = editLeaseSettingsSectionTask();

    assertEquals(api.getVAppApi().editLeaseSettingsSection(vAppURI, section), expected);
View Full Code Here

      return task;
   }

   public static LeaseSettingsSection getLeaseSettingsSection() {
      LeaseSettingsSection section = LeaseSettingsSection.builder()
            .build();

      return section;
   }
View Full Code Here

         logger.warn(e, "Error deleting template '%s'", vAppTemplate.getName());
      }
   }

   protected void cleanUpVApp(VApp vApp) {
      VAppApi vAppApi = context.getApi().getVAppApi();

      String vAppUrn = vApp.getId();
      vApp = vAppApi.get(vAppUrn); // Refresh
      if (vApp == null) {
         logger.info("Cannot find VApp at %s", vAppUrn);
         return; // Presumably vApp has already been removed. Ignore.
      }
      logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppUrn);

      // Wait for busy tasks to complete (don't care if it's failed or successful)
      // Otherwise, get error on remove "entity is busy completing an operation.
      if (vApp.getTasks() != null) {
         for (Task task : vApp.getTasks()) {
            if (!taskDoneEventually(task)) {
               logger.warn("Task '%s' did not complete", task.getOperationName());
            }
         }
      }

      // power off the VApp if necessary
      if (vApp.getStatus() == Status.POWERED_ON) {
         try {
            Task shutdownTask = vAppApi.powerOff(vAppUrn);
            taskDoneEventually(shutdownTask);
         } catch (Exception e) {
            // keep going; cleanup as much as possible
            logger.warn(e, "Continuing cleanup after error shutting down VApp %s", vApp.getName());
         }
      }

      // Undeploy the VApp if necessary
      if (vApp.isDeployed()) {
         try {
            UndeployVAppParams params = UndeployVAppParams.builder()
                     .undeployPowerAction(UndeployVAppParams.PowerAction.SHUTDOWN).build();
            Task undeployTask = vAppApi.undeploy(vAppUrn, params);
            taskDoneEventually(undeployTask);
         } catch (Exception e) {
            // keep going; cleanup as much as possible
            logger.warn(e, "Continuing cleanup after error undeploying VApp %s", vApp.getName());
         }
      }

      try {
         Task task = vAppApi.remove(vAppUrn);
         taskDoneEventually(task);
         vAppNames.remove(vApp.getName());
         logger.info("Deleted VApp %s", vApp.getName());
      } catch (Exception e) {
         vApp = vAppApi.get(vApp.getId()); // Refresh
         logger.warn(e, "Deleting VApp %s failed (%s)", vApp.getName(), vAppUrn);
      }
   }
View Full Code Here

         logger.warn(e, "Error deleting template '%s'", vAppTemplate.getName());
      }
   }

   protected void cleanUpVApp(VApp vApp) {
      VAppApi vAppApi = context.getApi().getVAppApi();

      String vAppUrn = vApp.getId();
      vApp = vAppApi.get(vAppUrn); // Refresh
      if (vApp == null) {
         logger.info("Cannot find VApp at %s", vAppUrn);
         return; // Presumably vApp has already been removed. Ignore.
      }
      logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppUrn);

      // Wait for busy tasks to complete (don't care if it's failed or successful)
      // Otherwise, get error on remove "entity is busy completing an operation.
      if (vApp.getTasks() != null) {
         for (Task task : vApp.getTasks()) {
            if (!taskDoneEventually(task)) {
               logger.warn("Task '%s' did not complete", task.getOperationName());
            }
         }
      }

      // power off the VApp if necessary
      if (vApp.getStatus() == Status.POWERED_ON) {
         try {
            Task shutdownTask = vAppApi.powerOff(vAppUrn);
            taskDoneEventually(shutdownTask);
         } catch (Exception e) {
            // keep going; cleanup as much as possible
            logger.warn(e, "Continuing cleanup after error shutting down VApp %s", vApp.getName());
         }
      }

      // Undeploy the VApp if necessary
      if (vApp.isDeployed()) {
         try {
            UndeployVAppParams params = UndeployVAppParams.builder()
                     .undeployPowerAction(UndeployVAppParams.PowerAction.SHUTDOWN).build();
            Task undeployTask = vAppApi.undeploy(vAppUrn, params);
            taskDoneEventually(undeployTask);
         } catch (Exception e) {
            // keep going; cleanup as much as possible
            logger.warn(e, "Continuing cleanup after error undeploying VApp %s", vApp.getName());
         }
      }

      try {
         Task task = vAppApi.remove(vAppUrn);
         taskDoneEventually(task);
         vAppNames.remove(vApp.getName());
         logger.info("Deleted VApp %s", vApp.getName());
      } catch (Exception e) {
         vApp = vAppApi.get(vApp.getId()); // Refresh
         logger.warn(e, "Deleting VApp %s failed (%s)", vApp.getName(), vAppUrn);
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.vcloud.director.v1_5.features.VAppApi

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.