List of usage examples for com.amazonaws.services.ec2.model DeleteKeyPairRequest DeleteKeyPairRequest
public DeleteKeyPairRequest()
From source file:aws.example.ec2.DeleteKeyPair.java
License:Open Source License
public static void main(String[] args) { final String USAGE = "To run this example, supply a key pair name\n" + "Ex: DeleteKeyPair <key-pair-name>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1);// w ww . j av a 2 s . c o m } String key_name = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DeleteKeyPairRequest request = new DeleteKeyPairRequest().withKeyName(key_name); DeleteKeyPairResult response = ec2.deleteKeyPair(request); System.out.printf("Successfully deleted key pair named %s", key_name); }
From source file:com.axemblr.provisionr.amazon.activities.DeleteKeyPair.java
License:Apache License
@Override public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) { String keyName = KeyPairs.formatNameFromBusinessKey(execution.getProcessBusinessKey()); LOG.info(">> Deleting key pair {}", keyName); client.deleteKeyPair(new DeleteKeyPairRequest().withKeyName(keyName)); }
From source file:com.axemblr.provisionr.amazon.activities.EnsureKeyPairExists.java
License:Apache License
@Override public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) { String keyName = KeyPairs.formatNameFromBusinessKey(execution.getProcessBusinessKey()); LOG.info(">> Importing admin access key pair as {}", keyName); final String publicKey = pool.getAdminAccess().getPublicKey(); try {/* ww w.j a va2 s.c o m*/ importPoolPublicKeyPair(client, keyName, publicKey); } catch (AmazonServiceException e) { if (e.getErrorCode().equals(ErrorCodes.DUPLICATE_KEYPAIR)) { LOG.info("<< Duplicate key pair found. Re-importing from pool description"); client.deleteKeyPair(new DeleteKeyPairRequest().withKeyName(keyName)); importPoolPublicKeyPair(client, keyName, publicKey); } } }
From source file:com.dowdandassociates.gentoo.bootstrap.DefaultKeyPairInformation.java
License:Apache License
@PreDestroy private void tearDown() { if (builtKeyPair) { log.info("Deleting key pair \"" + name + "\""); ec2Client.deleteKeyPair(new DeleteKeyPairRequest().withKeyName(name)); try {/* www.ja va 2s .co m*/ File file = new File(filename); file.delete(); } catch (NullPointerException | SecurityException e) { log.error(e.getMessage(), e); } } }
From source file:com.zotoh.cloudapi.aws.Keypair.java
License:Open Source License
@Override public void deleteKeypair(String name) throws InternalException, CloudException { tstEStrArg("keypair-name", name); _svc.getCloud().getEC2().deleteKeyPair(new DeleteKeyPairRequest().withKeyName(name)); }
From source file:ec2.DeleteKeyPair.java
License:Open Source License
public static void main(String[] args) { final String USAGE = "To run this example, supply a key pair name\n" + "Ex: DeleteKeyPair <key-pair-name>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1);/*from w w w . j a v a2 s. c o m*/ } String keyPairName = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DeleteKeyPairRequest request = new DeleteKeyPairRequest().withKeyName(keyPairName); DeleteKeyPairResult response = ec2.deleteKeyPair(request); System.out.printf("Successfully deleted key pair named %s", keyPairName); }
From source file:org.openinfinity.cloud.service.administrator.EC2Wrapper.java
License:Apache License
public void deleteKeypair(String name) { try {// w w w. jav a 2 s.c o m DeleteKeyPairRequest request = new DeleteKeyPairRequest(); request.setKeyName(name); ec2.deleteKeyPair(request); } catch (Exception e) { String message = e.getMessage(); LOG.error("Error deleting keypair: " + message); ExceptionUtil.throwSystemException(message, e); } }