コード例 #1
0
ファイル: TaskHandlerTest.java プロジェクト: GERey/jclouds
 public void testHrefWhenTaskElementIsNamespaced() {
   InputStream is = getClass().getResourceAsStream("/task-vcd15.xml");
   Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
   assertEquals(
       result.getHref(),
       URI.create(
           "https://mycloud.greenhousedata.com/api/v1.0/task/77a33fd4-3401-423c-8167-6711fc51ee9a"));
 }
コード例 #2
0
  @Override
  public Map<String, String> start(
      @Nullable URI VDC,
      URI templateId,
      String name,
      InstantiateVAppTemplateOptions options,
      int... portsToOpen) {
    checkNotNull(options, "options");
    logger.debug(
        ">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ",
        VDC, templateId, name, options);

    VCloudExpressVApp vAppResponse =
        VCloudExpressClient.class
            .cast(client)
            .instantiateVAppTemplateInVDC(VDC, templateId, name, options);
    logger.debug("<< instantiated VApp(%s)", vAppResponse.getName());
    if (options.shouldDeploy()) {
      logger.debug(">> deploying vApp(%s)", vAppResponse.getName());

      Task task = VCloudExpressClient.class.cast(client).deployVApp(vAppResponse.getHref());
      if (options.shouldBlock()) {
        if (!taskTester.apply(task.getHref())) {
          throw new RuntimeException(
              String.format("failed to %s %s: %s", "deploy", vAppResponse.getName(), task));
        }
        logger.debug("<< deployed vApp(%s)", vAppResponse.getName());
        if (options.shouldPowerOn()) {
          logger.debug(">> powering vApp(%s)", vAppResponse.getName());
          task = VCloudExpressClient.class.cast(client).powerOnVApp(vAppResponse.getHref());
          if (!taskTester.apply(task.getHref())) {
            throw new RuntimeException(
                String.format("failed to %s %s: %s", "powerOn", vAppResponse.getName(), task));
          }
          logger.debug("<< on vApp(%s)", vAppResponse.getName());
        }
      }
    }
    return parseAndValidateResponse(
        VCloudExpressClient.class.cast(client).getVAppTemplate(templateId), vAppResponse);
  }