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

项目: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()));
    }
}
项目: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()));
    }
}
项目:primecloud-controller    文件:AwsAddressProcess.java   
public void disassociateAddress(AwsProcessClient awsProcessClient, Long instanceNo, Long addressNo, Address address) {
    AwsAddress awsAddress = awsAddressDao.read(addressNo);

    // アドレスの切り離し
    DisassociateAddressRequest request = new DisassociateAddressRequest();

    // VPCの場合
    if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) {
        // 関連付けIDを指定する
        request.withAssociationId(address.getAssociationId());
    }
    // 非VPCの場合
    else {
        request.withPublicIp(awsAddress.getPublicIp());
    }

    awsProcessClient.getEc2Client().disassociateAddress(request);

    // ログ出力
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100132", awsAddress.getPublicIp(), awsAddress.getInstanceId()));
    }

    //イベントログ出力
    Instance instance = instanceDao.read(instanceNo);
    processLogger.debug(null, instance, "AwsElasticIpDisassociate", new Object[] { awsAddress.getInstanceId(),
            awsAddress.getPublicIp() });

    // データベースの更新
    awsAddress.setInstanceId(null);
    awsAddressDao.update(awsAddress);
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public void disassociateAddress(DisassociateAddressRequest disassociateAddressRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:ec2-util    文件:AwsEc2Client.java   
public static void disassociateAddress(AmazonEC2 ec2, Address address) {
    String associationId = address.getAssociationId();
    DisassociateAddressRequest disassociateAddressRequest = new DisassociateAddressRequest();
    disassociateAddressRequest.setAssociationId(associationId);
    ec2.disassociateAddress(disassociateAddressRequest);
}