diff options
Diffstat (limited to 'asdc-controller/src/main')
14 files changed, 241 insertions, 161 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/Application.java b/asdc-controller/src/main/java/org/onap/so/asdc/Application.java index a05eeea466..eb2957c6f8 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/Application.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/Application.java @@ -22,6 +22,8 @@ package org.onap.so.asdc; import javax.annotation.PostConstruct; import org.onap.so.asdc.activity.DeployActivitySpecs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -32,7 +34,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling @EnableJpaRepositories("org.onap.so.db.catalog.data.repository") public class Application { - + private static final Logger logger = LoggerFactory.getLogger(Application.class); private static final String MSO_CONFIG_PATH = "mso.config.path"; private static final String LOGS_DIR = "logs_dir"; @@ -55,6 +57,7 @@ public class Application { try { deployActivitySpecs.deployActivities(); } catch (Exception e) { + logger.warn("{} {}", "Exception on deploying activitySpecs: ", e.getMessage()); } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java b/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java index 3494945020..39bb836ff8 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java @@ -20,11 +20,9 @@ package org.onap.so.asdc; - import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; import org.springframework.context.annotation.Bean; @@ -36,6 +34,8 @@ import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; @Configuration @EnableTransactionManagement @@ -44,11 +44,17 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Profile({"!test"}) public class CatalogDBConfig { + @Bean + @ConfigurationProperties(prefix = "spring.datasource.hikari") + public HikariConfig catalogDbConfig() { + return new HikariConfig(); + } + @Primary @Bean(name = "dataSource") - @ConfigurationProperties(prefix = "spring.datasource") public DataSource dataSource() { - return DataSourceBuilder.create().build(); + HikariConfig hikariConfig = this.catalogDbConfig(); + return new HikariDataSource(hikariConfig); } @Primary diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java b/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java index 8320da01cf..821b2dacff 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java @@ -20,11 +20,9 @@ package org.onap.so.asdc; - import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; import org.springframework.context.annotation.Bean; @@ -35,6 +33,8 @@ import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; @Configuration @EnableTransactionManagement @@ -43,13 +43,18 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Profile({"!test"}) public class RequestDBConfig { + @Bean + @ConfigurationProperties(prefix = "request.datasource.hikari") + public HikariConfig requestDbConfig() { + return new HikariConfig(); + } + @Bean(name = "requestDataSource") - @ConfigurationProperties(prefix = "request.datasource") public DataSource dataSource() { - return DataSourceBuilder.create().build(); + HikariConfig hikariConfig = this.requestDbConfig(); + return new HikariDataSource(hikariConfig); } - @Bean(name = "requestEntityManagerFactory") public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, @Qualifier("requestDataSource") DataSource dataSource) { @@ -57,7 +62,6 @@ public class RequestDBConfig { .build(); } - @Bean(name = "requestTransactionManager") public PlatformTransactionManager transactionManager( @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java index c80e84b574..c37eccf594 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java @@ -22,6 +22,7 @@ package org.onap.so.asdc.activity; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpStatus; import org.apache.http.entity.ContentType; import org.onap.so.asdc.activity.beans.ActivitySpec; @@ -67,8 +68,10 @@ public class ActivitySpecsActions { Response response = httpClient.post(payload); int statusCode = response.getStatus(); - if (statusCode != HttpStatus.SC_OK) { - logger.warn("{} {} {}", "Error creating activity spec", activitySpec.getName(), statusCode); + if (statusCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) { + logger.warn(LoggingAnchor.THREE, "ActivitySpec", activitySpec.getName(), "already exists in SDC"); + } else if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED) { + logger.warn(LoggingAnchor.THREE, "Error creating activity spec", activitySpec.getName(), statusCode); } else { if (response.getEntity() != null) { ActivitySpecCreateResponse activitySpecCreateResponse = @@ -76,14 +79,14 @@ public class ActivitySpecsActions { if (activitySpecCreateResponse != null) { activitySpecId = activitySpecCreateResponse.getId(); } else { - logger.warn("{} {}", "Unable to read activity spec", activitySpec.getName()); + logger.warn(LoggingAnchor.TWO, "Unable to read activity spec", activitySpec.getName()); } } else { - logger.warn("{} {}", "No activity spec response returned", activitySpec.getName()); + logger.warn(LoggingAnchor.TWO, "No activity spec response returned", activitySpec.getName()); } } } catch (Exception e) { - logger.warn("{} {}", "Exception creating activitySpec", e.getMessage()); + logger.warn(LoggingAnchor.TWO, "Exception creating activitySpec", e); } return activitySpecId; @@ -108,14 +111,16 @@ public class ActivitySpecsActions { int statusCode = response.getStatus(); - if (statusCode != HttpStatus.SC_OK) { - logger.warn("{} {} {}", "Error certifying activity", activitySpecId, statusCode); + if (statusCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) { + logger.warn(LoggingAnchor.THREE, "ActivitySpec with id", activitySpecId, "is already certified in SDC"); + } else if (statusCode != HttpStatus.SC_OK) { + logger.warn(LoggingAnchor.THREE, "Error certifying activity", activitySpecId, statusCode); } else { certificationResult = true; } } catch (Exception e) { - logger.warn("{} {}", "Exception certifying activitySpec", e.getMessage()); + logger.warn(LoggingAnchor.TWO, "Exception certifying activitySpec", e); } return certificationResult; 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 43eb277d21..325ba913f8 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 @@ -22,9 +22,11 @@ package org.onap.so.asdc.activity; import java.util.ArrayList; import java.util.List; +import org.onap.so.logger.LoggingAnchor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import org.onap.so.asdc.activity.beans.ActivitySpec; import org.onap.so.asdc.activity.beans.Input; import org.onap.so.asdc.activity.beans.Output; @@ -52,26 +54,28 @@ public class DeployActivitySpecs { protected static final Logger logger = LoggerFactory.getLogger(DeployActivitySpecs.class); - + @Transactional public void deployActivities() throws Exception { String hostname = env.getProperty(SDC_ENDPOINT); + logger.debug("{} {}", "SDC ActivitySpec endpoint: ", hostname); if (hostname == null || hostname.isEmpty()) { return; } List<org.onap.so.db.catalog.beans.ActivitySpec> activitySpecsFromCatalog = activitySpecRepository.findAll(); for (org.onap.so.db.catalog.beans.ActivitySpec activitySpecFromCatalog : activitySpecsFromCatalog) { + logger.debug("{} {}", "Attempting to create activity ", activitySpecFromCatalog.getName()); ActivitySpec activitySpec = mapActivitySpecFromCatalogToSdc(activitySpecFromCatalog); String activitySpecId = activitySpecsActions.createActivitySpec(hostname, activitySpec); if (activitySpecId != null) { - logger.info("{} {}", "Successfully created activitySpec", activitySpec.getName()); + logger.info(LoggingAnchor.TWO, "Successfully created activitySpec", activitySpec.getName()); boolean certificationResult = activitySpecsActions.certifyActivitySpec(hostname, activitySpecId); if (certificationResult) { - logger.info("{} {}", "Successfully certified activitySpec", activitySpec.getName()); + logger.info(LoggingAnchor.TWO, "Successfully certified activitySpec", activitySpec.getName()); } else { - logger.info("{} {}", "Failed to certify activitySpec", activitySpec.getName()); + logger.info(LoggingAnchor.TWO, "Failed to certify activitySpec", activitySpec.getName()); } } else { - logger.info("{} {}", "Failed to create activitySpec", activitySpec.getName()); + logger.info(LoggingAnchor.TWO, "Failed to create activitySpec", activitySpec.getName()); } } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java index 2eace7587f..639a96eab6 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java @@ -9,9 +9,9 @@ * 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. @@ -22,7 +22,6 @@ package org.onap.so.asdc.client; - import java.security.GeneralSecurityException; import java.util.Arrays; import java.util.Collections; @@ -40,11 +39,11 @@ import org.springframework.stereotype.Component; public class ASDCConfiguration implements IConfiguration { // SHell command to obtain the same encryption, 128 bits key, key must be HEX - // echo -n "This is a test string" | openssl aes-128-ecb -e -K 546573746F736973546573746F736973 -nosalt | xxd + // echo -n "This is a test string" | openssl aes-128-ecb -e -K 546573746F736973546573746F736973 + // -nosalt | xxd private static Logger logger = LoggerFactory.getLogger(ASDCConfiguration.class); - private String asdcControllerName; public static final String HEAT = "HEAT"; @@ -57,9 +56,10 @@ public class ASDCConfiguration implements IConfiguration { public static final String TOSCA_CSAR = "TOSCA_CSAR"; public static final String WORKFLOW = "WORKFLOW"; public static final String VF_MODULES_METADATA = "VF_MODULES_METADATA"; + public static final String CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT = "CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT"; - private static final String[] SUPPORTED_ARTIFACT_TYPES = - {HEAT, HEAT_ARTIFACT, HEAT_ENV, HEAT_NESTED, HEAT_NET, HEAT_VOL, OTHER, TOSCA_CSAR, VF_MODULES_METADATA}; + private static final String[] SUPPORTED_ARTIFACT_TYPES = {HEAT, HEAT_ARTIFACT, HEAT_ENV, HEAT_NESTED, HEAT_NET, + HEAT_VOL, OTHER, TOSCA_CSAR, VF_MODULES_METADATA, CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, WORKFLOW}; public static final List<String> SUPPORTED_ARTIFACT_TYPES_LIST = Collections.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES)); @@ -73,7 +73,6 @@ public class ASDCConfiguration implements IConfiguration { @Value("${mso.asdc-connections.asdc-controller1.messageBusAddress}") private String[] messageBusAddress; - public void setAsdcControllerName(String asdcControllerName) { this.asdcControllerName = asdcControllerName; } @@ -95,15 +94,12 @@ public class ASDCConfiguration implements IConfiguration { } else { return Collections.emptyList(); } - - } public String getAsdcControllerName() { return asdcControllerName; } - @Override public String getConsumerGroup() { return getPropertyOrNull("mso.asdc-connections.asdc-controller1.consumerGroup"); @@ -171,6 +167,7 @@ public class ASDCConfiguration implements IConfiguration { try { return Boolean.valueOf(config); } catch (Exception e) { + logger.warn("Exception while getting boolean property with default property", e); return defaultValue; } } @@ -193,7 +190,8 @@ public class ASDCConfiguration implements IConfiguration { @Override public List<String> getRelevantArtifactTypes() { - // DO not return the Static List SUPPORTED_ARTIFACT_TYPES_LIST because the ASDC Client will try to modify it !!! + // DO not return the Static List SUPPORTED_ARTIFACT_TYPES_LIST because the ASDC Client will + // try to modify it !!! return Arrays.asList(SUPPORTED_ARTIFACT_TYPES); } 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 ea1d194c68..563291c479 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 @@ -36,6 +36,7 @@ import java.io.UnsupportedEncodingException; import java.nio.file.Paths; import java.util.List; import java.util.Optional; +import org.onap.so.logger.LoggingAnchor; import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.consumer.IDistributionStatusMessage; import org.onap.sdc.api.consumer.IFinalDistrStatusMessage; @@ -232,7 +233,8 @@ public class ASDCController { } this.changeControllerStatus(ASDCControllerStatus.IDLE); - logger.info("{} {} {}", MessageEnum.ASDC_INIT_ASDC_CLIENT_SUC.toString(), "ASDC", "changeControllerStatus"); + logger.info(LoggingAnchor.THREE, MessageEnum.ASDC_INIT_ASDC_CLIENT_SUC.toString(), "ASDC", + "changeControllerStatus"); } /** @@ -264,7 +266,7 @@ public class ASDCController { if (toscaInstaller.isResourceAlreadyDeployed(resource, serviceDeployed)) { - logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST.toString(), + logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST.toString(), resource.getResourceInstance().getResourceInstanceName(), resource.getResourceInstance().getResourceUUID(), resource.getResourceInstance().getResourceName()); @@ -334,7 +336,7 @@ public class ASDCController { try { downloadResult = distributionClient.download(artifact); if (null == downloadResult) { - logger.info("{} {}", MessageEnum.ASDC_ARTIFACT_NULL.toString(), artifact.getArtifactUUID()); + logger.info(LoggingAnchor.TWO, MessageEnum.ASDC_ARTIFACT_NULL.toString(), artifact.getArtifactUUID()); return downloadResult; } } catch (RuntimeException e) { @@ -346,11 +348,12 @@ public class ASDCController { } if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult())) { - logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_SUC.toString(), artifact.getArtifactURL(), - artifact.getArtifactUUID(), String.valueOf(downloadResult.getArtifactPayload().length)); + logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_ARTIFACT_DOWNLOAD_SUC.toString(), + artifact.getArtifactURL(), artifact.getArtifactUUID(), + String.valueOf(downloadResult.getArtifactPayload().length)); } else { - logger.error("{} {} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(), + logger.error(LoggingAnchor.SEVEN, MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(), artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(), downloadResult.getDistributionMessageResult(), ErrorCode.DataError.getValue(), "ASDC artifact download fail"); @@ -391,12 +394,12 @@ public class ASDCController { byte[] payloadBytes = resultArtifact.getArtifactPayload(); try (FileOutputStream outFile = new FileOutputStream(filePath)) { - logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), "***WRITE FILE ARTIFACT NAME", - "ASDC", artifact.getArtifactName()); + logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), + "***WRITE FILE ARTIFACT NAME", "ASDC", artifact.getArtifactName()); outFile.write(payloadBytes, 0, payloadBytes.length); } catch (Exception e) { logger.debug("Exception :", e); - logger.error("{} {} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(), + logger.error(LoggingAnchor.SEVEN, MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(), artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(), resultArtifact.getDistributionMessageResult(), ErrorCode.DataError.getValue(), "ASDC write to file failed"); @@ -444,7 +447,7 @@ public class ASDCController { protected void deployResourceStructure(ResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException { - logger.info("{} {} {} {}", MessageEnum.ASDC_START_DEPLOY_ARTIFACT.toString(), + logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_START_DEPLOY_ARTIFACT.toString(), resourceStructure.getResourceInstance().getResourceInstanceName(), resourceStructure.getResourceInstance().getResourceUUID(), "ASDC"); try { @@ -452,7 +455,7 @@ public class ASDCController { toscaInstaller.installTheResource(toscaResourceStructure, resourceStructure); } catch (ArtifactInstallerException e) { - logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(), + logger.info(LoggingAnchor.SIX, MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(), resourceStructure.getResourceInstance().getResourceName(), resourceStructure.getResourceInstance().getResourceUUID(), String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure"); @@ -461,7 +464,7 @@ public class ASDCController { } if (resourceStructure.isDeployedSuccessfully() || toscaResourceStructure.isDeployedSuccessfully()) { - logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), + logger.info(LoggingAnchor.SIX, MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), resourceStructure.getResourceInstance().getResourceName(), resourceStructure.getResourceInstance().getResourceUUID(), String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure"); @@ -484,7 +487,7 @@ public class ASDCController { if (errorReason != null) { event = event + "(" + errorReason + ")"; } - logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC.toString(), notificationType.name(), + logger.info(LoggingAnchor.SIX, MessageEnum.ASDC_SEND_NOTIF_ASDC.toString(), notificationType.name(), status.name(), artifactURL, "ASDC", "sendASDCNotification"); logger.debug(event); @@ -514,7 +517,7 @@ public class ASDCController { break; } } catch (RuntimeException e) { - logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC", + logger.warn(LoggingAnchor.FIVE, MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC", "sendASDCNotification", ErrorCode.SchemaError.getValue(), "RuntimeException - sendASDCNotification", e); } @@ -541,7 +544,7 @@ public class ASDCController { } catch (RuntimeException e) { logger.debug("Exception caught in sendFinalDistributionStatus {}", e.getMessage()); - logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC", + logger.warn(LoggingAnchor.FIVE, MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC", "sendASDCNotification", ErrorCode.SchemaError.getValue(), "RuntimeException - sendASDCNotification", e); } @@ -570,11 +573,11 @@ public class ASDCController { for (IResourceInstance resource : iNotif.getResources()) { noOfArtifacts += resource.getArtifacts().size(); } - logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_CALLBACK_NOTIF.toString(), String.valueOf(noOfArtifacts), - iNotif.getServiceUUID(), "ASDC"); + logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_RECEIVE_CALLBACK_NOTIF.toString(), + String.valueOf(noOfArtifacts), iNotif.getServiceUUID(), "ASDC"); try { logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif)); - logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), iNotif.getServiceUUID(), + logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), iNotif.getServiceUUID(), "ASDC", "treatNotification"); this.changeControllerStatus(ASDCControllerStatus.BUSY); @@ -665,7 +668,7 @@ public class ASDCController { "OptimisticLockingFailure for DistributionId: {} Another process " + "has already altered this distribution, so not going to process it on this site.", iNotif.getDistributionID()); - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Database concurrency exception: ", "ASDC", "treatNotification", ErrorCode.BusinessProcesssError.getValue(), "RuntimeException in treatNotification", e); @@ -787,27 +790,27 @@ public class ASDCController { errorMessage = e.getMessage(); logger.error("Exception occurred", e); } + } - if (!hasVFResource) { + if (!hasVFResource) { - logger.debug("No resources found for Service: " + iNotif.getServiceUUID()); + logger.debug("No resources found for Service: " + iNotif.getServiceUUID()); - logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID()); - try { - this.deployResourceStructure(resourceStructure, toscaResourceStructure); - } catch (ArtifactInstallerException e) { - deployStatus = DistributionStatusEnum.DEPLOY_ERROR; - errorMessage = e.getMessage(); - logger.error("Exception occurred", e); - } + logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID()); + try { + this.deployResourceStructure(resourceStructure, toscaResourceStructure); + } catch (ArtifactInstallerException e) { + deployStatus = DistributionStatusEnum.DEPLOY_ERROR; + errorMessage = e.getMessage(); + logger.error("Exception occurred", e); } - this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deployStatus, - errorMessage); } + this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deployStatus, + errorMessage); } catch (ASDCDownloadException | UnsupportedEncodingException e) { - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), + 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); } @@ -853,7 +856,7 @@ public class ASDCController { } catch (Exception e) { - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", ErrorCode.BusinessProcesssError.getValue(), "Exception in processCsarServiceArtifacts", e); @@ -874,7 +877,7 @@ public class ASDCController { } catch (Exception e) { logger.info("Whats the error {}", e.getMessage()); - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", ErrorCode.BusinessProcesssError.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 6a9c1aa848..56690a8c38 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 @@ -31,6 +31,7 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.asdc.client.ASDCController; import org.onap.so.asdc.client.exceptions.ASDCControllerException; import org.onap.so.asdc.client.exceptions.ASDCParametersException; @@ -104,11 +105,11 @@ public class ASDCRestInterface { toscaInstaller.installTheComponentStatus(statusData); controller.closeASDC(); - logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), statusData.getDistributionID(), - "ASDC", "ASDC Updates Are Complete"); + logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), + statusData.getDistributionID(), "ASDC", "ASDC Updates Are Complete"); } catch (Exception e) { logger.info("Error caught " + e.getMessage()); - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION.toString(), "Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService", ErrorCode.BusinessProcesssError.getValue(), "Exception in invokeASDCService", e); } 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 749a397ee0..c49cb3e50f 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,6 +25,7 @@ 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; @@ -142,14 +143,14 @@ public class ToscaResourceStructure { File spoolFile = new File(filePath); logger.debug("ASDC File path is: {}", spoolFile.getAbsolutePath()); - logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), "***PATH", "ASDC", + logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), "***PATH", "ASDC", spoolFile.getAbsolutePath()); sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath(), false); } catch (Exception e) { logger.debug(e.getMessage(), e); - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Exception caught during parser *****LOOK********* " + artifact.getArtifactName(), "ASDC", "processResourceNotification", ErrorCode.BusinessProcesssError.getValue(), "Exception in " + "processResourceNotification", e); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java index 16e9fda7c4..f954fe0c5a 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java @@ -25,10 +25,11 @@ package org.onap.so.asdc.installer; import java.io.IOException; import java.io.UnsupportedEncodingException; -import java.util.HashMap; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.asdc.client.ASDCConfiguration; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.asdc.util.ASDCNotificationLogging; @@ -80,6 +81,7 @@ public class VfResourceStructure extends ResourceStructure { super(notificationdata, resourceinstance); this.resourceType = ResourceType.VF_RESOURCE; vfModulesStructureList = new LinkedList<>(); + vfModulesMetadataList = new ArrayList<>(); } public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, @@ -105,7 +107,7 @@ public class VfResourceStructure extends ResourceStructure { } protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult, - VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException { + VfModuleArtifact vfModuleArtifact) { switch (artifactinfo.getArtifactType()) { case ASDCConfiguration.HEAT: @@ -115,6 +117,7 @@ public class VfResourceStructure extends ResourceStructure { case ASDCConfiguration.HEAT_ARTIFACT: case ASDCConfiguration.HEAT_NET: case ASDCConfiguration.OTHER: + case ASDCConfiguration.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT: artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact); break; case ASDCConfiguration.VF_MODULES_METADATA: @@ -132,9 +135,9 @@ public class VfResourceStructure extends ResourceStructure { public void createVfModuleStructures() throws ArtifactInstallerException { // for vender tosca VNF there is no VFModule in VF - if (vfModulesMetadataList == null) { - logger.info("{} {} {} {}", MessageEnum.ASDC_GENERAL_INFO.toString(), "There is no VF mudules in the VF.", - "ASDC", "createVfModuleStructures"); + if (vfModulesMetadataList.isEmpty()) { + logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_GENERAL_INFO.toString(), + "There is no VF mudules in the VF.", "ASDC", "createVfModuleStructures"); return; } for (IVfModuleData vfModuleMeta : vfModulesMetadataList) { @@ -147,6 +150,7 @@ public class VfResourceStructure extends ResourceStructure { return vfModulesStructureList; } + @Override public Map<String, VfModuleArtifact> getArtifactsMapByUUID() { return artifactsMapByUUID; } @@ -203,6 +207,6 @@ public class VfResourceStructure extends ResourceStructure { } catch (IOException e) { logger.debug("IOException : ", e); } - return null; + return new ArrayList<>(); } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java index 7945ad0174..095741c19b 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java @@ -33,7 +33,9 @@ import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; +import org.onap.so.logger.LoggingAnchor; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; @@ -45,6 +47,7 @@ import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.ByteArrayBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.HttpClientBuilder; +import org.onap.so.asdc.client.ASDCConfiguration; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; @@ -63,6 +66,9 @@ public class BpmnInstaller { @Autowired private Environment env; + @Autowired + private ASDCConfiguration asdcConfig; + public void installBpmn(String csarFilePath) { logger.info("Deploying BPMN files from {}", csarFilePath); try { @@ -83,7 +89,7 @@ public class BpmnInstaller { logger.debug("Response entity: {}", response.getEntity().toString()); if (response.getStatusLine().getStatusCode() != 200) { logger.debug("Failed deploying BPMN {}", name); - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), + logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), name, fileName, Integer.toString(response.getStatusLine().getStatusCode()), ErrorCode.DataError.getValue(), "ASDC BPMN deploy failed"); } else { @@ -91,7 +97,7 @@ public class BpmnInstaller { } } catch (Exception e) { logger.debug("Exception :", e); - logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), name, + logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), name, e.getMessage(), ErrorCode.DataError.getValue(), "ASDC BPMN deploy failed"); } } @@ -100,7 +106,7 @@ public class BpmnInstaller { csarFile.close(); } catch (IOException ex) { logger.debug("Exception :", ex); - logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), csarFilePath, + logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), csarFilePath, ex.getMessage(), ErrorCode.DataError.getValue(), "ASDC reading CSAR with workflows failed"); } return; @@ -119,8 +125,8 @@ public class BpmnInstaller { } } catch (Exception e) { logger.debug("Exception :", e); - logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), csarFilePath, e.getMessage(), - ErrorCode.DataError.getValue(), "ASDC Unable to check CSAR entries"); + logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), csarFilePath, + e.getMessage(), ErrorCode.DataError.getValue(), "ASDC Unable to check CSAR entries"); } return workflowsInCsar; } @@ -139,7 +145,7 @@ public class BpmnInstaller { protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws Exception { FileInputStream bpmnFileStream = new FileInputStream( - Paths.get(System.getProperty("mso.config.path"), "ASDC", version, bpmnFileName).normalize().toString()); + Paths.get(getMsoConfigPath(), "ASDC", version, bpmnFileName).normalize().toString()); byte[] bytesToSend = IOUtils.toByteArray(bpmnFileStream); HttpEntity requestEntity = @@ -193,4 +199,14 @@ public class BpmnInstaller { logger.error("Unable to open file.", e); } } + + private String getMsoConfigPath() { + String msoConfigPath = System.getProperty("mso.config.path"); + if (msoConfigPath == null) { + logger.info("Unable to find the system property mso.config.path, use the default configuration"); + msoConfigPath = StringUtils.defaultString(asdcConfig.getPropertyOrNull("mso.config.defaultpath")); + } + logger.info("MSO config path is: {}", msoConfigPath); + return msoConfigPath; + } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java index daeda2f976..b634c26cf0 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpResponse; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.so.asdc.installer.VfResourceStructure; @@ -88,7 +89,7 @@ public class WorkflowResource { logger.debug("Response entity: {}", response.getEntity().toString()); if (response.getStatusLine().getStatusCode() != 200) { logger.debug("Failed deploying BPMN {}", bpmnName); - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), bpmnName, + logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), bpmnName, bpmnName, Integer.toString(response.getStatusLine().getStatusCode()), ErrorCode.DataError.getValue(), "ASDC BPMN deploy failed"); throw (new Exception("Error from Camunda on deploying the BPMN: " + bpmnName)); @@ -97,7 +98,7 @@ public class WorkflowResource { } } catch (Exception e) { logger.debug("Exception :", e); - logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), bpmnName, + logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), bpmnName, e.getMessage(), ErrorCode.DataError.getValue(), "ASDC BPMN deploy failed"); throw e; } 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 edf8ff338c..d250021d19 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 @@ -38,7 +38,7 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import org.hibernate.StaleObjectStateException; +import org.onap.so.logger.LoggingAnchor; import org.hibernate.exception.ConstraintViolationException; import org.hibernate.exception.LockAcquisitionException; import org.onap.sdc.api.notification.IArtifactInfo; @@ -81,6 +81,7 @@ 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.so.db.catalog.beans.HeatTemplateParam; +import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.InstanceGroupType; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkInstanceGroup; @@ -294,6 +295,7 @@ public class ToscaResourceInstaller { status = vfResourceStructure.isDeployedSuccessfully(); } catch (RuntimeException e) { status = false; + logger.debug("Exception :", e); } try { Service existingService = @@ -323,8 +325,8 @@ public class ToscaResourceInstaller { } return status; } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(), - "Exception - isResourceAlreadyDeployed"); + logger.error(LoggingAnchor.THREE, MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), + ErrorCode.SchemaError.getValue(), "Exception - isResourceAlreadyDeployed"); throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e); } } @@ -394,7 +396,7 @@ public class ToscaResourceInstaller { if (dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) { - logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(), + logger.warn(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(), resourceStruct.getResourceInstance().getResourceName(), resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(), "Exception - ASCDC Artifact already deployed", e); @@ -402,7 +404,7 @@ public class ToscaResourceInstaller { String elementToLog = (!artifactListForLogging.isEmpty() ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString() : "No element listed"); - logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog, + logger.error(LoggingAnchor.FOUR, MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog, ErrorCode.DataError.getValue(), "Exception caught during installation of " + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback", e); @@ -431,7 +433,6 @@ public class ToscaResourceInstaller { for (NodeTemplate nodeTemplate : vfNodeTemplatesList) { Metadata metadata = nodeTemplate.getMetaData(); - String serviceType = toscaResourceStruct.getCatalogService().getServiceType(); String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper() .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY); processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata, @@ -474,7 +475,7 @@ public class ToscaResourceInstaller { if (dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) { - logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(), + logger.warn(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(), vfResourceStructure.getResourceInstance().getResourceName(), vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(), "Exception - ASCDC Artifact already deployed", e); @@ -482,7 +483,7 @@ public class ToscaResourceInstaller { String elementToLog = (!artifactListForLogging.isEmpty() ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString() : "No element listed"); - logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog, + logger.error(LoggingAnchor.FOUR, MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog, ErrorCode.DataError.getValue(), "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() @@ -498,7 +499,7 @@ public class ToscaResourceInstaller { List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates, ISdcCsarHelper iSdcCsarHelper) { - List<NodeTemplate> nodes = new ArrayList<NodeTemplate>(); + List<NodeTemplate> nodes = new ArrayList<>(); nodes.addAll(nodeTemplates); for (NodeTemplate nodeTemplate : nodeTemplates) { @@ -529,12 +530,12 @@ public class ToscaResourceInstaller { // This method retrieve resource sequence from csar file void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) { - List<String> resouceSequence = new ArrayList<String>(); - List<NodeTemplate> resultList = new ArrayList<NodeTemplate>(); + List<String> resouceSequence = new ArrayList<>(); + List<NodeTemplate> resultList = new ArrayList<>(); ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper(); List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates(); - List<NodeTemplate> nodes = new ArrayList<NodeTemplate>(); + List<NodeTemplate> nodes = new ArrayList<>(); nodes.addAll(nodeTemplates); for (NodeTemplate nodeTemplate : nodeTemplates) { @@ -696,14 +697,13 @@ public class ToscaResourceInstaller { .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); configCustomizationResource.setModelInstanceName(nodeTemplate.getName()); - configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); - configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)); - configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)); - configCustomizationResource - .setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID()); + configCustomizationResource.setFunction( + toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function")); + configCustomizationResource.setRole( + toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role")); + configCustomizationResource.setType( + toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type")); + configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization); configCustomizationResource.setConfigurationResource(configResource); configCustomizationResource.setService(service); @@ -723,9 +723,8 @@ public class ToscaResourceInstaller { List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION); - List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>(); - List<ConfigurationResourceCustomization> configurationResourceList = - new ArrayList<ConfigurationResourceCustomization>(); + List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<>(); + List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<>(); ServiceProxyResourceCustomization serviceProxy = null; @@ -740,8 +739,8 @@ public class ToscaResourceInstaller { toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll(); for (RequirementAssignment requirement : requirementsList) { if (requirement.getNodeTemplateName().equals(spNode.getName())) { - ConfigurationResourceCustomization configurationResource = - createConfiguration(configNode, toscaResourceStruct, serviceProxy, service); + ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, + toscaResourceStruct, serviceProxy, service, configurationResourceList); Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream() @@ -978,8 +977,8 @@ public class ToscaResourceInstaller { VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service); - Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>(); - Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>(); + Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>(); + Set<VnfcCustomization> existingVnfcSet = new HashSet<>(); for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { @@ -1111,7 +1110,7 @@ public class ToscaResourceInstaller { } } - if (tempGroupList.size() != 0 && tempGroupList.size() < groupList.size()) { + if (!tempGroupList.isEmpty() && tempGroupList.size() < groupList.size()) { getVNFCGroupSequenceList(strSequence, tempGroupList, nodes, iSdcCsarHelper); } } @@ -1157,7 +1156,8 @@ public class ToscaResourceInstaller { break; case ASDCConfiguration.HEAT_NET: case ASDCConfiguration.OTHER: - logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(), + case ASDCConfiguration.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT: + logger.warn(LoggingAnchor.FOUR, MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(), vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")", ErrorCode.DataError.getValue(), "Artifact type not supported"); @@ -1267,6 +1267,8 @@ public class ToscaResourceInstaller { vfModuleArtifact.getArtifactInfo().getArtifactUUID()); heatTemplate.setParameters(heatParam); vfModuleArtifact.setHeatTemplate(heatTemplate); + } else { + vfModuleArtifact.setHeatTemplate(existingHeatTemplate); } } @@ -1295,6 +1297,8 @@ public class ToscaResourceInstaller { heatEnvironment.setArtifactChecksum(MANUAL_RECORD); } vfModuleArtifact.setHeatEnvironment(heatEnvironment); + } else { + vfModuleArtifact.setHeatEnvironment(existingHeatEnvironment); } } @@ -1319,7 +1323,8 @@ public class ToscaResourceInstaller { heatFile.setArtifactChecksum(MANUAL_RECORD); } vfModuleArtifact.setHeatFiles(heatFile); - + } else { + vfModuleArtifact.setHeatFiles(existingHeatFiles); } } @@ -1350,6 +1355,13 @@ public class ToscaResourceInstaller { service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); service.setCsar(toscaResourceStructure.getCatalogToscaCsar()); + service.setNamingPolicy(serviceMetadata.getValue("namingPolicy")); + String generateNaming = serviceMetadata.getValue("ecompGeneratedNaming"); + Boolean generateNamingValue = null; + if (generateNaming != null) { + generateNamingValue = "true".equalsIgnoreCase(generateNaming); + } + service.setOnapGeneratedNaming(generateNamingValue); } @@ -1394,24 +1406,23 @@ public class ToscaResourceInstaller { protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization, - Service service) { + Service service, List<ConfigurationResourceCustomization> configurationResourceList) { ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization( nodeTemplate, toscaResourceStructure, spResourceCustomization, service); - ConfigurationResource configResource = getConfigurationResource(nodeTemplate); - - Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>(); - - configCustomizationResource.setConfigurationResource(configResource); - - configResourceCustomizationSet.add(configCustomizationResource); + ConfigurationResource configResource = null; - configResource.setConfigurationResourceCustomization(configResourceCustomizationSet); + ConfigurationResource existingConfigResource = findExistingConfiguration(service, + nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID), configurationResourceList); - toscaResourceStructure.setCatalogConfigurationResource(configResource); + if (existingConfigResource == null) { + configResource = getConfigurationResource(nodeTemplate); + } else { + configResource = existingConfigResource; + } - toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource); + configCustomizationResource.setConfigurationResource(configResource); return configCustomizationResource; } @@ -1648,7 +1659,7 @@ public class ToscaResourceInstaller { List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>(); List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = - new ArrayList<CollectionResourceInstanceGroupCustomization>(); + new ArrayList<>(); for (Group group : groupList) { @@ -1811,16 +1822,25 @@ public class ToscaResourceInstaller { VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) { Metadata instanceMetadata = group.getMetadata(); - // Populate InstanceGroup + + InstanceGroup existingInstanceGroup = + instanceGroupRepo.findByModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup(); - vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - vfcInstanceGroup.setToscaNodeType(group.getType()); - vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role - vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type + if (existingInstanceGroup == null) { + // Populate InstanceGroup + vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + vfcInstanceGroup + .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + vfcInstanceGroup.setToscaNodeType(group.getType()); + vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role + vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type + } else { + vfcInstanceGroup = (VFCInstanceGroup) existingInstanceGroup; + } // Populate VNFCInstanceGroupCustomization VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization(); @@ -1934,10 +1954,9 @@ public class ToscaResourceInstaller { // * Extract VFC's and CVFC's then add them to VFModule // ****************************************************************************************************************** - Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = - new HashSet<CvnfcConfigurationCustomization>(); - Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>(); - Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>(); + Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new HashSet<>(); + Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<>(); + Set<VnfcCustomization> vnfcCustomizations = new HashSet<>(); // Only set the CVNFC if this vfModule group is a member of it. List<NodeTemplate> groupMembers = @@ -2145,6 +2164,19 @@ public class ToscaResourceInstaller { return configResource; } + protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID, + List<ConfigurationResourceCustomization> configurationResourceList) { + ConfigurationResource configResource = null; + for (ConfigurationResourceCustomization configurationResourceCustom : configurationResourceList) { + if (configurationResourceCustom.getConfigurationResource() != null + && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) { + configResource = configurationResourceCustom.getConfigurationResource(); + } + } + + return configResource; + } + protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource, String vfModuleModelCustomizationUUID) { VfModuleCustomization vfModuleCustomization = null; @@ -2253,14 +2285,14 @@ public class ToscaResourceInstaller { if (matchingObject.isPresent()) { List<HeatFiles> heatFilesList = new ArrayList<>(); - List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>(); - List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>(); + List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<>(); + List<HeatTemplate> heatChildTemplates = new ArrayList<>(); HeatTemplate parentHeatTemplate = new HeatTemplate(); String parentArtifactType = null; Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts()); for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { - List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>(); + List<HeatTemplate> childNestedHeatTemplates = new ArrayList<>(); if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) { checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact, @@ -2577,7 +2609,7 @@ public class ToscaResourceInstaller { if (object == null) { return null; - } else if (object.equals("NULL")) { + } else if ("NULL".equals(object)) { return null; } else if (object instanceof Integer) { return object.toString(); @@ -2649,7 +2681,7 @@ public class ToscaResourceInstaller { // existing customization available in db. private void addVnfCustomization(Service service, VnfResourceCustomization vnfResourceCustomization) { List<Service> services = serviceRepo.findByModelUUID(service.getModelUUID()); - if (services.size() > 0) { + if (!services.isEmpty()) { // service exist in db Service existingService = services.get(0); List<VnfResourceCustomization> vnfCustomizations = existingService.getVnfCustomizations(); diff --git a/asdc-controller/src/main/resources/application.yaml b/asdc-controller/src/main/resources/application.yaml index 2d0a2acf94..beb40e5e65 100644 --- a/asdc-controller/src/main/resources/application.yaml +++ b/asdc-controller/src/main/resources/application.yaml @@ -4,15 +4,13 @@ server: spring: datasource: - jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb - username: ${DB_USERNAME} - password: ${DB_PASSWORD} - driver-class-name: org.mariadb.jdbc.Driver - dbcp2: - initial-size: 5 - max-total: 20 - validation-query: select 1 - test-on-borrow: true + hikari: + jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb + username: ${DB_USERNAME} + password: ${DB_PASSWORD} + driver-class-name: org.mariadb.jdbc.Driver + pool-name: catdb-pool + registerMbeans: true jpa: show-sql: true hibernate: @@ -23,10 +21,14 @@ spring: request: datasource: - jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb - username: ${DB_USERNAME} - password: ${DB_PASSWORD} - driver-class-name: org.mariadb.jdbc.Driver + hikari: + jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb + username: ${DB_USERNAME} + password: ${DB_PASSWORD} + driver-class-name: org.mariadb.jdbc.Driver + pool-name: reqdb-pool + registerMbeans: true + #Actuator management: endpoints: |