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

项目:aws-doc-sdk-examples    文件:ReleaseAddress.java   
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply an allocation ID.\n" +
        "Ex: ReleaseAddress <allocation_id>\n";

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

    String alloc_id = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    ReleaseAddressRequest request = new ReleaseAddressRequest()
        .withAllocationId(alloc_id);

    ReleaseAddressResult response = ec2.releaseAddress(request);

    System.out.printf(
        "Successfully released elastic IP address %s", alloc_id);
}
项目:cloudbreak    文件:AwsResourceConnector.java   
private void releaseReservedIp(AmazonEC2Client client, List<CloudResource> resources) {
    CloudResource elasticIpResource = getReservedIp(resources);
    if (elasticIpResource != null && elasticIpResource.getName() != null) {
        Address address;
        try {
            DescribeAddressesResult describeResult = client.describeAddresses(
                    new DescribeAddressesRequest().withAllocationIds(elasticIpResource.getName()));
            address = describeResult.getAddresses().get(0);
        } catch (AmazonServiceException e) {
            if (e.getErrorMessage().equals("The allocation ID '" + elasticIpResource.getName() + "' does not exist")) {
                LOGGER.warn("Elastic IP with allocation ID '{}' not found. Ignoring IP release.", elasticIpResource.getName());
                return;
            } else {
                throw e;
            }
        }
        if (address.getAssociationId() != null) {
            client.disassociateAddress(new DisassociateAddressRequest().withAssociationId(elasticIpResource.getName()));
        }
        client.releaseAddress(new ReleaseAddressRequest().withAllocationId(elasticIpResource.getName()));
    }
}
项目:photon-model    文件:AWSNetworkClient.java   
/**
 * Release an elastic IP address
 */
public DeferredResult<Void> releaseElasticIPAddress(String allocationId) {
    ReleaseAddressRequest req = new ReleaseAddressRequest()
            .withAllocationId(allocationId);

    String message = "Release AWS Elastic IP Address with allocation id [" + allocationId
            + "].";

    AWSDeferredResultAsyncHandler<ReleaseAddressRequest, ReleaseAddressResult> handler = new
            AWSDeferredResultAsyncHandler<>(this.service, message);
    this.client.releaseAddressAsync(req, handler);
    return handler.toDeferredResult()
            .thenApply(ignore -> null);
}
项目:cmn-project    文件:EC2VPC.java   
public void releaseEIP(List<String> instanceIds) {
    logger.info("release EIP for instances, instanceIds={}", instanceIds);

    DescribeAddressesResult result = ec2.describeAddresses(new DescribeAddressesRequest().withFilters(new Filter("instance-id").withValues(instanceIds)));
    for (Address address : result.getAddresses()) {
        logger.info("release EIP, ip={}, instanceId={}", address.getPublicIp(), address.getInstanceId());
        ec2.disassociateAddress(new DisassociateAddressRequest().withAssociationId(address.getAssociationId()));
        ec2.releaseAddress(new ReleaseAddressRequest().withAllocationId(address.getAllocationId()));
    }
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public void releaseAddress(ReleaseAddressRequest releaseAddressRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:ec2-util    文件:AwsEc2Client.java   
public static void releaseAddress(AmazonEC2 ec2, Address address) {
    String allocationId = address.getAllocationId();
    ReleaseAddressRequest releaseAddressRequest = new ReleaseAddressRequest();
    releaseAddressRequest.setAllocationId(allocationId);
    ec2.releaseAddress(releaseAddressRequest);
}
项目:primecloud-controller    文件:AwsAddressProcess.java   
/**
 * TODO: メソッドコメント
 * 
 * @param awsProcessClient
 * @param addressNo
 */
public void deleteAddress(AwsProcessClient awsProcessClient, Long addressNo) {
    // AWSアドレス情報の存在チェック
    AwsAddress awsAddress = awsAddressDao.read(addressNo);
    if (awsAddress == null) {
        return;
    }

    // Elastic IPのチェック
    if (StringUtils.isEmpty(awsAddress.getPublicIp())) {
        // Elastic IPが空ならAWSアドレス情報を削除して終了
        awsAddressDao.delete(awsAddress);
        return;
    }

    // Elastic IPを解放
    try {
        ReleaseAddressRequest request = new ReleaseAddressRequest();

        // VPCの場合
        if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) {
            // 割り当てIDを取得する
            Address address = awsCommonProcess.describeAddress(awsProcessClient, awsAddress.getPublicIp());
            request.withAllocationId(address.getAllocationId());
        }
        // 非VPCの場合
        else {
            request.withPublicIp(awsAddress.getPublicIp());
        }

        awsProcessClient.getEc2Client().releaseAddress(request);

        // イベントログ出力
        processLogger.debug(null, null, "AwsElasticIpRelease", new Object[] {
                awsProcessClient.getPlatform().getPlatformName(), awsAddress.getPublicIp() });

    } catch (Exception ignore) {
        // Elastic IPが実際には存在しない場合などに備えて、警告ログを出力して例外を握りつぶす
        log.warn(ignore.getMessage());
    }

    // AWSアドレス情報を削除
    awsAddressDao.delete(awsAddress);
}