Package org.jclouds.digitalocean.domain

Examples of org.jclouds.digitalocean.domain.SshKey


      DigitalOceanApi api = api(server.getUrl("/"));
      KeyPairApi keyPairApi = api.getKeyPairApi();

      try {
         String publicKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
         SshKey key = keyPairApi.create("my_key", publicKey);

         assertRequestHasParameters(server.takeRequest(), "/ssh_keys/new",
               ImmutableMultimap.of("name", "my_key", "ssh_pub_key", publicKey));

         assertEquals(key.getId(), 47);
         assertEquals(key.getName(), "my_key");
         assertNotNull(key.getPublicKey());
      } finally {
         api.close();
         server.shutdown();
      }
   }
View Full Code Here


      DigitalOceanApi api = api(server.getUrl("/"));
      KeyPairApi keyPairApi = api.getKeyPairApi();

      try {
         String publicKey = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-rsa.txt"));
         SshKey key = keyPairApi.edit(47, publicKey);

         assertRequestHasParameters(server.takeRequest(), "/ssh_keys/47/edit",
               ImmutableMultimap.of("ssh_pub_key", publicKey));

         assertEquals(key.getId(), 47);
         assertEquals(key.getName(), "my_key");
         assertNotNull(key.getPublicKey());
      } finally {
         api.close();
         server.shutdown();
      }
   }
View Full Code Here

      CreateDropletOptions.Builder options = CreateDropletOptions.builder();

      // Create a default keypair for the node so it has a known private key
      Map<String, String> defaultKeys = keyGenerator.get();
      logger.debug(">> creating default keypair for node...");
      SshKey defaultKey = api.getKeyPairApi().create(name, defaultKeys.get("public"));
      logger.debug(">> keypair created! %s", defaultKey);
      options.addSshKeyId(defaultKey.getId());

      // Check if there is a key to authorize in the portable options
      if (!Strings.isNullOrEmpty(template.getOptions().getPublicKey())) {
         logger.debug(">> creating user keypair for node...");
         // The DigitalOcean API accepts multiple key pairs with the same name. It will be useful to identify all
         // keypairs associated with the node when it comes to destroy it
         SshKey key = api.getKeyPairApi().create(name, template.getOptions().getPublicKey());
         logger.debug(">> keypair created! %s", key);
         options.addSshKeyId(key.getId());
      }

      // DigitalOcean specific options
      if (!templateOptions.getSshKeyIds().isEmpty()) {
         options.addSshKeyIds(templateOptions.getSshKeyIds());
View Full Code Here

TOP

Related Classes of org.jclouds.digitalocean.domain.SshKey

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.