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().getInRegion(DEFAULT_REGION_NAME, addOperation.getName());
      assertNotNull(operation);
      assertOperationEquals(operation, this.addOperation);
   }
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);
      expect(nwApi.get("this-network")).andReturn(null);
      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

      Network network = Network.builder().IPv4Range("0.0.0.0/0")
              .id("abcd").name("this-network").gatewayIPv4("1.2.3.4")
              .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.createInIPv4RangeWithGateway("this-network", "0.0.0.0/0", "1.2.3.4"))
              .andReturn(createOp);
      expect(globalApi.get("create-op")).andReturn(createOp);
      expect(nwApi.get("this-network")).andReturn(null);
      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", "1.2.3.4");

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

      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

      ImmutableMap.Builder<String, String> metadataBuilder = metatadaFromTemplateOptions.apply(options);
      instanceTemplate.metadata(metadataBuilder.build());
      instanceTemplate.serviceAccounts(options.getServiceAccounts());
      instanceTemplate.image(checkNotNull(template.getImage().getUri(), "image URI is null"));

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

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

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

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

      if (options.getTags().size() > 0) {
         Operation tagsOperation = api.getInstanceApiForProject(userProject.get()).setTagsInZone(template.getLocation().getId(),
                 name, options.getTags(), instance.get().getTags().getFingerprint());

         waitOperationDone(tagsOperation);

         retry(new Predicate<AtomicReference<Instance>>() {
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

   }

   @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

      instanceTemplate.serviceAccounts(options.getServiceAccounts());
      instanceTemplate.image(checkNotNull(template.getImage().getUri(), "image URI is null"));

      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 = new AtomicReference<Instance>();

      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

      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

      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);
      expect(nwApi.get("this-network")).andReturn(null);
      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

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.