com.amazonaws.services.ec2.model.ReleaseAddressRequest Java Examples
The following examples show how to use
com.amazonaws.services.ec2.model.ReleaseAddressRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UnusedElasticIPAutofix.java From pacbot with Apache License 2.0 | 6 votes |
@Override public FixResult executeFix(Map<String, String> issue, Map<String, Object> clientMap, Map<String, String> ruleParams) { try { AmazonEC2 amazonEC2 = (AmazonEC2) clientMap.get(PacmanSdkConstants.CLIENT); ReleaseAddressRequest request = new ReleaseAddressRequest().withAllocationId(issue.get(PacmanSdkConstants.ALLOCATION_ID)); amazonEC2.releaseAddress(request); if (LOGGER.isDebugEnabled()) LOGGER.debug(String.format(ELASTIC_IP_ALLOCATION_ID_RELEASED, issue.get(PacmanSdkConstants.RESOURCE_ID), issue.get(PacmanSdkConstants.ALLOCATION_ID))); return new FixResult(PacmanSdkConstants.STATUS_SUCCESS_CODE, String.format(ELASTIC_IP_ALLOCATION_ID_RELEASED, issue.get(PacmanSdkConstants.RESOURCE_ID), issue.get(PacmanSdkConstants.ALLOCATION_ID))); } catch (Exception e) { LOGGER.error(String.format(ELASTIC_IP_ALLOCATION_ID_RELEASE_FAILED, issue.get(PacmanSdkConstants.RESOURCE_ID), issue.get(PacmanSdkConstants.ALLOCATION_ID)), e.getMessage()); return new FixResult(PacmanSdkConstants.STATUS_FAILURE_CODE, String.format(ELASTIC_IP_ALLOCATION_ID_RELEASE_FAILED, issue.get(PacmanSdkConstants.RESOURCE_ID), issue.get(PacmanSdkConstants.ALLOCATION_ID), e.getMessage())); } }
Example #2
Source File: ReleaseAddress.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { final String USAGE = "To run this example, supply an allocation ID.\n" + "Ex: ReleaseAddress <allocation_id>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1); } String alloc_id = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); ReleaseAddressRequest request = new ReleaseAddressRequest() .withAllocationId(alloc_id); ReleaseAddressResult response = ec2.releaseAddress(request); System.out.printf( "Successfully released elastic IP address %s", alloc_id); }
Example #3
Source File: AwsAddressProcess.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
/** * TODO: メソッドコメント * * @param awsProcessClient * @param addressNo */ public void deleteAddress(AwsProcessClient awsProcessClient, Long addressNo) { // AWSアドレス情報の存在チェック AwsAddress awsAddress = awsAddressDao.read(addressNo); if (awsAddress == null) { return; } // Elastic IPのチェック if (StringUtils.isEmpty(awsAddress.getPublicIp())) { // Elastic IPが空ならAWSアドレス情報を削除して終了 awsAddressDao.delete(awsAddress); return; } // Elastic IPを解放 try { ReleaseAddressRequest request = new ReleaseAddressRequest(); // VPCの場合 if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) { // 割り当てIDを取得する Address address = awsCommonProcess.describeAddress(awsProcessClient, awsAddress.getPublicIp()); request.withAllocationId(address.getAllocationId()); } // 非VPCの場合 else { request.withPublicIp(awsAddress.getPublicIp()); } awsProcessClient.getEc2Client().releaseAddress(request); // イベントログ出力 processLogger.debug(null, null, "AwsElasticIpRelease", new Object[] { awsProcessClient.getPlatform().getPlatformName(), awsAddress.getPublicIp() }); } catch (Exception ignore) { // Elastic IPが実際には存在しない場合などに備えて、警告ログを出力して例外を握りつぶす log.warn(ignore.getMessage()); } // AWSアドレス情報を削除 awsAddressDao.delete(awsAddress); }