Package org.jclouds.domain

Examples of org.jclouds.domain.LoginCredentials


      // We have to actively wait until the droplet has been provisioned until
      // we can build the entire Droplet object we want to return
      nodeRunningPredicate.apply(dropletCreation.getEventId());
      Droplet droplet = api.getDropletApi().get(dropletCreation.getId());

      LoginCredentials defaultCredentials = LoginCredentials.builder().user("root")
            .privateKey(defaultKeys.get("private")).build();

      return new NodeAndInitialCredentials<Droplet>(droplet, String.valueOf(droplet.getId()), defaultCredentials);
   }
View Full Code Here


         instanceTemplate.addNetworkInterface(options.getNetwork().get());
      }

      instanceTemplate.disks(disks);

      LoginCredentials credentials = getFromImageAndOverrideIfRequired(template.getImage(), options);

      ImmutableMap.Builder<String, String> metadataBuilder = metatadaFromTemplateOptions.apply(options);

      metadataBuilder.put(GCE_IMAGE_METADATA_KEY, template.getImage().getUri().toString());
View Full Code Here

      throw new UnsupportedOperationException("suspend is not supported by GCE");
   }

   private LoginCredentials getFromImageAndOverrideIfRequired(org.jclouds.compute.domain.Image image,
                                                              GoogleComputeEngineTemplateOptions options) {
      LoginCredentials defaultCredentials = image.getDefaultCredentials();
      String[] keys = defaultCredentials.getPrivateKey().split(":");
      String publicKey = keys[0];
      String privateKey = keys[1];

      LoginCredentials.Builder credentialsBuilder = defaultCredentials.toBuilder();
      credentialsBuilder.privateKey(privateKey);

      // LoginCredentials from image stores the public key along with the private key in the privateKey field
      // @see GoogleComputePopulateDefaultLoginCredentialsForImageStrategy
      // so if options doesn't have a public key set we set it from the default
      if (options.getPublicKey() == null) {
         options.authorizePublicKey(publicKey);
      }
      if (options.hasLoginPrivateKeyOption()) {
         credentialsBuilder.privateKey(options.getPrivateKey());
      }
      if (options.getLoginUser() != null) {
         credentialsBuilder.identity(options.getLoginUser());
      }
      if (options.hasLoginPasswordOption()) {
         credentialsBuilder.password(options.getLoginPassword());
      }
      if (options.shouldAuthenticateSudo() != null) {
         credentialsBuilder.authenticateSudo(options.shouldAuthenticateSudo());
      }
      LoginCredentials credentials = credentialsBuilder.build();
      options.overrideLoginCredentials(credentials);
      return credentials;
   }
View Full Code Here

    public Set<NodeMetadata> call() throws Exception {
      Location location = new LocationBuilder().scope(LocationScope.ZONE)
            .id("loc").description("test location").build();
      Set<String> addresses = Sets.newHashSet();
      addresses.add("10.0.0.1");
      LoginCredentials loginCredentials = LoginCredentials.builder().user("id").privateKey("cred").build();

      Set<NodeMetadata> nodes = Sets.newHashSet();
      Map<?, Exception> executionExceptions = Maps.newHashMap();
      Map<NodeMetadata, Throwable> failedNodes = Maps.newHashMap();
      for (int i = 0; i < num; i++) {
View Full Code Here

      expect(instanceClient.runInstancesInRegion(region, zone, imageId, 1, input.count, ec2Options)).andReturn(
            Reservation.class.cast(reservation));
      expect(instance.getId()).andReturn(instanceCreatedId).atLeastOnce();
      // simulate a lazy credentials fetch
      LoginCredentials creds = LoginCredentials.builder().user("foo").privateKey("bar").build();
      expect(strategy.instanceToCredentials.apply(instance)).andReturn(Optional.of(creds));
      expect(instance.getRegion()).andReturn(region).atLeastOnce();
      expect(strategy.credentialStore.put("node#" + region + "/" + instanceCreatedId, creds)).andReturn(null);

      expect(strategy.presentInstances.apply(ImmutableSet.of(new RegionAndName(region, instanceCreatedId)))).andReturn(ImmutableSet.of(instance));
View Full Code Here

      expect(input.image.getProviderId()).andReturn(imageId).atLeastOnce();
      expect(instanceClient.runInstancesInRegion(region, zone, imageId, 1, input.count, ec2Options)).andReturn(
            Reservation.class.cast(reservation));
      expect(instance.getId()).andReturn(instanceCreatedId).atLeastOnce();
      // simulate a lazy credentials fetch
      LoginCredentials creds = LoginCredentials.builder().user("foo").privateKey("bar").build();
      expect(strategy.instanceToCredentials.apply(instance)).andReturn(Optional.of(creds));
      expect(instance.getRegion()).andReturn(region).atLeastOnce();
      expect(strategy.credentialStore.put("node#" + region + "/" + instanceCreatedId, creds)).andReturn(null);

      expect(strategy.presentInstances.apply(ImmutableSet.of(new RegionAndName(region, instanceCreatedId)))).andReturn(ImmutableSet.of(instance));
View Full Code Here

      }
      return started;
   }

   private void populateCredentials(Set<RunningInstance> input, TemplateOptions options) {
      LoginCredentials credentials = null;
      for (RunningInstance instance : input) {
         credentials = instanceToCredentials.apply(instance).orNull();
         if (credentials != null)
            break;
      }
View Full Code Here

      TemplateOptions options = client.templateOptions().blockOnPort(22, 120);
      try {
         Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
         NodeMetadata node = get(nodes, 0);
         LoginCredentials good = node.getCredentials();
         assert good.identity != null : nodes;

         for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
               runningInGroup(group), "hostname",
               wrapInInitScript(false).runAsRoot(false).overrideLoginCredentials(good)).entrySet()) {
View Full Code Here

      TemplateOptions options = client.templateOptions().blockOnPort(22, 120);
      try {
         Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
         NodeMetadata node = get(nodes, 0);
         LoginCredentials good = node.getCredentials();
         assert good.identity != null : nodes;

         for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
               runningInGroup(group), "hostname",
               wrapInInitScript(false).runAsRoot(false).overrideLoginCredentials(good)).entrySet()) {
View Full Code Here

      TemplateOptions options = client.templateOptions().blockOnPort(22, 120);
      try {
         Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
         NodeMetadata node = get(nodes, 0);
         LoginCredentials good = node.getCredentials();
         assert good.identity != null : nodes;
         assert good.credential != null : nodes;

         for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
               runningInGroup(group), "hostname",
View Full Code Here

TOP

Related Classes of org.jclouds.domain.LoginCredentials

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.