private void generateKeyPairAndAddKeyToSet(DigitalOcean2TemplateOptions options, Set<Integer> generatedSshKeyIds, String prefix) { logger.debug(">> creating default keypair for node..."); Map<String, String> defaultKeys = keyGenerator.get(); Key defaultKey = api.keyApi().create(prefix + "-" + System.getProperty("user.name"), defaultKeys.get("public")); generatedSshKeyIds.add(defaultKey.id()); logger.debug(">> keypair created! %s", defaultKey); // If a private key has not been explicitly set, configure the auto-generated one if (Strings.isNullOrEmpty(options.getLoginPrivateKey())) { options.overrideLoginPrivateKey(defaultKeys.get("private")); } }
private void generateKeyPairAndAddKeyToSet(DigitalOcean2TemplateOptions options, Set<Integer> generatedSshKeyIds, String prefix) { logger.debug(">> creating default keypair for node..."); Map<String, String> defaultKeys = keyGenerator.get(); Key defaultKey = api.keyApi().create(prefix + "-" + System.getProperty("user.name"), defaultKeys.get("public")); generatedSshKeyIds.add(defaultKey.id()); logger.debug(">> keypair created! %s", defaultKey); // If a private key has not been explicitly set, configure the auto-generated one if (Strings.isNullOrEmpty(options.getLoginPrivateKey())) { options.overrideLoginPrivateKey(defaultKeys.get("private")); } }
private void generateKeyPairAndAddKeyToSet(DigitalOcean2TemplateOptions options, Set<Integer> generatedSshKeyIds, String prefix) { logger.debug(">> creating default keypair for node..."); Map<String, String> defaultKeys = keyGenerator.get(); Key defaultKey = api.keyApi().create(prefix + "-" + System.getProperty("user.name"), defaultKeys.get("public")); generatedSshKeyIds.add(defaultKey.id()); logger.debug(">> keypair created! %s", defaultKey); // If a private key has not been explicitly set, configure the auto-generated one if (Strings.isNullOrEmpty(options.getLoginPrivateKey())) { options.overrideLoginPrivateKey(defaultKeys.get("private")); } }
@AfterClass(alwaysRun = true) public void tearDown() { if (key != null) { api.keyApi().delete(key.id()); } }
private void createKeyPairForPublicKeyInOptionsAndAddToSet(DigitalOcean2TemplateOptions options, Set<Integer> generatedSshKeyIds) { logger.debug(">> checking if the key pair already exists..."); PublicKey userKey = sshKeyToPublicKey.apply(options.getPublicKey()); String userFingerprint = computeFingerprint(userKey); Key key = api.keyApi().get(userFingerprint); if (key == null) { logger.debug(">> key pair not found. creating a new one..."); Key newKey = api.keyApi().create(userFingerprint, options.getPublicKey()); generatedSshKeyIds.add(newKey.id()); logger.debug(">> key pair created! %s", newKey); } else { logger.debug(">> key pair found! %s", key); generatedSshKeyIds.add(key.id()); } }
private void createKeyPairForPublicKeyInOptionsAndAddToSet(DigitalOcean2TemplateOptions options, Set<Integer> generatedSshKeyIds) { logger.debug(">> checking if the key pair already exists..."); PublicKey userKey = sshKeyToPublicKey.apply(options.getPublicKey()); String userFingerprint = computeFingerprint(userKey); Key key = api.keyApi().get(userFingerprint); if (key == null) { logger.debug(">> key pair not found. creating a new one..."); Key newKey = api.keyApi().create(userFingerprint, options.getPublicKey()); generatedSshKeyIds.add(newKey.id()); logger.debug(">> key pair created! %s", newKey); } else { logger.debug(">> key pair found! %s", key); generatedSshKeyIds.add(key.id()); } }
private void createKeyPairForPublicKeyInOptionsAndAddToSet(DigitalOcean2TemplateOptions options, Set<Integer> generatedSshKeyIds) { logger.debug(">> checking if the key pair already exists..."); PublicKey userKey = sshKeyToPublicKey.apply(options.getPublicKey()); String userFingerprint = computeFingerprint(userKey); Key key = api.keyApi().get(userFingerprint); if (key == null) { logger.debug(">> key pair not found. creating a new one..."); Key newKey = api.keyApi().create(userFingerprint, options.getPublicKey()); generatedSshKeyIds.add(newKey.id()); logger.debug(">> key pair created! %s", newKey); } else { logger.debug(">> key pair found! %s", key); generatedSshKeyIds.add(key.id()); } }
@AfterClass(alwaysRun = true) public void testDeleteKey() { if (dsa != null) { api().delete(dsa.id()); FluentIterable<Key> keys = api().list().concat(); assertFalse(keys.contains(dsa), "dsa key must not be present in list"); } if (ecdsa != null) { api().delete(ecdsa.fingerprint()); FluentIterable<Key> keys = api().list().concat(); assertFalse(keys.contains(ecdsa), "dsa key must not be present in list"); } }
public void testCreate() { DropletCreate dropletCreate = api().create(prefix + "-droplet-livetest", region.slug(), size.slug(), image.slug(), CreateDropletOptions.builder().backupsEnabled(true).addSshKeyId(key.id()).build()); dropletId = dropletCreate.droplet().id(); assertNodeRunning(dropletId); Droplet droplet = api().get(dropletId); assertNotNull(droplet, "Droplet should not be null"); }