Java 类com.amazonaws.services.ec2.model.AllocateAddressResult 实例源码

项目:photon-model    文件:AWSNetworkClient.java   
/**
 * Allocate an elastic IP address
 */
public DeferredResult<String> allocateElasticIPAddress() {
    AllocateAddressRequest req = new AllocateAddressRequest()
            .withDomain(DomainType.Vpc);

    String message = "Allocate AWS Elastic IP Address for use with instances in a VPC.";

    AWSDeferredResultAsyncHandler<AllocateAddressRequest, AllocateAddressResult> handler = new
            AWSDeferredResultAsyncHandler<>(this.service, message);
    this.client.allocateAddressAsync(req, handler);
    return handler.toDeferredResult()
            .thenApply(AllocateAddressResult::getAllocationId);
}
项目:aws-doc-sdk-examples    文件:AllocateAddress.java   
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply an instance id\n" +
        "Ex: AllocateAddress <instance_id>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String instance_id = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    AllocateAddressRequest allocate_request = new AllocateAddressRequest()
        .withDomain(DomainType.Vpc);

    AllocateAddressResult allocate_response =
        ec2.allocateAddress(allocate_request);

    String allocation_id = allocate_response.getAllocationId();

    AssociateAddressRequest associate_request =
        new AssociateAddressRequest()
            .withInstanceId(instance_id)
            .withAllocationId(allocation_id);

    AssociateAddressResult associate_response =
        ec2.associateAddress(associate_request);

    System.out.printf(
        "Successfully associated Elastic IP address %s " +
        "with instance %s",
        associate_response.getAssociationId(),
        instance_id);
}
项目:ec2-util    文件:AwsEc2Client.java   
public static Address allocateAddress(AmazonEC2 ec2, DomainType domainType) {
    AllocateAddressRequest addressRequest = new AllocateAddressRequest().withDomain(domainType);
    AllocateAddressResult addressResult = ec2.allocateAddress(addressRequest);
    Address address = new Address().withAllocationId(addressResult.getAllocationId())
            .withDomain(addressResult.getDomain()).withPublicIp(addressResult.getPublicIp());
    return address;
}
项目:cmn-project    文件:EC2VPC.java   
public String assignEIP(final String instanceId) throws Exception {
    final AllocateAddressResult address = ec2.allocateAddress(new AllocateAddressRequest().withDomain("vpc"));
    logger.info("associate eip to instance, instanceId={}, ip={}", instanceId, address.getPublicIp());

    new Runner<>()
        .retryInterval(Duration.ofSeconds(10))
        .maxAttempts(3)
        .retryOn(e -> e instanceof AmazonServiceException)
        .run(() -> {
            ec2.associateAddress(new AssociateAddressRequest().withInstanceId(instanceId).withAllocationId(address.getAllocationId()));
            return null;
        });

    return address.getPublicIp();
}
项目:primecloud-controller    文件:AwsAddressProcess.java   
/**
 * TODO: メソッドコメント
 * 
 * @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;
}
项目:vpc2vpc    文件:CreateConnection.java   
/**
 * Allocate Elastic IPs as needed and assign it to the endpoints. If there are
 * any errors, roll back by releasing all allocated IPs if possible
 *
 * @param vpnEndpoints
 */
private void allocateElasticIPs(List<VPNEndpoint> vpnEndpoints) {

  for (VPNEndpoint vpnEndpoint : vpnEndpoints) {
    ec2Client.setEndpoint(vpnEndpoint.getRegion().getEndpoint());
    AllocateAddressResult allocAddrResult = ec2Client.allocateAddress(new AllocateAddressRequest().withDomain(DomainType.Vpc));
    String publicIp = allocAddrResult.getPublicIp();
    vpnEndpoint.setElasticIPAddress(publicIp);
    vpnEndpoint.setElasticIPAllocationId(allocAddrResult.getAllocationId());
    LOG.debug("Allocated elastic IP " + publicIp + " in " + vpnEndpoint.getRegion().getEndpoint());
  }
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public AllocateAddressResult allocateAddress(AllocateAddressRequest allocateAddressRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public AllocateAddressResult allocateAddress() throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}