Search in sources :

Example 26 with Address

use of com.amazonaws.services.ec2.model.Address in project photon-model by vmware.

the class TestAWSProvisionTask method assertVmNetworksConfiguration.

private void assertVmNetworksConfiguration(Instance awsInstance) throws Throwable {
    // This assert is only suitable for real (non-mocking env).
    if (this.isMock) {
        return;
    }
    this.host.log(Level.INFO, "%s: Assert network configuration for [%s] VM", this.currentTestName.getMethodName(), this.vmState.name);
    ComputeState vm = this.host.getServiceState(null, ComputeState.class, UriUtils.buildUri(this.host, this.vmState.documentSelfLink));
    assertNotNull("ComputeState.address should be set to public IP.", vm.address);
    assertEquals("ComputeState.address should be set to AWS Instance public IP.", awsInstance.getPublicIpAddress(), vm.address);
    for (String nicLink : vm.networkInterfaceLinks) {
        NetworkInterfaceState nicState = this.host.getServiceState(null, NetworkInterfaceState.class, UriUtils.buildUri(this.host, nicLink));
        // for now validate only the 0 NIC as we are creating single NIC VM
        if (nicState.deviceIndex != 0) {
            continue;
        }
        InstanceNetworkInterface awsNic = null;
        for (InstanceNetworkInterface nic : awsInstance.getNetworkInterfaces()) {
            if (nic.getAttachment().getDeviceIndex() == nicState.deviceIndex) {
                awsNic = nic;
                break;
            }
        }
        assertNotNull("Unable to find AWS NIC with device index " + nicState.deviceIndex, awsNic);
        assertEquals("NetworkInterfaceState[" + nicState.deviceIndex + "].address should be set to AWS NIC private IP.", awsNic.getPrivateIpAddress(), nicState.address);
    }
    assertVMSercurityGroupsConfiguration(awsInstance, vm);
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) InstanceNetworkInterface(com.amazonaws.services.ec2.model.InstanceNetworkInterface)

Example 27 with Address

use of com.amazonaws.services.ec2.model.Address in project aws-doc-sdk-examples by awsdocs.

the class AllocateAddress method main.

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);
}
Also used : AssociateAddressResult(com.amazonaws.services.ec2.model.AssociateAddressResult) AssociateAddressRequest(com.amazonaws.services.ec2.model.AssociateAddressRequest) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) AllocateAddressRequest(com.amazonaws.services.ec2.model.AllocateAddressRequest) AllocateAddressResult(com.amazonaws.services.ec2.model.AllocateAddressResult)

Example 28 with Address

use of com.amazonaws.services.ec2.model.Address in project aws-doc-sdk-examples by awsdocs.

the class ReleaseAddress method main.

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);
}
Also used : ReleaseAddressResult(com.amazonaws.services.ec2.model.ReleaseAddressResult) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) ReleaseAddressRequest(com.amazonaws.services.ec2.model.ReleaseAddressRequest)

Example 29 with Address

use of com.amazonaws.services.ec2.model.Address in project gpconnect-demonstrator by nhsconnect.

the class StaticElementsHelper method getValidAddress.

public Address getValidAddress() {
    Address address = new Address();
    address.setType(AddressType.PHYSICAL);
    address.setUse(AddressUse.WORK);
    return address;
}
Also used : Address(org.hl7.fhir.dstu3.model.Address)

Example 30 with Address

use of com.amazonaws.services.ec2.model.Address in project gpconnect-demonstrator by nhsconnect.

the class OrganizationResourceProvider method getValidAddress.

private Address getValidAddress() {
    Address orgAddress = new Address();
    orgAddress.setType(AddressType.PHYSICAL);
    orgAddress.setUse(AddressUse.WORK);
    return orgAddress;
}
Also used : Address(org.hl7.fhir.dstu3.model.Address)

Aggregations

AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)8 Address (com.amazonaws.services.ec2.model.Address)7 Instance (com.amazonaws.services.ec2.model.Instance)7 Reservation (com.amazonaws.services.ec2.model.Reservation)7 DescribeAddressesResult (com.amazonaws.services.ec2.model.DescribeAddressesResult)6 Filter (com.amazonaws.services.ec2.model.Filter)6 List (java.util.List)6 Test (org.junit.Test)6 DescribeAddressesRequest (com.amazonaws.services.ec2.model.DescribeAddressesRequest)5 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)5 ArrayList (java.util.ArrayList)5 ReleaseAddressRequest (com.amazonaws.services.ec2.model.ReleaseAddressRequest)4 Address (com.google.api.services.people.v1.model.Address)4 Person (com.google.api.services.people.v1.model.Person)4 Address (org.hl7.fhir.dstu3.model.Address)4 AssociateAddressRequest (com.amazonaws.services.ec2.model.AssociateAddressRequest)3 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)3 Tag (com.amazonaws.services.ec2.model.Tag)3 Function (com.google.common.base.Function)3 TransportAddress (org.elasticsearch.common.transport.TransportAddress)3