use of com.amazonaws.services.ec2.model.InstanceNetworkInterface 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);
}
Aggregations