com.amazonaws.services.ec2.model.AssociateAddressRequest Java Examples
The following examples show how to use
com.amazonaws.services.ec2.model.AssociateAddressRequest.
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: AllocateAddress.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { final String USAGE = "To run this example, supply an instance id\n" + "Ex: AllocateAddress <instance_id>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1); } String instance_id = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); AllocateAddressRequest allocate_request = new AllocateAddressRequest() .withDomain(DomainType.Vpc); AllocateAddressResult allocate_response = ec2.allocateAddress(allocate_request); String allocation_id = allocate_response.getAllocationId(); AssociateAddressRequest associate_request = new AssociateAddressRequest() .withInstanceId(instance_id) .withAllocationId(allocation_id); AssociateAddressResult associate_response = ec2.associateAddress(associate_request); System.out.printf( "Successfully associated Elastic IP address %s " + "with instance %s", associate_response.getAssociationId(), instance_id); }
Example #2
Source File: AwsAddressProcess.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
public void associateAddress(AwsProcessClient awsProcessClient, Long instanceNo, Long addressNo, Address address) { AwsAddress awsAddress = awsAddressDao.read(addressNo); AwsInstance awsInstance = awsInstanceDao.read(instanceNo); // アドレスの関連付け AssociateAddressRequest request = new AssociateAddressRequest(); request.withInstanceId(awsInstance.getInstanceId()); // VPCの場合 if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) { // 割り当てIDを指定する request.withAllocationId(address.getAllocationId()); } // 非VPCの場合 else { request.withPublicIp(awsAddress.getPublicIp()); } awsProcessClient.getEc2Client().associateAddress(request); // ログ出力 if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100131", awsAddress.getPublicIp(), awsInstance.getInstanceId())); } // イベントログ出力 Instance instance2 = instanceDao.read(instanceNo); processLogger.debug(null, instance2, "AwsElasticIpAssociate", new Object[] { awsInstance.getInstanceId(), awsAddress.getPublicIp() }); // データベースの更新 awsAddress.setInstanceId(awsInstance.getInstanceId()); awsAddressDao.update(awsAddress); }
Example #3
Source File: Ec2MachineConfigurator.java From roboconf-platform with Apache License 2.0 | 5 votes |
/** * Associates an elastic IP with the VM. * @return true if there is nothing more to do about elastic IP configuration, false otherwise */ private boolean associateElasticIp() { String elasticIp = this.targetProperties.get( Ec2Constants.ELASTIC_IP ); if( ! Utils.isEmptyOrWhitespaces( elasticIp )) { this.logger.fine( "Associating an elastic IP with the instance. IP = " + elasticIp ); AssociateAddressRequest associateAddressRequest = new AssociateAddressRequest( this.machineId, elasticIp ); this.ec2Api.associateAddress( associateAddressRequest ); } return true; }
Example #4
Source File: AwsElasticIpService.java From cloudbreak with Apache License 2.0 | 4 votes |
private void associateElasticIpToInstance(AmazonEC2 amazonEC2Client, String eipAllocationId, String instanceId) { AssociateAddressRequest associateAddressRequest = new AssociateAddressRequest() .withAllocationId(eipAllocationId) .withInstanceId(instanceId); amazonEC2Client.associateAddress(associateAddressRequest); }