List of usage examples for com.amazonaws.services.ec2.model DisassociateAddressRequest DisassociateAddressRequest
public DisassociateAddressRequest()
From source file:com.netflix.eureka.aws.EIPManager.java
License:Apache License
/** * Unbind the EIP that this instance is associated with. *//*from ww w. j ava 2 s . c om*/ public void unbindEIP() throws Exception { InstanceInfo myInfo = applicationInfoManager.getInfo(); String myPublicIP = null; if (myInfo != null && myInfo.getDataCenterInfo().getName() == Name.Amazon) { myPublicIP = ((AmazonInfo) myInfo.getDataCenterInfo()).get(MetaDataKey.publicIpv4); if (myPublicIP == null) { logger.info("Instance is not associated with an EIP. Will not try to unbind"); return; } try { AmazonEC2 ec2Service = getEC2Service(); DescribeAddressesRequest describeAddressRequest = new DescribeAddressesRequest() .withPublicIps(myPublicIP); DescribeAddressesResult result = ec2Service.describeAddresses(describeAddressRequest); if ((result.getAddresses() != null) && (!result.getAddresses().isEmpty())) { Address eipAddress = result.getAddresses().get(0); DisassociateAddressRequest dissociateRequest = new DisassociateAddressRequest(); String domain = eipAddress.getDomain(); if ("vpc".equals(domain)) { dissociateRequest.setAssociationId(eipAddress.getAssociationId()); } else { dissociateRequest.setPublicIp(eipAddress.getPublicIp()); } ec2Service.disassociateAddress(dissociateRequest); logger.info("Dissociated the EIP {} from this instance", myPublicIP); } } catch (Throwable e) { throw new RuntimeException("Cannot dissociate address from this instance", e); } } }
From source file:com.netflix.eureka.util.EIPManager.java
License:Apache License
/** * Unbind the EIP that this instance is associated with. *//*from w w w .ja v a2 s .com*/ public void unbindEIP() { InstanceInfo myInfo = ApplicationInfoManager.getInstance().getInfo(); String myPublicIP = null; if (myInfo != null && myInfo.getDataCenterInfo().getName() == Name.Amazon) { myPublicIP = ((AmazonInfo) myInfo.getDataCenterInfo()).get(MetaDataKey.publicIpv4); try { AmazonEC2 ec2Service = getEC2Service(); DescribeAddressesRequest describeAddressRequest = new DescribeAddressesRequest() .withPublicIps(myPublicIP); DescribeAddressesResult result = ec2Service.describeAddresses(describeAddressRequest); if ((result.getAddresses() != null) && (!result.getAddresses().isEmpty())) { Address eipAddress = result.getAddresses().get(0); DisassociateAddressRequest dissociateRequest = new DisassociateAddressRequest(); String domain = eipAddress.getDomain(); if ("vpc".equals(domain)) { dissociateRequest.setAssociationId(eipAddress.getAssociationId()); } else { dissociateRequest.setPublicIp(eipAddress.getPublicIp()); } ec2Service.disassociateAddress(dissociateRequest); logger.info("Dissociated the EIP {} from this instance", myPublicIP); } } catch (Throwable e) { throw new RuntimeException("Cannot dissociate address" + myPublicIP + "from this instance", e); } } }
From source file:com.urbancode.terraform.tasks.aws.helpers.AWSHelper.java
License:Apache License
/** * removes the association of the elasticIp from the instance. This is done automatically by * amazon when an instance is terminated, there is a few seconds delay. * * @param associationId//from w w w. j a v a2 s. c o m * @param ec2Client */ public void disassociateElasticIp(String associationId, AmazonEC2 ec2Client) { DisassociateAddressRequest request = new DisassociateAddressRequest().withAssociationId(associationId); ec2Client.disassociateAddress(request); }
From source file:com.zotoh.cloudapi.aws.ElasticIP.java
License:Open Source License
@Override public void releaseFromServer(String addr) throws InternalException, CloudException { tstEStrArg("public-ip", addr); _svc.getCloud().getEC2().disassociateAddress(new DisassociateAddressRequest().withPublicIp(addr)); }
From source file:jp.primecloud.auto.process.aws.AwsAddressProcess.java
License:Open Source License
public void disassociateAddress(AwsProcessClient awsProcessClient, Long instanceNo, Long addressNo, Address address) {/*from w ww . j a va 2 s . com*/ 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); }