List of usage examples for com.amazonaws.services.ec2.model AllocateAddressResult getPublicIp
public String getPublicIp()
The Elastic IP address.
From source file:virtualIT.java
License:Open Source License
private void elasticIP(String createdInstanceId) { /* START Elastic IP Address */ AllocateAddressResult elasticResult = ec2.allocateAddress(); String elasticIp = elasticResult.getPublicIp(); System.out.println("New elastic IP: " + elasticIp); //associate//from w ww. j a va 2 s. co m AssociateAddressRequest aar = new AssociateAddressRequest(); aar.setInstanceId(createdInstanceId); aar.setPublicIp(elasticIp); ec2.associateAddress(aar); /* END Elastic IP Address */ }
From source file:com.hpcloud.daas.ec2.AwsConsoleApp.java
License:Open Source License
public static String assignPublicIp(String instanceId) { AllocateAddressResult result = ec2.allocateAddress(); AssociateAddressRequest assRequest = new AssociateAddressRequest(); assRequest.setAllocationId(result.getAllocationId()); assRequest.setPublicIp(result.getPublicIp()); assRequest.setInstanceId(instanceId); AssociateAddressResult resp = ec2.associateAddress(assRequest); System.out.println(resp);// w ww.j av a 2 s . c o m return (result.getPublicIp()); }
From source file:com.urbancode.terraform.tasks.aws.helpers.AWSHelper.java
License:Apache License
/** * This will request a new elastic IP from Amazon and return the AllocationId * associated with that new elasticIp./* ww w . j ava2 s . c o m*/ * * @param ec2Client * @return allocationId */ public String requestElasticIp(AmazonEC2 ec2Client) { String result = null; ; AllocateAddressRequest allReq = new AllocateAddressRequest().withDomain(DomainType.Vpc); AllocateAddressResult allRes = ec2Client.allocateAddress(allReq); result = allRes.getAllocationId(); log.info("Elastic Ip allocated: " + allRes.getPublicIp()); log.info("Allocation Id: " + result); return result; }
From source file:com.zotoh.cloudapi.aws.ElasticIP.java
License:Open Source License
@Override public String request(AddressType t) throws InternalException, CloudException { if (!AddressType.PUBLIC.equals(t)) { throw new IllegalArgumentException("Expecting type: PUBLIC, got: " + t); }//ww w . j av a2 s . c o m String rg = _svc.getCloud().getContext().getRegionId(); _svc.getCloud().setAWSSite(rg); AllocateAddressResult res = _svc.getCloud().getEC2().allocateAddress(new AllocateAddressRequest()); return res == null ? null : res.getPublicIp(); }
From source file:jp.primecloud.auto.process.aws.AwsAddressProcess.java
License:Open Source License
/** * TODO: //from ww w . j a va 2s .c o m * * @param awsProcessClient * @return */ public AwsAddress createAddress(AwsProcessClient awsProcessClient) { // Elastic IP?? AllocateAddressRequest request = new AllocateAddressRequest(); if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) { request.withDomain(DomainType.Vpc); } String publicIp; try { AllocateAddressResult result = awsProcessClient.getEc2Client().allocateAddress(request); publicIp = result.getPublicIp(); } catch (AutoException e) { // Elastic IP????? if (e.getCause() instanceof AmazonServiceException && "AddressLimitExceeded".equals(((AmazonServiceException) e.getCause()).getErrorCode())) { throw new AutoApplicationException("EPROCESS-000134"); } throw e; } // processLogger.debug(null, null, "AwsElasticIpAllocate", new Object[] { awsProcessClient.getPlatform().getPlatformName(), publicIp }); // AWS? AwsAddress awsAddress = new AwsAddress(); awsAddress.setUserNo(awsProcessClient.getUserNo()); awsAddress.setPlatformNo(awsProcessClient.getPlatform().getPlatformNo()); awsAddress.setPublicIp(publicIp); awsAddress.setComment("Allocate at " + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); awsAddressDao.create(awsAddress); return awsAddress; }