diff options
Diffstat (limited to 'asdc-controller/src/main')
13 files changed, 410 insertions, 171 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java index e00bb1eb36..ecffb683ca 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java @@ -22,16 +22,21 @@ package org.onap.so.asdc; +import java.security.SecureRandom; import javax.annotation.PreDestroy; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.asdc.client.ASDCController; import org.onap.so.asdc.client.exceptions.ASDCControllerException; +import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.ScheduledTasksMDCSetup; +import org.onap.so.utils.Components; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import java.security.SecureRandom; @Component @@ -42,12 +47,16 @@ public class ASDCControllerSingleton { private final ASDCController asdcController; @Autowired + private ScheduledTasksMDCSetup scheduledMDCSetup; + + @Autowired public ASDCControllerSingleton(final ASDCController asdcController) { this.asdcController = asdcController; } @Scheduled(fixedRate = 50000) public void periodicControllerTask() { + scheduledMDCSetup.mdcSetup(Components.ASDC_CONTROLLER, "periodicControllerTask"); try { final int randomNumber = new SecureRandom().nextInt(Integer.MAX_VALUE); asdcController.setControllerName("mso-controller" + randomNumber); @@ -57,8 +66,11 @@ public class ASDCControllerSingleton { asdcController.initASDC(); } } catch (final ASDCControllerException controllerException) { + scheduledMDCSetup.errorMDCSetup(ErrorCode.UnknownError, controllerException.getMessage()); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString()); logger.error("Exception occurred", controllerException); } + scheduledMDCSetup.exitAndClearMDC(); } @PreDestroy diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/SecurityFilters.java b/asdc-controller/src/main/java/org/onap/so/asdc/SecurityFilters.java new file mode 100644 index 0000000000..29c9d8f952 --- /dev/null +++ b/asdc-controller/src/main/java/org/onap/so/asdc/SecurityFilters.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.asdc; + +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.core.Ordered; + +@Configuration +@Profile("!test & aaf") +public class SecurityFilters { + + @Bean + public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() { + FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>(); + filterRegistrationBean.setFilter(new SoCadiFilter()); + filterRegistrationBean.setName("cadiFilter"); + filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); + return filterRegistrationBean; + } +} diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/SoCadiFilter.java b/asdc-controller/src/main/java/org/onap/so/asdc/SoCadiFilter.java new file mode 100644 index 0000000000..52144e264e --- /dev/null +++ b/asdc-controller/src/main/java/org/onap/so/asdc/SoCadiFilter.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP SO + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ +package org.onap.so.asdc; + +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.cadi.filter.CadiFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +@Component +@Profile("!test & aaf") +public class SoCadiFilter extends CadiFilter { + + protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); + + private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; + private static String AAF_API_VERSION = "aaf_api_version"; + + @Value("${mso.config.cadi.cadiLoglevel:#{null}}") + private String cadiLoglevel; + + @Value("${mso.config.cadi.cadiKeyFile:#{null}}") + private String cadiKeyFile; + + @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}") + private String cadiTrustStorePassword; + + @Value("${mso.config.cadi.cadiTrustStore:#{null}}") + private String cadiTrustStore; + + @Value("${mso.config.cadi.cadiLatitude:#{null}}") + private String cadiLatitude; + + @Value("${mso.config.cadi.cadiLongitude:#{null}}") + private String cadiLongitude; + + @Value("${mso.config.cadi.aafEnv:#{null}}") + private String aafEnv; + + @Value("${mso.config.cadi.aafApiVersion:#{null}}") + private String aafApiVersion; + + @Value("${mso.config.cadi.aafRootNs:#{null}}") + private String aafRootNs; + + @Value("${mso.config.cadi.aafId:#{null}}") + private String aafMechId; + + @Value("${mso.config.cadi.aafPassword:#{null}}") + private String aafMechIdPassword; + + @Value("${mso.config.cadi.aafLocateUrl:#{null}}") + private String aafLocateUrl; + + @Value("${mso.config.cadi.aafUrl:#{null}}") + private String aafUrl; + + @Value("${mso.config.cadi.apiEnforcement:#{null}}") + private String apiEnforcement; + + private void checkIfNullProperty(String key, String value) { + /* + * When value is null, it is not defined in application.yaml set nothing in System properties + */ + if (value != null) { + System.setProperty(key, value); + } + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel); + checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile); + checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore); + checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword); + checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude); + checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude); + checkIfNullProperty(Config.AAF_ENV, aafEnv); + checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion); + checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs); + checkIfNullProperty(Config.AAF_APPID, aafMechId); + checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword); + checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); + checkIfNullProperty(Config.AAF_URL, aafUrl); + checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); + // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); + logger.debug(" *** init Filter Config *** "); + super.init(filterConfig); + } + + +} diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java index b45b4f0749..8722d193fe 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java @@ -22,27 +22,57 @@ package org.onap.so.asdc; import org.onap.so.security.MSOSpringFirewall; import org.onap.so.security.WebSecurityConfig; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.web.firewall.StrictHttpFirewall; import org.springframework.util.StringUtils; +@Configuration @EnableWebSecurity public class WebSecurityConfigImpl extends WebSecurityConfig { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and() - .httpBasic(); + @Profile({"basic", "test"}) + @Bean + public WebSecurityConfigurerAdapter basicAuth() { + return new WebSecurityConfigurerAdapter() { + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() + .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and() + .httpBasic(); + } + + @Override + public void configure(WebSecurity web) throws Exception { + super.configure(web); + StrictHttpFirewall firewall = new MSOSpringFirewall(); + web.httpFirewall(firewall); + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) + .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); + } + + }; } - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); + @Profile("aaf") + @Bean + public WebSecurityConfigurerAdapter noAuth() { + return new WebSecurityConfigurerAdapter() { + @Override + protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests().anyRequest().permitAll(); + } + }; } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java index d60c377730..e53b792a74 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java @@ -58,7 +58,7 @@ public class DeployActivitySpecs { protected static final Logger logger = LoggerFactory.getLogger(DeployActivitySpecs.class); @Transactional - public void deployActivities() throws Exception { + public void deployActivities() { String hostname = env.getProperty(SDC_ENDPOINT); logger.debug("{} {}", "SDC ActivitySpec endpoint: ", hostname); if (hostname == null || hostname.isEmpty()) { @@ -155,7 +155,7 @@ public class DeployActivitySpecs { connection.setConnectTimeout(5000); responseCode = connection.getResponseCode(); } catch (Exception e) { - logger.warn("Exception on connecting to SDC WFD endpoint: " + e.getMessage()); + logger.warn("Exception on connecting to SDC WFD endpoint: ", e); } if (responseCode == HttpStatus.SC_OK || responseCode == HttpStatus.SC_NOT_FOUND) { isUp = true; diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 37f6462bba..f64adfd760 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -688,7 +688,7 @@ public class ASDCController { iNotif.getDistributionID()); logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Database concurrency exception: ", "ASDC", "treatNotification", - ErrorCode.BusinessProcesssError.getValue(), "RuntimeException in treatNotification", e); + ErrorCode.BusinessProcessError.getValue(), "RuntimeException in treatNotification", e); } catch (Exception e) { logger.error("", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), @@ -823,7 +823,7 @@ public class ASDCController { } catch (ASDCDownloadException | UnsupportedEncodingException e) { logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Exception caught during Installation of artifact", "ASDC", "processResourceNotification", - ErrorCode.BusinessProcesssError.getValue(), "Exception in processResourceNotification", e); + ErrorCode.BusinessProcessError.getValue(), "Exception in processResourceNotification", e); } } @@ -869,7 +869,7 @@ public class ASDCController { } catch (Exception e) { logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Exception caught during processCsarServiceArtifacts", "ASDC", - "processCsarServiceArtifacts", ErrorCode.BusinessProcesssError.getValue(), + "processCsarServiceArtifacts", ErrorCode.BusinessProcessError.getValue(), "Exception in processCsarServiceArtifacts", e); } } else if (artifact.getArtifactType().equals(ASDCConfiguration.WORKFLOW)) { @@ -890,7 +890,7 @@ public class ASDCController { logger.info("Whats the error {}", e.getMessage()); logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Exception caught during processCsarServiceArtifacts", "ASDC", - "processCsarServiceArtifacts", ErrorCode.BusinessProcesssError.getValue(), + "processCsarServiceArtifacts", ErrorCode.BusinessProcessError.getValue(), "Exception in processCsarServiceArtifacts", e); } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java index 24e1887847..a9d06d8e82 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java @@ -138,7 +138,7 @@ public class ASDCRestInterface { logger.info("Error caught " + e.getMessage()); logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION.toString(), "Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService", - ErrorCode.BusinessProcesssError.getValue(), "Exception in invokeASDCService", e); + ErrorCode.BusinessProcessError.getValue(), "Exception in invokeASDCService", e); } return null; diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java index c49cb3e50f..dcb49478f4 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java @@ -25,7 +25,6 @@ package org.onap.so.asdc.installer; import java.io.File; import java.nio.file.Paths; import java.util.List; -import org.onap.so.logger.LoggingAnchor; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; @@ -52,10 +51,10 @@ import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; public class ToscaResourceStructure { @@ -152,7 +151,7 @@ public class ToscaResourceStructure { logger.debug(e.getMessage(), e); logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Exception caught during parser *****LOOK********* " + artifact.getArtifactName(), "ASDC", - "processResourceNotification", ErrorCode.BusinessProcesssError.getValue(), + "processResourceNotification", ErrorCode.BusinessProcessError.getValue(), "Exception in " + "processResourceNotification", e); throw new ASDCDownloadException("Exception caught when passing the csar file to the parser ", e); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/WorkflowArtifact.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/WorkflowArtifact.java index 83b5614104..c94370feb2 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/WorkflowArtifact.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/WorkflowArtifact.java @@ -22,9 +22,6 @@ package org.onap.so.asdc.installer; import java.io.UnsupportedEncodingException; -import org.onap.so.db.catalog.beans.HeatEnvironment; -import org.onap.so.db.catalog.beans.HeatFiles; -import org.onap.so.db.catalog.beans.HeatTemplate; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.results.IDistributionClientDownloadResult; diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 8b3bccf892..240bb83862 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -51,9 +51,12 @@ import org.onap.sdc.tosca.parser.elements.queries.EntityQuery; import org.onap.sdc.tosca.parser.elements.queries.EntityQuery.EntityQueryBuilder; import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery; import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery.TopologyTemplateQueryBuilder; +import org.onap.sdc.tosca.parser.enums.EntityTemplateType; import org.onap.sdc.tosca.parser.enums.SdcTypes; import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; -import org.onap.sdc.toscaparser.api.*; +import org.onap.sdc.toscaparser.api.CapabilityAssignment; +import org.onap.sdc.toscaparser.api.Property; +import org.onap.sdc.toscaparser.api.RequirementAssignment; import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.sdc.toscaparser.api.functions.GetInput; import org.onap.sdc.toscaparser.api.parameters.Input; @@ -179,6 +182,12 @@ public class ToscaResourceInstaller { protected static final String SKIP_POST_INST_CONF = "skip_post_instantiation_configuration"; + private static final String CONTROLLER_ACTOR = "controller_actor"; + + private static final String CDS_MODEL_NAME = "cds_model_name"; + + private static final String CDS_MODEL_VERSION = "cds_model_version"; + @Autowired protected ServiceRepository serviceRepo; @@ -433,7 +442,6 @@ public class ToscaResourceInstaller { createToscaCsar(toscaResourceStruct); createService(toscaResourceStruct, vfResourceStruct); Service service = toscaResourceStruct.getCatalogService(); - List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList(); List<IEntityDetails> vfEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); @@ -449,8 +457,7 @@ public class ToscaResourceInstaller { arEntityDetails.add(vfEntityDetails); } - processVfModules(vfEntityDetails, vfNodeTemplatesList.get(0), toscaResourceStruct, vfResourceStructure, - service, metadata); + processVfModules(vfEntityDetails, toscaResourceStruct, vfResourceStructure, service, metadata); } processResourceSequence(toscaResourceStruct, service); @@ -510,24 +517,24 @@ public class ToscaResourceInstaller { } - List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates, + List<IEntityDetails> getRequirementList(List<IEntityDetails> resultList, List<IEntityDetails> entityDetails, ISdcCsarHelper iSdcCsarHelper) { - List<NodeTemplate> nodes = new ArrayList<>(); - nodes.addAll(nodeTemplates); + List<IEntityDetails> entities = new ArrayList<>(); + entityDetails.addAll(entityDetails); + + for (IEntityDetails entity : entityDetails) { + List<RequirementAssignment> requirements = entity.getRequirements(); - for (NodeTemplate nodeTemplate : nodeTemplates) { - RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate); - List<RequirementAssignment> reqAs = requirement.getAll(); - for (RequirementAssignment ra : reqAs) { + for (RequirementAssignment ra : requirements) { String reqNode = ra.getNodeTemplateName(); - for (NodeTemplate rNode : resultList) { - if (rNode.getName().equals(reqNode)) { - if (!resultList.contains(nodeTemplate)) { - resultList.add(nodeTemplate); + for (IEntityDetails rEntity : resultList) { + if (rEntity.getName().equals(reqNode)) { + if (!resultList.contains(entityDetails)) { + resultList.add(entity); } - if (nodes.contains(nodeTemplate)) { - nodes.remove(nodeTemplate); + if (entities.contains(entityDetails)) { + entities.remove(entityDetails); } break; } @@ -535,8 +542,8 @@ public class ToscaResourceInstaller { } } - if (!nodes.isEmpty()) { - getRequirementList(resultList, nodes, iSdcCsarHelper); + if (!entities.isEmpty()) { + getRequirementList(resultList, entities, iSdcCsarHelper); } return resultList; @@ -545,26 +552,30 @@ public class ToscaResourceInstaller { // This method retrieve resource sequence from csar file void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) { List<String> resouceSequence = new ArrayList<>(); - List<NodeTemplate> resultList = new ArrayList<>(); + List<IEntityDetails> resultList = new ArrayList<>(); ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper(); - List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates(); - List<NodeTemplate> nodes = new ArrayList<>(); - nodes.addAll(nodeTemplates); - for (NodeTemplate nodeTemplate : nodeTemplates) { - RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate); + List<IEntityDetails> vfEntityList = + getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE), + TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); - if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) { - resultList.add(nodeTemplate); - nodes.remove(nodeTemplate); + List<IEntityDetails> entities = new ArrayList<>(); + entities.addAll(vfEntityList); + + for (IEntityDetails entityDetails : vfEntityList) { + List<RequirementAssignment> requirements = entityDetails.getRequirements(); + + if (requirements == null || requirements.isEmpty()) { + resultList.add(entityDetails); + entities.remove(entityDetails); } } - resultList = getRequirementList(resultList, nodes, iSdcCsarHelper); + resultList = getRequirementList(resultList, entities, iSdcCsarHelper); - for (NodeTemplate node : resultList) { - String templateName = node.getMetaData().getValue("name"); + for (IEntityDetails entity : resultList) { + String templateName = entity.getMetadata().getValue("name"); if (!resouceSequence.contains(templateName)) { resouceSequence.add(templateName); } @@ -572,7 +583,7 @@ public class ToscaResourceInstaller { String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(",")); service.setResourceOrder(resourceSeqStr); - logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr); + logger.debug(" resourceSeq for service uuid {}: {}", service.getModelUUID(), resourceSeqStr); } @@ -608,13 +619,17 @@ public class ToscaResourceInstaller { Map<String, String> resouceRequest = new HashMap<>(); ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper(); + List<IEntityDetails> nodeTemplateEntityList = + getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE), + TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); + List<Input> serInput = iSdcCsarHelper.getServiceInputs(); - Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream() - .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)) + Optional<IEntityDetails> nodeTemplateOpt = nodeTemplateEntityList.stream() + .filter(e -> e.getMetadata().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)) .findFirst(); if (nodeTemplateOpt.isPresent()) { - NodeTemplate nodeTemplate = nodeTemplateOpt.get(); - LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties(); + IEntityDetails entityDetails = nodeTemplateOpt.get(); + Map<String, Property> resourceProperties = entityDetails.getProperties(); for (String key : resourceProperties.keySet()) { Property property = resourceProperties.get(key); @@ -629,8 +644,7 @@ public class ToscaResourceInstaller { String jsonStr = objectMapper.writeValueAsString(resouceRequest); jsonStr = jsonStr.replace("\"", "\\\""); - logger.debug( - "resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr); + logger.debug("resource request for resource customization id {}: {}", resourceCustomizationUuid, jsonStr); return jsonStr; } catch (JsonProcessingException e) { logger.error("resource input could not be deserialized for resource customization id (" @@ -673,8 +687,8 @@ public class ToscaResourceInstaller { networkCustomization.setResourceInput( getResourceInput(toscaResourceStruct, networkCustomization.getModelCustomizationUUID())); service.getNetworkCustomizations().add(networkCustomization); - logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for " - + networkResourceModelName); + logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for {}", + networkResourceModelName); } } @@ -714,24 +728,24 @@ public class ToscaResourceInstaller { } - protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) { - Metadata metadata = nodeTemplate.getMetaData(); + protected ConfigurationResource getConfigurationResource(IEntityDetails configEntity) { + Metadata metadata = configEntity.getMetadata(); ConfigurationResource configResource = new ConfigurationResource(); configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - configResource.setToscaNodeType(nodeTemplate.getType()); + configResource.setToscaNodeType(configEntity.getToscaType()); return configResource; } - protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate, + protected ConfigurationResourceCustomization getConfigurationResourceCustomization(IEntityDetails configEntity, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization, Service service) { - Metadata metadata = nodeTemplate.getMetaData(); + Metadata metadata = configEntity.getMetadata(); - ConfigurationResource configResource = getConfigurationResource(nodeTemplate); + ConfigurationResource configResource = getConfigurationResource(configEntity); ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization(); @@ -739,14 +753,12 @@ public class ToscaResourceInstaller { configCustomizationResource .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - configCustomizationResource.setModelInstanceName(nodeTemplate.getName()); - - configCustomizationResource.setFunction( - toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function")); - configCustomizationResource.setRole( - toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role")); - configCustomizationResource.setType( - toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type")); + configCustomizationResource.setModelInstanceName(configEntity.getName()); + + configCustomizationResource.setFunction(getLeafPropertyValue(configEntity, "function")); + configCustomizationResource.setRole(getLeafPropertyValue(configEntity, "role")); + configCustomizationResource.setType(getLeafPropertyValue(configEntity, "type")); + configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization); configCustomizationResource.setConfigurationResource(configResource); @@ -758,37 +770,39 @@ public class ToscaResourceInstaller { return configCustomizationResource; } - protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) { - List<NodeTemplate> serviceProxyResourceList = - toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY); + List<IEntityDetails> spEntityList = + getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY), + TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); - List<NodeTemplate> configurationNodeTemplatesList = - toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION); + List<IEntityDetails> configEntityList = + getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), + TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<>(); List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<>(); ServiceProxyResourceCustomization serviceProxy = null; - if (serviceProxyResourceList != null) { - for (NodeTemplate spNode : serviceProxyResourceList) { - serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct); + if (spEntityList != null) { + for (IEntityDetails spEntity : spEntityList) { + serviceProxy = createServiceProxy(spEntity, service, toscaResourceStruct); serviceProxyList.add(serviceProxy); - for (NodeTemplate configNode : configurationNodeTemplatesList) { + for (IEntityDetails configEntity : configEntityList) { + + List<RequirementAssignment> requirements = configEntity.getRequirements(); - List<RequirementAssignment> requirementsList = - toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll(); - for (RequirementAssignment requirement : requirementsList) { - if (requirement.getNodeTemplateName().equals(spNode.getName())) { - ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, + for (RequirementAssignment requirement : requirements) { + + if (requirement.getNodeTemplateName().equals(spEntity.getName())) { + ConfigurationResourceCustomization configurationResource = createConfiguration(configEntity, toscaResourceStruct, serviceProxy, service, configurationResourceList); Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream() - .filter(configurationResourceCustomization -> configNode.getMetaData() + .filter(configurationResourceCustomization -> configEntity.getMetadata() .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID) .equals(configurationResource.getModelCustomizationUUID())) .filter(configurationResourceCustomization -> configurationResourceCustomization @@ -966,8 +980,8 @@ public class ToscaResourceInstaller { pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME))); pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION))); pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF))); + pnfResourceCustomization.setControllerActor(getStringValue(properties.get(CONTROLLER_ACTOR))); pnfResourceCustomization.setPnfResources(pnfResource); - return pnfResourceCustomization; } @@ -993,32 +1007,31 @@ public class ToscaResourceInstaller { return String.valueOf(value); } - protected void processVfModules(IEntityDetails vfEntityDetails, NodeTemplate nodeTemplate, - ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, Service service, - Metadata metadata) throws Exception { + protected void processVfModules(IEntityDetails vfEntityDetails, ToscaResourceStructure toscaResourceStruct, + VfResourceStructure vfResourceStructure, Service service, Metadata metadata) throws Exception { String vfCustomizationCategory = vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); - logger.debug("VF Category is : " + vfCustomizationCategory); + logger.debug("VF Category is: {} ", vfCustomizationCategory); String vfCustomizationUUID = vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); - logger.debug("VFCustomizationUUID=" + vfCustomizationUUID); + logger.debug("VFCustomizationUUID= {}", vfCustomizationUUID); IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance(); // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before // comparing their VF Modules UUID's - logger.debug("Checking if Notification VF ResourceCustomizationUUID: " - + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: " - + vfCustomizationUUID); + logger.debug( + "Checking if Notification VF ResourceCustomizationUUID: {} matches Tosca VF Customization UUID: {}", + vfNotificationResource.getResourceCustomizationUUID(), vfCustomizationUUID); if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) { - logger.debug("vfCustomizationUUID: " + vfCustomizationUUID - + " matches vfNotificationResource CustomizationUUID"); + logger.debug("vfCustomizationUUID: {} matches vfNotificationResource CustomizationUUID ", + vfCustomizationUUID); VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service); @@ -1030,7 +1043,7 @@ public class ToscaResourceInstaller { for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { - logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); + logger.debug("vfModuleStructure: {}", vfModuleStructure); List<IEntityDetails> vfModuleEntityList = getEntityDetails(toscaResourceStruct, @@ -1062,16 +1075,16 @@ public class ToscaResourceInstaller { } } - // Check for VNFC Instance Group info and add it if there is List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"), TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false); + Set<VnfcCustomization> existingVnfcGroupSet = new HashSet<>(); for (IEntityDetails groupEntity : vfcEntityList) { - VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = - createVNFCInstanceGroup(groupEntity, nodeTemplate, vnfResource, toscaResourceStruct); + VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(groupEntity, + vfEntityDetails, vnfResource, toscaResourceStruct, existingVnfcGroupSet); vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization); } @@ -1079,7 +1092,7 @@ public class ToscaResourceInstaller { if (!CollectionUtils.isEmpty(seqResult)) { String resultStr = seqResult.stream().collect(Collectors.joining(",")); vnfResource.setVnfcInstanceGroupOrder(resultStr); - logger.debug("vnfcGroupOrder result for service uuid(" + service.getModelUUID() + ") : " + resultStr); + logger.debug("vnfcGroupOrder result for service uuid {}: {}", service.getModelUUID(), resultStr); } // add this vnfResource with existing vnfResource for this service addVnfCustomization(service, vnfResource); @@ -1109,7 +1122,7 @@ public class ToscaResourceInstaller { boolean hasRequirements = false; for (IEntityDetails vnfcDetails : vnfcMemberNodes) { - Map<String, RequirementAssignment> requirements = vnfcDetails.getRequirements(); + List<RequirementAssignment> requirements = vnfcDetails.getRequirements(); if (requirements != null && !requirements.isEmpty()) { hasRequirements = true; @@ -1145,15 +1158,14 @@ public class ToscaResourceInstaller { boolean isAllExists = true; - Map<String, RequirementAssignment> requirements = memberNode.getRequirements(); + List<RequirementAssignment> requirements = memberNode.getRequirements(); if (requirements == null || requirements.isEmpty()) { continue; } - for (Map.Entry<String, RequirementAssignment> entry : requirements.entrySet()) { - RequirementAssignment rqa = entry.getValue(); + for (RequirementAssignment rqa : requirements) { String name = rqa.getNodeTemplateName(); for (IEntityDetails node : vnfcMemberNodes) { if (name.equals(node.getName())) { @@ -1190,7 +1202,7 @@ public class ToscaResourceInstaller { watchdogDistributionStatusRepository.saveAndFlush(distributionStatus); } catch (ObjectOptimisticLockingFailureException e) { - logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString()); + logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : {} ", e); throw e; } } @@ -1394,7 +1406,6 @@ public class ToscaResourceInstaller { ResourceStructure resourceStructure) { Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata(); - List<Service> services = serviceRepo.findByModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); Service service; @@ -1431,6 +1442,10 @@ public class ToscaResourceInstaller { generateNamingValue = "true".equalsIgnoreCase(generateNaming); } service.setOnapGeneratedNaming(generateNamingValue); + service.setBlueprintName(serviceMetadata.getValue(CDS_MODEL_NAME)); + service.setBlueprintVersion(serviceMetadata.getValue(CDS_MODEL_VERSION)); + service.setSkipPostInstConf(Boolean.valueOf(serviceMetadata.getValue(SKIP_POST_INST_CONF))); + service.setControllerActor(serviceMetadata.getValue(CONTROLLER_ACTOR)); } @@ -1438,10 +1453,10 @@ public class ToscaResourceInstaller { return service; } - protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, + protected ServiceProxyResourceCustomization createServiceProxy(IEntityDetails spEntity, Service service, ToscaResourceStructure toscaResourceStructure) { - Metadata spMetadata = nodeTemplate.getMetaData(); + Metadata spMetadata = spEntity.getMetadata(); ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization(); @@ -1456,15 +1471,15 @@ public class ToscaResourceInstaller { spCustomizationResource .setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - spCustomizationResource.setModelInstanceName(nodeTemplate.getName()); - spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); + spCustomizationResource.setModelInstanceName(spEntity.getName()); + spCustomizationResource.setToscaNodeType(spEntity.getToscaType()); String sourceServiceUUID = spMetadata.getValue("sourceModelUuid"); Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID); spCustomizationResource.setSourceService(sourceService); - spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); + spCustomizationResource.setToscaNodeType(spEntity.getToscaType()); serviceProxyCustomizationSet.add(spCustomizationResource); @@ -1473,20 +1488,20 @@ public class ToscaResourceInstaller { return spCustomizationResource; } - protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, + protected ConfigurationResourceCustomization createConfiguration(IEntityDetails configEntity, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization, Service service, List<ConfigurationResourceCustomization> configurationResourceList) { ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization( - nodeTemplate, toscaResourceStructure, spResourceCustomization, service); + configEntity, toscaResourceStructure, spResourceCustomization, service); ConfigurationResource configResource = null; ConfigurationResource existingConfigResource = findExistingConfiguration(service, - nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID), configurationResourceList); + configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID), configurationResourceList); if (existingConfigResource == null) { - configResource = getConfigurationResource(nodeTemplate); + configResource = getConfigurationResource(configEntity); } else { configResource = existingConfigResource; } @@ -1887,8 +1902,8 @@ public class ToscaResourceInstaller { } protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(IEntityDetails vfcInstanceEntity, - NodeTemplate vnfcNodeTemplate, VnfResourceCustomization vnfResourceCustomization, - ToscaResourceStructure toscaResourceStructure) { + IEntityDetails vfEntityDetails, VnfResourceCustomization vnfResourceCustomization, + ToscaResourceStructure toscaResourceStructure, Set<VnfcCustomization> existingVnfcGroupSet) { Metadata instanceMetadata = vfcInstanceEntity.getMetadata(); @@ -1957,40 +1972,49 @@ public class ToscaResourceInstaller { vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup); - ArrayList<Input> inputs = vnfcNodeTemplate.getSubMappingToscaTemplate().getInputs(); - createVFCInstanceGroupMembers(vfcInstanceGroupCustom, vfcInstanceEntity, inputs); + List<Input> inputs = vfEntityDetails.getInputs(); + + createVFCInstanceGroupMembers(vfcInstanceGroupCustom, vfcInstanceEntity, inputs, existingVnfcGroupSet); return vfcInstanceGroupCustom; } private void createVFCInstanceGroupMembers(VnfcInstanceGroupCustomization vfcInstanceGroupCustom, - IEntityDetails vfcModuleEntity, List<Input> inputList) { + IEntityDetails vfcModuleEntity, List<Input> inputList, Set<VnfcCustomization> existingVnfcGroupSet) { List<IEntityDetails> members = vfcModuleEntity.getMemberNodes(); if (!CollectionUtils.isEmpty(members)) { for (IEntityDetails vfcEntity : members) { - VnfcCustomization vnfcCustomization = new VnfcCustomization(); - - Metadata metadata = vfcEntity.getMetadata(); - vnfcCustomization - .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - vnfcCustomization.setModelInstanceName(vfcEntity.getName()); - vnfcCustomization.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - vnfcCustomization - .setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - vnfcCustomization.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - vnfcCustomization.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - vnfcCustomization.setToscaNodeType(testNull(vfcEntity.getToscaType())); - vnfcCustomization - .setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); - vnfcCustomization.setResourceInput(getVnfcResourceInput(vfcEntity, inputList)); - vnfcCustomization.setVnfcInstanceGroupCustomization(vfcInstanceGroupCustom); - List<VnfcCustomization> vnfcCustomizations = vfcInstanceGroupCustom.getVnfcCustomizations(); - - if (vnfcCustomizations == null) { - vnfcCustomizations = new ArrayList<>(); - vfcInstanceGroupCustom.setVnfcCustomizations(vnfcCustomizations); + + VnfcCustomization existingVfcGroup = findExistingVfc(existingVnfcGroupSet, + vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + + if (existingVfcGroup == null) { + VnfcCustomization vnfcCustomization = new VnfcCustomization(); + + Metadata metadata = vfcEntity.getMetadata(); + vnfcCustomization.setModelCustomizationUUID( + metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + vnfcCustomization.setModelInstanceName(vfcEntity.getName()); + vnfcCustomization.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + vnfcCustomization + .setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + vnfcCustomization.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + vnfcCustomization.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + vnfcCustomization.setToscaNodeType(testNull(vfcEntity.getToscaType())); + vnfcCustomization + .setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + vnfcCustomization.setResourceInput(getVnfcResourceInput(vfcEntity, inputList)); + vnfcCustomization.setVnfcInstanceGroupCustomization(vfcInstanceGroupCustom); + List<VnfcCustomization> vnfcCustomizations = vfcInstanceGroupCustom.getVnfcCustomizations(); + + if (vnfcCustomizations == null) { + vnfcCustomizations = new ArrayList<>(); + vfcInstanceGroupCustom.setVnfcCustomizations(vnfcCustomizations); + } + vnfcCustomizations.add(vnfcCustomization); + + existingVnfcGroupSet.add(vnfcCustomization); } - vnfcCustomizations.add(vnfcCustomization); } } } @@ -2012,8 +2036,8 @@ public class ToscaResourceInstaller { ObjectMapper objectMapper = new ObjectMapper(); jsonStr = objectMapper.writeValueAsString(resouceRequest); jsonStr = jsonStr.replace("\"", "\\\""); - logger.debug("vfcResource request for resource customization id (" + resourceCustomizationUuid + ") : " - + jsonStr); + logger.debug("vfcResource request for resource customization id {}: {}", resourceCustomizationUuid, + jsonStr); } catch (JsonProcessingException e) { logger.debug("Json Exception: {}", e.getMessage()); logger.error("Exception occurred", e); @@ -2183,9 +2207,9 @@ public class ToscaResourceInstaller { for (IEntityDetails fabricEntity : fabricEntityList) { - Map<String, RequirementAssignment> requirements = fabricEntity.getRequirements(); + List<RequirementAssignment> requirements = fabricEntity.getRequirements(); - for (RequirementAssignment requirement : requirements.values()) { + for (RequirementAssignment requirement : requirements) { if (requirement.getNodeTemplateName().equals(cvfcEntity.getName())) { @@ -2366,6 +2390,14 @@ public class ToscaResourceInstaller { if (minInstances != null && minInstances.length() > 0) { vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances)); } + + String skipPostInstConfText = getLeafPropertyValue(vfModuleEntityDetails, SKIP_POST_INST_CONF); + + if (skipPostInstConfText != null) { + vfModuleCustomization.setSkipPostInstConf( + Boolean.parseBoolean(getLeafPropertyValue(vfModuleEntityDetails, SKIP_POST_INST_CONF))); + } + return vfModuleCustomization; } @@ -2408,8 +2440,7 @@ public class ToscaResourceInstaller { Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream() .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID() - .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))) + .equalsIgnoreCase(vfMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))) .findFirst(); if (matchingObject.isPresent()) { @@ -2561,25 +2592,31 @@ public class ToscaResourceInstaller { Boolean.parseBoolean(getLeafPropertyValue(entityDetails, SKIP_POST_INST_CONF))); } - + vnfResourceCustomization.setControllerActor(getLeafPropertyValue(entityDetails, CONTROLLER_ACTOR)); vnfResourceCustomization.setVnfResources(vnfResource); vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger( entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT))); - entityDetails.getCapabilities().get(SCALABLE); + List<CapabilityAssignment> capAssignList = entityDetails.getCapabilities(); + if (capAssignList != null) { - if (entityDetails.getCapabilities() != null) { + for (CapabilityAssignment capAssign : capAssignList) { - CapabilityAssignment capAssign = entityDetails.getCapabilities().get(SCALABLE); - if (capAssign != null) { - vnfResourceCustomization.setMinInstances(Integer - .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); - vnfResourceCustomization.setMaxInstances(Integer - .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); - } + if (capAssign != null) { + + String capabilityName = capAssign.getName(); + if (capabilityName.equalsIgnoreCase(SCALABLE)) { + vnfResourceCustomization.setMinInstances(Integer.getInteger( + getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); + vnfResourceCustomization.setMaxInstances(Integer.getInteger( + getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); + } + } + + } } if (vnfResourceCustomization.getMinInstances() == null && vnfResourceCustomization.getMaxInstances() == null) { @@ -2686,12 +2723,11 @@ public class ToscaResourceInstaller { } } - Map<String, CapabilityAssignment> capAssignmentList = arEntity.getCapabilities(); + List<CapabilityAssignment> capAssignmentList = arEntity.getCapabilities(); if (capAssignmentList != null) { - for (Map.Entry<String, CapabilityAssignment> entry : capAssignmentList.entrySet()) { - CapabilityAssignment arCapability = entry.getValue(); + for (CapabilityAssignment arCapability : capAssignmentList) { if (arCapability != null) { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java index 07eca567d5..6908fe4eda 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java @@ -714,6 +714,9 @@ public class ASDCNotificationLogging { if ("Allotted Resource".equalsIgnoreCase(category)) { + buffer.append(System.lineSeparator()); + buffer.append("Allotted Resource Properties:"); + buffer.append(System.lineSeparator()); buffer.append("Model Name:"); buffer.append(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); buffer.append(System.lineSeparator()); @@ -739,6 +742,7 @@ public class ASDCNotificationLogging { buffer.append("Model Description:"); buffer.append(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); buffer.append("Allotted Resource Customization Properties:"); @@ -784,6 +788,9 @@ public class ASDCNotificationLogging { if ("Allotted Resource".equalsIgnoreCase(category)) { + buffer.append(System.lineSeparator()); + buffer.append("Allotted Resource Properties:"); + buffer.append(System.lineSeparator()); buffer.append("Model Name:"); buffer.append(testNull(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); buffer.append(System.lineSeparator()); @@ -809,7 +816,7 @@ public class ASDCNotificationLogging { buffer.append("Model Description:"); buffer.append(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); buffer.append(System.lineSeparator()); - + buffer.append(System.lineSeparator()); buffer.append("Allotted Resource Customization Properties:"); buffer.append(System.lineSeparator()); diff --git a/asdc-controller/src/main/resources/application-aaf.yaml b/asdc-controller/src/main/resources/application-aaf.yaml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/asdc-controller/src/main/resources/application-aaf.yaml diff --git a/asdc-controller/src/main/resources/application-basic.yaml b/asdc-controller/src/main/resources/application-basic.yaml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/asdc-controller/src/main/resources/application-basic.yaml |