当前位置: 首页>>代码示例>>Java>>正文


Java Address.getAssociationId方法代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.model.Address.getAssociationId方法的典型用法代码示例。如果您正苦于以下问题:Java Address.getAssociationId方法的具体用法?Java Address.getAssociationId怎么用?Java Address.getAssociationId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.ec2.model.Address的用法示例。


在下文中一共展示了Address.getAssociationId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: releaseReservedIp

import com.amazonaws.services.ec2.model.Address; //导入方法依赖的package包/类
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()));
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:23,代码来源:AwsResourceConnector.java

示例2: createNATGateway

import com.amazonaws.services.ec2.model.Address; //导入方法依赖的package包/类
public NatGateway createNATGateway(String subnetId, String ip) {
    logger.info("create nat gateway, subnetId={}, ip={}", subnetId, ip);

    List<Address> addresses = AWS.vpc.ec2.describeAddresses(new DescribeAddressesRequest().withPublicIps(ip)).getAddresses();
    if (addresses.isEmpty()) throw new Error("cannot find eip, ip=" + ip);
    Address address = addresses.get(0);
    if (address.getAssociationId() != null) throw new Error("eip must not associated with other resource, ip=" + ip);

    CreateNatGatewayRequest request = new CreateNatGatewayRequest()
        .withSubnetId(subnetId)
        .withAllocationId(address.getAllocationId());
    String gatewayId = ec2.createNatGateway(request).getNatGateway().getNatGatewayId();

    NatGateway gateway;
    while (true) {
        Threads.sleepRoughly(Duration.ofSeconds(30));
        gateway = describeNATGateway(gatewayId);
        String state = gateway.getState();
        if ("pending".equals(state)) continue;
        if ("available".equals(state)) {
            break;
        } else {
            throw new Error("failed to create nat gateway, gatewayId=" + gatewayId + ", state=" + state);
        }
    }
    return gateway;
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:28,代码来源:EC2VPC.java

示例3: disassociateAddress

import com.amazonaws.services.ec2.model.Address; //导入方法依赖的package包/类
public static void disassociateAddress(AmazonEC2 ec2, Address address) {
	String associationId = address.getAssociationId();
	DisassociateAddressRequest disassociateAddressRequest = new DisassociateAddressRequest();
	disassociateAddressRequest.setAssociationId(associationId);
	ec2.disassociateAddress(disassociateAddressRequest);
}
 
开发者ID:betahikaru,项目名称:ec2-util,代码行数:7,代码来源:AwsEc2Client.java


注:本文中的com.amazonaws.services.ec2.model.Address.getAssociationId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。