List of usage examples for com.amazonaws.services.ec2.model AllocateAddressRequest withDomain
public AllocateAddressRequest withDomain(DomainType domain)
Set to vpc
to allocate the address for use with instances in a VPC.
From source file:jp.primecloud.auto.process.aws.AwsAddressProcess.java
License:Open Source License
/** * TODO: /* w w w.j av a2 s. c om*/ * * @param awsProcessClient * @return */ public AwsAddress createAddress(AwsProcessClient awsProcessClient) { // Elastic IP?? AllocateAddressRequest request = new AllocateAddressRequest(); if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) { request.withDomain(DomainType.Vpc); } String publicIp; try { AllocateAddressResult result = awsProcessClient.getEc2Client().allocateAddress(request); publicIp = result.getPublicIp(); } catch (AutoException e) { // Elastic IP????? if (e.getCause() instanceof AmazonServiceException && "AddressLimitExceeded".equals(((AmazonServiceException) e.getCause()).getErrorCode())) { throw new AutoApplicationException("EPROCESS-000134"); } throw e; } // processLogger.debug(null, null, "AwsElasticIpAllocate", new Object[] { awsProcessClient.getPlatform().getPlatformName(), publicIp }); // AWS? AwsAddress awsAddress = new AwsAddress(); awsAddress.setUserNo(awsProcessClient.getUserNo()); awsAddress.setPlatformNo(awsProcessClient.getPlatform().getPlatformNo()); awsAddress.setPublicIp(publicIp); awsAddress.setComment("Allocate at " + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); awsAddressDao.create(awsAddress); return awsAddress; }