Search in sources :

Example 16 with RelatedInstance

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

the class BBInputSetup method populateVfModule.

protected void populateVfModule(BBInputSetupParameter parameter) throws Exception {
    String vnfModelCustomizationUUID = null;
    String replaceVnfModelCustomizationUUID = null;
    if (parameter.getRelatedInstanceList() != null) {
        for (RelatedInstanceList relatedInstList : parameter.getRelatedInstanceList()) {
            RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
            if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
                if (parameter.getIsReplace()) {
                    replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
                } else {
                    vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
                }
            }
            if (relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) {
                parameter.getLookupKeyMap().put(ResourceKey.VOLUME_GROUP_ID, relatedInstance.getInstanceId());
            }
        }
    }
    GenericVnf vnf = null;
    for (GenericVnf tempVnf : parameter.getServiceInstance().getVnfs()) {
        if (tempVnf.getVnfId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID))) {
            vnf = tempVnf;
            vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId();
            ModelInfo vnfModelInfo = new ModelInfo();
            if (parameter.getIsReplace()) {
                vnfModelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID);
                this.mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getNewService());
            } else {
                vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
                this.mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getCurrentService());
            }
            Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(tempVnf, parameter.getModelInfo(), parameter.getCloudConfiguration().getCloudOwner(), parameter.getCloudConfiguration().getLcpCloudRegionId(), parameter.getLookupKeyMap());
            if (volumeGroupIdOp.isPresent()) {
                parameter.getLookupKeyMap().put(ResourceKey.VOLUME_GROUP_ID, volumeGroupIdOp.get());
            }
            break;
        }
    }
    if (vnf != null) {
        VfModule vfModule = null;
        for (VfModule vfModuleTemp : vnf.getVfModules()) {
            if (parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID) != null && vfModuleTemp.getVfModuleId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID))) {
                vfModule = vfModuleTemp;
            }
            String vfModuleCustId = bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModuleTemp.getVfModuleId()).getModelCustomizationId();
            ModelInfo modelInfoVfModule = new ModelInfo();
            modelInfoVfModule.setModelCustomizationId(vfModuleCustId);
            if (parameter.getIsReplace() && parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID) != null && vfModuleTemp.getVfModuleId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID))) {
                mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID);
            } else {
                mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID);
            }
        }
        if (vfModule == null && parameter.getBbName().equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) {
            vfModule = createVfModule(parameter.getLookupKeyMap(), parameter.getResourceId(), parameter.getInstanceName(), parameter.getInstanceParams());
            vnf.getVfModules().add(vfModule);
            if (parameter.getIsReplace()) {
                mapCatalogVfModule(vfModule, parameter.getModelInfo(), parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID);
            } else {
                mapCatalogVfModule(vfModule, parameter.getModelInfo(), parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID);
            }
        }
        if (vfModule != null && vfModule.getModelInfoVfModule() != null && vfModule.getModelInfoVfModule().getModelName() != null && vfModule.getModelInfoVfModule().getModelName().contains("helm")) {
            parameter.setIsHelm(true);
        }
    } else {
        logger.debug("Related VNF instance Id not found: {}", parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID));
        throw new Exception("Could not find relevant information for related VNF");
    }
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException)

Example 17 with RelatedInstance

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

the class BBInputSetup method getGBBCM.

protected GeneralBuildingBlock getGBBCM(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId) throws Exception {
    ServiceInstance serviceInstance = new ServiceInstance();
    String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
    serviceInstance.setServiceInstanceId(serviceInstanceId);
    Customer customer = new Customer();
    List<GenericVnf> genericVnfs = serviceInstance.getVnfs();
    String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
    if (vnfId != null) {
        org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
        GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
        genericVnfs.add(genericVnf);
    }
    String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID);
    if (instanceGroupId != null && !instanceGroupId.isEmpty()) {
        org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
        InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup);
        instanceGroup.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
        if (serviceInstanceId == null) {
            Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstanceOpt = bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
            if (aaiServiceInstanceOpt.isPresent()) {
                org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiServiceInstanceOpt.get();
                serviceInstance = this.mapperLayer.mapAAIServiceInstanceIntoServiceInstance(aaiServiceInstance);
                WorkflowResourceIds workflowResourceIds = executeBB.getWorkflowResourceIds();
                workflowResourceIds.setServiceInstanceId(serviceInstance.getServiceInstanceId());
                lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, workflowResourceIds.getServiceInstanceId());
            } else {
                throw new NoServiceInstanceFoundException("Related ServiceInstance not found in A&AI.");
            }
        }
        RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
        if (relatedInstanceList != null) {
            for (RelatedInstanceList relatedInstList : relatedInstanceList) {
                RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
                if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
                    org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(relatedInstance.getInstanceId());
                    GenericVnf vnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiVnf);
                    instanceGroup.getVnfs().add(vnf);
                }
            }
        }
        serviceInstance.getInstanceGroups().add(instanceGroup);
        customer.setServiceSubscription(new ServiceSubscription());
    }
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestDetails(requestDetails).setServiceInstance(serviceInstance).setExecuteBB(executeBB).setRequestAction(requestAction).setCustomer(customer).build();
    return this.populateGBBWithSIAndAdditionalInfo(parameter);
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException)

Example 18 with RelatedInstance

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

the class MsoRequest method getVnfType.

public String getVnfType(ServiceInstancesRequest sir, String requestScope) {
    String vnfType = null;
    RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
    String serviceModelName = null;
    String vnfModelName = null;
    String volumeGroupId = null;
    if (instanceList == null) {
        return null;
    }
    for (RelatedInstanceList relatedInstanceList : instanceList) {
        RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
        ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo();
        if (relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
            serviceModelName = relatedInstanceModelInfo.getModelName();
        } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) {
            vnfModelName = relatedInstanceModelInfo.getModelCustomizationName();
        } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) {
            volumeGroupId = relatedInstance.getInstanceId();
        }
    }
    if (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name())) {
        vnfType = serviceModelName + "/" + vnfModelName;
    } else if (requestScope.equalsIgnoreCase(ModelType.vfModule.name())) {
        vnfType = serviceModelName + "/" + vnfModelName;
        sir.setVolumeGroupInstanceId(volumeGroupId);
    } else if (requestScope.equalsIgnoreCase(ModelType.vnf.name()))
        vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName();
    return vnfType;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance)

Example 19 with RelatedInstance

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

the class BBInputSetupTest method testGBBMacroNoUserParamsVrfConfiguration.

@Test
public void testGBBMacroNoUserParamsVrfConfiguration() throws Exception {
    String resourceId = "123";
    String vnfType = "vnfType";
    String requestAction = "createInstance";
    Service service = Mockito.mock(Service.class);
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacroVrf.json"), RequestDetails.class);
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName("AssignVrfConfigurationBB");
    buildingBlock.setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
    doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
    RelatedInstance relatedVpnBinding = new RelatedInstance();
    relatedVpnBinding.setInstanceId("vpnBindingInstanceId");
    RelatedInstance relatedLocalNetwork = new RelatedInstance();
    relatedLocalNetwork.setInstanceId("localNetworkInstanceId");
    org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
    aaiVpnBinding.setVpnId("vpnBindingId");
    org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network();
    aaiLocalNetwork.setNetworkId("localNetworkId");
    Optional<org.onap.aai.domain.yang.VpnBinding> aaiAICVpnBindingOp = Optional.of(new org.onap.aai.domain.yang.VpnBinding());
    aaiAICVpnBindingOp.get().setVpnId("AICVpnBindingId");
    ServiceProxy proxy = new ServiceProxy();
    proxy.setType("transport");
    proxy.setServiceInstance(new ServiceInstance());
    proxy.getServiceInstance().setModelInfoServiceInstance(new ModelInfoServiceInstance());
    proxy.getServiceInstance().getModelInfoServiceInstance().setModelUuid("sourceServiceModelUUID");
    doReturn(relatedVpnBinding).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, ModelType.vpnBinding);
    doReturn(relatedLocalNetwork).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, ModelType.network);
    doReturn(aaiVpnBinding).when(SPY_bbInputSetupUtils).getAAIVpnBinding(relatedVpnBinding.getInstanceId());
    doReturn(aaiLocalNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(relatedLocalNetwork.getInstanceId());
    doReturn(aaiAICVpnBindingOp).when(SPY_bbInputSetupUtils).getAICVpnBindingFromNetwork(aaiLocalNetwork);
    doReturn(proxy).when(SPY_bbInputSetup).getServiceProxy(service);
    Configuration configuration = new Configuration();
    configuration.setConfigurationId("configurationId");
    gBB.getServiceInstance().getConfigurations().add(configuration);
    List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>();
    ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
    configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
    configurationCustList.add(configurationCust);
    doNothing().when(SPY_bbInputSetup).populateConfiguration(any(BBInputSetupParameter.class));
    gBB = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
    verify(SPY_bbInputSetup, times(1)).populateConfiguration(any(BBInputSetupParameter.class));
    assertEquals(gBB.getCustomer().getVpnBindings().get(0).getVpnId(), "vpnBindingId");
    assertEquals(gBB.getServiceInstance().getNetworks().get(0).getNetworkId(), "localNetworkId");
    assertEquals(gBB.getServiceInstance().getNetworks().get(0).getVpnBindings().get(0).getVpnId(), "AICVpnBindingId");
    assertEquals(gBB.getServiceInstance().getServiceProxies().get(0).getType(), "transport");
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ModelInfoServiceProxy(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) File(java.io.File) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) Test(org.junit.Test)

Example 20 with RelatedInstance

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

the class MembersValidation method validate.

@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException {
    RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo();
    RelatedInstanceList[] relatedInstanceList = info.getSir().getRequestDetails().getRelatedInstanceList();
    boolean vnfRelatedInstance = false;
    if (requestInfo == null) {
        throw new ValidationException("requestInfo", true);
    } else if (empty(requestInfo.getRequestorId())) {
        throw new ValidationException("requestorId", true);
    } else if (empty(requestInfo.getSource())) {
        throw new ValidationException("source", true);
    }
    if (relatedInstanceList == null) {
        throw new ValidationException("related instances", true);
    } else {
        for (RelatedInstanceList instanceList : relatedInstanceList) {
            RelatedInstance relatedInstance = instanceList.getRelatedInstance();
            ModelType modelType = relatedInstance.getModelInfo().getModelType();
            if (empty(relatedInstance.getInstanceId())) {
                throw new ValidationException("instanceId in relatedInstances", true);
            }
            if (modelType == null) {
                throw new ValidationException("modelType in relatedInstance", true);
            }
            if (modelType == ModelType.vnf) {
                vnfRelatedInstance = true;
            }
        }
        if (!vnfRelatedInstance) {
            throw new ValidationException("vnf relatedInstance", true);
        }
    }
    return info;
}
Also used : ValidationException(org.onap.so.exceptions.ValidationException) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) ModelType(org.onap.so.serviceinstancebeans.ModelType) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo)

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