Package org.jclouds.compute

Examples of org.jclouds.compute.ComputeService


 
  public ListenableFuture<ExecResponse> runStatementOnInstanceInCluster(StatementBuilder statementBuilder,
      Instance instance, ClusterSpec clusterSpec, RunScriptOptions options) {
    Statement statement = statementBuilder.name(getAction() + "-"
          + Joiner.on('_').join(instance.getRoles())).build(clusterSpec, instance);
    ComputeService compute = getCompute().apply(clusterSpec).getComputeService();
    return compute.submitScriptOnNode(
              instance.getId(),
              statement,
              options);
  }
View Full Code Here


      // note no ssh module since we are stub and not trying ssh, yet
      overrides.setProperty(NodePoolProperties.BACKEND_MODULES, SLF4JLoggingModule.class.getName() + ","
               + StubSshClientModule.class.getName());
      overrides.setProperty(POOL_ADMIN_ACCESS, "adminUsername=pooluser,adminPassword=poolpass");

      ComputeService stub = ContextBuilder.newBuilder("nodepool").credentials("foo", "bar").endpoint("gooend")
               .apiVersion("1.1").buildVersion("1.1-2").overrides(overrides).buildInjector()
               .getInstance(Key.get(new TypeLiteral<Supplier<ComputeService>>() {
               }, Backend.class)).get();

      assertEquals(stub.getContext().unwrap().getProviderMetadata().getEndpoint(), "gooend");
      assertEquals(stub.getContext().unwrap().getProviderMetadata().getApiMetadata().getVersion(), "1.1");
      assertEquals(stub.getContext().unwrap().getProviderMetadata().getApiMetadata().getBuildVersion().get(), "1.1-2");

      stub.getContext().close();
      new File(basedir).delete();

   }
View Full Code Here

    public void start(String id, NodeLauncherConfig cfg) throws Exception {
        JcloudsNodeLauncherConfig config = (JcloudsNodeLauncherConfig) cfg;
        m_currentConfig = config;

        ComputeService computeService = config.getComputeService();
        TemplateBuilder template = computeService.templateBuilder()
                .imageId(config.getImageId())
                .hardwareId(config.getHardwareId())
                .locationId(config.getLocation());

        int[] extraPorts = parseExtraPorts(config.getExtraPorts());
        int[] inboundPorts = mergePorts(DEFAULT_PORTS, extraPorts);

        TemplateOptions options = new EC2TemplateOptions()
                .as(EC2TemplateOptions.class).inboundPorts(inboundPorts)
                .blockOnComplete(false)
                .runAsRoot(config.isRunAsRoot());

        if (useConfiguredKeyPair(config)) {
            options.as(EC2TemplateOptions.class).keyPair(config.getKeyPair());
        }

        template.options(options);

        Set<? extends NodeMetadata> tag = computeService.createNodesInGroup(config.getTagPrefix() + id, 1, template.build());
        if (!useConfiguredPrivateKey(config)) {
            System.out.println("In case you need it, this is the key to ssh to " + id + ":\n" + tag.iterator().next().getCredentials().credential);
        }

        LoginCredentials.Builder loginBuilder = LoginCredentials.builder();

        if (config.getSshUser() != null && config.getSshUser().length() > 0) {
            loginBuilder.user(config.getSshUser());
        } else {
            loginBuilder.user("ec2-user");
        }

        if (useConfiguredPrivateKey(config)) {
            loginBuilder.privateKey(Files.toString(new File(config.getPrivateKeyFile()), Charset.defaultCharset()));
        }

        computeService.runScriptOnNodesMatching(runningInGroup(config.getTagPrefix() + id),
                Statements.exec(buildStartupScript(id, config)),
                RunScriptOptions.Builder.blockOnComplete(false).overrideLoginCredentials(loginBuilder.build()));
    }
View Full Code Here

      Properties properties = new Properties();
      properties.setProperty("oauth.identity", "MOMMA");
      properties.setProperty("oauth.credential", "MiA");

      ComputeService client = requestsSendResponses(ImmutableMap.<HttpRequest, HttpResponse>of(), createModule(),
              properties);
      Template template = client.templateBuilder().build();
      Template toMatch = client.templateBuilder().imageId(template.getImage().getId()).build();
      assertEquals(toMatch.getImage(), template.getImage());
   }
View Full Code Here

              .put(LIST_CENTOS_IMAGES_REQUEST, LIST_CENTOS_IMAGES_RESPONSE)
              .put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE)
              .put(LIST_CENTRAL1B_MACHINE_TYPES_REQUEST, LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE)
              .build();

      ComputeService client = requestsSendResponses(requestResponseMap);
      Template template = client.templateBuilder().build();
      Hardware defaultSize = client.templateBuilder().build().getHardware();

      Hardware smallest = client.templateBuilder().smallest().build().getHardware();
      assertEquals(defaultSize, smallest);

      Hardware fastest = client.templateBuilder().fastest().build().getHardware();
      assertNotNull(fastest);

      assertEquals(client.listHardwareProfiles().size(), 5);

      Template toMatch = client.templateBuilder()
              .imageId(template.getImage().getId())
              .build();
      assertEquals(toMatch.getImage(), template.getImage());
   }
View Full Code Here

              .add(GET_GLOBAL_OPERATION_RESPONSE)
              .add(SUCESSFULL_OPERATION_RESPONSE)
              .add(GET_GLOBAL_OPERATION_RESPONSE)
              .build();

      ComputeService client = orderedRequestsSendResponses(orderedRequests, orderedResponses);
      client.destroyNode("us-central1-a/test-delete-networks");

   }
View Full Code Here

              .put(LIST_CENTOS_IMAGES_REQUEST, LIST_CENTOS_IMAGES_RESPONSE)
              .put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE)
              .put(LIST_CENTRAL1B_MACHINE_TYPES_REQUEST, LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE)
              .build();

      ComputeService apiWhenServersExist = requestsSendResponses(requestResponseMap);

      Set<? extends Location> locations = apiWhenServersExist.listAssignableLocations();

      assertNotNull(locations);
      assertEquals(locations.size(), 2);
      assertEquals(locations.iterator().next().getId(), "us-central1-a");

      assertNotNull(apiWhenServersExist.listNodes());
      assertEquals(apiWhenServersExist.listNodes().size(), 1);
      assertEquals(apiWhenServersExist.listNodes().iterator().next().getId(), "us-central1-a/test-0");
      assertEquals(apiWhenServersExist.listNodes().iterator().next().getName(), "test-0");
   }
View Full Code Here

              .add(LIST_CENTOS_IMAGES_RESPONSE)
              .add(SUCESSFULL_OPERATION_RESPONSE)
              .build();


      ComputeService computeService = orderedRequestsSendResponses(orderedRequests, orderedResponses);

      GoogleComputeEngineTemplateOptions options = computeService.templateOptions().as(GoogleComputeEngineTemplateOptions.class);
      options.tags(ImmutableSet.of("aTag"));
      NodeMetadata node = getOnlyElement(computeService.createNodesInGroup("test", 1, options));
      assertEquals(node.getImageId(), "gcel-12-04-v20121106");
   }
View Full Code Here

      Set<? extends NodeMetadata> deadNodesGroup2 = (Set) ImmutableSet.builder()
              .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.TERMINATED)).build();

      Set<? extends NodeMetadata> allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2);

      ComputeService mock = createMock(ComputeService.class);
      expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
              .andReturn((Set) deadNodesGroup1).once();
      expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
              .andReturn((Set) deadNodesGroup2).once();

      replay(mock);

      OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new
View Full Code Here

      Set<? extends NodeMetadata> deadNodesGroup2 = (Set) ImmutableSet.builder()
              .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.TERMINATED)).build();

      Set<? extends NodeMetadata> allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2);

      ComputeService mock = createMock(ComputeService.class);
      expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
              .andReturn((Set) deadNodesGroup1).once();
      expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
              .andReturn((Set) ImmutableSet.of()).once();

      replay(mock);

      OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new
View Full Code Here

TOP

Related Classes of org.jclouds.compute.ComputeService

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.