Search in sources :

Example 1 with RelatedInstance

use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.

the class RelatedInstancesValidation method validate.

@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException {
    ServiceInstancesRequest sir = info.getSir();
    Actions action = info.getAction();
    int reqVersion = info.getReqVersion();
    String requestScope = info.getRequestScope();
    String serviceInstanceType = null;
    String networkType = null;
    String vnfType = null;
    String vfModuleType = null;
    String vfModuleModelName = null;
    ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo();
    RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
    String serviceModelName = null;
    String vnfModelName = null;
    String asdcServiceModelVersion = null;
    String volumeGroupId = null;
    boolean isRelatedServiceInstancePresent = false;
    boolean isRelatedVnfInstancePresent = false;
    boolean isSourceVnfPresent = false;
    boolean isDestinationVnfPresent = false;
    boolean isConnectionPointPresent = false;
    if (requestScope.equalsIgnoreCase(ModelType.service.name())) {
        serviceInstanceType = modelInfo.getModelName();
        info.setServiceInstanceType(serviceInstanceType);
    }
    if (requestScope.equalsIgnoreCase(ModelType.network.name())) {
        networkType = modelInfo.getModelName();
        info.setNetworkType(networkType);
    }
    if (instanceList != null) {
        for (RelatedInstanceList relatedInstanceList : instanceList) {
            RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
            ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo();
            if (relatedInstanceModelInfo == null) {
                throw new ValidationException("modelInfo in relatedInstance");
            }
            if (relatedInstanceModelInfo.getModelType() == null) {
                throw new ValidationException("modelType in relatedInstance");
            }
            if (empty(relatedInstance.getInstanceName()) && ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) {
                throw new ValidationException("instanceName in relatedInstance for pnf modelType");
            }
            if (!empty(relatedInstance.getInstanceName())) {
                if (!relatedInstance.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) {
                    throw new ValidationException("instanceName format in relatedInstance");
                }
            }
            if (empty(relatedInstance.getInstanceId()) && !ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) {
                throw new ValidationException("instanceId in relatedInstance");
            }
            if (!empty(relatedInstance.getInstanceId()) && !UUIDChecker.isValidUUID(relatedInstance.getInstanceId())) {
                throw new ValidationException("instanceId format in relatedInstance");
            }
            if (empty(relatedInstanceModelInfo.getModelVersionId()) && requestScope.equals(ModelType.instanceGroup.toString()) && relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
                throw new ValidationException("modelVersionId in relatedInstance", true);
            }
            if (requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
                isRelatedServiceInstancePresent = true;
            }
            if (requestScope.equalsIgnoreCase(ModelType.service.name())) {
                if (empty(relatedInstance.getInstanceName()) && ModelType.vpnBinding.equals(relatedInstanceModelInfo.getModelType())) {
                    throw new ValidationException("instanceName in relatedInstance for vpnBinding modelType", true);
                }
                if (empty(relatedInstance.getInstanceName()) && ModelType.network.equals(relatedInstanceModelInfo.getModelType())) {
                    throw new ValidationException("instanceName in relatedInstance for network modelType", true);
                }
            }
            if (action != Action.deleteInstance && !requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())) {
                if (!(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup) || relatedInstanceModelInfo.getModelType().equals(ModelType.connectionPoint) || relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) || relatedInstanceModelInfo.getModelType().equals(ModelType.networkInstanceGroup) || relatedInstanceModelInfo.getModelType().equals(ModelType.network) || relatedInstanceModelInfo.getModelType().equals(ModelType.vpnBinding))) {
                    if (empty(relatedInstanceModelInfo.getModelInvariantId())) {
                        throw new ValidationException("modelInvariantId in relatedInstance");
                    } else if (reqVersion >= 4 && empty(relatedInstanceModelInfo.getModelVersionId())) {
                        throw new ValidationException("modelVersionId in relatedInstance");
                    } else if (empty(relatedInstanceModelInfo.getModelName())) {
                        throw new ValidationException("modelName in relatedInstance");
                    } else if (empty(relatedInstanceModelInfo.getModelVersion())) {
                        throw new ValidationException("modelVersion in relatedInstance");
                    }
                }
                if (!empty(relatedInstanceModelInfo.getModelInvariantId()) && !UUIDChecker.isValidUUID(relatedInstanceModelInfo.getModelInvariantId())) {
                    throw new ValidationException("modelInvariantId format in relatedInstance");
                }
                if (ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
                    if (InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) {
                        isSourceVnfPresent = true;
                    } else if (InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) && (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf)))) {
                        isDestinationVnfPresent = true;
                    }
                }
                if (ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
                    isConnectionPointPresent = true;
                }
            }
            if (empty(relatedInstanceModelInfo.getModelCustomizationName()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) {
                if (reqVersion >= 4 && empty(relatedInstanceModelInfo.getModelCustomizationId()) && action != Action.deleteInstance) {
                    throw new ValidationException("modelCustomizationName or modelCustomizationId in relatedInstance of vnf");
                }
            }
            if (relatedInstanceModelInfo.getModelType().equals(ModelType.service) && !(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && action == Action.createInstance)) {
                isRelatedServiceInstancePresent = true;
                if (!relatedInstance.getInstanceId().equals(sir.getServiceInstanceId())) {
                    throw new ValidationException("serviceInstanceId matching the serviceInstanceId in request URI");
                }
                serviceModelName = relatedInstanceModelInfo.getModelName();
                asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion();
            } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) {
                isRelatedVnfInstancePresent = true;
                if (!relatedInstance.getInstanceId().equals(sir.getVnfInstanceId())) {
                    throw new ValidationException("vnfInstanceId matching the vnfInstanceId in request URI");
                }
                vnfModelName = relatedInstanceModelInfo.getModelCustomizationName();
            } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) {
                volumeGroupId = relatedInstance.getInstanceId();
            }
        }
        if (action == Action.createInstance && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
            if (!isSourceVnfPresent) {
                throw new ValidationException("source vnf relatedInstance for Port Configuration");
            }
            if (!isDestinationVnfPresent) {
                throw new ValidationException("destination vnf relatedInstance for Port Configuration");
            }
        }
        if ((action == Action.enablePort || action == Action.disablePort) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
            if (!isConnectionPointPresent) {
                throw new ValidationException("connectionPoint relatedInstance for Port Configuration");
            }
        }
        if (requestScope.equals(ModelType.instanceGroup.toString())) {
            if (!isRelatedServiceInstancePresent) {
                throw new ValidationException("related service instance for instanceGroup request", true);
            }
        }
        if (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name())) {
            if (!isRelatedServiceInstancePresent) {
                throw new ValidationException("related service instance for volumeGroup request");
            }
            if (!isRelatedVnfInstancePresent) {
                throw new ValidationException("related vnf instance for volumeGroup request");
            }
            serviceInstanceType = serviceModelName;
            vnfType = serviceModelName + "/" + vnfModelName;
            info.setServiceInstanceType(serviceInstanceType);
            info.setVnfType(vnfType);
        } else if (requestScope.equalsIgnoreCase(ModelType.vfModule.name())) {
            if (!isRelatedServiceInstancePresent) {
                throw new ValidationException("related service instance for vfModule request");
            }
            if (!isRelatedVnfInstancePresent) {
                throw new ValidationException("related vnf instance for vfModule request");
            }
            vfModuleModelName = modelInfo.getModelName();
            serviceInstanceType = serviceModelName;
            vnfType = serviceModelName + "/" + vnfModelName;
            vfModuleType = vnfType + "::" + vfModuleModelName;
            sir.setVolumeGroupInstanceId(volumeGroupId);
            info.setVfModuleModelName(vfModuleModelName);
            info.setVnfType(vnfType);
            info.setServiceInstanceType(serviceInstanceType);
            info.setVfModuleType(vfModuleType);
        } else if (requestScope.equalsIgnoreCase(ModelType.vnf.name())) {
            if (!isRelatedServiceInstancePresent) {
                throw new ValidationException("related service instance for vnf request");
            }
            vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName();
            info.setVnfType(vnfType);
        }
    } else if (((requestScope.equalsIgnoreCase(ModelType.vnf.name()) || requestScope.equalsIgnoreCase(ModelType.volumeGroup.name()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name()) || requestScope.equalsIgnoreCase(ModelType.configuration.name())) && (action == Action.createInstance || action == Action.enablePort || action == Action.disablePort)) || (reqVersion >= 4 && (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name())) && action == Action.updateInstance || (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)) || (requestScope.equalsIgnoreCase(ModelType.service.name()) && (action.equals(Action.addRelationships) || action.equals(Action.removeRelationships)))) {
        logger.debug("related instance exception");
        throw new ValidationException("related instances");
    }
    if (instanceList == null && requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && action == Action.createInstance) {
        throw new ValidationException("relatedInstanceList", true);
    }
    info.setVfModuleModelName(vfModuleModelName);
    info.setServiceInstanceType(serviceInstanceType);
    info.setVnfType(vnfType);
    info.setAsdcServiceModelVersion(asdcServiceModelVersion);
    info.setVfModuleType(vfModuleType);
    return info;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ValidationException(org.onap.so.exceptions.ValidationException) Actions(org.onap.so.apihandlerinfra.Actions) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest)

Example 2 with RelatedInstance

use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.

the class WorkflowAction method getConfigBuildingBlocks.

protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) throws AAIEntityNotFoundException, VnfcMultipleRelationshipException {
    List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
    List<OrchestrationFlow> result = dataObj.getOrchFlows().stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
    String vnfId = dataObj.getWorkflowResourceIds().getVnfId();
    String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId();
    String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
    String vfModuleCustomizationUUID;
    org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
    if (aaiVfModule == null) {
        logger.error("No matching VfModule is found in Generic-Vnf in AAI for vnfId: {} and vfModuleId : {}", vnfId, vfModuleId);
        throw new AAIEntityNotFoundException("No matching VfModule is found in Generic-Vnf in AAI for vnfId: " + vnfId + " and vfModuleId : " + vfModuleId);
    } else {
        vfModuleCustomizationUUID = aaiVfModule.getModelCustomizationId();
    }
    String replaceVfModuleCustomizationUUID = "";
    String replaceVnfModuleCustomizationUUID = "";
    boolean isReplace = false;
    if (dataObj.getRequestAction().equalsIgnoreCase("replaceInstance") || dataObj.getRequestAction().equalsIgnoreCase("replaceInstanceRetainAssignments")) {
        for (RelatedInstanceList relatedInstList : dataObj.getRequestDetails().getRelatedInstanceList()) {
            RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
            if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
                replaceVnfModuleCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
            }
        }
        replaceVfModuleCustomizationUUID = dataObj.getRequestDetails().getModelInfo().getModelCustomizationId();
        isReplace = true;
    }
    List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Vnfc.class, Types.VNFC);
    for (org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) {
        WorkflowResourceIds workflowIdsCopy = SerializationUtils.clone(dataObj.getWorkflowResourceIds());
        org.onap.aai.domain.yang.Configuration configuration = getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, Types.CONFIGURATION);
        if (configuration == null) {
            logger.warn(String.format("No configuration found for VNFC %s in AAI", vnfc.getVnfcName()));
            continue;
        }
        workflowIdsCopy.setConfigurationId(configuration.getConfigurationId());
        for (OrchestrationFlow orchFlow : result) {
            if (!isReplace || (isReplace && (orchFlow.getFlowName().contains("Delete")))) {
                if (!isReplace) {
                    dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
                    dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
                } else {
                    if (orchFlow.getFlowName().contains("Delete")) {
                        dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
                        dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
                    } else {
                        dataObj.getResourceKey().setVfModuleCustomizationId(replaceVfModuleCustomizationUUID);
                        dataObj.getResourceKey().setVnfCustomizationId(replaceVnfModuleCustomizationUUID);
                    }
                }
                dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
                String vnfcName = vnfc.getVnfcName();
                if (vnfcName == null || vnfcName.isEmpty()) {
                    buildAndThrowException(dataObj.getExecution(), "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match"));
                }
                ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), workflowIdsCopy, dataObj.getRequestDetails(), false, null, vnfcName, true, null);
                flowsToExecuteConfigs.add(ebb);
            }
        }
    }
    return flowsToExecuteConfigs;
}
Also used : WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Arrays(java.util.Arrays) BBConstants(org.onap.so.bpmn.common.BBConstants) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Vnfc(org.onap.aai.domain.yang.Vnfc) ServiceEBBLoader(org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.ServiceEBBLoader) CREATE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE) StringUtils(org.apache.commons.lang3.StringUtils) Matcher(java.util.regex.Matcher) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Map(java.util.Map) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) VnfEBBLoader(org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.VnfEBBLoader) UPGRADE_CNF(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPGRADE_CNF) BBInputSetupUtils(org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils) VnfcMultipleRelationshipException(org.onap.so.bpmn.infrastructure.workflow.tasks.excpetion.VnfcMultipleRelationshipException) WORKFLOW_ACTION_ERROR_MESSAGE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) FABRIC_CONFIGURATION(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION) BBInputSetup(org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup) Set(java.util.Set) UUID(java.util.UUID) ASSIGN_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE) Collectors(java.util.stream.Collectors) Pair(org.javatuples.Pair) CatalogDbClient(org.onap.so.db.catalog.client.CatalogDbClient) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) HEALTH_CHECK(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.HEALTH_CHECK) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RECREATE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.RECREATE_INSTANCE) AAIObjectName(org.onap.aaiclient.client.aai.AAIObjectName) Environment(org.springframework.core.env.Environment) CollectionUtils(org.springframework.util.CollectionUtils) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Pattern(java.util.regex.Pattern) WorkflowResourceIdsUtils(org.onap.so.bpmn.infrastructure.workflow.tasks.utils.WorkflowResourceIdsUtils) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) DELETE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DELETE_INSTANCE) HashMap(java.util.HashMap) SerializationUtils(org.apache.commons.lang3.SerializationUtils) UPDATE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPDATE_INSTANCE) ArrayList(java.util.ArrayList) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) LinkedHashSet(java.util.LinkedHashSet) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) REPLACEINSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE) Logger(org.slf4j.Logger) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) REPLACEINSTANCERETAINASSIGNMENTS(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS) SERVICE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE) Component(org.springframework.stereotype.Component) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Comparator(java.util.Comparator) CONTROLLER(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Vnfc(org.onap.aai.domain.yang.Vnfc) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) VnfcMultipleRelationshipException(org.onap.so.bpmn.infrastructure.workflow.tasks.excpetion.VnfcMultipleRelationshipException) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) IOException(java.io.IOException) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) Vnfc(org.onap.aai.domain.yang.Vnfc)

Example 3 with RelatedInstance

use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.

the class ServiceEBBLoader method traverseCatalogDbService.

public void traverseCatalogDbService(DelegateExecution execution, ServiceInstancesRequest sIRequest, List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds) throws JsonProcessingException, VrfBondingServiceException {
    String modelUUID = sIRequest.getRequestDetails().getModelInfo().getModelVersionId();
    org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(modelUUID);
    if (service == null) {
        buildAndThrowException(execution, "Could not find the service model in catalog db.");
    } else {
        Resource serviceResource = new Resource(WorkflowType.SERVICE, service.getModelUUID(), false, null);
        resourceList.add(serviceResource);
        RelatedInstance relatedVpnBinding = bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.vpnBinding);
        RelatedInstance relatedLocalNetwork = bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.network);
        if (relatedVpnBinding != null && relatedLocalNetwork != null) {
            traverseVrfConfiguration(aaiResourceIds, resourceList, serviceResource, service, relatedVpnBinding, relatedLocalNetwork);
        } else {
            traverseNetworkCollection(execution, resourceList, serviceResource, service);
        }
    }
}
Also used : RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)

Example 4 with RelatedInstance

use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.

the class BBInputSetupTest method testPopulateVolumeGroup.

@Test
public void testPopulateVolumeGroup() throws Exception {
    RequestDetails requestDetails = new RequestDetails();
    RelatedInstanceList ril = new RelatedInstanceList();
    RelatedInstance ri = new RelatedInstance();
    ModelInfo mi = new ModelInfo();
    mi.setModelType(ModelType.vnf);
    mi.setModelCustomizationUuid("vnfModelCustomizationUUID");
    mi.setModelCustomizationId("vnfModelCustomizationUUID");
    ri.setModelInfo(mi);
    ril.setRelatedInstance(ri);
    requestDetails.setRelatedInstanceList(new RelatedInstanceList[] { ril });
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationId("volumeGroupCustId");
    RequestInfo reqInfo = new RequestInfo();
    reqInfo.setInstanceName("volumeGroupName");
    requestDetails.setModelInfo(modelInfo);
    requestDetails.setRequestInfo(reqInfo);
    ServiceInstance serviceInstance = new ServiceInstance();
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("genericVnfId");
    VolumeGroup vg = new VolumeGroup();
    vg.setVolumeGroupName("volumeGroupName");
    vg.setVolumeGroupId("volumeGroupId");
    vg.setModelInfoVfModule(new ModelInfoVfModule());
    vg.getModelInfoVfModule().setModelCustomizationUUID("volumeGroupCustId");
    vnf.getVolumeGroups().add(vg);
    serviceInstance.getVnfs().add(vnf);
    Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(service);
    String bbName = AssignFlows.VOLUME_GROUP.toString();
    String resourceId = "123";
    doNothing().when(SPY_bbInputSetup).mapCatalogVolumeGroup(isA(VolumeGroup.class), eq(modelInfo), eq(service), eq("vnfModelCustomizationUUID"));
    org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = new org.onap.aai.domain.yang.GenericVnf();
    aaiGenericVnf.setModelCustomizationId("vnfModelCustomizationUUID");
    doReturn(aaiGenericVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRequestDetails(requestDetails).setInstanceName(reqInfo.getInstanceName()).setServiceModel(serviceModel).build();
    SPY_bbInputSetup.populateVolumeGroup(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(eq(vg), isA(ModelInfo.class), eq(service), eq("vnfModelCustomizationUUID"));
    vnf.getVolumeGroups().clear();
    SPY_bbInputSetup.populateVolumeGroup(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service, "vnfModelCustomizationUUID");
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) HashMap(java.util.HashMap) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) File(java.io.File) Test(org.junit.Test)

Example 5 with RelatedInstance

use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.

the class BBInputSetupTest method testPopulateVfModuleIsReplace.

@Test
public void testPopulateVfModuleIsReplace() throws Exception {
    String vnfId = "vnfId";
    String vfModuleId = "vfModuleId";
    String volumeGroupId = "volumeGroupId";
    String vfModuleCustomizationId = "vfModuleCustomizationId";
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationId(vfModuleCustomizationId);
    Service currentService = new Service();
    Service newService = new Service();
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(currentService);
    currentService.setModelUUID("currentUUID");
    serviceModel.setNewService(newService);
    currentService.setModelUUID("newUUID");
    String bbName = AssignFlows.VF_MODULE.toString();
    ServiceInstance serviceInstance = new ServiceInstance();
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId(vnfId);
    VolumeGroup volumeGroup = new VolumeGroup();
    volumeGroup.setVolumeGroupId(volumeGroupId);
    vnf.getVolumeGroups().add(volumeGroup);
    serviceInstance.getVnfs().add(vnf);
    VfModule vfModule1 = new VfModule();
    vfModule1.setVfModuleId("vfModuleId1");
    VfModule vfModule2 = new VfModule();
    vfModule2.setVfModuleId("vfModuleId2");
    vnf.getVfModules().add(vfModule1);
    vnf.getVfModules().add(vfModule2);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId);
    lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModuleId);
    String resourceId = vfModuleId;
    RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1];
    RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList();
    RelatedInstance relatedInstance = new RelatedInstance();
    relatedInstance.setInstanceId(vnfId);
    ModelInfo vnfModelInfo = new ModelInfo();
    vnfModelInfo.setModelCustomizationId("vnfCustomizationId");
    vnfModelInfo.setModelType(ModelType.vnf);
    relatedInstance.setModelInfo(vnfModelInfo);
    relatedInstanceListObj.setRelatedInstance(relatedInstance);
    relatedInstanceList[0] = relatedInstanceListObj;
    String instanceName = "vfModuleName";
    List<Map<String, String>> instanceParams = null;
    CloudConfiguration cloudConfiguration = new CloudConfiguration();
    org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
    vnfAAI.setModelCustomizationId("vnfModelCustId");
    org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup();
    volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId);
    org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule();
    vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId);
    doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER, cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
    doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class));
    doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class), isA(Service.class));
    doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class));
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setModelInfo(modelInfo).setService(newService).setServiceInstance(serviceInstance).setBbName(bbName).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRelatedInstanceList(relatedInstanceList).setInstanceName(instanceName).setInstanceParams(instanceParams).setCloudConfiguration(cloudConfiguration).setIsReplace(true).setServiceModel(serviceModel).build();
    SPY_bbInputSetup.populateVfModule(parameter);
    verify(SPY_bbInputSetup, times(2)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), eq(serviceModel.getCurrentService()), isA(String.class));
    verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), eq(serviceModel.getNewService()), isA(String.class));
    assertEquals("Lookup Key Map populated with VfModule Id", vfModuleId, lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
    assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) Service(org.onap.so.db.catalog.beans.Service) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Map(java.util.Map) BaseBBInputSetupTestHelper.prepareLookupKeyMap(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareLookupKeyMap) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

RelatedInstance (org.onap.so.serviceinstancebeans.RelatedInstance)22 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)18 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)13 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)7 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)7 Test (org.junit.Test)6 Service (org.onap.so.db.catalog.beans.Service)6 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)4 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)4 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)4 ServiceModel (org.onap.so.bpmn.servicedecomposition.entities.ServiceModel)4 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)4 NoServiceInstanceFoundException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException)4 Map (java.util.Map)3 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)3 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)3 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)3