Search in sources :

Example 6 with AAIResultWrapper

use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.

the class BpmnRequestBuilder method mapCloudConfigurationVolume.

public CloudConfiguration mapCloudConfigurationVolume(GenericVnf vnf, VolumeGroup volumeGroup) {
    CloudConfiguration cloudConfig = new CloudConfiguration();
    AAIResultWrapper wrapper = new AAIResultWrapper(vnf);
    Optional<org.onap.aaiclient.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
    String tenantId = null;
    String cloudOwner = null;
    String lcpRegionId = null;
    if (relationshipsOpt.isPresent()) {
        tenantId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)).orElse(null);
        cloudOwner = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)).orElse(null);
        lcpRegionId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)).orElse(null);
    }
    if (tenantId == null || cloudOwner == null || lcpRegionId == null) {
        Map<String, String[]> filters = createQueryRequest("volumeGroupId", volumeGroup.getVolumeGroupId());
        Optional<ServiceInstancesRequest> request = findServiceInstanceRequest(filters);
        if (request.isPresent()) {
            tenantId = request.get().getRequestDetails().getCloudConfiguration().getTenantId();
            cloudOwner = request.get().getRequestDetails().getCloudConfiguration().getCloudOwner();
            lcpRegionId = request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId();
        } else {
            throw new CloudConfigurationNotFoundException(CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND);
        }
    }
    cloudConfig.setTenantId(tenantId);
    cloudConfig.setCloudOwner(cloudOwner);
    cloudConfig.setLcpCloudRegionId(lcpRegionId);
    return cloudConfig;
}
Also used : CloudConfigurationNotFoundException(org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 7 with AAIResultWrapper

use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.

the class BpmnRequestBuilder method mapCloudConfiguration.

public CloudConfiguration mapCloudConfiguration(GenericVnf vnf, String vfModuleId) {
    CloudConfiguration cloudConfig = new CloudConfiguration();
    AAIResultWrapper wrapper = new AAIResultWrapper(vnf);
    Optional<org.onap.aaiclient.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
    String tenantId = null;
    String cloudOwner = null;
    String lcpRegionId = null;
    if (relationshipsOpt.isPresent()) {
        tenantId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)).orElse(null);
        cloudOwner = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)).orElse(null);
        lcpRegionId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)).orElse(null);
    }
    if (tenantId == null || cloudOwner == null || lcpRegionId == null) {
        Map<String, String[]> filters = createQueryRequest("vfModuleId", vfModuleId);
        Optional<ServiceInstancesRequest> request = findServiceInstanceRequest(filters);
        if (request.isPresent()) {
            if (request.get().getRequestDetails() != null && request.get().getRequestDetails().getCloudConfiguration() != null) {
                if (request.get().getRequestDetails().getCloudConfiguration().getTenantId() != null) {
                    tenantId = request.get().getRequestDetails().getCloudConfiguration().getTenantId();
                }
                if (request.get().getRequestDetails().getCloudConfiguration().getCloudOwner() != null) {
                    cloudOwner = request.get().getRequestDetails().getCloudConfiguration().getCloudOwner();
                }
                if (request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId() != null) {
                    lcpRegionId = request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId();
                }
            }
        } else {
            throw new CloudConfigurationNotFoundException(CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND);
        }
    }
    cloudConfig.setTenantId(tenantId);
    cloudConfig.setCloudOwner(cloudOwner);
    cloudConfig.setLcpCloudRegionId(lcpRegionId);
    return cloudConfig;
}
Also used : CloudConfigurationNotFoundException(org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 8 with AAIResultWrapper

use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.

the class ActivateVnfStatusOperationalEnvironment method getAAIOperationalEnvironment.

/**
 * Get OperationalEnvironment object
 *
 * @param operationalEnvironmentId - String
 * @return operationalEnv - OperationalEnvironment object
 */
private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
    AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
    Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class);
    return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null;
}
Also used : AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment)

Example 9 with AAIResultWrapper

use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.

the class ActivateVnfOperationalEnvironment method execute.

/**
 * The Point-Of-Entry from APIH with VID request to send activate request
 *
 * @param requestId - String
 * @param request - CloudOrchestrationRequest object
 * @return void - nothing
 */
public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException {
    String vnfOperationalEnvironmentId = request.getOperationalEnvironmentId();
    String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext();
    List<ServiceModelList> serviceModelVersionIdList = request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList();
    String ecompOperationalEnvironmentId = null;
    AAIResultWrapper wrapper = getAAIOperationalEnvironment(vnfOperationalEnvironmentId);
    Optional<Relationships> optRelationships = wrapper.getRelationships();
    if (optRelationships.isPresent()) {
        Relationships relationships = optRelationships.get();
        List<AAIResourceUri> operationalEnvironments = relationships.getRelatedUris(Types.OPERATIONAL_ENVIRONMENT);
        if (!operationalEnvironments.isEmpty()) {
            ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT.getUriParams().operationalEnvironmentId);
        }
    }
    logger.debug("  vnfOperationalEnvironmentId   : {}", vnfOperationalEnvironmentId);
    logger.debug("  ecompOperationalEnvironmentId : {}", ecompOperationalEnvironmentId);
    OperationalEnvironment operationalEnv = wrapper.asBean(OperationalEnvironment.class).get();
    String workloadContext = operationalEnv.getWorkloadContext();
    logger.debug("  aai workloadContext: {}", workloadContext);
    if (!vidWorkloadContext.equals(workloadContext)) {
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcessError).build();
        throw new ValidateException.Builder(" The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
    }
    if (ecompOperationalEnvironmentId == null) {
        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcessError).build();
        throw new ValidateException.Builder(" The ECOMP OE was not in aai record; the value of relationship.relationship-data key: " + AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT.getUriParams().operationalEnvironmentId, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
    }
    processActivateSDCRequest(requestId, ecompOperationalEnvironmentId, serviceModelVersionIdList, workloadContext, vnfOperationalEnvironmentId);
}
Also used : ServiceModelList(org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList) ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment)

Example 10 with AAIResultWrapper

use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.

the class DeactivateVnfOperationalEnvironment method getAAIOperationalEnvironment.

private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
    AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
    Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class);
    return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null;
}
Also used : AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment)

Aggregations

AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)88 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)47 Test (org.junit.Test)46 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)27 ArrayList (java.util.ArrayList)22 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)22 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)14 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)11 VpnBinding (org.onap.aai.domain.yang.VpnBinding)7 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 HashMap (java.util.HashMap)6 OperationalEnvironment (org.onap.aai.domain.yang.OperationalEnvironment)6 RelationshipList (org.onap.aai.domain.yang.RelationshipList)6 AAIResourcesClient (org.onap.aaiclient.client.aai.AAIResourcesClient)6 List (java.util.List)5 Optional (java.util.Optional)5 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)5 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)5 Map (java.util.Map)4