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


Java Address.getPublicIp方法代码示例

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


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

示例1: createEvaluations

import com.amazonaws.services.ec2.model.Address; //导入方法依赖的package包/类
/**
 * This method returns list of Evaluation objects.
 * @param allUnusedEIPs
 * @return List<Evaluation> returns list of Evaluation objects.
 */
private List<Evaluation> createEvaluations(List<Address> allUnusedEIPs) {
    
    List<Evaluation> evaluations = new ArrayList<>();
    
    if ( allUnusedEIPs == null || allUnusedEIPs.size() > 0 ) {
        
        for(Address address: allUnusedEIPs) {
            
            String EIP = address.getPublicIp();
            Evaluation evaluation = new Evaluation();
            evaluation.setComplianceResourceId(EIP);
            evaluation.setComplianceResourceType(COMPLIANCE_RESOURCE_TYPE);
            evaluation.setComplianceType(ComplianceType.NON_COMPLIANT);
            evaluation.setOrderingTimestamp(new Date());
            evaluations.add(evaluation);
        }
    }
    
    System.out.println("INFO : Number of evaluations : " + evaluations.size());
    return evaluations;
}
 
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:27,代码来源:EIPsUnused.java

示例2: checkExistsAddress

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

示例3: startByName

import com.amazonaws.services.ec2.model.Address; //导入方法依赖的package包/类
private int startByName(Ec2CommandOptions options) throws FileNotFoundException {
	String name = options.getName();
	InputStream inputStream = new FileInputStream(new File(options.getCredentialsPath()));
	ConfigProvider.loadConfigure(inputStream);
	AmazonEC2 ec2 = AwsEc2Client.getEc2();

	// Check Exists Instance
	Instance instance = AwsEc2Client.findInstanceByName(ec2, name);
	if (instance == null) {
		System.err.println("Not exists instance (name = " + name + ").");
		return 2;
	}
	String instanceId = instance.getInstanceId();
	System.out.println("Exists instance (id = " + instanceId + ")");

	// Start Ec2 Instance
	InstanceStateChange stateChange = AwsEc2Client.startInstance(ec2, instanceId);
	AwsEc2Client.showStateChange(stateChange, "Starting Instance");

	// Allocate Address
	DomainType domainType = (instance.getVpcId() == null) ? DomainType.Standard : DomainType.Vpc;
	Address address = AwsEc2Client.allocateAddress(ec2, domainType);
	String publicIp = address.getPublicIp();
	System.out.println("Allocated Address(" + publicIp + ", " + address.getAllocationId() + ")");
	if (address != null) {
		// TODO: Wait for Starting Instance.
		waitForStartingInstance();

		try {
			// Associate Address
			String associateAddress = AwsEc2Client.associateAddress(ec2, address, instanceId);
			System.out.println("Associated Address(" + publicIp + ", " + associateAddress + ")");

			String domain = options.getDomain();
			if (domain != null) {
				// Attach Domain to EIP
				AmazonRoute53 route53 = AwsRoute53Client.getRoute53();
				ChangeInfo attachedResult = AwsRoute53Client.attachDomainToEip(route53, publicIp, domain);
				if (attachedResult != null) {
					System.out.println("Attached domain(" + domain + ")");
				} else {
					System.err.println("Not Found Available Hosted Zone for specified Domain(" + domain + ")");
				}
			}
		} catch (AmazonServiceException e) {
			AwsEc2Client.releaseAddress(ec2, address);
			System.out.println("Released Address (" + publicIp + ")");
			return 2;
		}
	}
	return 0;
}
 
开发者ID:betahikaru,项目名称:ec2-util,代码行数:53,代码来源:Ec2StartCommand.java


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