Search in sources :

Example 41 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class AAIObjectMapperTest method vfModuleMap.

@Test
public void vfModuleMap() throws Exception {
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId("a");
    vfModule.setVfModuleName("b");
    vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
    ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
    modelInfoVfModule.setModelCustomizationUUID("f");
    modelInfoVfModule.setModelInvariantUUID("g");
    modelInfoVfModule.setModelUUID("h");
    modelInfoVfModule.setIsBaseBoolean(false);
    vfModule.setModelInfoVfModule(modelInfoVfModule);
    org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
    String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleMap.json")));
    ObjectMapper omapper = new ObjectMapper();
    org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.VfModule.class);
    assertThat(reqMapper1, sameBeanAs(AAIVfModule));
}
Also used : ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 42 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class AAIObjectMapperTest method vfModuleBaseMap.

@Test
public void vfModuleBaseMap() throws Exception {
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId("a");
    vfModule.setVfModuleName("b");
    vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
    ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
    modelInfoVfModule.setModelCustomizationUUID("f");
    modelInfoVfModule.setModelInvariantUUID("g");
    modelInfoVfModule.setModelUUID("h");
    modelInfoVfModule.setIsBaseBoolean(true);
    vfModule.setModelInfoVfModule(modelInfoVfModule);
    org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
    String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleBaseMap.json")));
    ObjectMapper omapper = new ObjectMapper();
    org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.VfModule.class);
    assertThat(reqMapper1, sameBeanAs(AAIVfModule));
}
Also used : ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 43 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class BBInputSetup method createVfModule.

protected VfModule createVfModule(Map<ResourceKey, String> lookupKeyMap, String vfModuleId, String instanceName, List<Map<String, String>> instanceParams) {
    lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModuleId);
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId(vfModuleId);
    vfModule.setVfModuleName(instanceName);
    vfModule.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
    if (instanceParams != null) {
        for (Map<String, String> params : instanceParams) {
            vfModule.getCloudParams().putAll(params);
        }
    }
    return vfModule;
}
Also used : VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)

Example 44 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class BBInputSetup method mapCatalogVfModule.

protected void mapCatalogVfModule(VfModule vfModule, ModelInfo modelInfo, Service service, String vnfModelCustomizationUUID) {
    if (modelInfo.getModelCustomizationUuid() != null) {
        modelInfo.setModelCustomizationId(modelInfo.getModelCustomizationUuid());
    }
    VnfResourceCustomization vnfResourceCustomization = null;
    for (VnfResourceCustomization resourceCust : service.getVnfCustomizations()) {
        if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(vnfModelCustomizationUUID)) {
            vnfResourceCustomization = resourceCust;
            break;
        }
    }
    VfModuleCustomization vfResourceCustomization = null;
    if (vnfResourceCustomization != null) {
        vfResourceCustomization = // Convert to steam
        vnfResourceCustomization.getVfModuleCustomizations().stream().filter(// find
        x -> modelInfo.getModelCustomizationId().equalsIgnoreCase(x.getModelCustomizationUUID())).findAny().orElse(null);
    }
    if (vfResourceCustomization == null) {
        vfResourceCustomization = bbInputSetupUtils.getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId());
    }
    if (vfResourceCustomization != null) {
        vfModule.setModelInfoVfModule(this.mapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization));
    }
}
Also used : WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) Vnfs(org.onap.so.serviceinstancebeans.Vnfs) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) StringUtils(org.apache.commons.lang3.StringUtils) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) JavaDelegate(org.camunda.bpm.engine.delegate.JavaDelegate) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) Service(org.onap.so.db.catalog.beans.Service) Map(java.util.Map) Tenant(org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) NetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) LineOfBusiness(org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) UUID(java.util.UUID) Pair(org.javatuples.Pair) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) Objects(java.util.Objects) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) HashMap(java.util.HashMap) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException) ArrayList(java.util.ArrayList) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) VfModules(org.onap.so.serviceinstancebeans.VfModules) RouteTableReference(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) OwningEntity(org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) Logger(org.slf4j.Logger) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Project(org.onap.so.bpmn.servicedecomposition.bbobjects.Project) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Networks(org.onap.so.serviceinstancebeans.Networks) Component(org.springframework.stereotype.Component) Platform(org.onap.so.bpmn.servicedecomposition.bbobjects.Platform) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) Resources(org.onap.so.serviceinstancebeans.Resources) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Example 45 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule 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)

Aggregations

VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)97 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)74 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)53 Test (org.junit.Test)46 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)45 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)37 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)35 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)30 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)27 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)27 HashMap (java.util.HashMap)22 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)20 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)18 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)14 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)14 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)13 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)12 Service (org.onap.so.db.catalog.beans.Service)12 Map (java.util.Map)11 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)11