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


Java DescribeAddressesResult类代码示例

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


DescribeAddressesResult类属于com.amazonaws.services.ec2.model包,在下文中一共展示了DescribeAddressesResult类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
public static void main(String[] args)
{
    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DescribeAddressesResult response = ec2.describeAddresses();

    for(Address address : response.getAddresses()) {
        System.out.printf(
                "Found address with public IP %s, " +
                "domain %s, " +
                "allocation id %s " +
                "and NIC id %s",
                address.getPublicIp(),
                address.getDomain(),
                address.getAllocationId(),
                address.getNetworkInterfaceId());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:19,代码来源:DescribeAddresses.java

示例2: itShouldStartAnEC2InstanceFromAnAMI

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
@Test
public void itShouldStartAnEC2InstanceFromAnAMI()
		throws ServiceBrokerException {

	when(
			ec2Client.runInstances(awsRqst(r -> r.getImageId().equals(
					"test_image")))).thenReturn(runInstanceResult);

	when(ec2Client.describeAddresses()).thenReturn(
			new DescribeAddressesResult().withAddresses(Collections
					.singleton(new Address().withPublicIp("10.10.10.10"))));

	when(ec2Client.describeInstanceStatus(any())).thenReturn(
			new DescribeInstanceStatusResult()
					.withInstanceStatuses(Collections
							.singleton(new InstanceStatus()
									.withInstanceState(new InstanceState()
											.withName("running")))));

	when(hostUtils.waitForBoot(anyString(), anyInt())).thenReturn(true);
	assertThat(aws.startEC2Instance("test_image"),
			is(equalTo("test_instance")));
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:24,代码来源:AWSHelperTest.java

示例3: describeAddress

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
public Address describeAddress(AwsProcessClient awsProcessClient, String publicIp) {
    // 単一アドレスの参照
    DescribeAddressesRequest request = new DescribeAddressesRequest();
    request.withPublicIps(publicIp);
    DescribeAddressesResult result = awsProcessClient.getEc2Client().describeAddresses(request);
    List<Address> addresses = result.getAddresses();

    // API実行結果チェック
    if (addresses.size() == 0) {
        // アドレスが存在しない場合
        throw new AutoException("EPROCESS-000117", publicIp);

    } else if (addresses.size() > 1) {
        // アドレスを複数参照できた場合
        AutoException exception = new AutoException("EPROCESS-000118", publicIp);
        exception.addDetailInfo("result=" + addresses);
        throw exception;
    }

    return addresses.get(0);
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:22,代码来源:AwsCommonProcess.java

示例4: releaseReservedIp

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的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

示例5: getAvaliableElasticIp

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
/**
 * Pull back a list of the elastic ip's that aren't attached to anything and
 * return the first one.
 * 
 * @return the first available IP.
 * @throws ServiceBrokerException
 */
public String getAvaliableElasticIp() throws ServiceBrokerException {
	DescribeAddressesResult result = ec2Client.describeAddresses();
	log.info("Found " + result.getAddresses().size() + " addresses!");
	return result
			.getAddresses()
			.stream()
			.filter(a -> null == a.getInstanceId())
			.findAny()
			.orElseThrow(
					() -> new ServiceBrokerException(
							"No elastic IP's avaliable!")).getPublicIp();

}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:21,代码来源:AWSHelper.java

示例6: itShouldReturnAFreeElasticIp

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
@Test
public void itShouldReturnAFreeElasticIp() throws ServiceBrokerException {
	when(ec2Client.describeAddresses()).thenReturn(
			new DescribeAddressesResult().withAddresses(Collections
					.singleton(new Address().withPublicIp("10.10.10.10"))));
	assertThat("10.10.10.10", is(aws.getAvaliableElasticIp()));
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:8,代码来源:AWSHelperTest.java

示例7: itShouldReturnOnlyOneFreeElasticIp

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
@Test
public void itShouldReturnOnlyOneFreeElasticIp()
		throws ServiceBrokerException {
	when(ec2Client.describeAddresses()).thenReturn(
			new DescribeAddressesResult().withAddresses(Arrays.asList(
					new Address().withPublicIp("10.10.10.10")
							.withInstanceId(null),
					new Address().withPublicIp("10.10.10.11")
							.withInstanceId(null))));
	assertThat("10.10.10.10", is(aws.getAvaliableElasticIp()));
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:12,代码来源:AWSHelperTest.java

示例8: itShouldReturnNullIfNoElasticIpIsAvaliable

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
@Test(expected = ServiceBrokerException.class)
public void itShouldReturnNullIfNoElasticIpIsAvaliable()
		throws ServiceBrokerException {
	when(ec2Client.describeAddresses()).thenReturn(
			new DescribeAddressesResult().withAddresses(new ArrayList<>()));
	assertNull(aws.getAvaliableElasticIp());
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:8,代码来源:AWSHelperTest.java

示例9: itShouldFilterOutAttachedElasticIPs

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
@Test
public void itShouldFilterOutAttachedElasticIPs()
		throws ServiceBrokerException {
	when(ec2Client.describeAddresses()).thenReturn(
			new DescribeAddressesResult().withAddresses(Arrays.asList(
					new Address().withPublicIp("10.10.10.10")
							.withInstanceId("the-instance"),
					new Address().withPublicIp("10.10.10.11")
							.withInstanceId(null))));
	assertThat("10.10.10.11", is(aws.getAvaliableElasticIp()));
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:12,代码来源:AWSHelperTest.java

示例10: checkExistsAddress

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
public static Address checkExistsAddress(AmazonEC2 ec2, String targetIp) {
	DescribeAddressesRequest addressRequest = new DescribeAddressesRequest().withPublicIps(targetIp);
	DescribeAddressesResult addressResult = ec2.describeAddresses(addressRequest);
	List<Address> addresses = addressResult.getAddresses();
	for (Address address : addresses) {
		String publicIp = address.getPublicIp();
		if (targetIp.equals(publicIp)) {
			return address;
		}
		break;
	}
	return null;
}
 
开发者ID:betahikaru,项目名称:ec2-util,代码行数:14,代码来源:AwsEc2Client.java

示例11: releaseEIP

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
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()));
    }
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:11,代码来源:EC2VPC.java

示例12: describeElasticIPs

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
@Override
public List<AbstractResource<?>> describeElasticIPs(Account account, Region region, DateTime dt, Ec2Filter... filters) {
    AmazonEC2 ec2 = findClient(account, region);

    DescribeAddressesRequest req = new DescribeAddressesRequest();
    for (Ec2Filter filter : filters) {
        Filter f = new Filter().withName(filter.getName()).withValues(filter.getValues());
        req.withFilters(f);
    }

    log.debug("start describing elastic ips for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region);
    DescribeAddressesResult res = ec2.describeAddresses(req);

    return converter.toEc2ElasticIPs(res.getAddresses(), account.getId(), region, dt);
}
 
开发者ID:veyronfei,项目名称:clouck,代码行数:16,代码来源:Ec2WrapperImpl.java

示例13: describeAddresses

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
@Override
public DescribeAddressesResult describeAddresses(DescribeAddressesRequest describeAddressesRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java

示例14: getFreeIps

import com.amazonaws.services.ec2.model.DescribeAddressesResult; //导入依赖的package包/类
private List<String> getFreeIps(List<String> eips, AmazonEC2Client amazonEC2Client) {
    DescribeAddressesResult addresses = amazonEC2Client.describeAddresses(new DescribeAddressesRequest().withAllocationIds(eips));
    return addresses.getAddresses().stream().filter(address -> address.getInstanceId() == null)
            .map(Address::getAllocationId).collect(Collectors.toList());
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:6,代码来源:AwsResourceConnector.java


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