Package org.jclouds.googlecomputeengine.domain

Examples of org.jclouds.googlecomputeengine.domain.Operation


      assertNotNull(deleteOperation);
   }

   @Test(groups = "live", dependsOnMethods = "testCreateOperations")
   public void testGetOperation() {
      Operation operation = api().get(addOperation.getName());
      assertNotNull(operation);
      assertOperationEquals(operation, this.addOperation);
   }
View Full Code Here


      instanceTemplate.metadata(metadataBuilder.build());
      instanceTemplate.tags(options.getTags());
      instanceTemplate.serviceAccounts(options.getServiceAccounts());
      instanceTemplate.image(checkNotNull(template.getImage().getUri(), "image URI is null"));

      Operation operation = api.getInstanceApiForProject(userProject.get())
              .createInZone(name, instanceTemplate, template.getLocation().getId());

      if (options.shouldBlockUntilRunning()) {
         waitOperationDone(operation);
      }
View Full Code Here

   }

   @Override
   public boolean apply(AtomicReference<Operation> input) {
      checkNotNull(input, "input");
      Operation current = api.getOperationApiForProject(project.get()).get(input.get().getName());
      switch (current.getStatus()) {
         case DONE:
            input.set(current);
            return true;
         case PENDING:
         case RUNNING:
View Full Code Here

   }

   @Override
   public boolean apply(AtomicReference<Operation> input) {
      checkNotNull(input, "input");
      Operation current = api.getGlobalOperationApiForProject(project.get()).get(input.get().getName());
      switch (current.getStatus()) {
         case DONE:
            input.set(current);
            return true;
         case PENDING:
         case RUNNING:
View Full Code Here

   @Override
   public boolean apply(AtomicReference<Operation> input) {
      checkNotNull(input, "input");

      Operation current = api.getRegionOperationApiForProject(project.get())
              .getInRegion(regions.get().get(input.get().getRegion().get()).getName(),
              input.get().getName());
      switch (current.getStatus()) {
         case DONE:
            input.set(current);
            return true;
         case PENDING:
         case RUNNING:
View Full Code Here

   }

   @Override
   public boolean apply(AtomicReference<Operation> input) {
      checkNotNull(input, "input");
      Operation current = api.getZoneOperationApiForProject(project.get())
              .getInZone(zones.get().get(input.get().getZone().get()).getId(),
                      input.get().getName());
      switch (current.getStatus()) {
         case DONE:
            input.set(current);
            return true;
         case PENDING:
         case RUNNING:
View Full Code Here

      Network network = Network.builder().IPv4Range("0.0.0.0/0")
              .id("abcd").name("this-network")
              .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
              .build();

      Operation createOp = createMock(Operation.class);

      final Supplier<String> userProject = new Supplier<String>() {
         @Override
         public String get() {
            return "myproject";
         }
      };

      expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
      expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();

      expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0"))
              .andReturn(createOp);
      expect(globalApi.get("create-op")).andReturn(createOp);
      // pre-creation
      expect(nwApi.get("this-network")).andReturn(null).times(2);
      // post-creation
      expect(nwApi.get("this-network")).andReturn(network);

      expect(createOp.getName()).andReturn("create-op");
      expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
      expect(createOp.getHttpError()).andReturn(fromNullable((HttpResponse)null));
      replay(api, nwApi, createOp, globalApi);

      NetworkAndAddressRange input = new NetworkAndAddressRange("this-network", "0.0.0.0/0", null);

      GlobalOperationDonePredicate pred = new GlobalOperationDonePredicate(api, userProject);
View Full Code Here

      instanceTemplate.metadata(metadataBuilder.build());
      instanceTemplate.serviceAccounts(options.getServiceAccounts());

      final InstanceApi instanceApi = api.getInstanceApiForProject(userProject.get());
      final String zone = template.getLocation().getId();
      Operation operation = instanceApi.createInZone(name, zone, instanceTemplate);

      if (options.shouldBlockUntilRunning()) {
         waitOperationDone(operation);
      }

      // some times the newly created instances are not immediately returned
      AtomicReference<Instance> instance = Atomics.newReference();

      retry(new Predicate<AtomicReference<Instance>>() {
         @Override
         public boolean apply(AtomicReference<Instance> input) {
            input.set(instanceApi.getInZone(zone, name));
            return input.get() != null;
         }
      }, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(instance);

      if (!options.getTags().isEmpty()) {
         Operation tagsOperation = instanceApi.setTagsInZone(zone,
                 name, options.getTags(), instance.get().getTags().getFingerprint());

         waitOperationDone(tagsOperation);

         retry(new Predicate<AtomicReference<Instance>>() {
View Full Code Here

      int diskSize = options.getBootDiskSize().or(10l).intValue();

      String diskName = instanceName + "-" + GCE_BOOT_DISK_SUFFIX;

      Operation diskOperation = api.getDiskApiForProject(userProject.get())
                                   .createFromImageWithSizeInZone(imageUri.toString(),
                                                                  diskName,
                                                                  diskSize,
                                                                  template.getLocation().getId());
View Full Code Here

      assertNotNull(deleteOperation);
   }

   @Test(groups = "live", dependsOnMethods = "testCreateOperations")
   public void testGetOperation() {
      Operation operation = api().getInZone(DEFAULT_ZONE_NAME, addOperation.getName());
      assertNotNull(operation);
      assertOperationEquals(operation, this.addOperation);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.googlecomputeengine.domain.Operation

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.