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

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

Introduction

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

Prototype


public AssociateAddressRequest withPublicIp(String publicIp) 

Source Link

Document

The Elastic IP address to associate with the instance.

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  w w w . ja v a  2 s  . co  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);
}