Search in sources :

Example 1 with REGION_KEY

use of com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.REGION_KEY in project photon-model by vmware.

the class AWSEndpointAdapterService method computeDesc.

private BiConsumer<ComputeDescription, Retriever> computeDesc() {
    return (cd, r) -> {
        cd.regionId = r.get(REGION_KEY).orElse(null);
        cd.zoneId = r.get(ZONE_KEY).orElse(null);
        cd.environmentName = ComputeDescription.ENVIRONMENT_NAME_AWS;
        List<String> children = new ArrayList<>();
        children.add(ComputeType.ZONE.toString());
        cd.supportedChildren = children;
        cd.instanceAdapterReference = AdapterUriUtil.buildPublicAdapterUri(getHost(), AWSUriPaths.AWS_INSTANCE_ADAPTER);
        cd.enumerationAdapterReference = AdapterUriUtil.buildPublicAdapterUri(getHost(), AWSUriPaths.AWS_ENUMERATION_ADAPTER);
        cd.powerAdapterReference = AdapterUriUtil.buildPublicAdapterUri(getHost(), AWSUriPaths.AWS_POWER_ADAPTER);
        cd.diskAdapterReference = AdapterUriUtil.buildPublicAdapterUri(getHost(), AWSUriPaths.AWS_DISK_ADAPTER);
        {
            URI statsAdapterUri = AdapterUriUtil.buildPublicAdapterUri(getHost(), AWSUriPaths.AWS_STATS_ADAPTER);
            URI costStatsAdapterUri = AdapterUriUtil.buildPublicAdapterUri(getHost(), AWSUriPaths.AWS_COST_STATS_ADAPTER);
            cd.statsAdapterReferences = new LinkedHashSet<>();
            cd.statsAdapterReferences.add(costStatsAdapterUri);
            cd.statsAdapterReferences.add(statsAdapterUri);
            cd.statsAdapterReference = statsAdapterUri;
        }
    };
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) Arrays(java.util.Arrays) QueryTask(com.vmware.xenon.services.common.QueryTask) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) Utils(com.vmware.xenon.common.Utils) AmazonIdentityManagementClientBuilder(com.amazonaws.services.identitymanagement.AmazonIdentityManagementClientBuilder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PHOTON_MODEL_ADAPTER_UNAUTHORIZED_MESSAGE(com.vmware.photon.controller.model.adapters.util.AdapterConstants.PHOTON_MODEL_ADAPTER_UNAUTHORIZED_MESSAGE) EXTERNAL_ID_KEY(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.EXTERNAL_ID_KEY) URI(java.net.URI) AWSCredentials(com.amazonaws.auth.AWSCredentials) AWSClientManager(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManager) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) DescribeAvailabilityZonesRequest(com.amazonaws.services.ec2.model.DescribeAvailabilityZonesRequest) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) AmazonServiceException(com.amazonaws.AmazonServiceException) StatelessService(com.vmware.xenon.common.StatelessService) CompletionException(java.util.concurrent.CompletionException) Collectors(java.util.stream.Collectors) PHOTON_MODEL_ADAPTER_UNAUTHORIZED_MESSAGE_CODE(com.vmware.photon.controller.model.adapters.util.AdapterConstants.PHOTON_MODEL_ADAPTER_UNAUTHORIZED_MESSAGE_CODE) List(java.util.List) RequestType(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.RequestType) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) STATUS_CODE_UNAUTHORIZED(com.vmware.xenon.common.Operation.STATUS_CODE_UNAUTHORIZED) AWSUtils.getEc2AsyncClient(com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.getEc2AsyncClient) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder) PRIVATE_KEY_KEY(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.PRIVATE_KEY_KEY) AWSDeferredResultAsyncHandler(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSDeferredResultAsyncHandler) DescribeAvailabilityZonesResult(com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult) HashMap(java.util.HashMap) PRIVATE_KEYID_KEY(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.PRIVATE_KEYID_KEY) ArrayList(java.util.ArrayList) Regions(com.amazonaws.regions.Regions) ZONE_KEY(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.ZONE_KEY) EndpointConfigRequest(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest) Query(com.vmware.xenon.services.common.QueryTask.Query) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) BiConsumer(java.util.function.BiConsumer) Retriever(com.vmware.photon.controller.model.adapters.util.EndpointAdapterUtils.Retriever) EndpointType(com.vmware.photon.controller.model.constants.PhotonModelConstants.EndpointType) LinkedHashSet(java.util.LinkedHashSet) ServiceErrorResponse(com.vmware.xenon.common.ServiceErrorResponse) EndpointAdapterUtils(com.vmware.photon.controller.model.adapters.util.EndpointAdapterUtils) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AdapterUriUtil(com.vmware.photon.controller.model.adapters.util.AdapterUriUtil) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) AmazonIdentityManagementClient(com.amazonaws.services.identitymanagement.AmazonIdentityManagementClient) ARN_KEY(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.ARN_KEY) LocalizableValidationException(com.vmware.xenon.common.LocalizableValidationException) PhotonModelConstants(com.vmware.photon.controller.model.constants.PhotonModelConstants) REGION_KEY(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.REGION_KEY) AWSClientManagerFactory(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManagerFactory) AmazonEC2AsyncClient(com.amazonaws.services.ec2.AmazonEC2AsyncClient) List(java.util.List) ArrayList(java.util.ArrayList) URI(java.net.URI)

Aggregations

AmazonServiceException (com.amazonaws.AmazonServiceException)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 Regions (com.amazonaws.regions.Regions)1 AmazonEC2AsyncClient (com.amazonaws.services.ec2.AmazonEC2AsyncClient)1 DescribeAvailabilityZonesRequest (com.amazonaws.services.ec2.model.DescribeAvailabilityZonesRequest)1 DescribeAvailabilityZonesResult (com.amazonaws.services.ec2.model.DescribeAvailabilityZonesResult)1 AmazonIdentityManagementClient (com.amazonaws.services.identitymanagement.AmazonIdentityManagementClient)1 AmazonIdentityManagementClientBuilder (com.amazonaws.services.identitymanagement.AmazonIdentityManagementClientBuilder)1 EndpointConfigRequest (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest)1 ARN_KEY (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.ARN_KEY)1 EXTERNAL_ID_KEY (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.EXTERNAL_ID_KEY)1 PRIVATE_KEYID_KEY (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.PRIVATE_KEYID_KEY)1 PRIVATE_KEY_KEY (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.PRIVATE_KEY_KEY)1 REGION_KEY (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.REGION_KEY)1 RequestType (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.RequestType)1 ZONE_KEY (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.ZONE_KEY)1 AWSUtils.getEc2AsyncClient (com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.getEc2AsyncClient)1 AWSClientManager (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManager)1