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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations