Java 类com.amazonaws.services.ec2.model.DeleteKeyPairRequest 实例源码

项目:aws-doc-sdk-examples    文件:DeleteKeyPair.java   
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);
    }

    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);
}
项目:incubator-provisionr    文件:EnsureKeyPairExists.java   
@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 {
        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);
        }
    }
}
项目:cfnassist    文件:TestKeyPairCreationAndSave.java   
private List<KeyPairInfo> deleteKeyPair(String keypairName) {
    List<KeyPairInfo> keys;
    try {
        DescribeKeyPairsRequest query = new DescribeKeyPairsRequest().withKeyNames(keypairName);
        DescribeKeyPairsResult keysFound = ec2Client.describeKeyPairs(query);
        keys = keysFound.getKeyPairs();
    } catch (AmazonServiceException exception) {
        keys = new LinkedList<>();
    }

    if (keys.size() > 0) {
        DeleteKeyPairRequest deleteRequest = new DeleteKeyPairRequest().withKeyName(keypairName);
        ec2Client.deleteKeyPair(deleteRequest);
    }
    return keys;
}
项目:swordfish-service    文件:EC2KeyPairImpl.java   
@Override
public void delete(Instance instance) {
    DeleteKeyPairRequest deleteKeyPairRequest = new DeleteKeyPairRequest();
    deleteKeyPairRequest.withKeyName(instance.getKeyName());

    ec2UserClient.amazonEC2Async().deleteKeyPair(deleteKeyPairRequest);
}
项目:aws-ant-tasks    文件:TearDownCloudFormationTestsTask.java   
public void execute() {
    checkParams();
    AmazonEC2Client ec2Client = getOrCreateClient(AmazonEC2Client.class);
    ec2Client
            .deleteKeyPair(new DeleteKeyPairRequest().withKeyName(keyName));
    AmazonCloudFormationClient cloudFormationClient = getOrCreateClient(AmazonCloudFormationClient.class);
    cloudFormationClient.deleteStack(new DeleteStackRequest()
            .withStackName(stackName));
}
项目:cloudbreak    文件:AwsResourceConnector.java   
private void deleteKeyPair(AuthenticatedContext ac, CloudStack stack) {
    AwsCredentialView awsCredential = new AwsCredentialView(ac.getCloudCredential());
    String region = ac.getCloudContext().getLocation().getRegion().value();
    if (!awsClient.existingKeyPairNameSpecified(stack.getInstanceAuthentication())) {
        try {
            AmazonEC2Client client = awsClient.createAccess(awsCredential, region);
            DeleteKeyPairRequest deleteKeyPairRequest = new DeleteKeyPairRequest(awsClient.getKeyPairName(ac));
            client.deleteKeyPair(deleteKeyPairRequest);
        } catch (Exception e) {
            String errorMessage = String.format("Failed to delete public key [roleArn:'%s', region: '%s'], detailed message: %s",
                    awsCredential.getRoleArn(), region, e.getMessage());
            LOGGER.error(errorMessage, e);
        }
    }
}
项目:incubator-provisionr    文件:DeleteKeyPair.java   
@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));
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public void deleteKeyPair(DeleteKeyPairRequest deleteKeyPairRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:cmn-project    文件:EC2.java   
public void deleteKeyPair(String keyPairName) {
    logger.info("delete keyPair, keyName={}", keyPairName);
    ec2.deleteKeyPair(new DeleteKeyPairRequest(keyPairName));
}
项目:aws-sdk-java-resources    文件:KeyPairImpl.java   
@Override
public void delete(DeleteKeyPairRequest request) {
    delete(request, null);
}
项目:aws-sdk-java-resources    文件:KeyPairImpl.java   
@Override
public void delete(DeleteKeyPairRequest request, ResultCapture<Void>
        extractor) {

    resource.performAction("Delete", request, extractor);
}
项目:aws-sdk-java-resources    文件:KeyPairImpl.java   
@Override
public void delete(ResultCapture<Void> extractor) {
    DeleteKeyPairRequest request = new DeleteKeyPairRequest();
    delete(request, extractor);
}
项目:incubator-provisionr    文件:DeleteKeyPairLiveTest.java   
@Override
public void tearDown() throws Exception {
    client.deleteKeyPair(new DeleteKeyPairRequest().withKeyName(KEYPAIR_NAME));
    super.tearDown();
}
项目:incubator-provisionr    文件:EnsureKeyPairExistsLiveTest.java   
@Override
public void tearDown() throws Exception {
    client.deleteKeyPair(new DeleteKeyPairRequest().withKeyName(KEYPAIR_NAME));
    super.tearDown();
}
项目:aws-sdk-java-resources    文件:KeyPair.java   
/**
 * Performs the <code>Delete</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>KeyPair</code> resource, and any conflicting parameter value set in
 * the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>KeyName</code></b>
 *         - mapped from the <code>Name</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteKeyPairRequest
 */
void delete(DeleteKeyPairRequest request);
项目:aws-sdk-java-resources    文件:KeyPair.java   
/**
 * Performs the <code>Delete</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>KeyPair</code> resource, and any conflicting parameter value set in
 * the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>KeyName</code></b>
 *         - mapped from the <code>Name</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteKeyPairRequest
 */
void delete(DeleteKeyPairRequest request, ResultCapture<Void> extractor);