Package org.jclouds.trmk.vcloud_0_8.domain

Examples of org.jclouds.trmk.vcloud_0_8.domain.Task


   }

   public void testSelf() {
      InputStream is = getClass().getResourceAsStream("/task-self.xml");

      Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);

      Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"), null,
            TaskStatus.QUEUED, null, null, null, null, null);
      assertEquals(result, expects);

   }
View Full Code Here


   }

   public void testError() {
      InputStream is = getClass().getResourceAsStream("/task-error.xml");

      Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);

      Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), null, TaskStatus.ERROR,
            dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"),
            dateService.iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new ReferenceTypeImpl("testapp1",
                  TerremarkVCloudMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")), new ErrorImpl(
                  "Error processing job", 500, MinorCode.UNRECOGNIZED,
                  " Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00", null));
View Full Code Here

   }

   public boolean apply(URI taskId) {
      logger.trace("looking for status on task %s", taskId);

      Task task = client.getTask(taskId);
      // perhaps task isn't available, yet
      if (task == null)
         return false;
      logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task.getStatus());
      if (task.getStatus() == TaskStatus.ERROR)
         throw new RuntimeException("error on task: " + task.getHref() + " error: " + task.getError());
      return task.getStatus() == TaskStatus.SUCCESS;
   }
View Full Code Here

      VApp vAppResponse = 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 = 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 = 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());
            }
View Full Code Here

      logger.debug("<< deleted vApp(%s))", vApp.getName());
   }

   private void powerOffAndWait(VApp vApp) {
      logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
      Task task = client.powerOffVApp(vApp.getHref());
      if (!taskTester.apply(task.getHref()))
         throw new RuntimeException(String.format("failed to %s %s: %s", "powerOff", vApp.getName(), task));
   }
View Full Code Here

   }

   void blockOnLastTask(VApp vApp) {
      TasksList list = client.findTasksListInOrgNamed(null, null);
      try {
         Task lastTask = getLast(filter(list.getTasks(), new Predicate<Task>() {

            public boolean apply(Task input) {
               return input.getStatus() == TaskStatus.QUEUED || input.getStatus() == TaskStatus.RUNNING;
            }

         }));
         if (!taskTester.apply(lastTask.getHref()))
            throw new RuntimeException(String.format("failed to %s %s: %s", "powerOff", vApp.getName(), lastTask));
      } catch (NoSuchElementException ex) {

      }
   }
View Full Code Here

    *           vApp to reboot
    */
   public void reset(URI id) {
      VApp vApp = refreshVApp(id);
      logger.debug(">> resetting vApp(%s)", vApp.getName());
      Task task = reset(vApp);
      if (!taskTester.apply(task.getHref())) {
         throw new RuntimeException(String.format("failed to %s %s: %s", "resetVApp", vApp.getName(), task));
      }
      logger.debug("<< on vApp(%s)", vApp.getName());
   }
View Full Code Here

      logger.debug("<< on vApp(%s)", vApp.getName());
   }

   protected void deleteVApp(VApp vApp) {
      logger.debug(">> deleting vApp(%s)", vApp.getName());
      Task task = client.deleteVApp(vApp.getHref());
      if (task != null)
         if (!taskTester.apply(task.getHref()))
            throw new RuntimeException(String.format("failed to %s %s: %s", "delete", vApp.getName(), task));
   }
View Full Code Here

      InternetServiceAndPublicIpAddressSupplier supplier = createMock(InternetServiceAndPublicIpAddressSupplier.class);
      expect(client.getVAppTemplate(templateURI)).andReturn(template);
      expect(
            client.instantiateVAppTemplateInVDC(vdcURI, templateURI, "name",
                  new InstantiateVAppTemplateOptions().productProperty("password", "password"))).andReturn(vApp);
      Task task = createMock(Task.class);
      URI vappLocation = URI.create("vapp");
      URI taskLocation = URI.create("task");

      expect(vApp.getHref()).andReturn(vappLocation).atLeastOnce();
      expect(vApp.getName()).andReturn("name").atLeastOnce();
      expect(client.deployVApp(vappLocation)).andReturn(task);
      expect(task.getHref()).andReturn(taskLocation).atLeastOnce();
      Predicate<URI> successTester = createMock(Predicate.class);
      expect(successTester.apply(taskLocation)).andReturn(true).atLeastOnce();
      expect(client.powerOnVApp(vappLocation)).andReturn(task);

      Predicate<VApp> notFoundTester = createMock(Predicate.class);
View Full Code Here

      this.getNode = getNode;
   }

   @Override
   public NodeMetadata rebootNode(String in) {
      Task task = client.resetVApp(URI.create(checkNotNull(in, "node.id")));
      return returnWhenTaskCompletes(in, task);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.trmk.vcloud_0_8.domain.Task

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.