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

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

Introduction

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

Prototype


public AssociateAddressRequest 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

public void associateAddress(AwsProcessClient awsProcessClient, Long instanceNo, Long addressNo,
        Address address) {/*from www.j  a v  a2 s  .  c  o  m*/
    AwsAddress awsAddress = awsAddressDao.read(addressNo);
    AwsInstance awsInstance = awsInstanceDao.read(instanceNo);

    // ??
    AssociateAddressRequest request = new AssociateAddressRequest();
    request.withInstanceId(awsInstance.getInstanceId());

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

    awsProcessClient.getEc2Client().associateAddress(request);

    // 
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100131", awsAddress.getPublicIp(),
                awsInstance.getInstanceId()));
    }

    // 
    Instance instance2 = instanceDao.read(instanceNo);
    processLogger.debug(null, instance2, "AwsElasticIpAssociate",
            new Object[] { awsInstance.getInstanceId(), awsAddress.getPublicIp() });

    // ?
    awsAddress.setInstanceId(awsInstance.getInstanceId());
    awsAddressDao.update(awsAddress);
}