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

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

Introduction

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

Prototype


public AssociateAddressRequest withInstanceId(String instanceId) 

Source Link

Document

The ID of 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 .  j a v a 2s .  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);
}