Example usage for com.amazonaws.services.ec2.model ReleaseAddressRequest withAllocationId

List of usage examples for com.amazonaws.services.ec2.model ReleaseAddressRequest withAllocationId

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model ReleaseAddressRequest withAllocationId.

Prototype


public ReleaseAddressRequest withAllocationId(String allocationId) 

Source Link

Document

[EC2-VPC] The allocation ID.

Usage

From source file:jp.primecloud.auto.process.aws.AwsAddressProcess.java

License:Open Source License

/**
 * TODO: //from w  ww .  j av a 2 s  .c  om
 * 
 * @param awsProcessClient
 * @param addressNo
 */
public void deleteAddress(AwsProcessClient awsProcessClient, Long addressNo) {
    // AWS??
    AwsAddress awsAddress = awsAddressDao.read(addressNo);
    if (awsAddress == null) {
        return;
    }

    // Elastic IP??
    if (StringUtils.isEmpty(awsAddress.getPublicIp())) {
        // Elastic IP??AWS??
        awsAddressDao.delete(awsAddress);
        return;
    }

    // Elastic IP
    try {
        ReleaseAddressRequest request = new ReleaseAddressRequest();

        // VPC??
        if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) {
            // ?ID??
            Address address = awsCommonProcess.describeAddress(awsProcessClient, awsAddress.getPublicIp());
            request.withAllocationId(address.getAllocationId());
        }
        // ?VPC??
        else {
            request.withPublicIp(awsAddress.getPublicIp());
        }

        awsProcessClient.getEc2Client().releaseAddress(request);

        // 
        processLogger.debug(null, null, "AwsElasticIpRelease",
                new Object[] { awsProcessClient.getPlatform().getPlatformName(), awsAddress.getPublicIp() });

    } catch (Exception ignore) {
        // Elastic IP???????????????????
        log.warn(ignore.getMessage());
    }

    // AWS
    awsAddressDao.delete(awsAddress);
}