summaryrefslogtreecommitdiffstats
path: root/asdc-controller
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java14
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java16
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java17
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java15
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java13
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java100
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java8
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java4
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java7
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java34
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java2
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java5
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java15
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java11
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java5
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java334
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java14
-rw-r--r--asdc-controller/src/main/resources/application.yaml28
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java26
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java59
-rw-r--r--asdc-controller/src/test/resources/schema.sql6
21 files changed, 514 insertions, 219 deletions
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 619d89438e..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;
@@ -68,9 +69,9 @@ public class ActivitySpecsActions {
int statusCode = response.getStatus();
if (statusCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) {
- logger.warn("{} {} {}", "ActivitySpec", activitySpec.getName(), "already exists in SDC");
+ logger.warn(LoggingAnchor.THREE, "ActivitySpec", activitySpec.getName(), "already exists in SDC");
} else if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED) {
- logger.warn("{} {} {}", "Error creating activity spec", activitySpec.getName(), statusCode);
+ logger.warn(LoggingAnchor.THREE, "Error creating activity spec", activitySpec.getName(), statusCode);
} else {
if (response.getEntity() != null) {
ActivitySpecCreateResponse activitySpecCreateResponse =
@@ -78,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;
@@ -111,15 +112,15 @@ public class ActivitySpecsActions {
int statusCode = response.getStatus();
if (statusCode == HttpStatus.SC_UNPROCESSABLE_ENTITY) {
- logger.warn("{} {} {}", "ActivitySpec with id", activitySpecId, "is already certified in SDC");
+ logger.warn(LoggingAnchor.THREE, "ActivitySpec with id", activitySpecId, "is already certified in SDC");
} else if (statusCode != HttpStatus.SC_OK) {
- logger.warn("{} {} {}", "Error certifying activity", activitySpecId, statusCode);
+ 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 54da1b9247..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,6 +22,7 @@ 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;
@@ -66,15 +67,15 @@ public class DeployActivitySpecs {
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());
}
}
}
@@ -94,7 +95,7 @@ public class DeployActivitySpecs {
if (activitySpecActivitySpecCategories == null || activitySpecActivitySpecCategories.size() == 0) {
return;
}
- List<String> categoryList = new ArrayList<String>();
+ List<String> categoryList = new ArrayList<>();
for (ActivitySpecActivitySpecCategories activitySpecCat : activitySpecActivitySpecCategories) {
if (activitySpecCat != null) {
if (activitySpecCat.getActivitySpecCategories() != null) {
@@ -110,8 +111,8 @@ public class DeployActivitySpecs {
if (activitySpecActivitySpecParameters == null || activitySpecActivitySpecParameters.size() == 0) {
return;
}
- List<Input> inputs = new ArrayList<Input>();
- List<Output> outputs = new ArrayList<Output>();
+ List<Input> inputs = new ArrayList<>();
+ List<Output> outputs = new ArrayList<>();
for (ActivitySpecActivitySpecParameters activitySpecParam : activitySpecActivitySpecParameters) {
if (activitySpecParam != null) {
if (activitySpecParam.getActivitySpecParameters() != null) {
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 60abdc33ef..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
@@ -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";
@@ -74,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;
}
@@ -96,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");
@@ -172,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;
}
}
@@ -194,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 c0f403f388..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;
@@ -79,6 +80,8 @@ public class ASDCController {
protected static final Logger logger = LoggerFactory.getLogger(ASDCController.class);
+ private static final String UNKNOWN = "Unknown";
+
protected boolean isAsdcClientAutoManaged = false;
protected String controllerName;
@@ -117,6 +120,25 @@ public class ASDCController {
@Autowired
DeployActivitySpecs deployActivitySpecs;
+ public ASDCController() {
+ this("");
+ }
+
+ public ASDCController(String controllerConfigName) {
+ isAsdcClientAutoManaged = true;
+ this.controllerName = controllerConfigName;
+ }
+
+ public ASDCController(String controllerConfigName, IDistributionClient asdcClient,
+ IVfResourceInstaller resourceinstaller) {
+ distributionClient = asdcClient;
+ }
+
+ public ASDCController(String controllerConfigName, IDistributionClient asdcClient) {
+ distributionClient = asdcClient;
+ this.controllerName = controllerConfigName;
+ }
+
public int getNbOfNotificationsOngoing() {
return nbOfNotificationsOngoing;
}
@@ -157,25 +179,6 @@ public class ASDCController {
return this.controllerStatus;
}
- public ASDCController() {
- this("");
- }
-
- public ASDCController(String controllerConfigName) {
- isAsdcClientAutoManaged = true;
- this.controllerName = controllerConfigName;
- }
-
- public ASDCController(String controllerConfigName, IDistributionClient asdcClient,
- IVfResourceInstaller resourceinstaller) {
- distributionClient = asdcClient;
- }
-
- public ASDCController(String controllerConfigName, IDistributionClient asdcClient) {
- distributionClient = asdcClient;
- this.controllerName = controllerConfigName;
- }
-
public String getControllerName() {
return controllerName;
}
@@ -230,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");
}
/**
@@ -262,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());
@@ -332,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) {
@@ -344,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");
@@ -389,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");
@@ -409,7 +414,7 @@ public class ASDCController {
for (IArtifactInfo artifactInfo : resourceStructure.getResourceInstance().getArtifacts()) {
if ((DistributionStatusEnum.DEPLOY_OK.equals(distribStatus)
- && !artifactInfo.getArtifactType().equalsIgnoreCase("OTHER")
+ && !("OTHER").equalsIgnoreCase(artifactInfo.getArtifactType())
&& !resourceStructure.isAlreadyDeployed())
// This could be NULL if the artifact is a VF module artifact, this won't be present in the MAP
&& resourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null
@@ -442,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 {
@@ -450,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");
@@ -459,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");
@@ -482,11 +487,11 @@ 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);
- String action = "";
+
try {
IDistributionStatusMessage message =
new DistributionStatusMessage(artifactURL, consumerID, distributionID, status, timestamp);
@@ -498,7 +503,7 @@ public class ASDCController {
} else {
this.distributionClient.sendDownloadStatus(message);
}
- action = "sendDownloadStatus";
+
break;
case DEPLOY:
if (errorReason != null) {
@@ -506,13 +511,13 @@ public class ASDCController {
} else {
this.distributionClient.sendDeploymentStatus(message);
}
- action = "sendDeploymentdStatus";
+
break;
default:
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);
}
@@ -539,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);
}
@@ -568,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);
@@ -641,6 +646,8 @@ public class ASDCController {
}
}
+ wd.updateCatalogDBStatus(iNotif.getServiceInvariantUUID(), overallStatus);
+
if (isDeploySuccess && watchdogError == null) {
sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK,
null);
@@ -655,14 +662,13 @@ public class ASDCController {
wdsRepo.save(wds);
}
-
} catch (ObjectOptimisticLockingFailureException e) {
logger.debug(
"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);
@@ -804,7 +810,7 @@ public class ASDCController {
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);
}
@@ -850,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);
@@ -871,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);
@@ -882,7 +888,7 @@ public class ASDCController {
}
}
- private static final String UNKNOWN = "Unknown";
+
/**
* @return the address of the ASDC we are connected to.
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java
index f4d3e5ce48..20cd9801e9 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java
@@ -33,16 +33,16 @@ public class JsonVfModuleMetaData implements IVfModuleData {
@JsonProperty("artifacts")
private List<String> artifacts;
@JsonProperty("properties")
- // private List<Map<String, Object>> properties = new ArrayList<>();
+
private Map<String, String> properties = new HashMap<>();
+ @JsonIgnore
+ private Map<String, Object> attributesMap = new HashMap<>();
+
public Map<String, String> getProperties() {
return properties;
}
- @JsonIgnore
- private Map<String, Object> attributesMap = new HashMap<>();
-
@Override
public List<String> getArtifacts() {
return artifacts;
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
index c61306fb77..9fd5c2adeb 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
@@ -124,7 +124,7 @@ public class NotificationDataImpl implements INotificationData {
@Override
public List<IResourceInstance> getResources() {
- List<IResourceInstance> ret = new ArrayList<IResourceInstance>();
+ List<IResourceInstance> ret = new ArrayList<>();
if (resources != null) {
ret.addAll(resources);
}
@@ -145,7 +145,7 @@ public class NotificationDataImpl implements INotificationData {
@Override
public List<IArtifactInfo> getServiceArtifacts() {
- List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ List<IArtifactInfo> temp = new ArrayList<>();
if (serviceArtifacts != null) {
temp.addAll(serviceArtifacts);
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
index 62d11ffec9..2f109cd9d3 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
@@ -31,7 +31,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResourceInfoImpl implements IResourceInstance {
- public ResourceInfoImpl() {}
private String resourceInstanceName;
private String resourceCustomizationUUID;
@@ -44,6 +43,8 @@ public class ResourceInfoImpl implements IResourceInstance {
private String subcategory;
private List<ArtifactInfoImpl> artifacts;
+ public ResourceInfoImpl() {}
+
private ResourceInfoImpl(IResourceInstance resourceInstance) {
resourceInstanceName = resourceInstance.getResourceInstanceName();
resourceCustomizationUUID = resourceInstance.getResourceCustomizationUUID();
@@ -58,7 +59,7 @@ public class ResourceInfoImpl implements IResourceInstance {
}
public static List<ResourceInfoImpl> convertToJsonContainer(List<IResourceInstance> resources) {
- List<ResourceInfoImpl> buildResources = new ArrayList<ResourceInfoImpl>();
+ List<ResourceInfoImpl> buildResources = new ArrayList<>();
if (resources != null) {
for (IResourceInstance resourceInstance : resources) {
buildResources.add(new ResourceInfoImpl(resourceInstance));
@@ -114,7 +115,7 @@ public class ResourceInfoImpl implements IResourceInstance {
@Override
public List<IArtifactInfo> getArtifacts() {
- List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ List<IArtifactInfo> temp = new ArrayList<>();
if (artifacts != null) {
temp.addAll(artifacts);
}
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 14ea0cde4b..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;
@@ -50,13 +51,12 @@ import org.springframework.stereotype.Component;
* This is a TEST only rest interface. It is not used in production, it is used to aid in testing the ASDC service on
* jboss without the need to be connected to the ASDC service broker. It starts the test at the treatNotification step
* and simulates both the notification step as well as the artifact download step.
- *
+ * <p>
* i.e. http://localhost:8080/asdc/treatNotification/v1
- *
+ * <p>
* i.e. http://localhost:8080/asdc/statusData/v1
- *
- * @author jm5423
*
+ * @author jm5423
*/
@Path("/")
@@ -64,10 +64,6 @@ import org.springframework.stereotype.Component;
@Profile("test")
public class ASDCRestInterface {
- private static DistributionClientEmulator distributionClientEmulator;
-
- private static JsonStatusData statusData;
-
private static final Logger logger = LoggerFactory.getLogger(ASDCRestInterface.class);
@Autowired
@@ -83,7 +79,7 @@ public class ASDCRestInterface {
public Response invokeASDCService(NotificationDataImpl request,
@HeaderParam("resource-location") String resourceLocation)
throws ASDCControllerException, ASDCParametersException, IOException {
- distributionClientEmulator = new DistributionClientEmulator(resourceLocation);
+ DistributionClientEmulator distributionClientEmulator = new DistributionClientEmulator(resourceLocation);
asdcController.setControllerName("asdc-controller1");
asdcController.setDistributionClient(distributionClientEmulator);
@@ -100,22 +96,24 @@ public class ASDCRestInterface {
public Response invokeASDCStatusData(String request) {
try {
- distributionClientEmulator = new DistributionClientEmulator("resource-examples/");
- statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
+ DistributionClientEmulator distributionClientEmulator =
+ new DistributionClientEmulator("resource-examples/");
+ JsonStatusData statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
- ASDCController asdcController = new ASDCController("asdc-controller1", distributionClientEmulator);
- asdcController.initASDC();
+ ASDCController controller = new ASDCController("asdc-controller1", distributionClientEmulator);
+ controller.initASDC();
toscaInstaller.installTheComponentStatus(statusData);
- asdcController.closeASDC();
+ controller.closeASDC();
+
+ 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);
}
- logger.info("ASDC Updates are complete");
- logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), statusData.getDistributionID(),
- "ASDC", "ASDC Updates Are Complete");
+
return null;
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
index 043055e23c..81b0843671 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
@@ -47,7 +47,7 @@ public class ASDCElementInfo {
* <li>{@link ASDCElementTypeEnum#VNF_RESOURCE}</li>
* <ul>
*/
- public static enum ASDCElementTypeEnum {
+ public enum ASDCElementTypeEnum {
/**
* The type VNF_RESOURCE. Represents a VNF_RESOURCE element.
*/
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 0f58a21747..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:
@@ -133,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) {
@@ -148,6 +150,7 @@ public class VfResourceStructure extends ResourceStructure {
return vfModulesStructureList;
}
+ @Override
public Map<String, VfModuleArtifact> getArtifactsMapByUUID() {
return artifactsMapByUUID;
}
@@ -204,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 0379e2a423..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,6 +33,7 @@ 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;
@@ -88,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 {
@@ -96,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");
}
}
@@ -105,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;
@@ -124,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;
}
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 b3c7776c9a..46c440db0d 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;
@@ -104,7 +105,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));
@@ -113,7 +114,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 ca5cdf4fde..30196379a3 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
@@ -26,6 +26,7 @@ package org.onap.so.asdc.installer.heat;
import java.sql.Timestamp;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -34,8 +35,10 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
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;
@@ -47,14 +50,7 @@ import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.CapabilityAssignment;
-import org.onap.sdc.toscaparser.api.CapabilityAssignments;
-import org.onap.sdc.toscaparser.api.Group;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
-import org.onap.sdc.toscaparser.api.Policy;
-import org.onap.sdc.toscaparser.api.Property;
-import org.onap.sdc.toscaparser.api.RequirementAssignment;
-import org.onap.sdc.toscaparser.api.RequirementAssignments;
+import org.onap.sdc.toscaparser.api.*;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.toscaparser.api.functions.GetInput;
import org.onap.sdc.toscaparser.api.parameters.Input;
@@ -146,6 +142,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.util.CollectionUtils;
@Component
public class ToscaResourceInstaller {
@@ -298,6 +295,7 @@ public class ToscaResourceInstaller {
status = vfResourceStructure.isDeployedSuccessfully();
} catch (RuntimeException e) {
status = false;
+ logger.debug("Exception :", e);
}
try {
Service existingService =
@@ -327,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);
}
}
@@ -398,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);
@@ -406,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);
@@ -435,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,
@@ -479,7 +476,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);
@@ -487,7 +484,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()
@@ -503,7 +500,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) {
@@ -534,12 +531,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) {
@@ -565,27 +562,31 @@ public class ToscaResourceInstaller {
logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
}
- private static String getValue(Object value, List<Input> servInputs) {
- String output = null;
+
+ // this of temporary solution
+ private static String getValue(Object value, List<Input> inputs) {
+ String outInput;
+ String defaultValue = null;
if (value instanceof Map) {
- // currently this logic handles only one level of nesting.
- return ((LinkedHashMap) value).values().toArray()[0].toString();
+ outInput = ((LinkedHashMap) value).values().toArray()[0].toString();
} else if (value instanceof GetInput) {
String inputName = ((GetInput) value).getInputName();
-
- for (Input input : servInputs) {
- if (input.getName().equals(inputName)) {
- // keep both input name and default value
- // if service input does not supplies value the use default value
- String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
- output = inputName + "|" + defaultValue;// return default value
- }
+ Optional<Input> inputOptional =
+ inputs.stream().filter(input -> input.getName().equals(inputName)).findFirst();
+ if (inputOptional.isPresent()) {
+ Input input = inputOptional.get();
+ defaultValue = input.getDefault() != null ? input.getDefault().toString() : "";
}
-
+ // Gets a value between [ and ]
+ String regex = "\\[.*?\\]";
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(value.toString());
+ String valueStr = matcher.find() ? matcher.group() : inputName;
+ outInput = valueStr + "|" + defaultValue;
} else {
- output = value != null ? value.toString() : "";
+ outInput = value != null ? value.toString() : "";
}
- return output; // return property value
+ return outInput;
}
String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid)
@@ -697,14 +698,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);
@@ -724,9 +724,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;
@@ -741,8 +740,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()
@@ -979,8 +978,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()) {
@@ -1022,8 +1021,15 @@ public class ToscaResourceInstaller {
vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
}
-
- service.getVnfCustomizations().add(vnfResource);
+ List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, groupList);
+ if (!CollectionUtils.isEmpty(seqResult)) {
+ String resultStr = seqResult.stream().collect(Collectors.joining(","));
+ vnfResource.setVnfcInstanceGroupOrder(resultStr);
+ logger.debug(
+ "vnfcGroupOrder result for service uuid(" + service.getModelUUID() + ") : " + resultStr);
+ }
+ // add this vnfResource with existing vnfResource for this service
+ addVnfCustomization(service, vnfResource);
} else {
logger.debug("Notification VF ResourceCustomizationUUID: "
+ vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
@@ -1032,6 +1038,85 @@ public class ToscaResourceInstaller {
}
}
+ private List<String> processVNFCGroupSequence(ToscaResourceStructure toscaResourceStructure,
+ List<Group> groupList) {
+ if (CollectionUtils.isEmpty(groupList)) {
+ return Collections.emptyList();
+ }
+
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+ List<String> strSequence = new ArrayList<>(groupList.size());
+ List<Group> tempGroupList = new ArrayList<>(groupList.size());
+ List<NodeTemplate> nodes = new ArrayList<>();
+ tempGroupList.addAll(groupList);
+
+ for (Group group : groupList) {
+ List<NodeTemplate> nodeList = group.getMemberNodes();
+ boolean hasRequirements = false;
+ for (NodeTemplate node : nodeList) {
+ RequirementAssignments requirements = iSdcCsarHelper.getRequirementsOf(node);
+ if (requirements != null && requirements.getAll() != null && !requirements.getAll().isEmpty()) {
+ hasRequirements = true;
+ break;
+ }
+ }
+
+ if (!hasRequirements) {
+ strSequence.add(group.getName());
+ tempGroupList.remove(group);
+ nodes.addAll(nodeList);
+ }
+ }
+
+ getVNFCGroupSequenceList(strSequence, tempGroupList, nodes, iSdcCsarHelper);
+
+ return strSequence;
+
+ }
+
+ private void getVNFCGroupSequenceList(List<String> strSequence, List<Group> groupList, List<NodeTemplate> nodes,
+ ISdcCsarHelper iSdcCsarHelper) {
+ if (CollectionUtils.isEmpty(groupList)) {
+ return;
+ }
+
+ List<Group> tempGroupList = new ArrayList<>();
+ tempGroupList.addAll(groupList);
+
+ for (Group group : groupList) {
+ ArrayList<NodeTemplate> members = group.getMemberNodes();
+ for (NodeTemplate memberNode : members) {
+ boolean isAllExists = true;
+ RequirementAssignments requirements = iSdcCsarHelper.getRequirementsOf(memberNode);
+ if (requirements == null || requirements.getAll() == null || requirements.getAll().isEmpty()) {
+ continue;
+ }
+ List<RequirementAssignment> rqaList = requirements.getAll();
+ for (RequirementAssignment rqa : rqaList) {
+ String name = rqa.getNodeTemplateName();
+ for (NodeTemplate node : nodes) {
+ if (name.equals(node.getName())) {
+ break;
+ }
+ }
+
+ isAllExists = false;
+ break;
+ }
+
+ if (isAllExists) {
+ strSequence.add(group.getName());
+ tempGroupList.remove(group);
+ nodes.addAll(group.getMemberNodes());
+ }
+ }
+
+ if (!tempGroupList.isEmpty() && tempGroupList.size() < groupList.size()) {
+ getVNFCGroupSequenceList(strSequence, tempGroupList, nodes, iSdcCsarHelper);
+ }
+ }
+ }
+
public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
String consumerId) {
WatchdogServiceModVerIdLookup modVerIdLookup =
@@ -1073,7 +1158,7 @@ public class ToscaResourceInstaller {
case ASDCConfiguration.HEAT_NET:
case ASDCConfiguration.OTHER:
case ASDCConfiguration.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT:
- logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
+ 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");
@@ -1271,6 +1356,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);
}
@@ -1315,24 +1407,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;
}
@@ -1569,7 +1660,7 @@ public class ToscaResourceInstaller {
List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList =
- new ArrayList<CollectionResourceInstanceGroupCustomization>();
+ new ArrayList<>();
for (Group group : groupList) {
@@ -1776,11 +1867,65 @@ public class ToscaResourceInstaller {
.getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
+ ArrayList<Input> inputs = vnfcNodeTemplate.getSubMappingToscaTemplate().getInputs();
+ createVFCInstanceGroupMembers(vfcInstanceGroupCustom, group, inputs);
return vfcInstanceGroupCustom;
}
+ private void createVFCInstanceGroupMembers(VnfcInstanceGroupCustomization vfcInstanceGroupCustom, Group group,
+ List<Input> inputList) {
+ List<NodeTemplate> members = group.getMemberNodes();
+ if (!CollectionUtils.isEmpty(members)) {
+ for (NodeTemplate vfcTemplate : members) {
+ VnfcCustomization vnfcCustomization = new VnfcCustomization();
+
+ Metadata metadata = vfcTemplate.getMetaData();
+ vnfcCustomization
+ .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vnfcCustomization.setModelInstanceName(vfcTemplate.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(vfcTemplate.getType()));
+ vnfcCustomization
+ .setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vnfcCustomization.setResourceInput(getVnfcResourceInput(vfcTemplate, inputList));
+ vfcInstanceGroupCustom.getVnfcCustomizations().add(vnfcCustomization);
+ }
+ }
+ }
+
+ public String getVnfcResourceInput(NodeTemplate vfcTemplate, List<Input> inputList) {
+ Map<String, String> resouceRequest = new HashMap<>();
+ LinkedHashMap<String, Property> vfcTemplateProperties = vfcTemplate.getProperties();
+ for (String key : vfcTemplateProperties.keySet()) {
+ Property property = vfcTemplateProperties.get(key);
+ String resourceValue = getValue(property.getValue(), inputList);
+ resouceRequest.put(key, resourceValue);
+ }
+
+ String resourceCustomizationUuid =
+ vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+
+ String jsonStr = null;
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ jsonStr = objectMapper.writeValueAsString(resouceRequest);
+ jsonStr = jsonStr.replace("\"", "\\\"");
+ logger.debug("vfcResource request for resource customization id (" + resourceCustomizationUuid + ") : "
+ + jsonStr);
+ } catch (JsonProcessingException e) {
+ logger.debug("Json Exception: {}", e.getMessage());
+ logger.error("Exception occurred", e);
+ }
+
+ return jsonStr;
+ }
+
protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
@@ -1810,10 +1955,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 =
@@ -2021,6 +2165,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;
@@ -2129,14 +2286,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,
@@ -2214,20 +2371,25 @@ public class ToscaResourceInstaller {
}
protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
+ ToscaResourceStructure toscaResourceStructure, Service service) throws ArtifactInstallerException {
VnfResourceCustomization vnfResourceCustomization = null;
if (vnfResourceCustomization == null) {
VnfResource vnfResource = findExistingVnfResource(service,
vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- if (vnfResource == null)
+ if (vnfResource == null) {
vnfResource = createVnfResource(vfNodeTemplate);
+ }
vnfResourceCustomization =
createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure, vnfResource);
vnfResourceCustomization.setVnfResources(vnfResource);
vnfResourceCustomization.setService(service);
- vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
+
+ // setting resource input for vnf customization
+ vnfResourceCustomization.setResourceInput(
+ getResourceInput(toscaResourceStructure, vnfResourceCustomization.getModelCustomizationUUID()));
+ service.getVnfCustomizations().add(vnfResourceCustomization);
}
return vnfResourceCustomization;
@@ -2297,6 +2459,13 @@ public class ToscaResourceInstaller {
}
+ if (vnfResourceCustomization.getMinInstances() == null && vnfResourceCustomization.getMaxInstances() == null) {
+ vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ }
+
toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
return vnfResourceCustomization;
@@ -2441,7 +2610,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();
@@ -2509,6 +2678,19 @@ public class ToscaResourceInstaller {
return inputName;
}
+ // this method add provided vnfCustomization to service with
+ // existing customization available in db.
+ private void addVnfCustomization(Service service, VnfResourceCustomization vnfResourceCustomization) {
+ List<Service> services = serviceRepo.findByModelUUID(service.getModelUUID());
+ if (!services.isEmpty()) {
+ // service exist in db
+ Service existingService = services.get(0);
+ List<VnfResourceCustomization> vnfCustomizations = existingService.getVnfCustomizations();
+ vnfCustomizations.forEach(e -> service.getVnfCustomizations().add(e));
+ }
+ service.getVnfCustomizations().add(vnfResourceCustomization);
+ }
+
protected static Timestamp getCurrentTimeStamp() {
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java
index 3659ceed12..0128078a59 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java
@@ -30,6 +30,7 @@ import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
@@ -140,7 +141,6 @@ public class WatchdogDistribution {
logger.debug("Updating overall DistributionStatus to: {} for distributionId: ", status,
distributionId);
- watchdogDistributionStatus.setDistributionIdStatus(status);
watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
} else {
logger.debug("Components Size Didn't match with the WatchdogComponentDistributionStatus results.");
@@ -181,6 +181,8 @@ public class WatchdogDistribution {
throw new Exception(error);
}
+
+
AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, serviceModelInvariantUUID,
serviceModelVersionId);
aaiUri.depth(Depth.ZERO); // Do not return relationships if any
@@ -198,6 +200,16 @@ public class WatchdogDistribution {
}
}
+ public void updateCatalogDBStatus(String serviceModelVersionId, String status) {
+ try {
+ Service foundService = serviceRepo.findOneByModelUUID(serviceModelVersionId);
+ foundService.setDistrobutionStatus(status);
+ serviceRepo.save(foundService);
+ } catch (Exception e) {
+ logger.error("Error updating CatalogDBStatus", e);
+ }
+ }
+
public AAIResourcesClient getAaiClient() {
if (aaiClient == null) {
aaiClient = new AAIResourcesClient();
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:
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
index 844adeede2..846eaf47e2 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
@@ -33,10 +33,7 @@ import org.onap.sdc.toscaparser.api.parameters.Input;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.asdc.installer.ToscaResourceStructure;
import org.onap.so.db.catalog.beans.Service;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
+import java.util.*;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
@@ -61,6 +58,27 @@ public class ToscaResourceInputTest {
Input input;
@Test
+ public void getListResourceInput() {
+ ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
+ LinkedHashMap<String, Property> hashMap = new LinkedHashMap<>();
+ hashMap.put("key1", property);
+ Map<String, Object> map = new HashMap<>();
+ map.put("customizationUUID", "69df3303-d2b3-47a1-9d04-41604d3a95fd");
+ Metadata metadata = new Metadata(map);
+ when(nodeTemplate.getProperties()).thenReturn(hashMap);
+ when(property.getValue()).thenReturn(getInput);
+ when(getInput.getInputName()).thenReturn("nameKey");
+ when(input.getName()).thenReturn("nameKey");
+ when(input.getDefault()).thenReturn("defaultValue");
+ when(getInput.toString()).thenReturn("getinput:[sites,INDEX,role]");
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ List<Input> inputs = new ArrayList<>();
+ inputs.add(input);
+ String resourceInput = toscaResourceInstaller.getVnfcResourceInput(nodeTemplate, inputs);
+ assertEquals("{\\\"key1\\\":\\\"[sites,INDEX,role]|defaultValue\\\"}", resourceInput);
+ }
+
+ @Test
public void processResourceSequenceTest() {
ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index dd107f7775..bd8e877369 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -34,6 +34,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import org.hibernate.exception.LockAcquisitionException;
import org.junit.Before;
import org.junit.Rule;
@@ -42,6 +43,7 @@ import org.junit.rules.ExpectedException;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcCsarHelperImpl;
@@ -56,6 +58,7 @@ import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl;
import org.onap.so.asdc.client.test.emulators.JsonStatusData;
import org.onap.so.asdc.client.test.emulators.NotificationDataImpl;
+import org.onap.so.asdc.installer.ResourceStructure;
import org.onap.so.asdc.installer.ToscaResourceStructure;
import org.onap.so.db.catalog.beans.ConfigurationResource;
import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
@@ -340,7 +343,59 @@ public class ToscaResourceInstallerTest extends BaseTest {
return actualWatchdogComponentDistributionStatus;
}
-
+ @Test
+ public void createServiceTest() {
+ ToscaResourceStructure toscaResourceStructure = mock(ToscaResourceStructure.class);
+ ResourceStructure resourceStructure = mock(ResourceStructure.class);
+ Metadata metadata = mock(Metadata.class);
+ INotificationData notification = mock(INotificationData.class);
+
+ doReturn("e2899e5c-ae35-434c-bada-0fabb7c1b44d").when(toscaResourceStructure).getServiceVersion();
+ doReturn(metadata).when(toscaResourceStructure).getServiceMetadata();
+ doReturn("production").when(notification).getWorkloadContext();
+ doReturn(notification).when(resourceStructure).getNotification();
+
+ String serviceType = "test-type";
+ String serviceRole = "test-role";
+ String category = "Network L4+";
+ String description = "Customer Orderable service description";
+ String name = "Customer Orderable Service";
+ String uuid = "72db5868-4575-4804-b546-0b0d3c3b5ac6";
+ String invariantUUID = "6f30bbe3-4590-4185-a7e0-4f9610926c6f";
+ String namingPolicy = "naming Policy";
+ String ecompGeneratedNaming = "true";
+ String environmentContext = "General_Revenue-Bearing";
+
+ doReturn(serviceType).when(metadata).getValue("serviceType");
+ doReturn(serviceRole).when(metadata).getValue("serviceRole");
+
+ doReturn(category).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ doReturn(description).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION);
+
+ doReturn(name).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+
+ doReturn(uuid).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+
+ doReturn(environmentContext).when(metadata).getValue(metadata.getValue("environmentContext"));
+ doReturn(invariantUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
+ doReturn(namingPolicy).when(metadata).getValue("namingPolicy");
+ doReturn(ecompGeneratedNaming).when(metadata).getValue("ecompGeneratedNaming");
+
+ Service service = toscaInstaller.createService(toscaResourceStructure, resourceStructure);
+
+ assertNotNull(service);
+
+ verify(toscaResourceStructure, times(2)).getServiceVersion();
+ assertNotNull(service.getNamingPolicy());
+ assertEquals(serviceType, service.getServiceType());
+ assertEquals(serviceRole, service.getServiceRole());
+ assertEquals(category, service.getCategory());
+ assertEquals(description, service.getDescription());
+ assertEquals(uuid, service.getModelUUID());
+ assertEquals(invariantUUID, service.getModelInvariantUUID());
+ assertEquals(namingPolicy, service.getNamingPolicy());
+ assertTrue(service.getOnapGeneratedNaming());
+ }
private void prepareConfigurationResource() {
doReturn(metadata).when(nodeTemplate).getMetaData();
@@ -396,7 +451,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
assertNotNull(configurationResourceCustomization);
assertNotNull(configurationResourceCustomization.getConfigurationResource());
assertEquals(MockConstants.MODEL_CUSTOMIZATIONUUID,
- configurationResourceCustomization.getServiceProxyResourceCustomizationUUID());
+ configurationResourceCustomization.getServiceProxyResourceCustomization().getModelCustomizationUUID());
}
@Test
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index 8cc5ee9d49..5e4af83e0e 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -806,6 +806,9 @@ CREATE TABLE `service` (
`WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL,
`SERVICE_CATEGORY` varchar(200) DEFAULT NULL,
`RESOURCE_ORDER` varchar(200) default NULL,
+ `OVERALL_DISTRIBUTION_STATUS` varchar(45),
+ `ONAP_GENERATED_NAMING` TINYINT(1) DEFAULT NULL,
+ `NAMING_POLICY` varchar(200) DEFAULT NULL,
PRIMARY KEY (`MODEL_UUID`),
KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`),
CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
@@ -1109,6 +1112,7 @@ CREATE TABLE `vnf_resource_customization` (
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
`SERVICE_MODEL_UUID` varchar(200) NOT NULL,
+ `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`),
KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`),
@@ -1135,6 +1139,8 @@ CREATE TABLE `vnfc_customization` (
`MODEL_NAME` varchar(200) NOT NULL,
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
+ `RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;