- Resource genericResource = fetchAndSetDerivedFromGenericType(resource);
- resource = createResourceTransaction(resource,
- csarInfo.getModifier(), isNormative);
- log.trace("************* createResourceFromYaml after full create resource {}", yamlName);
- log.trace("************* Going to add inputs from yaml {}", yamlName);
- if (resource.shouldGenerateInputs())
- generateAndAddInputsFromGenericTypeProperties(resource, genericResource);
-
- Map<String, InputDefinition> inputs = parsedToscaYamlInfo.getInputs();
- resource = createInputsOnResource(resource, inputs);
- log.trace("************* Finish to add inputs from yaml {}", yamlName);
-
- Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap = parsedToscaYamlInfo
- .getInstances();
- log.trace("************* Going to create nodes, RI's and Relations from yaml {}", yamlName);
-
- resource = createRIAndRelationsFromYaml(yamlName, resource, uploadComponentInstanceInfoMap,
- topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
- nodeTypesArtifactsToCreate, nodeName);
+ loggerSupportability.log(LoggerSupportabilityActions.CREATE_INPUTS, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
+ "Starting to add inputs from yaml: {}", yamlName);
+ if (processSubstitutableAsNodeType(resource, parsedToscaYamlInfo)) {
+ final Map<String, Object> substitutableAsNodeType = getSubstitutableAsNodeTypeFromTemplate(
+ (Map<String, Object>) new Yaml().load(topologyTemplateYaml), parsedToscaYamlInfo.getSubstitutionMappingNodeType());
+ resource.setToscaResourceName(parsedToscaYamlInfo.getSubstitutionMappingNodeType());
+ final Resource genericResource = fetchAndSetDerivedFromGenericType(resource,
+ (String) substitutableAsNodeType.get(TypeUtils.ToscaTagNamesEnum.DERIVED_FROM.getElementName()));
+ resource = createResourceTransaction(resource, csarInfo.getModifier(), isNormative);
+ generatePropertiesFromGenericType(resource, genericResource);
+ generatePropertiesFromNodeType(resource, substitutableAsNodeType);
+ final String resourceId = resource.getUniqueId();
+ resource.getProperties().forEach(propertyDefinition -> propertyDefinition.setUniqueId(
+ UniqueIdBuilder.buildPropertyUniqueId(resourceId, propertyDefinition.getName())));
+
+ createResourcePropertiesOnGraph(resource);
+ final Map<String, UploadComponentInstanceInfo> instancesToCreate = getInstancesToCreate(parsedToscaYamlInfo, resource.getModel());
+
+ if (MapUtils.isNotEmpty(instancesToCreate)) {
+ log.trace("************* Going to create nodes, RI's and Relations from yaml {}", yamlName);
+ loggerSupportability
+ .log(LoggerSupportabilityActions.CREATE_RESOURCE_FROM_YAML, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
+ "Start create nodes, RI and Relations from yaml: {}", yamlName);
+ resource = createRIAndRelationsFromYaml(yamlName, resource, instancesToCreate, topologyTemplateYaml,
+ nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, nodeName,
+ parsedToscaYamlInfo.getSubstitutionMappingNodeType());
+ }
+ } else {
+ final Resource genericResource = fetchAndSetDerivedFromGenericType(resource, null);
+ resource = createResourceTransaction(resource, csarInfo.getModifier(), isNormative);
+ log.trace("************* createResourceFromYaml after full create resource {}", yamlName);
+ log.trace("************* Going to add inputs from yaml {}", yamlName);
+ if (resource.shouldGenerateInputs()) {
+ generateAndAddInputsFromGenericTypeProperties(resource, genericResource);
+ }
+ final Map<String, InputDefinition> inputs = parsedToscaYamlInfo.getInputs();
+ resource = createInputsOnResource(resource, inputs);
+
+ log.trace("************* Finish to add inputs from yaml {}", yamlName);
+ loggerSupportability.log(LoggerSupportabilityActions.CREATE_INPUTS, resource.getComponentMetadataForSupportLog(), StatusCode.COMPLETE,
+ "Finish to add inputs from yaml: {}", yamlName);
+ if (resource.getResourceType() == ResourceTypeEnum.PNF) {
+ log.trace("************* Adding generic properties to PNF");
+ resource = (Resource) propertyBusinessLogic.copyPropertyToComponent(resource, genericResource.getProperties());
+ log.trace("************* Adding software information to PNF");
+ softwareInformationBusinessLogic.setSoftwareInformation(resource, csarInfo);
+ log.trace("************* Removing non-mano software information file from PNF");
+ if (csarInfo.getSoftwareInformationPath().isPresent() && !softwareInformationBusinessLogic.removeSoftwareInformationFile(
+ csarInfo)) {
+ log.warn(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, ResourceBusinessLogic.class.getName(), "catalog-be",
+ "Could not remove the software information file.");
+ }
+ }
+ final Map<String, UploadComponentInstanceInfo> instancesToCreate = getInstancesToCreate(parsedToscaYamlInfo);
+
+ log.trace("************* Going to create nodes, RI's and Relations from yaml {}", yamlName);
+ loggerSupportability
+ .log(LoggerSupportabilityActions.CREATE_RESOURCE_FROM_YAML, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
+ "Start create nodes, RI and Relations from yaml: {}", yamlName);
+ resource = createRIAndRelationsFromYaml(yamlName, resource, instancesToCreate, topologyTemplateYaml,
+ nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, nodeName, null);
+ }