Search in sources :

Example 1 with AWSNetworkEnumerationRequest

use of com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSNetworkStateEnumerationAdapterService.AWSNetworkEnumerationRequest in project photon-model by vmware.

the class AWSEnumerationAndCreationAdapterService method refreshVPCInformation.

private void refreshVPCInformation(EnumerationCreationContext aws, AWSEnumerationRefreshSubStage next) {
    AWSNetworkEnumerationRequest networkEnumeration = new AWSNetworkEnumerationRequest();
    networkEnumeration.tenantLinks = aws.parentCompute.tenantLinks;
    networkEnumeration.endpointAuth = aws.endpointAuth;
    networkEnumeration.regionId = aws.request.regionId;
    networkEnumeration.request = aws.request.original;
    networkEnumeration.parentComputeLink = aws.request.parentCompute.documentSelfLink;
    Operation patchNetworkOperation = Operation.createPatch(this, AWSNetworkStateEnumerationAdapterService.SELF_LINK).setBody(networkEnumeration).setReferer(UriUtils.buildUri(getHost().getPublicUri(), getSelfLink()));
    this.getHost().sendWithDeferredResult(patchNetworkOperation, AWSNetworkStateEnumerationAdapterService.AWSNetworkEnumerationResponse.class).thenAccept(networkResponse -> {
        logFine(() -> "Successfully enumerated network states");
        aws.enumeratedNetworks = networkResponse;
        aws.refreshSubStage = next;
        processRefreshSubStages(aws);
    }).exceptionally(throwable -> {
        if (throwable != null) {
            logWarning(() -> String.format("Failed to enumerate network states: %s ", throwable.getLocalizedMessage()));
            aws.error = throwable;
            aws.refreshSubStage = next;
            processRefreshSubStages(aws);
        }
        return null;
    });
}
Also used : PowerState(com.vmware.photon.controller.model.resources.ComputeService.PowerState) ServiceMetadata(com.vmware.photon.controller.model.util.StartServicesHelper.ServiceMetadata) QueryTask(com.vmware.xenon.services.common.QueryTask) StringUtils(org.apache.commons.lang3.StringUtils) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) Utils(com.vmware.xenon.common.Utils) StartServicesHelper(com.vmware.photon.controller.model.util.StartServicesHelper) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) Map(java.util.Map) AWSClientManager(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManager) ResourceEnumerationTaskService(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService) Reservation(com.amazonaws.services.ec2.model.Reservation) DescribeAvailabilityZonesRequest(com.amazonaws.services.ec2.model.DescribeAvailabilityZonesRequest) AWSComputeDescriptionCreationState(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSComputeDescriptionEnumerationAdapterService.AWSComputeDescriptionCreationState) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) AWSAsyncHandler(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSAsyncHandler) StatelessService(com.vmware.xenon.common.StatelessService) Collection(java.util.Collection) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) AWSNetworkEnumerationRequest(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSNetworkStateEnumerationAdapterService.AWSNetworkEnumerationRequest) Collectors(java.util.stream.Collectors) AWSConstants.getQueryPageSize(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.getQueryPageSize) List(java.util.List) Stream(java.util.stream.Stream) AWSUtils.getAWSNonTerminatedInstancesFilter(com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.getAWSNonTerminatedInstancesFilter) SOURCE_TASK_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.SOURCE_TASK_LINK) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) ZoneData(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.ZoneData) AWSLoadBalancerEnumerationRequest(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSLoadBalancerEnumerationAdapterService.AWSLoadBalancerEnumerationRequest) OperationContext(com.vmware.xenon.common.OperationContext) DescribeAvailabilityZonesResult(com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult) HashMap(java.util.HashMap) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AWSConstants(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants) ServiceStateCollectionUpdateRequest(com.vmware.xenon.common.ServiceStateCollectionUpdateRequest) AuthCredentialsService(com.vmware.xenon.services.common.AuthCredentialsService) Query(com.vmware.xenon.services.common.QueryTask.Query) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) Filter(com.amazonaws.services.ec2.model.Filter) EnumerationAction(com.vmware.photon.controller.model.adapterapi.EnumerationAction) OperationSequence(com.vmware.xenon.common.OperationSequence) Instance(com.amazonaws.services.ec2.model.Instance) AWSSecurityGroupEnumerationResponse(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSSecurityGroupEnumerationAdapterService.AWSSecurityGroupEnumerationResponse) AWSConstants.getQueryResultLimit(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.getQueryResultLimit) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) AWSNetworkEnumerationResponse(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSNetworkStateEnumerationAdapterService.AWSNetworkEnumerationResponse) AWSUtils(com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils) ServiceMetadata.service(com.vmware.photon.controller.model.util.StartServicesHelper.ServiceMetadata.service) Consumer(java.util.function.Consumer) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) AvailabilityZone(com.amazonaws.services.ec2.model.AvailabilityZone) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) AsyncHandler(com.amazonaws.handlers.AsyncHandler) ComputeEnumerateAdapterRequest(com.vmware.photon.controller.model.adapters.util.ComputeEnumerateAdapterRequest) AWSComputeStateCreationRequest(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSComputeStateCreationAdapterService.AWSComputeStateCreationRequest) AWSClientManagerFactory(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManagerFactory) Collections(java.util.Collections) AWSUriPaths(com.vmware.photon.controller.model.adapters.awsadapter.AWSUriPaths) OperationJoin(com.vmware.xenon.common.OperationJoin) AmazonEC2AsyncClient(com.amazonaws.services.ec2.AmazonEC2AsyncClient) AWSNetworkEnumerationRequest(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSNetworkStateEnumerationAdapterService.AWSNetworkEnumerationRequest) Operation(com.vmware.xenon.common.Operation)

Aggregations

AsyncHandler (com.amazonaws.handlers.AsyncHandler)1 AmazonEC2AsyncClient (com.amazonaws.services.ec2.AmazonEC2AsyncClient)1 AvailabilityZone (com.amazonaws.services.ec2.model.AvailabilityZone)1 DescribeAvailabilityZonesRequest (com.amazonaws.services.ec2.model.DescribeAvailabilityZonesRequest)1 DescribeAvailabilityZonesResult (com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult)1 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)1 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)1 Filter (com.amazonaws.services.ec2.model.Filter)1 Instance (com.amazonaws.services.ec2.model.Instance)1 Reservation (com.amazonaws.services.ec2.model.Reservation)1 EnumerationAction (com.vmware.photon.controller.model.adapterapi.EnumerationAction)1 AWSConstants (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants)1 AWSConstants.getQueryPageSize (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.getQueryPageSize)1 AWSConstants.getQueryResultLimit (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.getQueryResultLimit)1 AWSUriPaths (com.vmware.photon.controller.model.adapters.awsadapter.AWSUriPaths)1 AWSUtils (com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils)1 AWSUtils.getAWSNonTerminatedInstancesFilter (com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.getAWSNonTerminatedInstancesFilter)1 AWSComputeDescriptionCreationState (com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSComputeDescriptionEnumerationAdapterService.AWSComputeDescriptionCreationState)1 AWSComputeStateCreationRequest (com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSComputeStateCreationAdapterService.AWSComputeStateCreationRequest)1 AWSLoadBalancerEnumerationRequest (com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSLoadBalancerEnumerationAdapterService.AWSLoadBalancerEnumerationRequest)1