Search in sources :

Example 6 with InstanceNetworkInterface

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

Aggregations

InstanceNetworkInterface (com.amazonaws.services.ec2.model.InstanceNetworkInterface)4 NetworkInterfaceState (com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState)3 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)2 Instance (com.amazonaws.services.ec2.model.Instance)2 AmazonInfo (com.netflix.appinfo.AmazonInfo)2 InstanceInfo (com.netflix.appinfo.InstanceInfo)2 AdapterUtils.createDeleteOperation (com.vmware.photon.controller.model.adapters.util.AdapterUtils.createDeleteOperation)2 AdapterUtils.createPatchOperation (com.vmware.photon.controller.model.adapters.util.AdapterUtils.createPatchOperation)2 AdapterUtils.createPostOperation (com.vmware.photon.controller.model.adapters.util.AdapterUtils.createPostOperation)2 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)2 Operation (com.vmware.xenon.common.Operation)2 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)1 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)1 DetachNetworkInterfaceRequest (com.amazonaws.services.ec2.model.DetachNetworkInterfaceRequest)1 Filter (com.amazonaws.services.ec2.model.Filter)1 GroupIdentifier (com.amazonaws.services.ec2.model.GroupIdentifier)1 AWSUtils.getAWSNonTerminatedInstancesFilter (com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.getAWSNonTerminatedInstancesFilter)1 InstanceDescKey (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.InstanceDescKey)1 ZoneData (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.ZoneData)1 AWSEnumerationUtils.mapInstanceToComputeState (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.mapInstanceToComputeState)1