From 66481e1dd76fbfa22f41ec0ce453336221cf9ae8 Mon Sep 17 00:00:00 2001 From: eeginux Date: Sat, 16 Mar 2019 16:07:16 +0000 Subject: [PATCH] PNF ingestion in SO catalogdb Support PNF csar ingestion in SO catalogdb Add integation test for TOSCA installer Fix the VNF resource/resource customization insert https://jira.onap.org/browse/SO-1604 subtask so-1607 and SO-1608 are included The catalogdb table contents are attached in the jira Issue-ID: SO-1604 Change-Id: Ie08c4a1219a6cce96ba081b0dd9d3e5fd997da8f Signed-off-by: eeginux --- .../so/db/catalog/client/CatalogDbClientTest.java | 13 +- asdc-controller/pom.xml | 529 +-- .../org/onap/so/asdc/client/ASDCController.java | 1066 +++-- .../client/test/emulators/ArtifactInfoImpl.java | 2 +- .../test/emulators/NotificationDataImpl.java | 4 + .../client/test/emulators/ResourceInfoImpl.java | 2 +- .../so/asdc/installer/PnfResourceStructure.java | 50 + .../onap/so/asdc/installer/ResourceStructure.java | 152 + .../org/onap/so/asdc/installer/ResourceType.java | 41 + .../so/asdc/installer/ToscaResourceStructure.java | 43 +- .../onap/so/asdc/installer/VfModuleArtifact.java | 3 +- .../so/asdc/installer/VfResourceStructure.java | 337 +- .../installer/heat/ToscaResourceInstaller.java | 4314 +++++++++++--------- .../onap/so/asdc/client/ASDCControllerITTest.java | 442 ++ asdc-controller/src/test/resources/ASDC/.gitignore | 2 +- .../src/test/resources/application-test.yaml | 4 +- .../resources/download/service-Svc140-VF-csar.csar | Bin 0 -> 35636 bytes .../download/service-Testservice140-csar.csar | Bin 0 -> 35457 bytes asdc-controller/src/test/resources/schema.sql | 55 +- .../tasks/ExtractPojosForBB.java | 2 +- .../repository/PnfCustomizationRepository.java | 3 - .../repository/VnfCustomizationRepository.java | 15 +- .../repository/PnfCustomizationRepositoryTest.java | 4 - .../repository/VnfCustomizationRepositoryTest.java | 3 +- mso-catalog-db/src/test/resources/schema.sql | 2 +- 25 files changed, 4048 insertions(+), 3040 deletions(-) create mode 100644 asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java create mode 100644 asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java create mode 100644 asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java create mode 100644 asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java create mode 100644 asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csar create mode 100644 asdc-controller/src/test/resources/download/service-Testservice140-csar.csar diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index d28784bb93..ea8cb5d616 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -23,13 +23,9 @@ package org.onap.so.db.catalog.client; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.when; import java.util.List; import java.util.UUID; - -import javax.ws.rs.core.UriBuilder; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -54,20 +50,15 @@ import org.onap.so.db.catalog.beans.VnfComponentsRecipe; import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.core.parameters.P; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import com.fasterxml.jackson.databind.ObjectMapper; - @RunWith(SpringRunner.class) @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @@ -201,7 +192,6 @@ public class CatalogDbClientTest { Assert.assertNotNull(vnfResourceCustomization.getVnfResources()); Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations()); Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName()); - } @Test @@ -659,7 +649,6 @@ public class CatalogDbClientTest { pnfResource.getModelInvariantUUID()); assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion()); assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode()); - } @Test diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml index 50fbdd447b..7b774a2cce 100644 --- a/asdc-controller/pom.xml +++ b/asdc-controller/pom.xml @@ -1,265 +1,270 @@ - - 4.0.0 - - org.onap.so - so - 1.4.0-SNAPSHOT - + + 4.0.0 + + org.onap.so + so + 1.4.0-SNAPSHOT + - org.onap.so - asdc-controller - asdc-controller - ASDC CLient and Controller - - UTF-8 - UTF-8 - 4.7.1 - 1.8 - + org.onap.so + asdc-controller + asdc-controller + ASDC CLient and Controller + + UTF-8 + UTF-8 + 4.7.1 + 1.8 + 1.5.0 + 1.5.0 + - - ${project.artifactId}-${project.version} - - - org.jacoco - jacoco-maven-plugin - 0.7.7.201606060606 - - -+ **/resource-examples/** - - - - - default-prepare-agent - - prepare-agent - - - - default-report - - report - - - - default-check - - check - - - - - BUNDLE - - - INSTRUCTION - COVEREDRATIO - - - - - - - - - - org.antlr - antlr4-maven-plugin - ${antlr.version} - - - antlr - generate-test-resources - - antlr4 - - - true - ${project.build.directory}/generated-sources - - - - - - maven-compiler-plugin - - - default-testCompile - test-compile - - testCompile - - - ${project.build.directory}/generated-sources - - - - - - org.springframework.boot - spring-boot-maven-plugin - - org.onap.so.asdc.Application - - - - - repackage - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - extract-docker-file - - - - - io.fabric8 - fabric8-maven-plugin - - - start - - - - - org.apache.maven.plugins - maven-jar-plugin - - - original - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - io.swagger - swagger-jersey2-jaxrs - 1.5.16 - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-jersey - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.apache.tomcat - tomcat-jdbc - - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.onap.so - mso-catalog-db - ${project.version} - - - org.onap.sdc.sdc-distribution-client - sdc-distribution-client - 1.3.0 - - - org.slf4j - slf4j-log4j12 - - - - - org.onap.sdc.sdc-tosca - sdc-tosca - 1.4.8 - - - org.onap.sdc.jtosca - jtosca - 1.4.8 - - - org.onap.so - common - ${project.version} - - - org.onap.so - mso-api-handler-common - ${project.version} - - - commons-io - commons-io - - - org.onap.so - mso-requests-db - ${project.version} - - - org.onap.so - mso-requests-db-repositories - ${project.version} - - - org.antlr - antlr4 - ${antlr.version} - test - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.mariadb.jdbc - mariadb-java-client - - - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 - test - - - org.springframework.cloud - spring-cloud-contract-wiremock - 1.2.4.RELEASE - - - io.micrometer - micrometer-core - - - io.micrometer - micrometer-registry-prometheus - - - javax.interceptor - javax.interceptor-api - - + + ${project.artifactId}-${project.version} + + + org.jacoco + jacoco-maven-plugin + 0.7.7.201606060606 + + + + + **/resource-examples/** + + + + + default-prepare-agent + + prepare-agent + + + + default-report + + report + + + + default-check + + check + + + + + BUNDLE + + + INSTRUCTION + COVEREDRATIO + + + + + + + + + + org.antlr + antlr4-maven-plugin + ${antlr.version} + + + antlr + generate-test-resources + + antlr4 + + + true + ${project.build.directory}/generated-sources + + + + + + maven-compiler-plugin + + + default-testCompile + test-compile + + testCompile + + + ${project.build.directory}/generated-sources + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + org.onap.so.asdc.Application + + + + + repackage + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + extract-docker-file + + + + + io.fabric8 + fabric8-maven-plugin + + + start + + + + + org.apache.maven.plugins + maven-jar-plugin + + + original + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + io.swagger + swagger-jersey2-jaxrs + 1.5.16 + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-jersey + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.apache.tomcat + tomcat-jdbc + + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.onap.so + mso-catalog-db + ${project.version} + + + org.onap.sdc.sdc-distribution-client + sdc-distribution-client + 1.3.0 + + + org.slf4j + slf4j-log4j12 + + + + + org.onap.sdc.sdc-tosca + sdc-tosca + ${sdc.tosca.version} + + + org.onap.sdc.jtosca + jtosca + ${jtosca.version} + + + org.onap.so + common + ${project.version} + + + org.onap.so + mso-api-handler-common + ${project.version} + + + commons-io + commons-io + + + org.onap.so + mso-requests-db + ${project.version} + + + org.onap.so + mso-requests-db-repositories + ${project.version} + + + org.antlr + antlr4 + ${antlr.version} + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.mariadb.jdbc + mariadb-java-client + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + org.springframework.cloud + spring-cloud-contract-wiremock + 1.2.4.RELEASE + + + io.micrometer + micrometer-core + + + io.micrometer + micrometer-registry-prometheus + + + javax.interceptor + javax.interceptor-api + + 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 fd810e1e67..c9332e8f84 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 @@ -24,6 +24,11 @@ d * ============LICENSE_START=================================================== package org.onap.so.asdc.client; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -31,7 +36,6 @@ import java.io.UnsupportedEncodingException; import java.nio.file.Paths; import java.util.List; import java.util.Optional; - import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.consumer.IDistributionStatusMessage; import org.onap.sdc.api.consumer.IFinalDistrStatusMessage; @@ -48,6 +52,9 @@ import org.onap.so.asdc.client.exceptions.ASDCDownloadException; import org.onap.so.asdc.client.exceptions.ASDCParametersException; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.asdc.installer.IVfResourceInstaller; +import org.onap.so.asdc.installer.PnfResourceStructure; +import org.onap.so.asdc.installer.ResourceStructure; +import org.onap.so.asdc.installer.ResourceType; import org.onap.so.asdc.installer.ToscaResourceStructure; import org.onap.so.asdc.installer.VfResourceStructure; import org.onap.so.asdc.installer.bpmn.BpmnInstaller; @@ -65,12 +72,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.ObjectOptimisticLockingFailureException; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - @Component public class ASDCController { @@ -79,54 +80,49 @@ public class ASDCController { protected boolean isAsdcClientAutoManaged = false; protected String controllerName; - + private ASDCControllerStatus controllerStatus = ASDCControllerStatus.STOPPED; - + protected int nbOfNotificationsOngoing = 0; @Autowired private ToscaResourceInstaller toscaInstaller; - + @Autowired private BpmnInstaller bpmnInstaller; - + @Autowired private WatchdogDistributionStatusRepository wdsRepo; - + @Autowired private ASDCConfiguration asdcConfig; - + @Autowired private ASDCStatusCallBack asdcStatusCallBack; - + @Autowired private ASDCNotificationCallBack asdcNotificationCallBack; - + private IDistributionClient distributionClient; - + private static final String UUID_PARAM = "(UUID:"; - + @Autowired private WatchdogDistribution wd; - - public int getNbOfNotificationsOngoing () { + public int getNbOfNotificationsOngoing() { return nbOfNotificationsOngoing; - } + } public IDistributionClient getDistributionClient() { - return distributionClient; - } - - - - public void setDistributionClient(IDistributionClient distributionClient) { - this.distributionClient = distributionClient; - } - + return distributionClient; + } + public void setDistributionClient(IDistributionClient distributionClient) { + this.distributionClient = distributionClient; + } - protected void changeControllerStatus (ASDCControllerStatus newControllerStatus) { + protected void changeControllerStatus(ASDCControllerStatus newControllerStatus) { switch (newControllerStatus) { case BUSY: @@ -150,97 +146,99 @@ public class ASDCController { } } - public ASDCControllerStatus getControllerStatus () { + public ASDCControllerStatus getControllerStatus() { return this.controllerStatus; } - - public ASDCController () { - isAsdcClientAutoManaged = true; + + public ASDCController() { + this(""); } - public ASDCController (String controllerConfigName) { + 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, + IVfResourceInstaller resourceinstaller) { + distributionClient = asdcClient; } - public ASDCController (String controllerConfigName,IDistributionClient asdcClient) { + public ASDCController(String controllerConfigName, IDistributionClient asdcClient) { distributionClient = asdcClient; - this.controllerName = controllerConfigName; + this.controllerName = controllerConfigName; } + public String getControllerName() { - return controllerName; - } + return controllerName; + } - public void setControllerName(String controllerName) { - this.controllerName = controllerName; - } + public void setControllerName(String controllerName) { + this.controllerName = controllerName; + } - /** + /** * This method initializes the ASDC Controller and the ASDC Client. * * @throws ASDCControllerException It throws an exception if the ASDC Client cannot be instantiated or if an init - * attempt is done when already initialized + * attempt is done when already initialized * @throws ASDCParametersException If there is an issue with the parameters provided * @throws IOException In case of issues when trying to load the key file */ - public void initASDC () throws ASDCControllerException { + public void initASDC() throws ASDCControllerException { String event = "Initialize the ASDC Controller"; logger.debug(event); - if (this.getControllerStatus () != ASDCControllerStatus.STOPPED) { + if (this.getControllerStatus() != ASDCControllerStatus.STOPPED) { String endEvent = "The controller is already initialized, call the closeASDC method first"; - throw new ASDCControllerException (endEvent); + throw new ASDCControllerException(endEvent); } - if (asdcConfig != null) { + if (asdcConfig != null) { asdcConfig.setAsdcControllerName(controllerName); - } + } if (this.distributionClient == null) { - distributionClient = DistributionClientFactory.createDistributionClient (); + distributionClient = DistributionClientFactory.createDistributionClient(); } - - IDistributionClientResult result = this.distributionClient.init (asdcConfig, - asdcNotificationCallBack, asdcStatusCallBack); - if (!result.getDistributionActionResult ().equals (DistributionActionResultEnum.SUCCESS)) { + + IDistributionClientResult result = this.distributionClient.init(asdcConfig, + asdcNotificationCallBack, asdcStatusCallBack); + if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { String endEvent = "ASDC distribution client init failed with reason:" - + result.getDistributionMessageResult (); - logger.debug (endEvent); - this.changeControllerStatus (ASDCControllerStatus.STOPPED); - throw new ASDCControllerException ("Initialization of the ASDC Controller failed with reason: " - + result.getDistributionMessageResult ()); + + result.getDistributionMessageResult(); + logger.debug(endEvent); + this.changeControllerStatus(ASDCControllerStatus.STOPPED); + throw new ASDCControllerException("Initialization of the ASDC Controller failed with reason: " + + result.getDistributionMessageResult()); } - result = this.distributionClient.start (); - if (!result.getDistributionActionResult ().equals (DistributionActionResultEnum.SUCCESS)) { + result = this.distributionClient.start(); + if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { String endEvent = "ASDC distribution client start failed with reason:" - + result.getDistributionMessageResult (); - logger.debug (endEvent); - this.changeControllerStatus (ASDCControllerStatus.STOPPED); - throw new ASDCControllerException ("Startup of the ASDC Controller failed with reason: " - + result.getDistributionMessageResult ()); + + result.getDistributionMessageResult(); + logger.debug(endEvent); + this.changeControllerStatus(ASDCControllerStatus.STOPPED); + throw new ASDCControllerException("Startup of the ASDC Controller failed with reason: " + + result.getDistributionMessageResult()); } - this.changeControllerStatus (ASDCControllerStatus.IDLE); + this.changeControllerStatus(ASDCControllerStatus.IDLE); logger.info("{} {} {}", MessageEnum.ASDC_INIT_ASDC_CLIENT_SUC.toString(), "ASDC", "changeControllerStatus"); } /** * This method closes the ASDC Controller and the ASDC Client. * - * @throws ASDCControllerException It throws an exception if the ASDC Client cannot be closed because - * it's currently BUSY in processing notifications. + * @throws ASDCControllerException It throws an exception if the ASDC Client cannot be closed because it's currently + * BUSY in processing notifications. */ - public void closeASDC () throws ASDCControllerException { + public void closeASDC() throws ASDCControllerException { - if (this.getControllerStatus () == ASDCControllerStatus.BUSY) { - throw new ASDCControllerException ("Cannot close the ASDC controller as it's currently in BUSY state"); + if (this.getControllerStatus() == ASDCControllerStatus.BUSY) { + throw new ASDCControllerException("Cannot close the ASDC controller as it's currently in BUSY state"); } if (this.distributionClient != null) { - this.distributionClient.stop (); + this.distributionClient.stop(); // If auto managed we can set it to Null, ASDCController controls it. // In the other case the client of this class has specified it, so we can't reset it if (isAsdcClientAutoManaged) { @@ -249,59 +247,54 @@ public class ASDCController { } } - this.changeControllerStatus (ASDCControllerStatus.STOPPED); + this.changeControllerStatus(ASDCControllerStatus.STOPPED); } - private boolean checkResourceAlreadyDeployed (VfResourceStructure resource) throws ArtifactInstallerException { + private boolean checkResourceAlreadyDeployed(VfResourceStructure resource) throws ArtifactInstallerException { - - if (toscaInstaller.isResourceAlreadyDeployed (resource)) { - logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST.toString(), - resource.getResourceInstance().getResourceInstanceName(), - resource.getResourceInstance().getResourceUUID(), - resource.getResourceInstance().getResourceName()); + if (toscaInstaller.isResourceAlreadyDeployed(resource)) { + logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST.toString(), + resource.getResourceInstance().getResourceInstanceName(), + resource.getResourceInstance().getResourceUUID(), + resource.getResourceInstance().getResourceName()); - this.sendDeployNotificationsForResource(resource,DistributionStatusEnum.ALREADY_DOWNLOADED,null); - this.sendDeployNotificationsForResource(resource,DistributionStatusEnum.ALREADY_DEPLOYED,null); + this.sendDeployNotificationsForResource(resource, DistributionStatusEnum.ALREADY_DOWNLOADED, null); + this.sendDeployNotificationsForResource(resource, DistributionStatusEnum.ALREADY_DEPLOYED, null); - return true; - } else { - return false; - } + return true; + } else { + return false; + } } - - protected IDistributionClientDownloadResult downloadTheArtifact (IArtifactInfo artifact, - String distributionId) throws ASDCDownloadException { + protected IDistributionClientDownloadResult downloadTheArtifact(IArtifactInfo artifact, + String distributionId) throws ASDCDownloadException { - logger.debug("Trying to download the artifact : " + artifact.getArtifactURL () - + UUID_PARAM - + artifact.getArtifactUUID () - + ")"); + logger.info("Trying to download the artifact UUID: {} from URL: {}", artifact.getArtifactUUID(), + artifact.getArtifactURL()); IDistributionClientDownloadResult downloadResult; - try { - downloadResult = distributionClient.download (artifact); + downloadResult = distributionClient.download(artifact); if (null == downloadResult) { - logger.info ("{} {}", MessageEnum.ASDC_ARTIFACT_NULL.toString(), artifact.getArtifactUUID()); - return downloadResult; + logger.info("{} {}", MessageEnum.ASDC_ARTIFACT_NULL.toString(), artifact.getArtifactUUID()); + return downloadResult; } } catch (RuntimeException e) { - logger.debug ("Not able to download the artifact due to an exception: " + artifact.getArtifactURL ()); - this.sendASDCNotification (NotificationType.DOWNLOAD, - artifact.getArtifactURL (), - asdcConfig.getConsumerID (), - distributionId, - DistributionStatusEnum.DOWNLOAD_ERROR, - e.getMessage (), - System.currentTimeMillis ()); - - throw new ASDCDownloadException ("Exception caught when downloading the artifact", e); + logger.debug("Not able to download the artifact due to an exception: " + artifact.getArtifactURL()); + this.sendASDCNotification(NotificationType.DOWNLOAD, + artifact.getArtifactURL(), + asdcConfig.getConsumerID(), + distributionId, + DistributionStatusEnum.DOWNLOAD_ERROR, + e.getMessage(), + System.currentTimeMillis()); + + throw new ASDCDownloadException("Exception caught when downloading the artifact", e); } - if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult ())) { + if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult())) { logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_SUC.toString(), artifact.getArtifactURL(), artifact.getArtifactUUID(), String.valueOf(downloadResult.getArtifactPayload().length)); @@ -311,143 +304,144 @@ public class ASDCController { downloadResult.getDistributionMessageResult(), ErrorCode.DataError.getValue(), "ASDC artifact download fail"); - this.sendASDCNotification (NotificationType.DOWNLOAD, - artifact.getArtifactURL (), - asdcConfig.getConsumerID (), - distributionId, - DistributionStatusEnum.DOWNLOAD_ERROR, - downloadResult.getDistributionMessageResult (), - System.currentTimeMillis ()); - - throw new ASDCDownloadException ("Artifact " + artifact.getArtifactName () - + " could not be downloaded from ASDC URL " - + artifact.getArtifactURL () - + UUID_PARAM - + artifact.getArtifactUUID () - + ")" - + System.lineSeparator () - + "Error message is " - + downloadResult.getDistributionMessageResult () - + System.lineSeparator ()); + this.sendASDCNotification(NotificationType.DOWNLOAD, + artifact.getArtifactURL(), + asdcConfig.getConsumerID(), + distributionId, + DistributionStatusEnum.DOWNLOAD_ERROR, + downloadResult.getDistributionMessageResult(), + System.currentTimeMillis()); + + throw new ASDCDownloadException("Artifact " + artifact.getArtifactName() + + " could not be downloaded from ASDC URL " + + artifact.getArtifactURL() + + UUID_PARAM + + artifact.getArtifactUUID() + + ")" + + System.lineSeparator() + + "Error message is " + + downloadResult.getDistributionMessageResult() + + System.lineSeparator()); } - this.sendASDCNotification (NotificationType.DOWNLOAD, - artifact.getArtifactURL (), - asdcConfig.getConsumerID (), - distributionId, - DistributionStatusEnum.DOWNLOAD_OK, - null, - System.currentTimeMillis ()); + this.sendASDCNotification(NotificationType.DOWNLOAD, + artifact.getArtifactURL(), + asdcConfig.getConsumerID(), + distributionId, + DistributionStatusEnum.DOWNLOAD_OK, + null, + System.currentTimeMillis()); return downloadResult; } - private void writeArtifactToFile (IArtifactInfo artifact, - IDistributionClientDownloadResult resultArtifact) { + private void writeArtifactToFile(IArtifactInfo artifact, IDistributionClientDownloadResult resultArtifact) { - logger.debug( - "Trying to write artifact to file : " + artifact.getArtifactURL() + UUID_PARAM + artifact.getArtifactUUID() - + ")"); - - String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize().toString(); - // make parent directory - File file = new File(filePath); - File fileParent = file.getParentFile(); - if (!fileParent.exists()) { - fileParent.mkdirs(); - } - - 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()); - outFile.write(payloadBytes, 0, payloadBytes.length); - outFile.close(); - } catch (Exception e) { - logger.debug("Exception :", e); - logger.error("{} {} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(), - artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(), - resultArtifact.getDistributionMessageResult(), ErrorCode.DataError.getValue(), - "ASDC write to file failed"); + String filePath = Paths + .get(getMsoConfigPath(), "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize() + .toString(); + + logger.info("Trying to write artifact UUID: {}, URL: {} to file: {}", artifact.getArtifactUUID(), + artifact.getArtifactURL(), filePath); + + // make parent directory + File file = new File(filePath); + File fileParent = file.getParentFile(); + if (!fileParent.exists()) { + fileParent.mkdirs(); + } + + 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()); + outFile.write(payloadBytes, 0, payloadBytes.length); + } catch (Exception e) { + logger.debug("Exception :", e); + logger.error("{} {} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(), + artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(), + resultArtifact.getDistributionMessageResult(), ErrorCode.DataError.getValue(), + "ASDC write to file failed"); } } - protected void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) { - - for (IArtifactInfo artifactInfo : vfResourceStructure.getResourceInstance().getArtifacts()) { - - if ((DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) && !artifactInfo.getArtifactType().equalsIgnoreCase("OTHER") && !vfResourceStructure.isAlreadyDeployed()) - // This could be NULL if the artifact is a VF module artifact, this won't be present in the MAP - && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null - && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()).getDeployedInDb() == 0) { - this.sendASDCNotification (NotificationType.DEPLOY, - artifactInfo.getArtifactURL (), - asdcConfig.getConsumerID (), - vfResourceStructure.getNotification().getDistributionID(), - DistributionStatusEnum.DEPLOY_ERROR, - "The artifact has not been used by the modules defined in the resource", - System.currentTimeMillis ()); - } else { - this.sendASDCNotification (NotificationType.DEPLOY, - artifactInfo.getArtifactURL (), - asdcConfig.getConsumerID (), - vfResourceStructure.getNotification().getDistributionID(), - distribStatus, - errorReason, - System.currentTimeMillis ()); - } - } + protected void sendDeployNotificationsForResource(ResourceStructure resourceStructure, + DistributionStatusEnum distribStatus, String errorReason) { + + for (IArtifactInfo artifactInfo : resourceStructure.getResourceInstance().getArtifacts()) { + + if ((DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) && !artifactInfo.getArtifactType() + .equalsIgnoreCase("OTHER") && !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 + && resourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()).getDeployedInDb() + == 0) { + this.sendASDCNotification(NotificationType.DEPLOY, + artifactInfo.getArtifactURL(), + asdcConfig.getConsumerID(), + resourceStructure.getNotification().getDistributionID(), + DistributionStatusEnum.DEPLOY_ERROR, + "The artifact has not been used by the modules defined in the resource", + System.currentTimeMillis()); + } else { + this.sendASDCNotification(NotificationType.DEPLOY, + artifactInfo.getArtifactURL(), + asdcConfig.getConsumerID(), + resourceStructure.getNotification().getDistributionID(), + distribStatus, + errorReason, + System.currentTimeMillis()); + } + } } - - protected void sendCsarDeployNotification(INotificationData iNotif, VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) { - - IArtifactInfo csarArtifact = toscaResourceStructure.getToscaArtifact(); - - if(deploySuccessful){ - - this.sendASDCNotification (NotificationType.DEPLOY, - csarArtifact.getArtifactURL (), - asdcConfig.getConsumerID (), - resourceStructure.getNotification().getDistributionID(), - DistributionStatusEnum.DEPLOY_OK, - errorReason, - System.currentTimeMillis ()); - - } else { - - this.sendASDCNotification (NotificationType.DEPLOY, - csarArtifact.getArtifactURL (), - asdcConfig.getConsumerID (), - resourceStructure.getNotification().getDistributionID(), - DistributionStatusEnum.DEPLOY_ERROR, - errorReason, - System.currentTimeMillis ()); - - } + + protected void sendCsarDeployNotification(INotificationData iNotif, ResourceStructure resourceStructure, + ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) { + + IArtifactInfo csarArtifact = toscaResourceStructure.getToscaArtifact(); + + if (deploySuccessful) { + + this.sendASDCNotification(NotificationType.DEPLOY, + csarArtifact.getArtifactURL(), + asdcConfig.getConsumerID(), + resourceStructure.getNotification().getDistributionID(), + DistributionStatusEnum.DEPLOY_OK, + errorReason, + System.currentTimeMillis()); + + } else { + + this.sendASDCNotification(NotificationType.DEPLOY, + csarArtifact.getArtifactURL(), + asdcConfig.getConsumerID(), + resourceStructure.getNotification().getDistributionID(), + DistributionStatusEnum.DEPLOY_ERROR, + errorReason, + System.currentTimeMillis()); + + } } - - protected void deployResourceStructure (VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException { + + protected void deployResourceStructure(ResourceStructure resourceStructure, + ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException { logger.info("{} {} {} {}", MessageEnum.ASDC_START_DEPLOY_ARTIFACT.toString(), resourceStructure.getResourceInstance().getResourceInstanceName(), resourceStructure.getResourceInstance().getResourceUUID(), "ASDC"); try { - String resourceType = resourceStructure.getResourceInstance().getResourceType(); - String category = resourceStructure.getResourceInstance().getCategory(); - if("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)){ - resourceStructure.createVfModuleStructures(); - } - toscaInstaller.installTheResource(toscaResourceStructure, resourceStructure); + resourceStructure.prepareInstall(); + toscaInstaller.installTheResource(toscaResourceStructure, resourceStructure); } catch (ArtifactInstallerException e) { logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(), resourceStructure.getResourceInstance().getResourceName(), resourceStructure.getResourceInstance().getResourceUUID(), - String.valueOf(resourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure"); + String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure"); sendDeployNotificationsForResource(resourceStructure, DistributionStatusEnum.DEPLOY_ERROR, e.getMessage()); throw e; } @@ -456,66 +450,66 @@ public class ASDCController { logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), resourceStructure.getResourceInstance().getResourceName(), resourceStructure.getResourceInstance().getResourceUUID(), - String.valueOf(resourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure"); + String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure"); sendDeployNotificationsForResource(resourceStructure, DistributionStatusEnum.DEPLOY_OK, null); } } - + private enum NotificationType { - DOWNLOAD, DEPLOY + DOWNLOAD, DEPLOY } - protected void sendASDCNotification (NotificationType notificationType, - String artifactURL, - String consumerID, - String distributionID, - DistributionStatusEnum status, - String errorReason, - long timestamp) { - - String event = "Sending " + notificationType.name () - + "(" - + status.name () - + ")" - + " notification to ASDC for artifact:" - + artifactURL; + protected void sendASDCNotification(NotificationType notificationType, + String artifactURL, + String consumerID, + String distributionID, + DistributionStatusEnum status, + String errorReason, + long timestamp) { + + String event = "Sending " + notificationType.name() + + "(" + + status.name() + + ")" + + " notification to ASDC for artifact:" + + artifactURL; if (errorReason != null) { - event=event+"("+errorReason+")"; + event = event + "(" + errorReason + ")"; } logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC.toString(), notificationType.name(), status.name(), artifactURL, "ASDC", "sendASDCNotification"); - logger.debug (event); + logger.debug(event); String action = ""; try { - IDistributionStatusMessage message = new DistributionStatusMessage (artifactURL, - consumerID, - distributionID, - status, - timestamp); + IDistributionStatusMessage message = new DistributionStatusMessage(artifactURL, + consumerID, + distributionID, + status, + timestamp); switch (notificationType) { case DOWNLOAD: if (errorReason != null) { - this.distributionClient.sendDownloadStatus (message, errorReason); + this.distributionClient.sendDownloadStatus(message, errorReason); } else { - this.distributionClient.sendDownloadStatus (message); + this.distributionClient.sendDownloadStatus(message); } action = "sendDownloadStatus"; break; case DEPLOY: if (errorReason != null) { - this.distributionClient.sendDeploymentStatus (message, errorReason); + this.distributionClient.sendDeploymentStatus(message, errorReason); } else { - this.distributionClient.sendDeploymentStatus (message); + this.distributionClient.sendDeploymentStatus(message); } action = "sendDeploymentdStatus"; break; default: - break; + break; } } catch (RuntimeException e) { logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC", @@ -523,148 +517,150 @@ public class ASDCController { "RuntimeException - sendASDCNotification", e); } } - - protected void sendFinalDistributionStatus ( - String distributionID, - DistributionStatusEnum status, - String errorReason) { + protected void sendFinalDistributionStatus( + String distributionID, + DistributionStatusEnum status, + String errorReason) { - logger.debug("Enter sendFinalDistributionStatus with DistributionID " + distributionID + " and Status of " + status + logger.debug( + "Enter sendFinalDistributionStatus with DistributionID " + distributionID + " and Status of " + status .name() + " and ErrorReason " + errorReason); - long subStarttime = System.currentTimeMillis (); - try { - - - IFinalDistrStatusMessage finalDistribution = new FinalDistributionStatusMessage(distributionID,status,subStarttime, asdcConfig.getConsumerID()); - - if(errorReason == null){ - this.distributionClient.sendFinalDistrStatus(finalDistribution); - }else{ - this.distributionClient.sendFinalDistrStatus(finalDistribution, errorReason); - } - - - } catch (RuntimeException e) { - logger.debug("Exception caught in sendFinalDistributionStatus {}", e.getMessage()); - logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC", "sendASDCNotification", - ErrorCode.SchemaError.getValue(), "RuntimeException - sendASDCNotification", e); - } + long subStarttime = System.currentTimeMillis(); + try { + + IFinalDistrStatusMessage finalDistribution = new FinalDistributionStatusMessage(distributionID, status, + subStarttime, asdcConfig.getConsumerID()); + + if (errorReason == null) { + this.distributionClient.sendFinalDistrStatus(finalDistribution); + } else { + this.distributionClient.sendFinalDistrStatus(finalDistribution, errorReason); + } + + + } catch (RuntimeException e) { + logger.debug("Exception caught in sendFinalDistributionStatus {}", e.getMessage()); + logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC", + "sendASDCNotification", + ErrorCode.SchemaError.getValue(), "RuntimeException - sendASDCNotification", e); + } } - private Optional getNotificationJson(INotificationData iNotif) { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - mapper.setSerializationInclusion(Include.NON_EMPTY); - mapper.setSerializationInclusion(Include.NON_ABSENT); + private Optional getNotificationJson(INotificationData iNotif) { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + mapper.setSerializationInclusion(Include.NON_EMPTY); + mapper.setSerializationInclusion(Include.NON_ABSENT); mapper.enable(MapperFeature.USE_ANNOTATIONS); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - Optional returnValue = Optional.empty(); - try { - returnValue = Optional.of(mapper.writeValueAsString(iNotif)); - } catch (JsonProcessingException e) { - logger.error("Error converting incoming ASDC notification to JSON" , e); - } - return returnValue; - } - - public void treatNotification (INotificationData iNotif) { - - int noOfArtifacts = 0; - - - for (IResourceInstance resource : iNotif.getResources ()) { - noOfArtifacts += resource.getArtifacts ().size (); - } + Optional returnValue = Optional.empty(); + try { + returnValue = Optional.of(mapper.writeValueAsString(iNotif)); + } catch (JsonProcessingException e) { + logger.error("Error converting incoming ASDC notification to JSON", e); + } + return returnValue; + } + + public void treatNotification(INotificationData iNotif) { + + int noOfArtifacts = 0; + + for (IResourceInstance resource : iNotif.getResources()) { + noOfArtifacts += resource.getArtifacts().size(); + } logger.info("{} {} {} {}", 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(), "ASDC", + logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif)); + logger + .info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), iNotif.getServiceUUID(), "ASDC", "treatNotification"); this.changeControllerStatus(ASDCControllerStatus.BUSY); - Optional notificationMessage = getNotificationJson(iNotif); - toscaInstaller.processWatchdog(iNotif.getDistributionID(), iNotif.getServiceUUID(), notificationMessage, - asdcConfig.getConsumerID()); - - // Process only the Resource artifacts in MSO - this.processResourceNotification(iNotif); - - //******************************************************************************************************** - //Start Watchdog loop and wait for all components to complete before reporting final status back. - // **If timer expires first then we will report a Distribution Error back to ASDC - //******************************************************************************************************** - long initialStartTime = System.currentTimeMillis(); - boolean componentsComplete = false; - String distributionStatus = null; - String watchdogError = null; - String overallStatus = null; - int watchDogTimeout = asdcConfig.getWatchDogTimeout() * 1000; - boolean isDeploySuccess = false; - - while(!componentsComplete && (System.currentTimeMillis() - initialStartTime) < watchDogTimeout) - { - - try{ - distributionStatus = wd.getOverallDistributionStatus(iNotif.getDistributionID()); - Thread.sleep(watchDogTimeout / 10); - }catch(Exception e){ - logger.debug ("Exception in Watchdog Loop {}", e.getMessage()); - Thread.sleep(watchDogTimeout / 10); - } - - if(distributionStatus != null && !distributionStatus.equalsIgnoreCase(DistributionStatus.INCOMPLETE.name())){ - - if(distributionStatus.equalsIgnoreCase(DistributionStatus.SUCCESS.name())){ - isDeploySuccess = true; - overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.name(); - }else{ - overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name(); - } - componentsComplete = true; - } - } - - if(!componentsComplete){ - logger.debug("Timeout of {} seconds was reached before all components reported status", watchDogTimeout); - watchdogError = "Timeout occurred while waiting for all components to report status"; - overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name(); - } - - if(distributionStatus == null){ - overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name(); - logger.debug("DistributionStatus is null for DistributionId: {}", iNotif.getDistributionID()); - } - - try { - wd.executePatchAAI(iNotif.getDistributionID(), iNotif.getServiceInvariantUUID(), overallStatus); - logger.debug("A&AI Updated succefully with Distribution Status!"); - } - catch(Exception e) { - logger.debug("Exception in Watchdog executePatchAAI(): {}", e.getMessage()); - watchdogError = "Error calling A&AI " + e.getMessage(); - if(e.getCause() != null) { - logger.debug("Exception caused by: {}", e.getCause().getMessage()); - } - } - - - if(isDeploySuccess && watchdogError == null){ - sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK, null); - WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID()); - wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.toString()); - wdsRepo.save(wds); - } else { - sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, watchdogError); - WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID()); - wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString()); - wdsRepo.save(wds); - } - - - } catch(ObjectOptimisticLockingFailureException e) { + Optional notificationMessage = getNotificationJson(iNotif); + toscaInstaller.processWatchdog(iNotif.getDistributionID(), iNotif.getServiceUUID(), notificationMessage, + asdcConfig.getConsumerID()); + + // Process only the Resource artifacts in MSO + this.processResourceNotification(iNotif); + + //******************************************************************************************************** + //Start Watchdog loop and wait for all components to complete before reporting final status back. + // **If timer expires first then we will report a Distribution Error back to ASDC + //******************************************************************************************************** + long initialStartTime = System.currentTimeMillis(); + boolean componentsComplete = false; + String distributionStatus = null; + String watchdogError = null; + String overallStatus = null; + int watchDogTimeout = asdcConfig.getWatchDogTimeout() * 1000; + boolean isDeploySuccess = false; + + while (!componentsComplete && (System.currentTimeMillis() - initialStartTime) < watchDogTimeout) { + + try { + distributionStatus = wd.getOverallDistributionStatus(iNotif.getDistributionID()); + Thread.sleep(watchDogTimeout / 10); + } catch (Exception e) { + logger.debug("Exception in Watchdog Loop {}", e.getMessage()); + Thread.sleep(watchDogTimeout / 10); + } + + if (distributionStatus != null && !distributionStatus + .equalsIgnoreCase(DistributionStatus.INCOMPLETE.name())) { + + if (distributionStatus.equalsIgnoreCase(DistributionStatus.SUCCESS.name())) { + isDeploySuccess = true; + overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.name(); + } else { + overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name(); + } + componentsComplete = true; + } + } + + if (!componentsComplete) { + logger + .debug("Timeout of {} seconds was reached before all components reported status", watchDogTimeout); + watchdogError = "Timeout occurred while waiting for all components to report status"; + overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name(); + } + + if (distributionStatus == null) { + overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name(); + logger.debug("DistributionStatus is null for DistributionId: {}", iNotif.getDistributionID()); + } + + try { + wd.executePatchAAI(iNotif.getDistributionID(), iNotif.getServiceInvariantUUID(), overallStatus); + logger.debug("A&AI Updated succefully with Distribution Status!"); + } catch (Exception e) { + logger.debug("Exception in Watchdog executePatchAAI(): {}", e.getMessage()); + watchdogError = "Error calling A&AI " + e.getMessage(); + if (e.getCause() != null) { + logger.debug("Exception caused by: {}", e.getCause().getMessage()); + } + } + + if (isDeploySuccess && watchdogError == null) { + sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK, + null); + WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID()); + wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.toString()); + wdsRepo.save(wds); + } else { + sendFinalDistributionStatus(iNotif.getDistributionID(), + DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, watchdogError); + WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID()); + wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString()); + 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.", @@ -675,9 +671,10 @@ public class ASDCController { } catch (Exception e) { logger.error("", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), - "Unexpected exception caught during the notification processing", "ASDC", - "treatNotification", ErrorCode.SchemaError.getValue(), "RuntimeException in treatNotification", - e); + "Unexpected exception caught during the notification processing", "ASDC", + "treatNotification", ErrorCode.SchemaError.getValue(), + "RuntimeException in treatNotification", + e); try { wd.executePatchAAI(iNotif.getDistributionID(), iNotif.getServiceInvariantUUID(), @@ -690,167 +687,168 @@ public class ASDCController { logger.debug("Exception caused by: {}", aaiException.getCause().getMessage()); } } - - sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, e.getMessage()); - - WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID()); - wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString()); - wdsRepo.save(wds); - + + sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, + e.getMessage()); + + WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID()); + wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString()); + wdsRepo.save(wds); + } finally { - this.changeControllerStatus (ASDCControllerStatus.IDLE); + this.changeControllerStatus(ASDCControllerStatus.IDLE); } } - protected void processResourceNotification (INotificationData iNotif) { - // For each artifact, create a structure describing the VFModule in a ordered flat level - VfResourceStructure resourceStructure = null; - ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(); - boolean deploySuccessful = true; - boolean hasVFResource = false; - String errorMessage = null; - - try { - - this.processCsarServiceArtifacts(iNotif, toscaResourceStructure); - IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact(); - String filePath = System.getProperty("mso.config.path") + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact.getArtifactName(); - File csarFile = new File(filePath); - String csarFilePath = csarFile.getAbsolutePath(); - if (bpmnInstaller.containsWorkflows(csarFilePath)) { - bpmnInstaller.installBpmn(csarFilePath); - } - - for (IResourceInstance resource : iNotif.getResources()){ - - resourceStructure = new VfResourceStructure(iNotif,resource); - - String resourceType = resourceStructure.getResourceInstance().getResourceType(); - String category = resourceStructure.getResourceInstance().getCategory(); - - logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: " + resourceStructure - .getResourceInstance().getResourceUUID()); - - if("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)){ - - hasVFResource = true; - - for (IArtifactInfo artifact : resource.getArtifacts()) { - IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact, - iNotif.getDistributionID()); - if (resultArtifact != null) { - - if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) { - logger.debug("VF_MODULE_ARTIFACT: "+ new String(resultArtifact.getArtifactPayload(),"UTF-8")); - logger.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(resourceStructure.decodeVfModuleArtifact - (resultArtifact.getArtifactPayload()))); - } - resourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact); - } - } - - //Deploy VF resource and artifacts - logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID()); - try{ - - this.deployResourceStructure(resourceStructure, toscaResourceStructure); - - } catch(ArtifactInstallerException e){ - deploySuccessful = false; - errorMessage = e.getMessage(); - logger.error("Exception occurred", e); - } - } - - } - - // There are cases where the Service has no VF resources, those are handled here - if (!hasVFResource) { - - logger.debug("No resources found for Service: {}", iNotif.getServiceUUID()); - - try{ - resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance()); - - this.deployResourceStructure(resourceStructure, toscaResourceStructure); - - } catch(ArtifactInstallerException e){ - deploySuccessful = false; - errorMessage = e.getMessage(); - logger.error("Exception occurred", e); - } - } - this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful, errorMessage); - - } catch (ASDCDownloadException | UnsupportedEncodingException e) { - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), - "Exception caught during Installation of artifact", "ASDC", "processResourceNotification", - ErrorCode.BusinessProcesssError.getValue(), "Exception in processResourceNotification", e); - } + protected void processResourceNotification(INotificationData iNotif) { + // For each artifact, create a structure describing the VFModule in a ordered flat level + ResourceStructure resourceStructure = null; + String msoConfigPath = getMsoConfigPath(); + ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(msoConfigPath); + boolean deploySuccessful = true; + String errorMessage = null; + + try { + this.processCsarServiceArtifacts(iNotif, toscaResourceStructure); + IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact(); + String filePath = + msoConfigPath + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact + .getArtifactName(); + File csarFile = new File(filePath); + String csarFilePath = csarFile.getAbsolutePath(); + if (bpmnInstaller.containsWorkflows(csarFilePath)) { + bpmnInstaller.installBpmn(csarFilePath); + } + + for (IResourceInstance resource : iNotif.getResources()) { + + String resourceType = resource.getResourceType(); + String category = resource.getCategory(); + + logger.info("Processing Resource Type: {}, Model UUID: {}", resourceType, resource.getResourceUUID()); + + if ("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)) { + resourceStructure = new VfResourceStructure(iNotif, resource); + } else if ("PNF".equals(resourceType)) { + resourceStructure = new PnfResourceStructure(iNotif, resource); + } else { + // There are cases where the Service has no VF resources, those are handled here + logger.info("No resources found for Service: {}", iNotif.getServiceUUID()); + resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance()); + resourceStructure.setResourceType(ResourceType.OTHER); + } + + for (IArtifactInfo artifact : resource.getArtifacts()) { + IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact, + iNotif.getDistributionID()); + if (resultArtifact != null) { + resourceStructure.addArtifactToStructure(distributionClient, artifact, resultArtifact); + } + } + + //Deploy VF resource and artifacts + logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID()); + try { + this.deployResourceStructure(resourceStructure, toscaResourceStructure); + } catch (ArtifactInstallerException e) { + deploySuccessful = false; + errorMessage = e.getMessage(); + logger.error("Exception occurred", e); + } + + this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful, + errorMessage); + } + + + } catch (ASDCDownloadException | UnsupportedEncodingException e) { + logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), + "Exception caught during Installation of artifact", "ASDC", "processResourceNotification", + ErrorCode.BusinessProcesssError.getValue(), "Exception in processResourceNotification", e); + } } - protected void processCsarServiceArtifacts (INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) { - - List serviceArtifacts = iNotif.getServiceArtifacts(); - - for(IArtifactInfo artifact : serviceArtifacts){ - - if(artifact.getArtifactType().equals(ASDCConfiguration.TOSCA_CSAR)){ - - try{ - - toscaResourceStructure.setToscaArtifact(artifact); - - IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,iNotif.getDistributionID()); - - writeArtifactToFile(artifact, resultArtifact); - - toscaResourceStructure.updateResourceStructure(artifact); - - toscaResourceStructure.setServiceVersion(iNotif.getServiceVersion()); - - logger.debug(ASDCNotificationLogging.dumpCSARNotification(iNotif, toscaResourceStructure)); - - - } catch(Exception e){ - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), - "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", - ErrorCode.BusinessProcesssError.getValue(), "Exception in processCsarServiceArtifacts", e); - } - } - else if(artifact.getArtifactType().equals(ASDCConfiguration.WORKFLOWS)){ - - try{ - - IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,iNotif.getDistributionID()); - - writeArtifactToFile(artifact, resultArtifact); - - toscaResourceStructure.setToscaArtifact(artifact); - - logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif)); - - - } catch(Exception e){ - logger.info("Whats the error {}", e.getMessage()); - logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), - "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", - ErrorCode.BusinessProcesssError.getValue(), "Exception in processCsarServiceArtifacts", - 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 = asdcConfig.getPropertyOrNull("mso.config.defaultpath"); + } + if (msoConfigPath == null) { + logger.info("Unable to find the property: {} from configuration.", "mso.config.defaultpath"); + msoConfigPath = ""; + } + logger.info("MSO config path is: {}", msoConfigPath); + return msoConfigPath; + } + + protected void processCsarServiceArtifacts(INotificationData iNotif, + ToscaResourceStructure toscaResourceStructure) { + + List serviceArtifacts = iNotif.getServiceArtifacts(); + + for (IArtifactInfo artifact : serviceArtifacts) { + + if (artifact.getArtifactType().equals(ASDCConfiguration.TOSCA_CSAR)) { + + try { + + toscaResourceStructure.setToscaArtifact(artifact); + + IDistributionClientDownloadResult resultArtifact = this + .downloadTheArtifact(artifact, iNotif.getDistributionID()); + + writeArtifactToFile(artifact, resultArtifact); + + toscaResourceStructure.updateResourceStructure(artifact); + + toscaResourceStructure.setServiceVersion(iNotif.getServiceVersion()); + + logger.debug(ASDCNotificationLogging.dumpCSARNotification(iNotif, toscaResourceStructure)); + + + } catch (Exception e) { + logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), + "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", + ErrorCode.BusinessProcesssError.getValue(), + "Exception in processCsarServiceArtifacts", e); + } + } else if (artifact.getArtifactType().equals(ASDCConfiguration.WORKFLOWS)) { + + try { + + IDistributionClientDownloadResult resultArtifact = this + .downloadTheArtifact(artifact, iNotif.getDistributionID()); + + writeArtifactToFile(artifact, resultArtifact); + + toscaResourceStructure.setToscaArtifact(artifact); + + logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif)); + + + } catch (Exception e) { + logger.info("Whats the error {}", e.getMessage()); + logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), + "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", + ErrorCode.BusinessProcesssError.getValue(), + "Exception in processCsarServiceArtifacts", + e); + } } - } - - } + + } } - - private static final String UNKNOWN="Unknown"; - + + private static final String UNKNOWN = "Unknown"; + /** * @return the address of the ASDC we are connected to. */ - public String getAddress () { + public String getAddress() { if (asdcConfig != null) { - return asdcConfig.getAsdcAddress (); + return asdcConfig.getAsdcAddress(); } return UNKNOWN; } @@ -858,9 +856,9 @@ public class ASDCController { /** * @return the environment name of the ASDC we are connected to. */ - public String getEnvironment () { + public String getEnvironment() { if (asdcConfig != null) { - return asdcConfig.getEnvironmentName (); + return asdcConfig.getEnvironmentName(); } return UNKNOWN; } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java index ed97f5bdea..759d88f196 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java @@ -41,7 +41,7 @@ public class ArtifactInfoImpl implements IArtifactInfo { private ArtifactInfoImpl generatedArtifact; private List relatedArtifactsInfo; private List relatedArtifactsImpl; - ArtifactInfoImpl(){} + public ArtifactInfoImpl(){} private ArtifactInfoImpl(IArtifactInfo iArtifactInfo){ artifactName = iArtifactInfo.getArtifactName(); 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 cbe16d864a..9462cc85d8 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 @@ -129,6 +129,10 @@ public class NotificationDataImpl implements INotificationData { } return ret; } + + public void setResources(List resources){ + this.resources = resources; + } public List getResourcesImpl(){ return resources; 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 dad7e64931..9103ae132e 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,7 @@ import org.onap.sdc.api.notification.IResourceInstance; import com.fasterxml.jackson.annotation.JsonIgnore; public class ResourceInfoImpl implements IResourceInstance{ - ResourceInfoImpl (){} + public ResourceInfoImpl (){} private String resourceInstanceName; private String resourceCustomizationUUID; private String resourceName; diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java new file mode 100644 index 0000000000..1c1351b272 --- /dev/null +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.asdc.installer; + +import java.io.UnsupportedEncodingException; +import org.onap.sdc.api.IDistributionClient; +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.api.results.IDistributionClientDownloadResult; +import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; + +/** + * This class represents the PNF resource structure. + */ +public class PnfResourceStructure extends ResourceStructure { + + public PnfResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) { + super(notificationData, resourceInstance); + this.resourceType = ResourceType.PNF_RESOURCE; + } + + @Override + public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, + IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { + + } + + @Override + public void prepareInstall() throws ArtifactInstallerException { + + } +} diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java new file mode 100644 index 0000000000..53cc74f7e4 --- /dev/null +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java @@ -0,0 +1,152 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.asdc.installer; + +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Map; +import org.onap.sdc.api.IDistributionClient; +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.api.results.IDistributionClientDownloadResult; +import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Abstract class to represent the resource structure. + * + * This structure exists to avoid having issues if the order of the resource artifact of tree structure is not good. + */ +public abstract class ResourceStructure { + + /** + * Flag to indicate whether the resource is deployed successfully. + */ + protected boolean isDeployedSuccessfully = false; + + /** + * Flag to indicate whether the resource is already deployed. + */ + protected boolean isAlreadyDeployed = false; + + /** + * The resource type. + */ + protected ResourceType resourceType; + + /** + * The Raw notification data. + */ + protected INotificationData notificationData; + + /** + * The resource we will try to deploy. + */ + protected IResourceInstance resourceInstance; + + /** + * Number of resources provided by the resource structure. + */ + protected int NumberOfResources; + + /** + * The list of artifacts existing in this resource hashed by UUID. + */ + protected final Map artifactsMapByUUID; + + public ResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) { + this.notificationData = notificationData; + this.resourceInstance = resourceInstance; + artifactsMapByUUID = new HashMap<>(); + } + + /** + * Add artifact to the resource structure. + * + * @param distributionClient + * @param artifactinfo + * @param clientResult + * @throws UnsupportedEncodingException + */ + public abstract void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, + IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException; + + /** + * Prepare the resource for installation. + * + * @throws ArtifactInstallerException + */ + public abstract void prepareInstall() throws ArtifactInstallerException; + + public boolean isDeployedSuccessfully() { + return isDeployedSuccessfully; + } + + public void setDeployedSuccessfully(boolean deployedSuccessfully) { + isDeployedSuccessfully = deployedSuccessfully; + } + + public boolean isAlreadyDeployed() { + return isAlreadyDeployed; + } + + public void setAlreadyDeployed(boolean alreadyDeployed) { + isAlreadyDeployed = alreadyDeployed; + } + + public ResourceType getResourceType() { + return resourceType; + } + + public void setResourceType(ResourceType resourceType) { + this.resourceType = resourceType; + } + + public INotificationData getNotification() { + return notificationData; + } + + public void setNotification(INotificationData notificationData) { + this.notificationData = notificationData; + } + + public IResourceInstance getResourceInstance() { + return resourceInstance; + } + + public void setResourceInstance(IResourceInstance resourceInstance) { + this.resourceInstance = resourceInstance; + } + + public int getNumberOfResources() { + return NumberOfResources; + } + + public void setNumberOfResources(int numberOfResources) { + NumberOfResources = numberOfResources; + } + + public Map getArtifactsMapByUUID() { + return artifactsMapByUUID; + } + +} diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java new file mode 100644 index 0000000000..8d55f57dfa --- /dev/null +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java @@ -0,0 +1,41 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.asdc.installer; + +/** + * This enum defines the resource type, it's used for tosca parsing, extraction and ingestion in SO. + */ +public enum ResourceType { + + /** + * VF resource and the category is not allotted_resource. + */ + VF_RESOURCE, + + /** + * PNF resource. + */ + PNF_RESOURCE, + + /** + * Other resource type, including VF resource of allotted_resource category. + */ + OTHER +} 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 6616bf4b54..3efc503fcb 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 @@ -43,6 +43,7 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkInstanceGroup; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup; @@ -54,8 +55,16 @@ import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; public class ToscaResourceStructure { + + protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceStructure.class); + + /** + * mso config path, used for the config files, like download csar files. + */ + private String msoConfigPath; Metadata serviceMetadata; private Service catalogService; @@ -100,6 +109,8 @@ public class ToscaResourceStructure { private VfModuleCustomization vfModuleCustomization; private VnfResourceCustomization vnfResourceCustomization; + + private PnfResourceCustomization pnfResourceCustomization; private AllottedResource allottedResource; @@ -111,22 +122,21 @@ public class ToscaResourceStructure { private ToscaCsar toscaCsar; - protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceStructure.class); - - public ToscaResourceStructure(){ + this(System.getProperty("mso.config.path")); } - + + public ToscaResourceStructure(final String msoConfigPath){ + this.msoConfigPath = msoConfigPath; + logger.info("MSO config path is: {}", msoConfigPath); + } + public void updateResourceStructure(IArtifactInfo artifact) throws ASDCDownloadException { - - + try { - SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();//Autoclosable - - logger.debug("MSO config path is: " + System.getProperty("mso.config.path")); - - String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize().toString(); + + String filePath = Paths.get(msoConfigPath, "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize().toString(); File spoolFile = new File(filePath); @@ -137,7 +147,7 @@ public class ToscaResourceStructure { sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath(),false); }catch(Exception e){ - logger.info("System out {}", e.getMessage()); + logger.debug(e.getMessage(), e); logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Exception caught during parser *****LOOK********* " + artifact.getArtifactName(), "ASDC", "processResourceNotification", ErrorCode.BusinessProcesssError.getValue(), @@ -259,6 +269,15 @@ public class ToscaResourceStructure { this.vnfResourceCustomization = vnfResourceCustomization; } + public PnfResourceCustomization getPnfResourceCustomization() { + return pnfResourceCustomization; + } + + public void setPnfResourceCustomization(PnfResourceCustomization pnfResourceCustomization) { + this.pnfResourceCustomization = pnfResourceCustomization; + } + + public VfModuleCustomization getCatalogVfModuleCustomization() { return vfModuleCustomization; } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java index 92fc598e7d..cb4761c557 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java @@ -42,8 +42,7 @@ public final class VfModuleArtifact { private HeatEnvironment heatEnvironment; public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { - artifactInfo=artifactinfo; - result = new String(clientResult.getArtifactPayload(), "UTF-8"); + this(artifactinfo, clientResult, null); } public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) throws UnsupportedEncodingException { 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 5b24dc56a1..402af160c1 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 @@ -10,9 +10,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. @@ -31,6 +31,7 @@ import java.util.List; import java.util.Map; import org.onap.so.asdc.client.ASDCConfiguration; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; +import org.onap.so.asdc.util.ASDCNotificationLogging; import org.onap.so.db.catalog.beans.AllottedResourceCustomization; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Service; @@ -49,186 +50,156 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * This structure exists to avoid having issues if the order of the vfResource/vfmodule artifact is not good (tree structure). - * + * This structure exists to avoid having issues if the order of the vfResource/vfmodule artifact is not good (tree + * structure). */ - - -public class VfResourceStructure { - - protected static final Logger logger = LoggerFactory.getLogger(VfResourceStructure.class); - - private boolean isDeployedSuccessfully=false; - /** - * The Raw notification data. - */ - private final INotificationData notification; - /** - * The Raw notification data. - */ - private boolean isAlreadyDeployed=false; - - /** - * The resource we will try to deploy. - */ - private final IResourceInstance resourceInstance; - - /** - * The list of VfModules defined for this resource. - */ - private final List vfModulesStructureList; - - /** - * The list of VfModulesMetadata defined for this resource. - */ - private List vfModulesMetadataList; - - private VnfResource catalogVnfResource; - - private NetworkResourceCustomization catalogNetworkResourceCustomization; - - private AllottedResourceCustomization catalogResourceCustomization; - - private Service catalogService; - - /** - * The list of artifacts existing in this resource hashed by UUID. - */ - private final Map artifactsMapByUUID; - - - public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) { - notification=notificationdata; - resourceInstance=resourceinstance; - vfModulesStructureList = new LinkedList<>(); - artifactsMapByUUID = new HashMap<>(); - } - - public void addArtifactToStructure(IDistributionClient distributionClient,IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { - VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo,clientResult); - addArtifactByType(artifactinfo,clientResult,vfModuleArtifact); - } - - public void addArtifactToStructure(IDistributionClient distributionClient,IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) throws UnsupportedEncodingException { - VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo,clientResult,modifiedHeatTemplate); - addArtifactByType(artifactinfo,clientResult,vfModuleArtifact); - } - - protected void addArtifactByType(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException { - - switch(artifactinfo.getArtifactType()) { - case ASDCConfiguration.HEAT: - case ASDCConfiguration.HEAT_ENV: - case ASDCConfiguration.HEAT_VOL: - case ASDCConfiguration.HEAT_NESTED: // For 1607 only 1 level tree is supported - case ASDCConfiguration.HEAT_ARTIFACT: - case ASDCConfiguration.HEAT_NET: - case ASDCConfiguration.OTHER: - artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact); - break; - case ASDCConfiguration.VF_MODULES_METADATA: - vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload()); - break; - default: - break; - } - } - - 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"); - return; - } - for (IVfModuleData vfModuleMeta:vfModulesMetadataList) { - vfModulesStructureList.add(new VfModuleStructure(this,vfModuleMeta)); - } - } - - public INotificationData getNotification() { - return notification; - } - - public IResourceInstance getResourceInstance() { - return resourceInstance; - } - - public List getVfModuleStructure() { - return vfModulesStructureList; - } - - public boolean isDeployedSuccessfully() { - return isDeployedSuccessfully; - } - - public void setSuccessfulDeployment() { - isDeployedSuccessfully = true; - } - - public boolean isAlreadyDeployed() { - return isAlreadyDeployed; - } - - public void setAlreadyDeployed(boolean isAlreadyDeployed) { - this.isAlreadyDeployed = isAlreadyDeployed; - } - - public Map getArtifactsMapByUUID() { - return artifactsMapByUUID; - } - - public List getVfModulesStructureList() { - return vfModulesStructureList; - } - - public VnfResource getCatalogVnfResource() { - return catalogVnfResource; - } - - public void setCatalogVnfResource(VnfResource catalogVnfResource) { - this.catalogVnfResource = catalogVnfResource; - } - - // Network Only - public NetworkResourceCustomization getCatalogNetworkResourceCustomization() { - return catalogNetworkResourceCustomization; - } - // Network Only - public void setCatalogNetworkResourceCustomization(NetworkResourceCustomization catalogNetworkResourceCustomization) { - this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization; - } - - public AllottedResourceCustomization getCatalogResourceCustomization() { - return catalogResourceCustomization; - } - - public void setCatalogResourceCustomization( - AllottedResourceCustomization catalogResourceCustomization) { - this.catalogResourceCustomization = catalogResourceCustomization; - } - - public Service getCatalogService() { - return catalogService; - } - - public void setCatalogService(Service catalogService) { - this.catalogService = catalogService; - } - - public List decodeVfModuleArtifact(byte[] arg0) { - try { - List listVFModuleMetaData = new ObjectMapper().readValue(arg0, new TypeReference>(){}); - return listVFModuleMetaData; - - } catch (JsonParseException e) { - logger.debug("JsonParseException : ",e); - } catch (JsonMappingException e) { - logger.debug("JsonMappingException : ",e); - } catch (IOException e) { - logger.debug("IOException : ",e); - } - return null; - } +public class VfResourceStructure extends ResourceStructure { + + protected static final Logger logger = LoggerFactory.getLogger(VfResourceStructure.class); + + /** + * The list of VfModules defined for this resource. + */ + private final List vfModulesStructureList; + + /** + * The list of VfModulesMetadata defined for this resource. + */ + private List vfModulesMetadataList; + + private VnfResource catalogVnfResource; + + private NetworkResourceCustomization catalogNetworkResourceCustomization; + + private AllottedResourceCustomization catalogResourceCustomization; + + private Service catalogService; + + + public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) { + super(notificationdata, resourceinstance); + this.resourceType = ResourceType.VF_RESOURCE; + vfModulesStructureList = new LinkedList<>(); + } + + public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, + IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { + this.addArtifactToStructure(distributionClient, artifactinfo, clientResult, null); + } + + public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, + IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) + throws UnsupportedEncodingException { + VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo, clientResult, modifiedHeatTemplate); + addArtifactByType(artifactinfo, clientResult, vfModuleArtifact); + if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactinfo.getArtifactType())) { + logger.debug("VF_MODULE_ARTIFACT: " + new String(clientResult.getArtifactPayload(), "UTF-8")); + logger.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(vfModulesMetadataList)); + } + } + + protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult, + VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException { + + switch (artifactinfo.getArtifactType()) { + case ASDCConfiguration.HEAT: + case ASDCConfiguration.HEAT_ENV: + case ASDCConfiguration.HEAT_VOL: + case ASDCConfiguration.HEAT_NESTED: // For 1607 only 1 level tree is supported + case ASDCConfiguration.HEAT_ARTIFACT: + case ASDCConfiguration.HEAT_NET: + case ASDCConfiguration.OTHER: + artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact); + break; + case ASDCConfiguration.VF_MODULES_METADATA: + vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload()); + break; + default: + break; + } + } + + public void prepareInstall() throws ArtifactInstallerException{ + createVfModuleStructures(); + } + + 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"); + return; + } + for (IVfModuleData vfModuleMeta : vfModulesMetadataList) { + vfModulesStructureList.add(new VfModuleStructure(this, vfModuleMeta)); + } + setNumberOfResources(vfModulesMetadataList.size()); + } + + public List getVfModuleStructure() { + return vfModulesStructureList; + } + + public Map getArtifactsMapByUUID() { + return artifactsMapByUUID; + } + + public List getVfModulesStructureList() { + return vfModulesStructureList; + } + + public VnfResource getCatalogVnfResource() { + return catalogVnfResource; + } + + public void setCatalogVnfResource(VnfResource catalogVnfResource) { + this.catalogVnfResource = catalogVnfResource; + } + + // Network Only + public NetworkResourceCustomization getCatalogNetworkResourceCustomization() { + return catalogNetworkResourceCustomization; + } + + // Network Only + public void setCatalogNetworkResourceCustomization( + NetworkResourceCustomization catalogNetworkResourceCustomization) { + this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization; + } + + public AllottedResourceCustomization getCatalogResourceCustomization() { + return catalogResourceCustomization; + } + + public void setCatalogResourceCustomization( + AllottedResourceCustomization catalogResourceCustomization) { + this.catalogResourceCustomization = catalogResourceCustomization; + } + + public Service getCatalogService() { + return catalogService; + } + + public void setCatalogService(Service catalogService) { + this.catalogService = catalogService; + } + + public List decodeVfModuleArtifact(byte[] arg0) { + try { + List listVFModuleMetaData = new ObjectMapper() + .readValue(arg0, new TypeReference>() { + }); + return listVFModuleMetaData; + + } catch (JsonParseException e) { + logger.debug("JsonParseException : ", e); + } catch (JsonMappingException e) { + logger.debug("JsonMappingException : ", e); + } catch (IOException e) { + logger.debug("IOException : ", e); + } + return null; + } } 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 5af427a81a..db639dad0a 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 @@ -10,9 +10,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. @@ -24,6 +24,8 @@ package org.onap.so.asdc.installer.heat; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; @@ -35,13 +37,15 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; - import org.hibernate.exception.ConstraintViolationException; import org.hibernate.exception.LockAcquisitionException; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.IResourceInstance; import org.onap.sdc.api.notification.IStatusData; +import org.onap.sdc.tosca.parser.api.IEntityDetails; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +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; @@ -62,6 +66,8 @@ import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.asdc.installer.ASDCElementInfo; import org.onap.so.asdc.installer.BigDecimalVersion; import org.onap.so.asdc.installer.IVfModuleData; +import org.onap.so.asdc.installer.PnfResourceStructure; +import org.onap.so.asdc.installer.ResourceStructure; import org.onap.so.asdc.installer.ToscaResourceStructure; import org.onap.so.asdc.installer.VfModuleArtifact; import org.onap.so.asdc.installer.VfModuleStructure; @@ -84,6 +90,8 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkInstanceGroup; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.PnfResource; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.SubType; @@ -109,6 +117,8 @@ import org.onap.so.db.catalog.data.repository.HeatTemplateRepository; import org.onap.so.db.catalog.data.repository.InstanceGroupRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; +import org.onap.so.db.catalog.data.repository.PnfCustomizationRepository; +import org.onap.so.db.catalog.data.repository.PnfResourceRepository; import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.ServiceRepository; import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository; @@ -133,2007 +143,2323 @@ import org.springframework.orm.ObjectOptimisticLockingFailureException; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - @Component public class ToscaResourceInstaller { - protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry"; - - protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor"; - - protected static final String ALLOTTED_RESOURCE = "Allotted Resource"; - - protected static final String MULTI_STAGE_DESIGN = "multi_stage_design"; - - protected static final String SCALABLE = "scalable"; - - protected static final String BASIC = "BASIC"; - - protected static final String PROVIDER = "PROVIDER"; - - protected static final String HEAT = "HEAT"; - - protected static final String MANUAL_RECORD = "MANUAL_RECORD"; - - protected static final String MSO = "SO"; - - - @Autowired - protected ServiceRepository serviceRepo; - - @Autowired - protected InstanceGroupRepository instanceGroupRepo; - - @Autowired - protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo; - - @Autowired - protected CollectionResourceRepository collectionRepo; - - @Autowired - protected CollectionResourceCustomizationRepository collectionCustomizationRepo; - - @Autowired - protected ConfigurationResourceCustomizationRepository configCustomizationRepo; - - @Autowired - protected ConfigurationResourceRepository configRepo; - - @Autowired - protected VnfResourceRepository vnfRepo; - - @Autowired - protected VnfCustomizationRepository vnfCustomizationRepo; - - @Autowired - protected VFModuleRepository vfModuleRepo; - - @Autowired - protected VFModuleCustomizationRepository vfModuleCustomizationRepo; - - @Autowired - protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo; - - @Autowired - protected VnfcCustomizationRepository vnfcCustomizationRepo; - - @Autowired - protected CvnfcCustomizationRepository cvnfcCustomizationRepo; - - @Autowired - protected AllottedResourceRepository allottedRepo; - - @Autowired - protected AllottedResourceCustomizationRepository allottedCustomizationRepo; - - @Autowired - protected NetworkResourceRepository networkRepo; - - @Autowired - protected HeatTemplateRepository heatRepo; - - @Autowired - protected NetworkResourceCustomizationRepository networkCustomizationRepo; - - @Autowired - protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository; - @Autowired - protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository; - @Autowired - protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository; - - @Autowired - protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo; - - @Autowired - protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository; - - protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class); - - public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException { - boolean status = false; - VfResourceStructure vfResourceStructure = vfResourceStruct; - try { - status = vfResourceStructure.isDeployedSuccessfully(); - } catch (RuntimeException e) { - status = false; - } - try { - Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID()); - if(existingService != null) - status = true; - if (status) { - logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(), - vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), - vfResourceStructure.getNotification().getServiceName(), - BigDecimalVersion.castAndCheckNotificationVersionToString( - vfResourceStructure.getNotification().getServiceVersion()), - vfResourceStructure.getNotification().getServiceUUID(), - vfResourceStructure.getResourceInstance().getResourceName(), "", ""); - WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO); - wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name()); - watchdogCDStatusRepository.saveAndFlush(wdStatus); - } else { - logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(), - vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), - vfResourceStructure.getNotification().getServiceName(), - BigDecimalVersion.castAndCheckNotificationVersionToString( - vfResourceStructure.getNotification().getServiceVersion()), - vfResourceStructure.getNotification().getServiceUUID(), - vfResourceStructure.getResourceInstance().getResourceName(), "", ""); - } - return status; - } catch (Exception e) { - logger - .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(), - "Exception - isResourceAlreadyDeployed"); - throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e); - } - } - - public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException { - logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}", - iStatus.getDistributionID(), iStatus.getComponentName()); - - try { - WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(), - iStatus.getComponentName()); - cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString()); - watchdogCDStatusRepository.save(cdStatus); - - } catch (Exception e) { - logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage()); - throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage()); - } - } - - @Transactional(rollbackFor = { ArtifactInstallerException.class }) - public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct) - throws ArtifactInstallerException { - VfResourceStructure vfResourceStructure = vfResourceStruct; - extractHeatInformation(toscaResourceStruct, vfResourceStructure); - - // PCLO: in case of deployment failure, use a string that will represent - // the type of artifact that failed... - List artifactListForLogging = new ArrayList<>(); - try { - createToscaCsar(toscaResourceStruct); - Service service = createService(toscaResourceStruct, vfResourceStruct); - - processResourceSequence(toscaResourceStruct, service); - processVFResources(toscaResourceStruct, service, vfResourceStructure); - List allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources(); - processAllottedResources(toscaResourceStruct, service, allottedResourceList); - processNetworks(toscaResourceStruct, service); - // process Network Collections - processNetworkCollections(toscaResourceStruct, service); - // Process Service Proxy & Configuration - processServiceProxyAndConfiguration(toscaResourceStruct, service); - - serviceRepo.save(service); - - WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO); - status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name()); - watchdogCDStatusRepository.save(status); - - toscaResourceStruct.setSuccessfulDeployment(); - - } catch (Exception e) { - logger.debug("Exception :", e); - WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO); - status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name()); - watchdogCDStatusRepository.save(status); - Throwable dbExceptionToCapture = e; - while (!(dbExceptionToCapture instanceof ConstraintViolationException - || dbExceptionToCapture instanceof LockAcquisitionException) - && (dbExceptionToCapture.getCause() != null)) { - dbExceptionToCapture = dbExceptionToCapture.getCause(); - } - - if (dbExceptionToCapture instanceof ConstraintViolationException - || dbExceptionToCapture instanceof LockAcquisitionException) { - logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(), - vfResourceStructure.getResourceInstance().getResourceName(), - vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(), - "Exception - ASCDC Artifact already deployed", e); - } else { - String elementToLog = (!artifactListForLogging.isEmpty() - ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString() - : "No element listed"); - logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog, - ErrorCode.DataError.getValue(), - "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() - + ". Transaction rollback", e); - throw new ArtifactInstallerException("Exception caught during installation of " - + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e); - } - } - } - - - List getRequirementList(List resultList, List nodeTemplates, - ISdcCsarHelper iSdcCsarHelper) { - - List nodes = new ArrayList(); - nodes.addAll(nodeTemplates); - - for (NodeTemplate nodeTemplate : nodeTemplates) { - RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate); - List reqAs = requirement.getAll(); - for (RequirementAssignment ra : reqAs) { - String reqNode = ra.getNodeTemplateName(); - for (NodeTemplate rNode : resultList) { - if (rNode.getName().equals(reqNode)) { - if(!resultList.contains(nodeTemplate)) { - resultList.add(nodeTemplate); - } - if(nodes.contains(nodeTemplate)) { - nodes.remove(nodeTemplate); - } - break; - } - } - } - } - - if (!nodes.isEmpty()) { - getRequirementList(resultList, nodes, iSdcCsarHelper); - } - - return resultList; - } - - // This method retrieve resource sequence from csar file - void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) { - List resouceSequence = new ArrayList(); - List resultList = new ArrayList(); - - ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper(); - List nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates(); - List nodes = new ArrayList(); - nodes.addAll(nodeTemplates); - - for (NodeTemplate nodeTemplate : nodeTemplates) { - RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate); - - if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) { - resultList.add(nodeTemplate); - nodes.remove(nodeTemplate); - } - } - - resultList = getRequirementList(resultList, nodes, iSdcCsarHelper); - - for (NodeTemplate node : resultList) { - String templateName = node.getMetaData().getValue("name"); - if (!resouceSequence.contains(templateName)) { - resouceSequence.add(templateName); - } - } - - String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(",")); - service.setResourceOrder(resourceSeqStr); - logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr); - } - - private static String CUSTOMIZATION_UUID = "customizationUUID"; - - private static String getValue(Object value, List servInputs) { - String output = null; - if(value instanceof Map) { - // currently this logic handles only one level of nesting. - return ((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 - } - } - - } else { - output = value != null ? value.toString() : ""; - } - return output; // return property value - } - - String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid) throws ArtifactInstallerException { - Map resouceRequest = new HashMap<>(); - ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper(); - - List serInput = iSdcCsarHelper.getServiceInputs(); - Optional nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream() - .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst(); - if(nodeTemplateOpt.isPresent()) { - NodeTemplate nodeTemplate = nodeTemplateOpt.get(); - LinkedHashMap resourceProperties = nodeTemplate.getProperties(); - - for(String key : resourceProperties.keySet()) { - Property property = resourceProperties.get(key); - - String value = getValue(property.getValue(), serInput); - resouceRequest.put(key, value); - } - } - - try { - ObjectMapper objectMapper = new ObjectMapper(); - String jsonStr = objectMapper.writeValueAsString(resouceRequest); - - jsonStr = jsonStr.replace("\"", "\\\""); - logger.debug("resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr); - return jsonStr; - } catch (JsonProcessingException e) { - logger.error("resource input could not be deserialized for resource customization id (" - + resourceCustomizationUuid + ")"); - throw new ArtifactInstallerException("resource input could not be parsed", e); - } - } - - protected void processNetworks (ToscaResourceStructure toscaResourceStruct, - Service service) throws ArtifactInstallerException { - List nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList (); - - if (nodeTemplatesVLList != null) { - for (NodeTemplate vlNode : nodeTemplatesVLList) { - String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME); + protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry"; + + protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor"; + + protected static final String ALLOTTED_RESOURCE = "Allotted Resource"; + + protected static final String MULTI_STAGE_DESIGN = "multi_stage_design"; + + protected static final String SCALABLE = "scalable"; + + protected static final String BASIC = "BASIC"; + + protected static final String PROVIDER = "PROVIDER"; + + protected static final String HEAT = "HEAT"; + + protected static final String MANUAL_RECORD = "MANUAL_RECORD"; + + protected static final String MSO = "SO"; + + protected static final String SDNC_MODEL_NAME = "sdnc_model_name"; + + protected static final String SDNC_MODEL_VERSION = "sdnc_model_version"; + + private static String CUSTOMIZATION_UUID = "customizationUUID"; + + + @Autowired + protected ServiceRepository serviceRepo; + + @Autowired + protected InstanceGroupRepository instanceGroupRepo; + + @Autowired + protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo; + + @Autowired + protected CollectionResourceRepository collectionRepo; + + @Autowired + protected CollectionResourceCustomizationRepository collectionCustomizationRepo; + + @Autowired + protected ConfigurationResourceCustomizationRepository configCustomizationRepo; + + @Autowired + protected ConfigurationResourceRepository configRepo; + + @Autowired + protected VnfResourceRepository vnfRepo; + + @Autowired + protected VnfCustomizationRepository vnfCustomizationRepo; + + @Autowired + protected VFModuleRepository vfModuleRepo; + + @Autowired + protected VFModuleCustomizationRepository vfModuleCustomizationRepo; + + @Autowired + protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo; + + @Autowired + protected VnfcCustomizationRepository vnfcCustomizationRepo; + + @Autowired + protected CvnfcCustomizationRepository cvnfcCustomizationRepo; + + @Autowired + protected AllottedResourceRepository allottedRepo; + + @Autowired + protected AllottedResourceCustomizationRepository allottedCustomizationRepo; + + @Autowired + protected NetworkResourceRepository networkRepo; + + @Autowired + protected HeatTemplateRepository heatRepo; + + @Autowired + protected NetworkResourceCustomizationRepository networkCustomizationRepo; + + @Autowired + protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository; + @Autowired + protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository; + @Autowired + protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository; + + @Autowired + protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo; + + @Autowired + protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository; + + @Autowired + protected PnfResourceRepository pnfResourceRepository; + + @Autowired + protected PnfCustomizationRepository pnfCustomizationRepository; + + protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class); + + public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException { + boolean status = false; + VfResourceStructure vfResourceStructure = vfResourceStruct; + try { + status = vfResourceStructure.isDeployedSuccessfully(); + } catch (RuntimeException e) { + status = false; + } + try { + Service existingService = serviceRepo + .findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID()); + if (existingService != null) { + status = true; + } + if (status) { + logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(), + vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), + vfResourceStructure.getNotification().getServiceName(), + BigDecimalVersion.castAndCheckNotificationVersionToString( + vfResourceStructure.getNotification().getServiceVersion()), + vfResourceStructure.getNotification().getServiceUUID(), + vfResourceStructure.getResourceInstance().getResourceName(), "", ""); + WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus( + vfResourceStruct.getNotification().getDistributionID(), MSO); + wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name()); + watchdogCDStatusRepository.saveAndFlush(wdStatus); + } else { + logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(), + vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), + vfResourceStructure.getNotification().getServiceName(), + BigDecimalVersion.castAndCheckNotificationVersionToString( + vfResourceStructure.getNotification().getServiceVersion()), + vfResourceStructure.getNotification().getServiceUUID(), + vfResourceStructure.getResourceInstance().getResourceName(), "", ""); + } + return status; + } catch (Exception e) { + logger + .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), + ErrorCode.SchemaError.getValue(), + "Exception - isResourceAlreadyDeployed"); + throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e); + } + } + + public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException { + logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}", + iStatus.getDistributionID(), iStatus.getComponentName()); + + try { + WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus( + iStatus.getDistributionID(), + iStatus.getComponentName()); + cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString()); + watchdogCDStatusRepository.save(cdStatus); + + } catch (Exception e) { + logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage()); + throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage()); + } + } + + @Transactional(rollbackFor = {ArtifactInstallerException.class}) + public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct) + throws ArtifactInstallerException { + if (resourceStruct instanceof VfResourceStructure) { + installTheVfResouce(toscaResourceStruct, (VfResourceStructure) resourceStruct); + } else if (resourceStruct instanceof PnfResourceStructure) { + installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct); + } else { + logger.warn("Unrecognized resource type"); + } + } + + private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct) + throws ArtifactInstallerException { + + // PCLO: in case of deployment failure, use a string that will represent + // the type of artifact that failed... + List artifactListForLogging = new ArrayList<>(); + try { + createToscaCsar(toscaResourceStruct); + Service service = createService(toscaResourceStruct, resourceStruct); + + processResourceSequence(toscaResourceStruct, service); + processPnfResources(toscaResourceStruct, service, resourceStruct); + serviceRepo.save(service); + + WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus( + resourceStruct.getNotification().getDistributionID(), MSO); + status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name()); + watchdogCDStatusRepository.save(status); + + toscaResourceStruct.setSuccessfulDeployment(); + + } catch (Exception e) { + logger.debug("Exception :", e); + WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus( + resourceStruct.getNotification().getDistributionID(), MSO); + status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name()); + watchdogCDStatusRepository.save(status); + Throwable dbExceptionToCapture = e; + while (!(dbExceptionToCapture instanceof ConstraintViolationException + || dbExceptionToCapture instanceof LockAcquisitionException) + && (dbExceptionToCapture.getCause() != null)) { + dbExceptionToCapture = dbExceptionToCapture.getCause(); + } + + if (dbExceptionToCapture instanceof ConstraintViolationException + || dbExceptionToCapture instanceof LockAcquisitionException) { + logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(), + resourceStruct.getResourceInstance().getResourceName(), + resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(), + "Exception - ASCDC Artifact already deployed", e); + } else { + String elementToLog = (!artifactListForLogging.isEmpty() + ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString() + : "No element listed"); + logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog, + ErrorCode.DataError.getValue(), + "Exception caught during installation of " + resourceStruct.getResourceInstance() + .getResourceName() + + ". Transaction rollback", e); + throw new ArtifactInstallerException("Exception caught during installation of " + + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.", e); + } + } + } + + private void installTheVfResouce(ToscaResourceStructure toscaResourceStruct, VfResourceStructure resourceStruct) + throws ArtifactInstallerException { + VfResourceStructure vfResourceStructure = resourceStruct; + extractHeatInformation(toscaResourceStruct, vfResourceStructure); + + // PCLO: in case of deployment failure, use a string that will represent + // the type of artifact that failed... + List artifactListForLogging = new ArrayList<>(); + try { + createToscaCsar(toscaResourceStruct); + Service service = createService(toscaResourceStruct, resourceStruct); + + processResourceSequence(toscaResourceStruct, service); + processVFResources(toscaResourceStruct, service, vfResourceStructure); + List allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources(); + processAllottedResources(toscaResourceStruct, service, allottedResourceList); + processNetworks(toscaResourceStruct, service); + // process Network Collections + processNetworkCollections(toscaResourceStruct, service); + // Process Service Proxy & Configuration + processServiceProxyAndConfiguration(toscaResourceStruct, service); + + serviceRepo.save(service); + + WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus( + resourceStruct.getNotification().getDistributionID(), MSO); + status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name()); + watchdogCDStatusRepository.save(status); + + toscaResourceStruct.setSuccessfulDeployment(); + + } catch (Exception e) { + logger.debug("Exception :", e); + WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus( + resourceStruct.getNotification().getDistributionID(), MSO); + status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name()); + watchdogCDStatusRepository.save(status); + Throwable dbExceptionToCapture = e; + while (!(dbExceptionToCapture instanceof ConstraintViolationException + || dbExceptionToCapture instanceof LockAcquisitionException) + && (dbExceptionToCapture.getCause() != null)) { + dbExceptionToCapture = dbExceptionToCapture.getCause(); + } + + if (dbExceptionToCapture instanceof ConstraintViolationException + || dbExceptionToCapture instanceof LockAcquisitionException) { + logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(), + vfResourceStructure.getResourceInstance().getResourceName(), + vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(), + "Exception - ASCDC Artifact already deployed", e); + } else { + String elementToLog = (!artifactListForLogging.isEmpty() + ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString() + : "No element listed"); + logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog, + ErrorCode.DataError.getValue(), + "Exception caught during installation of " + vfResourceStructure.getResourceInstance() + .getResourceName() + + ". Transaction rollback", e); + throw new ArtifactInstallerException("Exception caught during installation of " + + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e); + } + } + } + + + List getRequirementList(List resultList, List nodeTemplates, + ISdcCsarHelper iSdcCsarHelper) { + + List nodes = new ArrayList(); + nodes.addAll(nodeTemplates); + + for (NodeTemplate nodeTemplate : nodeTemplates) { + RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate); + List reqAs = requirement.getAll(); + for (RequirementAssignment ra : reqAs) { + String reqNode = ra.getNodeTemplateName(); + for (NodeTemplate rNode : resultList) { + if (rNode.getName().equals(reqNode)) { + if (!resultList.contains(nodeTemplate)) { + resultList.add(nodeTemplate); + } + if (nodes.contains(nodeTemplate)) { + nodes.remove(nodeTemplate); + } + break; + } + } + } + } + + if (!nodes.isEmpty()) { + getRequirementList(resultList, nodes, iSdcCsarHelper); + } + + return resultList; + } + + // This method retrieve resource sequence from csar file + void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) { + List resouceSequence = new ArrayList(); + List resultList = new ArrayList(); + + ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper(); + List nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates(); + List nodes = new ArrayList(); + nodes.addAll(nodeTemplates); + + for (NodeTemplate nodeTemplate : nodeTemplates) { + RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate); + + if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) { + resultList.add(nodeTemplate); + nodes.remove(nodeTemplate); + } + } + + resultList = getRequirementList(resultList, nodes, iSdcCsarHelper); + + for (NodeTemplate node : resultList) { + String templateName = node.getMetaData().getValue("name"); + if (!resouceSequence.contains(templateName)) { + resouceSequence.add(templateName); + } + } + + String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(",")); + service.setResourceOrder(resourceSeqStr); + logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr); + } + + private static String getValue(Object value, List servInputs) { + String output = null; + if (value instanceof Map) { + // currently this logic handles only one level of nesting. + return ((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 + } + } + + } else { + output = value != null ? value.toString() : ""; + } + return output; // return property value + } + + String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid) + throws ArtifactInstallerException { + Map resouceRequest = new HashMap<>(); + ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper(); + + List serInput = iSdcCsarHelper.getServiceInputs(); + Optional nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream() + .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst(); + if (nodeTemplateOpt.isPresent()) { + NodeTemplate nodeTemplate = nodeTemplateOpt.get(); + LinkedHashMap resourceProperties = nodeTemplate.getProperties(); + + for (String key : resourceProperties.keySet()) { + Property property = resourceProperties.get(key); + + String value = getValue(property.getValue(), serInput); + resouceRequest.put(key, value); + } + } + + try { + ObjectMapper objectMapper = new ObjectMapper(); + String jsonStr = objectMapper.writeValueAsString(resouceRequest); + + jsonStr = jsonStr.replace("\"", "\\\""); + logger.debug( + "resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr); + return jsonStr; + } catch (JsonProcessingException e) { + logger.error("resource input could not be deserialized for resource customization id (" + + resourceCustomizationUuid + ")"); + throw new ArtifactInstallerException("resource input could not be parsed", e); + } + } + + protected void processNetworks(ToscaResourceStructure toscaResourceStruct, + Service service) throws ArtifactInstallerException { + List nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList(); + + if (nodeTemplatesVLList != null) { + for (NodeTemplate vlNode : nodeTemplatesVLList) { + String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME); TempNetworkHeatTemplateLookup tempNetworkLookUp = - tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName); + tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName); if (tempNetworkLookUp != null) { HeatTemplate heatTemplate = - heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ()); + heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid()); if (heatTemplate != null) { NetworkResourceCustomization networkCustomization = - createNetwork (vlNode, - toscaResourceStruct, - heatTemplate, - tempNetworkLookUp.getAicVersionMax (), - tempNetworkLookUp.getAicVersionMin (), - service); - service.getNetworkCustomizations ().add (networkCustomization); + createNetwork(vlNode, + toscaResourceStruct, + heatTemplate, + tempNetworkLookUp.getAicVersionMax(), + tempNetworkLookUp.getAicVersionMin(), + service); + service.getNetworkCustomizations().add(networkCustomization); + } else { + throw new ArtifactInstallerException("No HeatTemplate found for artifactUUID: " + + tempNetworkLookUp.getHeatTemplateArtifactUuid()); + } + } else { + NetworkResourceCustomization networkCustomization = createNetwork(vlNode, + toscaResourceStruct, + null, + null, + null, + service); + service.getNetworkCustomizations().add(networkCustomization); + logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for " + + networkResourceModelName); + } + + } + } + } + + protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service, + List allottedResourceList) { + if (allottedResourceList != null) { + for (NodeTemplate allottedNode : allottedResourceList) { + service.getAllottedCustomizations() + .add(createAllottedResource(allottedNode, toscaResourceStruct, service)); + } + } + } + + + protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) { + Metadata metadata = nodeTemplate.getMetaData(); + ConfigurationResource configResource = new ConfigurationResource(); + configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + configResource.setToscaNodeType(nodeTemplate.getType()); + return configResource; + } + + protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate, + ToscaResourceStructure toscaResourceStructure, + ServiceProxyResourceCustomization spResourceCustomization) { + Metadata metadata = nodeTemplate.getMetaData(); + + ConfigurationResource configResource = getConfigurationResource(nodeTemplate); + + ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization(); + + Set configResourceCustomizationSet = new HashSet<>(); + + configCustomizationResource + .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.setConfigurationResource(configResource); + configResourceCustomizationSet.add(configCustomizationResource); + + configResource.setConfigurationResourceCustomization(configResourceCustomizationSet); + return configCustomizationResource; + } + + + protected Optional getVnrNodeTemplate( + List configurationNodeTemplatesList, + ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) { + Optional configurationResourceCust = Optional.empty(); + for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) { + StatefulEntityType entityType = nodeTemplate.getTypeDefinition(); + String type = entityType.getType(); + + if (VLAN_NETWORK_RECEPTOR.equals(type)) { + configurationResourceCust = Optional.of(getConfigurationResourceCustomization(nodeTemplate, + toscaResourceStructure, spResourceCustomization)); + break; + } + } + + return configurationResourceCust; + } + + protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) { + + List serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper() + .getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY); + + List configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper() + .getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION); + + List serviceProxyList = new ArrayList(); + List configurationResourceList = new ArrayList(); + + ServiceProxyResourceCustomization serviceProxy = null; + + if (serviceProxyResourceList != null) { + for (NodeTemplate spNode : serviceProxyResourceList) { + serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct); + serviceProxyList.add(serviceProxy); + Optional vnrResourceCustomization = getVnrNodeTemplate( + configurationNodeTemplatesList, toscaResourceStruct, serviceProxy); + + for (NodeTemplate configNode : configurationNodeTemplatesList) { + + List requirementsList = toscaResourceStruct.getSdcCsarHelper() + .getRequirementsOf(configNode).getAll(); + for (RequirementAssignment requirement : requirementsList) { + if (requirement.getNodeTemplateName().equals(spNode.getName())) { + ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, + toscaResourceStruct, serviceProxy, vnrResourceCustomization); + + Optional matchingObject = configurationResourceList + .stream() + .filter(configurationResourceCustomization -> configNode.getMetaData() + .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID) + .equals(configurationResource.getModelCustomizationUUID())) + .findFirst(); + if (!matchingObject.isPresent()) { + configurationResourceList.add(configurationResource); + } + + break; + } + } + } + + } + } + + service.setConfigurationCustomizations(configurationResourceList); + service.setServiceProxyCustomizations(serviceProxyList); + } + + protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) { + + List networkCollectionList = toscaResourceStruct.getSdcCsarHelper() + .getServiceNodeTemplateBySdcType(SdcTypes.CR); + + if (networkCollectionList != null) { + for (NodeTemplate crNode : networkCollectionList) { + + createNetworkCollection(crNode, toscaResourceStruct, service); + collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource()); + + List networkInstanceGroupList = toscaResourceStruct + .getCatalogNetworkInstanceGroup(); + for (NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList) { + instanceGroupRepo.saveAndFlush(networkInstanceGroup); + } + + } + } + service.getCollectionResourceCustomizations() + .add(toscaResourceStruct.getCatalogCollectionResourceCustomization()); + } + + + protected void processVFResources(ToscaResourceStructure toscaResourceStruct, Service service, + VfResourceStructure vfResourceStructure) + throws Exception { + logger.debug("processVFResources"); + + List vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList(); + + for (NodeTemplate nodeTemplate : vfNodeTemplatesList) { + Metadata metadata = nodeTemplate.getMetaData(); + String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); + logger.debug("VF Category is : " + vfCustomizationCategory); + + // Do not treat Allotted Resources as VNF resources + if (ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)) { + continue; + } + + String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); + logger.debug("VFCustomizationUUID=" + vfCustomizationUUID); + + IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance(); + + // Make sure the VF ResourceCustomizationUUID from the notification and tosca + // customizations match before comparing their VF Modules UUID's + logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: " + + vfCustomizationUUID); + + if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) { + logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + + " matches vfNotificationResource CustomizationUUID"); + + processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata, + vfCustomizationCategory); + } else { + logger.debug("Notification VF ResourceCustomizationUUID: " + + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " + + "Tosca VF Customization UUID: " + vfCustomizationUUID); + } + } + } + + /** + * This is used to process the PNF specific resource, including resource and resource_customization. {@link + * IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for details. + */ + protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service, + PnfResourceStructure resourceStructure) throws Exception { + logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID()); + + ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper(); + EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build(); + TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build(); + + List entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false); + for (IEntityDetails entityDetails : entityDetailsList) { + Metadata metadata = entityDetails.getMetadata(); + String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); + String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID); + String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID(); + if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) { + logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}", + customizationUUID, notifCustomizationUUID); + + if (checkExistingPnfResourceCutomization(customizationUUID)) { + logger.info("Resource customization UUID: {} already deployed", customizationUUID); + } else { + PnfResource pnfResource = findExistingPnfResource(service, modelUuid); + if (pnfResource == null) { + pnfResource = createPnfResource(entityDetails); + } + PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails, + pnfResource); + pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization); + toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization); + service.getPnfCustomizations().add(pnfResourceCustomization); + } + } else { + logger + .warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}", + customizationUUID, notifCustomizationUUID); + } + } + } + + private PnfResource findExistingPnfResource(Service service, String modelUuid) { + PnfResource pnfResource = null; + for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) { + if (pnfResourceCustomization.getPnfResources() != null && pnfResourceCustomization.getPnfResources() + .getModelUUID().equals(modelUuid)) { + pnfResource = pnfResourceCustomization.getPnfResources(); + } + } + if (pnfResource == null) { + pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource); + } + return pnfResource; + } + + private boolean checkExistingPnfResourceCutomization(String customizationUUID) { + return pnfCustomizationRepository.findById(customizationUUID).isPresent(); + } + + /** + * Construct the {@link PnfResource} from {@link IEntityDetails} object. + */ + private PnfResource createPnfResource(IEntityDetails entity) { + PnfResource pnfResource = new PnfResource(); + Metadata metadata = entity.getMetadata(); + pnfResource.setModelInvariantUUID( + testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + pnfResource.setModelVersion( + testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + pnfResource.setDescription( + testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY))); + pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY))); + pnfResource.setToscaNodeType(entity.getToscaType()); + return pnfResource; + } + + /** + * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object. + */ + private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails, + PnfResource pnfResource) { + + PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); + Metadata metadata = entityDetails.getMetadata(); + Map properties = entityDetails.getProperties(); + pnfResourceCustomization + .setModelCustomizationUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); + pnfResourceCustomization.setModelInstanceName(entityDetails.getName()); + pnfResourceCustomization + .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION))); + pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE))); + pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE))); + pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE))); + pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN))); + pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME))); + pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION))); + + pnfResourceCustomization.setPnfResources(pnfResource); + + return pnfResourceCustomization; + } + + /** + * Get value from {@link Property} and cast to String value. Return empty String if property is null value. + */ + private String getStringValue(Property property) { + if (null == property) { + return ""; + } + Object value = property.getValue(); + return String.valueOf(value); + } + + protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, + Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) + throws Exception { + + logger.debug("VF Category is : " + vfCustomizationCategory); + + VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service); + + if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure() + .isEmpty()) { + + String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper() + .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); + logger.debug("VFCustomizationUUID=" + vfCustomizationUUID); + + IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance(); + + // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's + logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource + .getResourceCustomizationUUID() + + " matches Tosca VF Customization UUID: " + vfCustomizationUUID); + + if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) { + + logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + + " matches vfNotificationResource CustomizationUUID"); + + Set existingCvnfcSet = new HashSet(); + Set existingVnfcSet = new HashSet(); + + for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { + + logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); + List vfGroups = toscaResourceStruct + .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); + IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); + + logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata + .getVfModuleModelCustomizationUUID()); + + Optional matchingObject = vfGroups.stream() + .peek(group -> logger.debug( + "To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata() + .getValue("vfModuleModelCustomizationUUID"))) + .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID") + .equals(vfMetadata.getVfModuleModelCustomizationUUID())) + .findFirst(); + if (matchingObject.isPresent()) { + VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), + nodeTemplate, toscaResourceStruct, + vfResourceStructure, vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet); + vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources()); + } else { + throw new Exception( + "Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata + .getVfModuleModelCustomizationUUID()); + } + + } + + } else { + logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource + .getResourceCustomizationUUID() + " doesn't match " + + "Tosca VF Customization UUID: " + vfCustomizationUUID); + } + } + + service.getVnfCustomizations().add(vnfResource); + } + + public void processWatchdog(String distributionId, String servideUUID, Optional distributionNotification, + String consumerId) { + WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID, + distributionNotification, consumerId); + watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup); + + try { + + WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId); + watchdogDistributionStatusRepository.saveAndFlush(distributionStatus); + + } catch (ObjectOptimisticLockingFailureException e) { + logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString()); + throw e; + } + } + + protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct, + VfResourceStructure vfResourceStructure) { + for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { + + switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) { + case ASDCConfiguration.HEAT: + case ASDCConfiguration.HEAT_NESTED: + createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, + vfModuleArtifact); + break; + case ASDCConfiguration.HEAT_VOL: + createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, + vfModuleArtifact); + VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, + vfModuleArtifact); + createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact); + break; + case ASDCConfiguration.HEAT_ENV: + createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact); + break; + case ASDCConfiguration.HEAT_ARTIFACT: + createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact, + toscaResourceStruct); + break; + case ASDCConfiguration.HEAT_NET: + case ASDCConfiguration.OTHER: + logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(), + vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact + .getArtifactInfo() + .getArtifactName() + ")", ErrorCode.DataError.getValue(), + "Artifact type not supported"); + break; + default: + break; + + } + } + } + + protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure, + VfModuleArtifact vfModuleArtifact) { + String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName(); + artifactName = artifactName.substring(0, artifactName.indexOf('.')); + for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { + if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName) + && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) { + return moduleArtifact; + } + } + return null; + } + + public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure, + List listTypes) { + String newFileBody = filebody; + for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { + + if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) { + + newFileBody = verifyTheFilePrefixInString(newFileBody, + moduleArtifact.getArtifactInfo().getArtifactName()); + } + } + return newFileBody; + } + + public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) { + + String needlePrefix = "file:///"; + String prefixedFilenameToVerify = needlePrefix + filenameToVerify; + + if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) { + return body; + } + + StringBuilder sb = new StringBuilder(body.length()); + + int currentIndex = 0; + int startIndex = 0; + + while (currentIndex != -1) { + startIndex = currentIndex; + currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex); + + if (currentIndex == -1) { + break; + } + // We append from the startIndex up to currentIndex (start of File + // Name) + sb.append(body.substring(startIndex, currentIndex)); + sb.append(filenameToVerify); + + currentIndex += prefixedFilenameToVerify.length(); + } + + sb.append(body.substring(startIndex)); + + return sb.toString(); + } + + protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure, + ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) { + HeatTemplate heatTemplate = new HeatTemplate(); + List typeList = new ArrayList<>(); + typeList.add(ASDCConfiguration.HEAT_NESTED); + typeList.add(ASDCConfiguration.HEAT_ARTIFACT); + + heatTemplate.setTemplateBody( + verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList)); + heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName()); + + if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) { + heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout()); + } else { + heatTemplate.setTimeoutMinutes(240); + } + + heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); + heatTemplate.setVersion(BigDecimalVersion + .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); + heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + + if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) { + heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); + } else { + heatTemplate.setArtifactChecksum(MANUAL_RECORD); + } + + Set heatParam = extractHeatTemplateParameters( + vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + heatTemplate.setParameters(heatParam); + vfModuleArtifact.setHeatTemplate(heatTemplate); + } + + protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure, + VfModuleArtifact vfModuleArtifact) { + HeatEnvironment heatEnvironment = new HeatEnvironment(); + heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName()); + List typeList = new ArrayList<>(); + typeList.add(ASDCConfiguration.HEAT); + typeList.add(ASDCConfiguration.HEAT_VOL); + heatEnvironment.setEnvironment( + verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList)); + heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); + heatEnvironment.setVersion(BigDecimalVersion + .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); + heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + + if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) { + heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); + } else { + heatEnvironment.setArtifactChecksum(MANUAL_RECORD); + } + vfModuleArtifact.setHeatEnvironment(heatEnvironment); + } + + protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure, + VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) { + + HeatFiles heatFile = new HeatFiles(); + heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); + heatFile.setFileBody(vfModuleArtifact.getResult()); + heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName()); + heatFile.setVersion(BigDecimalVersion + .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); + toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) { + heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); + } else { + heatFile.setArtifactChecksum(MANUAL_RECORD); + } + vfModuleArtifact.setHeatFiles(heatFile); + } + + protected Service createService(ToscaResourceStructure toscaResourceStructure, + ResourceStructure resourceStructure) { + + Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata(); + + Service service = new Service(); + + if (serviceMetadata != null) { + + if (toscaResourceStructure.getServiceVersion() != null) { + service.setModelVersion(toscaResourceStructure.getServiceVersion()); + } + + service.setServiceType(serviceMetadata.getValue("serviceType")); + service.setServiceRole(serviceMetadata.getValue("serviceRole")); + service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); + service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + service.setEnvironmentContext(serviceMetadata.getValue("environmentContext")); + + if (resourceStructure != null) { + service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext()); + } + + service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + service.setCsar(toscaResourceStructure.getCatalogToscaCsar()); + } + + toscaResourceStructure.setCatalogService(service); + return service; + } + + protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, + ToscaResourceStructure toscaResourceStructure) { + + Metadata spMetadata = nodeTemplate.getMetaData(); + + ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization(); + + Set serviceProxyCustomizationSet = new HashSet<>(); + + spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + spCustomizationResource + .setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + + spCustomizationResource + .setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + spCustomizationResource.setModelInstanceName(nodeTemplate.getName()); + spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); + + String sourceServiceUUID = spMetadata.getValue("sourceModelUuid"); + + Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID); + + spCustomizationResource.setSourceService(sourceService); + spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); + serviceProxyCustomizationSet.add(spCustomizationResource); + + toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource); + + return spCustomizationResource; + } + + protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, + ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization, + Optional vnrResourceCustomization) { + + ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization( + nodeTemplate, + toscaResourceStructure, spResourceCustomization); + + ConfigurationResource configResource = getConfigurationResource(nodeTemplate); + + Set configResourceCustomizationSet = new HashSet<>(); + + StatefulEntityType entityType = nodeTemplate.getTypeDefinition(); + String type = entityType.getType(); + + if (NODES_VRF_ENTRY.equals(type)) { + configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null)); + } + + configCustomizationResource.setConfigurationResource(configResource); + + configResourceCustomizationSet.add(configCustomizationResource); + + configResource.setConfigurationResourceCustomization(configResourceCustomizationSet); + + toscaResourceStructure.setCatalogConfigurationResource(configResource); + + toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource); + + return configCustomizationResource; + } + + protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate, + ToscaResourceStructure toscaResourceStructure) { + + Metadata fabricMetadata = nodeTemplate.getMetaData(); + + ConfigurationResource configResource = new ConfigurationResource(); + + configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + configResource.setToscaNodeType(nodeTemplate.getType()); + + return configResource; + } + + protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) { + ToscaCsar toscaCsar = new ToscaCsar(); + if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) { + toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum()); + } else { + toscaCsar.setArtifactChecksum(MANUAL_RECORD); + } + toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID()); + toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName()); + toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion()); + toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription()); + toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL()); + + toscaResourceStructure.setCatalogToscaCsar(toscaCsar); + } + + protected VnfcCustomization findExistingVfc(Set vnfcCustomizations, String customizationUUID) { + VnfcCustomization vnfcCustomization = null; + for (VnfcCustomization vnfcCustom : vnfcCustomizations) { + if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) { + vnfcCustomization = vnfcCustom; + } + } + + if (vnfcCustomization == null) { + vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID); + } + + return vnfcCustomization; + } + + protected CvnfcCustomization findExistingCvfc(Set cvnfcCustomizations, + String customizationUUID) { + CvnfcCustomization cvnfcCustomization = null; + for (CvnfcCustomization cvnfcCustom : cvnfcCustomizations) { + if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) { + cvnfcCustomization = cvnfcCustom; + } + } + + if (cvnfcCustomization == null) { + cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID); + } + + return cvnfcCustomization; + } + + protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate, + ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin, + Service service) { + + NetworkResourceCustomization networkResourceCustomization = networkCustomizationRepo + .findOneByModelCustomizationUUID( + networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + + boolean networkUUIDsMatch = true; + // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from the distribution. + // If not we'll update the Customization record with latest from the distribution + if (networkResourceCustomization != null) { + String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID(); + String latestNetworkModelUUID = networkNodeTemplate.getMetaData() + .getValue(SdcPropertyNames.PROPERTY_NAME_UUID); + + if (!existingNetworkModelUUID.equals(latestNetworkModelUUID)) { + networkUUIDsMatch = false; + } + + } + + if (networkResourceCustomization != null && !networkUUIDsMatch) { + + NetworkResource networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, + heatTemplate, + aicMax, aicMin); + + networkResourceCustomization.setNetworkResource(networkResource); + + networkCustomizationRepo.saveAndFlush(networkResourceCustomization); + + } else if (networkResourceCustomization == null) { + networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate, + toscaResourceStructure); + + NetworkResource networkResource = findExistingNetworkResource(service, + networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + if (networkResource == null) { + networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate, + aicMax, aicMin); + } + + networkResource.addNetworkResourceCustomization(networkResourceCustomization); + networkResourceCustomization.setNetworkResource(networkResource); + } + + return networkResourceCustomization; + } + + protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) { + NetworkResource networkResource = null; + for (NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()) { + if (networkCustom.getNetworkResource() != null + && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) { + networkResource = networkCustom.getNetworkResource(); + } + } + if (networkResource == null) { + networkResource = networkRepo.findResourceByModelUUID(modelUUID); + } + + return networkResource; + } + + protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate, + ToscaResourceStructure toscaResourceStructure) { + NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization(); + networkResourceCustomization.setModelInstanceName( + testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + networkResourceCustomization.setModelCustomizationUUID( + testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); + + networkResourceCustomization.setNetworkTechnology( + testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, + SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY))); + networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE))); + networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE))); + networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE))); + return networkResourceCustomization; + } + + protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate, + ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) { + NetworkResource networkResource = new NetworkResource(); + String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue( + networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK); + + if ("true".equalsIgnoreCase(providerNetwork)) { + networkResource.setNeutronNetworkType(PROVIDER); + } else { + networkResource.setNeutronNetworkType(BASIC); + } + + networkResource.setModelName( + testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + + networkResource.setModelInvariantUUID( + testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + networkResource.setModelUUID( + testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + networkResource.setModelVersion( + testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + + networkResource.setAicVersionMax(aicMax); + networkResource.setAicVersionMin(aicMin); + networkResource.setToscaNodeType(networkNodeTemplate.getType()); + networkResource.setDescription( + testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + networkResource.setOrchestrationMode(HEAT); + networkResource.setHeatTemplate(heatTemplate); + return networkResource; + } + + protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate, + ToscaResourceStructure toscaResourceStructure, Service service) { + + CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization(); + + // **** Build Object to populate Collection_Resource table + CollectionResource collectionResource = new CollectionResource(); + + collectionResource + .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + collectionResource.setModelInvariantUUID( + networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + collectionResource + .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + collectionResource + .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + collectionResource + .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + collectionResource.setToscaNodeType(networkNodeTemplate.getType()); + + toscaResourceStructure.setCatalogCollectionResource(collectionResource); + + // **** Build object to populate Collection_Resource_Customization table + NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization(); + + ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, + "cr_function")); + ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, + "cr_role")); + ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, + "cr_type")); + + ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + ncfc.setModelCustomizationUUID( + networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + + Set networkResourceCustomizationSet = new HashSet<>(); + networkResourceCustomizationSet.add(collectionNetworkResourceCustomization); + + ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet); + + ncfc.setCollectionResource(collectionResource); + toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc); + + //*** Build object to populate the Instance_Group table + List groupList = toscaResourceStructure.getSdcCsarHelper() + .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate, + "org.openecomp.groups.NetworkCollection"); + + List networkInstanceGroupList = new ArrayList<>(); + + List collectionResourceInstanceGroupCustomizationList = new ArrayList(); + + for (Group group : groupList) { + + NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup(); + Metadata instanceMetadata = group.getMetadata(); + networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + networkInstanceGroup + .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + networkInstanceGroup.setToscaNodeType(group.getType()); + networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set + // Role + networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set + // type + networkInstanceGroup.setCollectionResource(collectionResource); + + // ****Build object to populate + // Collection_Resource_Instance_Group_Customization table + CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization(); + crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup); + crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + crInstanceGroupCustomization.setModelCustomizationUUID( + networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + + // Loop through the template policy to find the subinterface_network_quantity property name. Then extract the value for it. + List policyList = toscaResourceStructure.getSdcCsarHelper() + .getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate, + "org.openecomp.policies.scaling.Fixed"); + + if (policyList != null) { + for (Policy policy : policyList) { + for (String policyNetworkCollection : policy.getTargets()) { + + if (policyNetworkCollection.equalsIgnoreCase(group.getName())) { + + Map propMap = policy.getPolicyProperties(); + + if (propMap.get("quantity") != null) { + + String quantity = toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(networkNodeTemplate, + getPropertyInput(propMap.get("quantity").toString())); + + if (quantity != null) { + crInstanceGroupCustomization + .setSubInterfaceNetworkQuantity(Integer.parseInt(quantity)); + } + + } + + } + } + } + } + + crInstanceGroupCustomization.setDescription( + toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, + instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME) + + "_network_collection_description")); + crInstanceGroupCustomization.setFunction( + toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, + instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME) + + "_network_collection_function")); + crInstanceGroupCustomization.setCollectionResourceCust(ncfc); + collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization); + + networkInstanceGroup + .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList); + + networkInstanceGroupList.add(networkInstanceGroup); + + toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList); + + List vlNodeList = toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL); + + List collectionNetworkResourceCustomizationList = new ArrayList<>(); + + //*****Build object to populate the NetworkResource table + NetworkResource networkResource = new NetworkResource(); + + for (NodeTemplate vlNodeTemplate : vlNodeList) { + + String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue( + vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK); + + if ("true".equalsIgnoreCase(providerNetwork)) { + networkResource.setNeutronNetworkType(PROVIDER); + } else { + networkResource.setNeutronNetworkType(BASIC); + } + + networkResource + .setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + + networkResource.setModelInvariantUUID( + vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + networkResource + .setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + networkResource + .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + + networkResource.setAicVersionMax( + vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)); + + TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo + .findFirstBynetworkResourceModelName( + vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + + if (tempNetworkLookUp != null) { + + HeatTemplate heatTemplate = heatRepo + .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid()); + networkResource.setHeatTemplate(heatTemplate); + + networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin()); + + } + + networkResource.setToscaNodeType(vlNodeTemplate.getType()); + networkResource + .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + networkResource.setOrchestrationMode(HEAT); + + // Build object to populate the + // Collection_Network_Resource_Customization table + for (NodeTemplate memberNode : group.getMemberNodes()) { + collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName()); + } + + collectionNetworkResourceCustomization.setModelCustomizationUUID( + vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + + collectionNetworkResourceCustomization.setNetworkTechnology( + toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate, + SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)); + collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)); + collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)); + collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)); + collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup); + collectionNetworkResourceCustomization.setNetworkResource(networkResource); + collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc); + + collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization); + } + + } + + return collectionNetworkResourceCustomization; + } + + protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group, + VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) { + + Metadata instanceMetadata = group.getMetadata(); + // Populate InstanceGroup + 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 + + //Populate VNFCInstanceGroupCustomization + VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization(); + + vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID()); + vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + + String getInputName = null; + String groupProperty = toscaResourceStructure.getSdcCsarHelper() + .getGroupPropertyLeafValue(group, "vfc_instance_group_function"); + if (groupProperty != null) { + int getInputIndex = groupProperty.indexOf("{get_input="); + if (getInputIndex > -1) { + getInputName = groupProperty.substring(getInputIndex + 11, groupProperty.length() - 1); + } + } + vfcInstanceGroupCustom.setFunction( + toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName)); + + vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup); + vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization); + + return vfcInstanceGroupCustom; + + } + + protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate, + ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, + IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, + Set existingCvnfcSet, Set existingVnfcSet) { + + VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource, + vfModuleData.getVfModuleModelCustomizationUUID()); + if (vfModuleCustomization == null) { + VfModule vfModule = findExistingVfModule(vnfResource, + vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); + Metadata vfMetadata = group.getMetadata(); + if (vfModule == null) { + vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata); + } + + vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData); + setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization, + vfMetadata); + vfModuleCustomization.setVfModule(vfModule); + vfModule.getVfModuleCustomization().add(vfModuleCustomization); + vnfResource.getVfModuleCustomizations().add(vfModuleCustomization); + } else { + vfResourceStructure.setAlreadyDeployed(true); + } + + //****************************************************************************************************************** + //* Extract VFC's and CVFC's then add them to VFModule + //****************************************************************************************************************** + + Set vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet(); + Set cvnfcCustomizations = new HashSet(); + Set vnfcCustomizations = new HashSet(); + + // Only set the CVNFC if this vfModule group is a member of it. + List groupMembers = toscaResourceStructure.getSdcCsarHelper() + .getMembersOfVfModule(vfTemplate, group); + String vfModuleMemberName = null; + + for (NodeTemplate node : groupMembers) { + vfModuleMemberName = node.getName(); + } + + // Extract CVFC lists + List cvfcList = toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC); + + for (NodeTemplate cvfcTemplate : cvfcList) { + + CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, + cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + + if (vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())) { + + //Extract associated VFC - Should always be just one + List vfcList = toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC); + + for (NodeTemplate vfcTemplate : vfcList) { + + VnfcCustomization vnfcCustomization = new VnfcCustomization(); + VnfcCustomization existingVnfcCustomization = null; + + existingVnfcCustomization = findExistingVfc(existingVnfcSet, + vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + + if (existingVnfcCustomization == null) { + vnfcCustomization = new VnfcCustomization(); } else { - throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: " - + tempNetworkLookUp.getHeatTemplateArtifactUuid ()); - } - } else { - NetworkResourceCustomization networkCustomization = createNetwork (vlNode, - toscaResourceStruct, - null, - null, - null, - service); - service.getNetworkCustomizations().add (networkCustomization); - logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for " - + networkResourceModelName); - } - - } - } - } - - protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service, - List allottedResourceList) { - if (allottedResourceList != null) { - for (NodeTemplate allottedNode : allottedResourceList) { - service.getAllottedCustomizations() - .add(createAllottedResource(allottedNode, toscaResourceStruct, service)); - } - } - } - - - protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) { - Metadata metadata = nodeTemplate.getMetaData(); - ConfigurationResource configResource = new ConfigurationResource(); - configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - configResource.setToscaNodeType(nodeTemplate.getType()); - return configResource; - } - - protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, - ServiceProxyResourceCustomization spResourceCustomization ) { - Metadata metadata = nodeTemplate.getMetaData(); - - ConfigurationResource configResource = getConfigurationResource(nodeTemplate); - - ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization(); - - Set configResourceCustomizationSet = new HashSet<>(); - - configCustomizationResource.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.setConfigurationResource(configResource); - configResourceCustomizationSet.add(configCustomizationResource); - - configResource.setConfigurationResourceCustomization(configResourceCustomizationSet); - return configCustomizationResource; - } - - - protected Optional getVnrNodeTemplate(List configurationNodeTemplatesList, - ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) { - Optional configurationResourceCust = Optional.empty(); - for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) { - StatefulEntityType entityType = nodeTemplate.getTypeDefinition(); - String type = entityType.getType(); - - if(VLAN_NETWORK_RECEPTOR.equals(type)) { - configurationResourceCust= Optional.of(getConfigurationResourceCustomization(nodeTemplate, - toscaResourceStructure,spResourceCustomization)); - break; - } - } - - return configurationResourceCust; - } - - protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) { - - List serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY); - - List configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION); - - List serviceProxyList = new ArrayList(); - List configurationResourceList = new ArrayList(); - - ServiceProxyResourceCustomization serviceProxy = null; - - if (serviceProxyResourceList != null) { - for (NodeTemplate spNode : serviceProxyResourceList) { - serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct); - serviceProxyList.add(serviceProxy); - Optional vnrResourceCustomization = getVnrNodeTemplate(configurationNodeTemplatesList,toscaResourceStruct,serviceProxy); - - for (NodeTemplate configNode : configurationNodeTemplatesList) { - - List requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll(); - for (RequirementAssignment requirement : requirementsList) { - if (requirement.getNodeTemplateName().equals(spNode.getName())) { - ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy, vnrResourceCustomization); - - Optional matchingObject = configurationResourceList.stream() - .filter(configurationResourceCustomization -> configNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID())) - .findFirst(); - if(!matchingObject.isPresent()){ - configurationResourceList.add(configurationResource); - } - - break; - } - } - } - - } - } - - service.setConfigurationCustomizations(configurationResourceList); - service.setServiceProxyCustomizations(serviceProxyList); - } - - protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) { - - List networkCollectionList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR); - - if (networkCollectionList != null) { - for (NodeTemplate crNode : networkCollectionList) { - - createNetworkCollection(crNode, toscaResourceStruct, service); - collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource()); - - List networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup(); - for(NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList){ - instanceGroupRepo.saveAndFlush(networkInstanceGroup); - } - - } - } - service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization()); - } - - - protected void processVFResources (ToscaResourceStructure toscaResourceStruct, Service service, VfResourceStructure vfResourceStructure) - throws Exception{ - logger.debug("processVFResources"); - - List vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList(); -// String servicecategory = toscaResourceStruct.getCatalogService().getCategory(); -// String serviceType = toscaResourceStruct.getCatalogService().getServiceType(); - - for (NodeTemplate nodeTemplate : vfNodeTemplatesList) { - Metadata metadata = nodeTemplate.getMetaData(); - String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); - logger.debug("VF Category is : " + vfCustomizationCategory); - - // Do not treat Allotted Resources as VNF resources - if(ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)){ - continue; - } - - String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); - logger.debug("VFCustomizationUUID=" + vfCustomizationUUID); - - IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance(); - - // Make sure the VF ResourceCustomizationUUID from the notification and tosca - // customizations match before comparing their VF Modules UUID's - logger.debug("Checking if Notification VF ResourceCustomizationUUID: " - + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: " - + vfCustomizationUUID); - - if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) { - logger.debug("vfCustomizationUUID: " + vfCustomizationUUID - + " matches vfNotificationResource CustomizationUUID"); - - processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata, - vfCustomizationCategory); - } else { - logger.debug("Notification VF ResourceCustomizationUUID: " - + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " - + "Tosca VF Customization UUID: " + vfCustomizationUUID); - } - } - } - - - protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, - Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception { - - logger.debug("VF Category is : " + vfCustomizationCategory); - - if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) - { - - String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper() - .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); - logger.debug("VFCustomizationUUID=" + vfCustomizationUUID); - - IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance(); - - // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's - logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + - " matches Tosca VF Customization UUID: " + vfCustomizationUUID); - - if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){ - - logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID"); - - VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service); - - Set existingCvnfcSet = new HashSet(); - Set existingVnfcSet = new HashSet(); - - for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { - - logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); - List vfGroups = toscaResourceStruct - .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); - IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); - - logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID()); - - Optional matchingObject = vfGroups.stream() - .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"))) - .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())) - .findFirst(); - if(matchingObject.isPresent()){ - VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, - vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet); - vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources()); - }else - throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID()); - - } - service.getVnfCustomizations().add(vnfResource); - } else{ - logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " + - "Tosca VF Customization UUID: " + vfCustomizationUUID); - } - } - } - - public void processWatchdog(String distributionId, String servideUUID, Optional distributionNotification, - String consumerId) { - WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID, - distributionNotification, consumerId); - watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup); - - try{ - - WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId); - watchdogDistributionStatusRepository.saveAndFlush(distributionStatus); - - } catch(ObjectOptimisticLockingFailureException e){ - logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString()); - throw e; - } - } - - protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct, - VfResourceStructure vfResourceStructure) { - for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { - - switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) { - case ASDCConfiguration.HEAT: - case ASDCConfiguration.HEAT_NESTED: - createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, - vfModuleArtifact); - break; - case ASDCConfiguration.HEAT_VOL: - createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, - vfModuleArtifact); - VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact); - createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact); - break; - case ASDCConfiguration.HEAT_ENV: - createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact); - break; - case ASDCConfiguration.HEAT_ARTIFACT: - createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact, - toscaResourceStruct); - break; - case ASDCConfiguration.HEAT_NET: - case ASDCConfiguration.OTHER: - logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(), - vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact.getArtifactInfo() - .getArtifactName() + ")", ErrorCode.DataError.getValue(), "Artifact type not supported"); - break; - default: - break; - - } - } - } - - protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure, - VfModuleArtifact vfModuleArtifact) { - String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName(); - artifactName = artifactName.substring(0, artifactName.indexOf('.')); - for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { - if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName) - && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) { - return moduleArtifact; - } - } - return null; - } - - public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure, - List listTypes) { - String newFileBody = filebody; - for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { - - if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) { - - newFileBody = verifyTheFilePrefixInString(newFileBody, - moduleArtifact.getArtifactInfo().getArtifactName()); - } - } - return newFileBody; - } - - public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) { - - String needlePrefix = "file:///"; - String prefixedFilenameToVerify = needlePrefix + filenameToVerify; - - if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) { - return body; - } - - StringBuilder sb = new StringBuilder(body.length()); - - int currentIndex = 0; - int startIndex = 0; - - while (currentIndex != -1) { - startIndex = currentIndex; - currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex); - - if (currentIndex == -1) { - break; - } - // We append from the startIndex up to currentIndex (start of File - // Name) - sb.append(body.substring(startIndex, currentIndex)); - sb.append(filenameToVerify); - - currentIndex += prefixedFilenameToVerify.length(); - } - - sb.append(body.substring(startIndex)); - - return sb.toString(); - } - - protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure, - ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) { - HeatTemplate heatTemplate = new HeatTemplate(); - List typeList = new ArrayList<>(); - typeList.add(ASDCConfiguration.HEAT_NESTED); - typeList.add(ASDCConfiguration.HEAT_ARTIFACT); - - heatTemplate.setTemplateBody( - verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList)); - heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName()); - - if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) { - heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout()); - } else { - heatTemplate.setTimeoutMinutes(240); - } - - heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); - heatTemplate.setVersion(BigDecimalVersion - .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); - heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - - if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) { - heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); - } else { - heatTemplate.setArtifactChecksum(MANUAL_RECORD); - } - - Set heatParam = extractHeatTemplateParameters( - vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - heatTemplate.setParameters(heatParam); - vfModuleArtifact.setHeatTemplate(heatTemplate); - } - - protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure, - VfModuleArtifact vfModuleArtifact) { - HeatEnvironment heatEnvironment = new HeatEnvironment(); - heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName()); - List typeList = new ArrayList<>(); - typeList.add(ASDCConfiguration.HEAT); - typeList.add(ASDCConfiguration.HEAT_VOL); - heatEnvironment.setEnvironment( - verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList)); - heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); - heatEnvironment.setVersion(BigDecimalVersion - .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); - heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - - if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) { - heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); - } else { - heatEnvironment.setArtifactChecksum(MANUAL_RECORD); - } - vfModuleArtifact.setHeatEnvironment(heatEnvironment); - } - - protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure, - VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) { - - HeatFiles heatFile = new HeatFiles(); - heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); - heatFile.setFileBody(vfModuleArtifact.getResult()); - heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName()); - heatFile.setVersion(BigDecimalVersion - .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); - toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) { - heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); - } else { - heatFile.setArtifactChecksum(MANUAL_RECORD); - } - vfModuleArtifact.setHeatFiles(heatFile); - } - - protected Service createService(ToscaResourceStructure toscaResourceStructure, - VfResourceStructure vfResourceStructure) { - - Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata(); - - Service service = new Service(); - - if (serviceMetadata != null) { - - if (toscaResourceStructure.getServiceVersion() != null) { - service.setModelVersion(toscaResourceStructure.getServiceVersion()); - } - - service.setServiceType(serviceMetadata.getValue("serviceType")); - service.setServiceRole(serviceMetadata.getValue("serviceRole")); - - service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - service.setEnvironmentContext(serviceMetadata.getValue("environmentContext")); - - if (vfResourceStructure != null) - service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext()); - - service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - service.setCsar(toscaResourceStructure.getCatalogToscaCsar()); - } - - - toscaResourceStructure.setCatalogService(service); - return service; - } - - protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) { - - Metadata spMetadata = nodeTemplate.getMetaData(); - - ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization(); - - Set serviceProxyCustomizationSet = new HashSet<>(); - - spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - spCustomizationResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - - spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - spCustomizationResource.setModelInstanceName(nodeTemplate.getName()); - spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); - - String sourceServiceUUID = spMetadata.getValue("sourceModelUuid"); - - Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID); - - spCustomizationResource.setSourceService(sourceService); - spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); - serviceProxyCustomizationSet.add(spCustomizationResource); - - - toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource); - - return spCustomizationResource; - } - - protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, - ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization, - Optional vnrResourceCustomization) { - - ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(nodeTemplate, - toscaResourceStructure,spResourceCustomization); - - ConfigurationResource configResource = getConfigurationResource(nodeTemplate); - - Set configResourceCustomizationSet = new HashSet<>(); - - StatefulEntityType entityType = nodeTemplate.getTypeDefinition(); - String type = entityType.getType(); - - if(NODES_VRF_ENTRY.equals(type)) { - configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null)); - } - - configCustomizationResource.setConfigurationResource(configResource); - - configResourceCustomizationSet.add(configCustomizationResource); - - configResource.setConfigurationResourceCustomization(configResourceCustomizationSet); - - toscaResourceStructure.setCatalogConfigurationResource(configResource); - - toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource); - - return configCustomizationResource; - } - - protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) { - - Metadata fabricMetadata = nodeTemplate.getMetaData(); - - ConfigurationResource configResource = new ConfigurationResource(); - - configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - configResource.setToscaNodeType(nodeTemplate.getType()); - - return configResource; - } - - protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) { - ToscaCsar toscaCsar = new ToscaCsar(); - if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) { - toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum()); - } else { - toscaCsar.setArtifactChecksum(MANUAL_RECORD); - } - toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID()); - toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName()); - toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion()); - toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription()); - toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL()); - - toscaResourceStructure.setCatalogToscaCsar(toscaCsar); - } - - protected VnfcCustomization findExistingVfc(Set vnfcCustomizations, String customizationUUID) { - VnfcCustomization vnfcCustomization = null; - for(VnfcCustomization vnfcCustom : vnfcCustomizations){ - if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) { - vnfcCustomization = vnfcCustom; - } - } - - if(vnfcCustomization==null) - vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID); - - return vnfcCustomization; - } - - protected CvnfcCustomization findExistingCvfc(Set cvnfcCustomizations, String customizationUUID) { - CvnfcCustomization cvnfcCustomization = null; - for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){ - if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) { - cvnfcCustomization = cvnfcCustom; - } - } - - if(cvnfcCustomization==null) - cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID); - - return cvnfcCustomization; - } - - protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate, - ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) { - - NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - - boolean networkUUIDsMatch = true; - // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from the distribution. - // If not we'll update the Customization record with latest from the distribution - if(networkResourceCustomization != null){ - String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID(); - String latestNetworkModelUUID = networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID); - - if(!existingNetworkModelUUID.equals(latestNetworkModelUUID)){ - networkUUIDsMatch = false; - } - - } - - if (networkResourceCustomization!=null && !networkUUIDsMatch){ - - NetworkResource networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate, - aicMax, aicMin); - - networkResourceCustomization.setNetworkResource(networkResource); - - networkCustomizationRepo.saveAndFlush(networkResourceCustomization); - - } - else if(networkResourceCustomization==null){ - networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate, - toscaResourceStructure); - - NetworkResource networkResource = findExistingNetworkResource(service, - networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - if(networkResource == null) - networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate, - aicMax, aicMin); - - networkResource.addNetworkResourceCustomization(networkResourceCustomization); - networkResourceCustomization.setNetworkResource(networkResource); - } - - return networkResourceCustomization; - } - - protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) { - NetworkResource networkResource = null; - for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){ - if (networkCustom.getNetworkResource() != null - && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) { - networkResource = networkCustom.getNetworkResource(); - } - } - if(networkResource==null) - networkResource = networkRepo.findResourceByModelUUID(modelUUID); - - return networkResource; - } - - protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate, - ToscaResourceStructure toscaResourceStructure) { - NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization(); - networkResourceCustomization.setModelInstanceName( - testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); - networkResourceCustomization.setModelCustomizationUUID( - testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); - - networkResourceCustomization.setNetworkTechnology( - testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, - SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY))); - networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE))); - networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE))); - networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE))); - return networkResourceCustomization; - } - - protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate, - ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) { - NetworkResource networkResource = new NetworkResource(); - String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue( - networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK); - - if ("true".equalsIgnoreCase(providerNetwork)) { - networkResource.setNeutronNetworkType(PROVIDER); - } else { - networkResource.setNeutronNetworkType(BASIC); - } - - networkResource.setModelName( - testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); - - networkResource.setModelInvariantUUID( - testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); - networkResource.setModelUUID( - testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); - networkResource.setModelVersion( - testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); - - networkResource.setAicVersionMax(aicMax); - networkResource.setAicVersionMin(aicMin); - networkResource.setToscaNodeType(networkNodeTemplate.getType()); - networkResource.setDescription( - testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); - networkResource.setOrchestrationMode(HEAT); - networkResource.setHeatTemplate(heatTemplate); - return networkResource; - } - - protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate, - ToscaResourceStructure toscaResourceStructure, Service service) { - - CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization(); - - // **** Build Object to populate Collection_Resource table - CollectionResource collectionResource = new CollectionResource(); - - collectionResource - .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - collectionResource.setModelInvariantUUID( - networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - collectionResource - .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - collectionResource - .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - collectionResource - .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - collectionResource.setToscaNodeType(networkNodeTemplate.getType()); - - toscaResourceStructure.setCatalogCollectionResource(collectionResource); - - // **** Build object to populate Collection_Resource_Customization table - NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization(); - - ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, - "cr_function")); - ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, - "cr_role")); - ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, - "cr_type")); - - ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - ncfc.setModelCustomizationUUID( - networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - - Set networkResourceCustomizationSet = new HashSet<>(); - networkResourceCustomizationSet.add(collectionNetworkResourceCustomization); - - ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet); - - ncfc.setCollectionResource(collectionResource); - toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc); - - //*** Build object to populate the Instance_Group table - List groupList = toscaResourceStructure.getSdcCsarHelper() - .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate, - "org.openecomp.groups.NetworkCollection"); - - List networkInstanceGroupList = new ArrayList<>(); - - List collectionResourceInstanceGroupCustomizationList = new ArrayList(); - - for (Group group : groupList) { - - NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup(); - Metadata instanceMetadata = group.getMetadata(); - networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - networkInstanceGroup - .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - networkInstanceGroup.setToscaNodeType(group.getType()); - networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set - // Role - networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set - // type - networkInstanceGroup.setCollectionResource(collectionResource); - - // ****Build object to populate - // Collection_Resource_Instance_Group_Customization table - CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization(); - crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup); - crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - crInstanceGroupCustomization.setModelCustomizationUUID( - networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - - // Loop through the template policy to find the subinterface_network_quantity property name. Then extract the value for it. - List policyList = toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate, "org.openecomp.policies.scaling.Fixed"); - - if(policyList != null){ - for(Policy policy : policyList){ - for(String policyNetworkCollection : policy.getTargets()){ - - if(policyNetworkCollection.equalsIgnoreCase(group.getName())){ - - Map propMap = policy.getPolicyProperties(); - - if(propMap.get("quantity") != null){ - - String quantity = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, getPropertyInput(propMap.get("quantity").toString())); - - if(quantity != null){ - crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(quantity)); - } - - } - - } - } - } - } - - crInstanceGroupCustomization.setDescription( - toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, - instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME) - + "_network_collection_description")); - crInstanceGroupCustomization.setFunction( - toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, - instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME) - + "_network_collection_function")); - crInstanceGroupCustomization.setCollectionResourceCust(ncfc); - collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization); - - networkInstanceGroup - .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList); - - networkInstanceGroupList.add(networkInstanceGroup); - - - toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList); - - List vlNodeList = toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL); - - List collectionNetworkResourceCustomizationList = new ArrayList<>(); - - //*****Build object to populate the NetworkResource table - NetworkResource networkResource = new NetworkResource(); - - for(NodeTemplate vlNodeTemplate : vlNodeList){ - - String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue( - vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK); - - if ("true".equalsIgnoreCase(providerNetwork)) { - networkResource.setNeutronNetworkType(PROVIDER); - } else { - networkResource.setNeutronNetworkType(BASIC); - } - - networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - - networkResource.setModelInvariantUUID( - vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - networkResource - .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - - networkResource.setAicVersionMax( - vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)); - - TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName( - vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - - if (tempNetworkLookUp != null ) { - - HeatTemplate heatTemplate = heatRepo - .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid()); - networkResource.setHeatTemplate(heatTemplate); - - networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin()); - - } - - networkResource.setToscaNodeType(vlNodeTemplate.getType()); - networkResource - .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - networkResource.setOrchestrationMode(HEAT); - - // Build object to populate the - // Collection_Network_Resource_Customization table - for (NodeTemplate memberNode : group.getMemberNodes()) { - collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName()); - } - - collectionNetworkResourceCustomization.setModelCustomizationUUID( - vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - - collectionNetworkResourceCustomization.setNetworkTechnology( - toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate, - SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)); - collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)); - collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)); - collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)); - collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup); - collectionNetworkResourceCustomization.setNetworkResource(networkResource); - collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc); - - collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization); - } - - } - - return collectionNetworkResourceCustomization; - } - - protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group, - VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) { - - Metadata instanceMetadata = group.getMetadata(); - // Populate InstanceGroup - 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 - - //Populate VNFCInstanceGroupCustomization - VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization(); - - vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID()); - vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - - String getInputName = null; - String groupProperty = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, "vfc_instance_group_function"); - if (groupProperty != null) { - int getInputIndex = groupProperty.indexOf("{get_input="); - if (getInputIndex > -1) { - getInputName = groupProperty.substring(getInputIndex+11, groupProperty.length()-1); - } - } - vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName)); - - vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup); - vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization); - - return vfcInstanceGroupCustom; - - } - - protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate, - ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, - IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set existingCvnfcSet, Set existingVnfcSet) { - - VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource, - vfModuleData.getVfModuleModelCustomizationUUID()); - if(vfModuleCustomization == null){ - VfModule vfModule = findExistingVfModule(vnfResource, - vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); - Metadata vfMetadata = group.getMetadata(); - if(vfModule==null) - vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata); - - vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData); - setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization, - vfMetadata); - vfModuleCustomization.setVfModule(vfModule); - vfModule.getVfModuleCustomization().add(vfModuleCustomization); - vnfResource.getVfModuleCustomizations().add(vfModuleCustomization); - } else { - vfResourceStructure.setAlreadyDeployed(true); - } - - //****************************************************************************************************************** - //* Extract VFC's and CVFC's then add them to VFModule - //****************************************************************************************************************** - - Set vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet(); - Set cvnfcCustomizations = new HashSet(); - Set vnfcCustomizations = new HashSet(); - - // Only set the CVNFC if this vfModule group is a member of it. - List groupMembers = toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate, group); - String vfModuleMemberName = null; - - for(NodeTemplate node : groupMembers){ - vfModuleMemberName = node.getName(); - } - - // Extract CVFC lists - List cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC); - - for(NodeTemplate cvfcTemplate : cvfcList) { - - if(vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())){ - - //Extract associated VFC - Should always be just one - List vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC); - - for(NodeTemplate vfcTemplate : vfcList) { - - VnfcCustomization vnfcCustomization = new VnfcCustomization(); - VnfcCustomization existingVnfcCustomization = null; - - existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - - if(existingVnfcCustomization == null){ - vnfcCustomization = new VnfcCustomization(); - } else { - vnfcCustomization = existingVnfcCustomization; - } - - // Only Add Abstract VNFC's to our DB, ignore all others - if(existingVnfcCustomization == null && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){ - vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - vnfcCustomization.setModelInstanceName(vfcTemplate.getName()); - vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - - vnfcCustomization.setModelVersion( - testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); - vnfcCustomization.setDescription( - testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); - vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType())); - - vnfcCustomizations.add(vnfcCustomization); - existingVnfcSet.add(vnfcCustomization); - } - - // This check is needed incase the VFC subcategory is something other than Abstract. In that case we want to skip adding that record to our DB. - if(vnfcCustomization.getModelCustomizationUUID() != null){ - - CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); - - cvnfcCustomization = new CvnfcCustomization(); - cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName()); - cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - - cvnfcCustomization.setModelVersion( - testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); - cvnfcCustomization.setDescription( - testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); - cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType())); - - if(existingVnfcCustomization != null){ - cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization); - }else{ - cvnfcCustomization.setVnfcCustomization(vnfcCustomization); - } - - cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function")); - cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code")); - cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); - cvnfcCustomization.setVnfResourceCustomization(vnfResource); - - cvnfcCustomizations.add(cvnfcCustomization); - existingCvnfcSet.add(cvnfcCustomization); - - //***************************************************************************************************************************************** - //* Extract Fabric Configuration - //***************************************************************************************************************************************** - - List fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION); - - for(NodeTemplate fabricTemplate : fabricConfigList) { - - ConfigurationResource fabricConfig = null; - - ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - - if(existingConfig == null){ - - fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure); - - }else { - fabricConfig = existingConfig; - } - - VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure, - vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName); - vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization); - } - cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations); - } - - } - - } - } - vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations); - vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations); - - return vfModuleCustomization; - } - - protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct, - VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization, - ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) { - - Metadata fabricMetadata = fabricTemplate.getMetaData(); - - VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization(); - - vfModuleToCvnfc.setConfigurationResource(configResource); - vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization); - vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName()); - vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization); - vfModuleToCvnfc.setVnfResourceCustomization(vnfResource); - - List policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External"); - - if(policyList != null){ - for(Policy policy : policyList){ - - for(String policyCvfcTarget : policy.getTargets()){ - - if(policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)){ - - Map propMap = policy.getPolicyProperties(); - - if(propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")){ - vfModuleToCvnfc.setPolicyName(propMap.get("name").toString()); - } - } - } - } - } - - vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function")); - vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role")); - vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type")); - - return vfModuleToCvnfc; - } - - protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) { - ConfigurationResource configResource = null; - for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){ - if (configurationResourceCustom.getConfigurationResource() != null - && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) { - configResource = configurationResourceCustom.getConfigurationResource(); - } - } - if(configResource==null) - configResource = configRepo.findResourceByModelUUID(modelUUID); - - return configResource; - } - - protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource, - String vfModuleModelCustomizationUUID) { - VfModuleCustomization vfModuleCustomization = null; - for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){ - if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){ - vfModuleCustomization = vfModuleCustom; - } - } - if(vfModuleCustomization==null) - vfModuleCustomization = vfModuleCustomizationRepo - .findByModelCustomizationUUID(vfModuleModelCustomizationUUID); - - return vfModuleCustomization; - } - - protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) { - VfModule vfModule = null; - for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){ - if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){ - vfModule = vfModuleCustom.getVfModule(); - } - } - if(vfModule==null) - vfModule = vfModuleRepo.findByModelUUID(modelUUID); - - return vfModule; - } - - protected VfModuleCustomization createVfModuleCustomization(Group group, - ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) { - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - - vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID()); - - vfModuleCustomization.setVfModule(vfModule); - - String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT); - if (initialCount != null && initialCount.length() > 0) { - vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount)); - } - - vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper() - .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT))); - - String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT); - if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) { - vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount)); - } - - vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL)); - - String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES); - if (maxInstances != null && maxInstances.length() > 0) { - vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances)); - } - - String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES); - if (minInstances != null && minInstances.length() > 0) { - vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances)); - } - return vfModuleCustomization; - } - - protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure, - IVfModuleData vfModuleData, Metadata vfMetadata) { - VfModule vfModule = new VfModule(); - String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID(); - - if(vfModuleModelUUID == null) { - vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); - } else if (vfModuleModelUUID.indexOf('.') > -1) { - vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.')); - } - - vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper() - .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID))); - vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME))); - vfModule.setModelUUID(vfModuleModelUUID); - vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION))); - vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); - - String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, - SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE); - if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) { - vfModule.setIsBase(true); - } else { - vfModule.setIsBase(false); - } - return vfModule; - } - - protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure, - VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization, - Metadata vfMetadata) { - - Optional matchingObject = vfResourceStructure.getVfModuleStructure().stream() - .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID() - .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, - SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))) - .findFirst(); - - if (matchingObject.isPresent()) { - List heatFilesList = new ArrayList<>(); - List volumeHeatChildTemplates = new ArrayList(); - List heatChildTemplates = new ArrayList(); - HeatTemplate parentHeatTemplate = new HeatTemplate(); - String parentArtifactType = null; - Set artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts()); - for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { - - List childNestedHeatTemplates = new ArrayList(); - - if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) { - checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact, - childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure); - } - - if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){ - parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact); - - if(!childNestedHeatTemplates.isEmpty()){ - - if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) { - volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0)); - } else { - heatChildTemplates.add(childNestedHeatTemplates.get(0)); - } - } - } - - } - if(!heatFilesList.isEmpty()){ - vfModule.setHeatFiles(heatFilesList); - } - - - // Set all Child Templates related to HEAT_VOLUME - if(!volumeHeatChildTemplates.isEmpty()){ - if(vfModule.getVolumeHeatTemplate() != null){ - vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates); - }else{ - logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()"); - } - } - - // Set all Child Templates related to HEAT - if(!heatChildTemplates.isEmpty()){ - if(vfModule.getModuleHeatTemplate() != null){ - vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates); - }else{ - logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()"); - } - } - } - } - - protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization, - List heatFilesList, VfModuleArtifact vfModuleArtifact, List nestedHeatTemplates, - HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) { - if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) { - vfModuleArtifact.incrementDeployedInDB(); - vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate()); - } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) { - vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate()); - VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact); - vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment()); - vfModuleArtifact.incrementDeployedInDB(); - } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) { - if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) { - vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment()); - } else { - vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment()); - } - vfModuleArtifact.incrementDeployedInDB(); - } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) { - heatFilesList.add(vfModuleArtifact.getHeatFiles()); - vfModuleArtifact.incrementDeployedInDB(); - } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) { - nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate()); - vfModuleArtifact.incrementDeployedInDB(); - } - } - - protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate, - ToscaResourceStructure toscaResourceStructure, Service service) { - VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID( - vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - if(vnfResourceCustomization == null){ - VnfResource vnfResource = findExistingVnfResource(service, - vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - - if(vnfResource==null) - vnfResource=createVnfResource(vfNodeTemplate); - - vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure, - vnfResource); - vnfResourceCustomization.setVnfResources(vnfResource); - vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization); - - // Fetch VNFC Instance Group Info - List groupList = toscaResourceStructure.getSdcCsarHelper() - .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate, - "org.openecomp.groups.VfcInstanceGroup"); - - for (Group group : groupList) { - - VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate, group, vnfResourceCustomization, toscaResourceStructure); - - vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization); - } - } - return vnfResourceCustomization; - } - - protected VnfResource findExistingVnfResource(Service service, String modelUUID) { - VnfResource vnfResource = null; - for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){ - if (vnfResourceCustom.getVnfResources() != null - && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) { - vnfResource = vnfResourceCustom.getVnfResources(); - } - } - if(vnfResource==null) - vnfResource = vnfRepo.findResourceByModelUUID(modelUUID); - - return vnfResource; - } - - protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate, - ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) { - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - vnfResourceCustomization.setModelCustomizationUUID( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); - vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName()); - - vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION))); - vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code"))); - vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE))); - vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE))); - - vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN)); - - vnfResourceCustomization.setVnfResources(vnfResource); - vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger( - vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT))); - - CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper() - .getCapabilitiesOf(vfNodeTemplate); - - if (vnfCustomizationCapability != null) { - CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE); - - if (capAssign != null) { - vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper() - .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); - vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper() - .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); - } - - } - - toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization); - - return vnfResourceCustomization; - } - - protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) { - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelInvariantUUID( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); - vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); - vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); - - vnfResource.setModelVersion( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); - vnfResource.setDescription( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); - vnfResource.setOrchestrationMode(HEAT); - vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType())); - vnfResource.setAicVersionMax( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); - vnfResource.setAicVersionMin( - testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); - vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); - vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)); - - return vnfResource; - } - - protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate, - ToscaResourceStructure toscaResourceStructure, Service service) { - AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo - .findOneByModelCustomizationUUID( - nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - - if(allottedResourceCustomization == null){ - AllottedResource allottedResource = findExistingAllottedResource(service, - nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - - if(allottedResource==null) - allottedResource=createAR(nodeTemplate); - - toscaResourceStructure.setAllottedResource(allottedResource); - allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure); - allottedResourceCustomization.setAllottedResource(allottedResource); - allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization); - } - return allottedResourceCustomization; - } - - protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) { - AllottedResource allottedResource = null; - for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){ - if (allottedResourceCustom.getAllottedResource() != null - && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) { - allottedResource = allottedResourceCustom.getAllottedResource(); - } - } - if(allottedResource==null) - allottedResource = allottedRepo.findResourceByModelUUID(modelUUID); - - return allottedResource; - } - - protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate, - ToscaResourceStructure toscaResourceStructure) { - AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization(); - allottedResourceCustomization.setModelCustomizationUUID( - testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); - allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName()); - - - allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION))); - allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code"))); - allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE))); - allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper() - .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE))); - - List vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID()); - - if(vfcNodes != null){ - for(NodeTemplate vfcNode : vfcNodes){ - - allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid")); - allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid")); - allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name")); - } - } - - - CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper() - .getCapabilitiesOf(nodeTemplate); - - if (arCustomizationCapability != null) { - CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE); - - if (capAssign != null) { - allottedResourceCustomization.setMinInstances( - Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue( - capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); - allottedResourceCustomization.setMaxInstances( - Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue( - capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); - } - } - return allottedResourceCustomization; - } - - protected AllottedResource createAR(NodeTemplate nodeTemplate) { - AllottedResource allottedResource = new AllottedResource(); - allottedResource - .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); - allottedResource.setModelInvariantUUID( - testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); - allottedResource - .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); - allottedResource - .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); - allottedResource.setToscaNodeType(testNull(nodeTemplate.getType())); - allottedResource.setSubcategory( - testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY))); - allottedResource - .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - return allottedResource; - } - - protected Set extractHeatTemplateParameters(String yamlFile, String artifactUUID) { - // Scan the payload downloadResult and extract the HeatTemplate - // parameters - YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes()); - return yamlEditor.getParameterList(artifactUUID); - } - - protected String testNull(Object object) { - - if (object == null) { - return null; - } else if (object.equals("NULL")) { - return null; - } else if (object instanceof Integer) { - return object.toString(); - } else if (object instanceof String) { - return (String) object; - } else { - return "Type not recognized"; - } - } - - protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure, - VfModuleArtifact heatNestedArtifact) { - - if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure - .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) { - for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0) - .getArtifactInfo().getRelatedArtifacts()) { - if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) { - return ASDCConfiguration.HEAT; - } - - } - } - - if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null - && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo() - .getRelatedArtifacts() != null) { - for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) - .get(0).getArtifactInfo().getRelatedArtifacts()) { - if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) { - return ASDCConfiguration.HEAT_VOL; - } - - } - } - - // Does not belong to anything - return null; - - } - - protected static String createVNFName(VfResourceStructure vfResourceStructure) { - - return vfResourceStructure.getNotification().getServiceName() + "/" - + vfResourceStructure.getResourceInstance().getResourceInstanceName(); - } - - protected static String createVfModuleName(VfModuleStructure vfModuleStructure) { - - return createVNFName(vfModuleStructure.getParentVfResource()) + "::" - + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName(); - } - - protected String getPropertyInput(String propertyName){ - - String inputName = new String(); - - if (propertyName != null) { - int getInputIndex = propertyName.indexOf("{get_input="); - if (getInputIndex > -1) { - inputName = propertyName.substring(getInputIndex+11, propertyName.length()-1); - } - } - - return inputName; - } - - - protected static Timestamp getCurrentTimeStamp() { - - return new Timestamp(new Date().getTime()); - } + vnfcCustomization = existingVnfcCustomization; + } + + // Only Add Abstract VNFC's to our DB, ignore all others + if (existingVnfcCustomization == null && vfcTemplate.getMetaData() + .getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) { + vnfcCustomization.setModelCustomizationUUID( + vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + vnfcCustomization.setModelInstanceName(vfcTemplate.getName()); + vnfcCustomization.setModelInvariantUUID( + vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + vnfcCustomization + .setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + vnfcCustomization + .setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + + vnfcCustomization.setModelVersion( + testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + vnfcCustomization.setDescription( + testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType())); + + vnfcCustomizations.add(vnfcCustomization); + existingVnfcSet.add(vnfcCustomization); + } + + // This check is needed incase the VFC subcategory is something other than Abstract. In that case we want to skip adding that record to our DB. + if (vnfcCustomization.getModelCustomizationUUID() != null) { + + CvnfcCustomization cvnfcCustomization = null; + + if (existingCvnfcCustomization != null) { + cvnfcCustomization = existingCvnfcCustomization; + } else { + + cvnfcCustomization = new CvnfcCustomization(); + cvnfcCustomization.setModelCustomizationUUID( + cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName()); + cvnfcCustomization.setModelInvariantUUID( + cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + cvnfcCustomization + .setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + cvnfcCustomization + .setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + + cvnfcCustomization.setModelVersion( + testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + cvnfcCustomization.setDescription( + testNull( + cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType())); + + if (existingVnfcCustomization != null) { + cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization); + } else { + cvnfcCustomization.setVnfcCustomization(vnfcCustomization); + } + + cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function")); + cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code")); + cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); + cvnfcCustomization.setVnfResourceCustomization(vnfResource); + + cvnfcCustomizations.add(cvnfcCustomization); + existingCvnfcSet.add(cvnfcCustomization); + } + + //***************************************************************************************************************************************** + //* Extract Fabric Configuration + //***************************************************************************************************************************************** + + List fabricConfigList = toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION); + + for (NodeTemplate fabricTemplate : fabricConfigList) { + + ConfigurationResource fabricConfig = null; + + ConfigurationResource existingConfig = findExistingConfiguration(service, + fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + + if (existingConfig == null) { + + fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure); + + } else { + fabricConfig = existingConfig; + } + + VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization( + fabricTemplate, toscaResourceStructure, + vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate, + vfModuleMemberName); + + vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization); + } + + } + + } + + } + + } + + vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations); + vfModuleCustomization + .setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations); + + return vfModuleCustomization; + } + + protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, + ToscaResourceStructure toscaResourceStruct, + VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, + CvnfcCustomization cvnfcCustomization, + ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) { + + Metadata fabricMetadata = fabricTemplate.getMetaData(); + + VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization(); + + vfModuleToCvnfc.setConfigurationResource(configResource); + vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization); + vfModuleToCvnfc + .setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName()); + vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization); + vfModuleToCvnfc.setVnfResourceCustomization(vnfResource); + + List policyList = toscaResourceStruct.getSdcCsarHelper() + .getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External"); + + if (policyList != null) { + for (Policy policy : policyList) { + + for (String policyCvfcTarget : policy.getTargets()) { + + if (policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)) { + + Map propMap = policy.getPolicyProperties(); + + if (propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")) { + vfModuleToCvnfc.setPolicyName(propMap.get("name").toString()); + } + } + } + } + } + + vfModuleToCvnfc.setConfigurationFunction( + toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function")); + vfModuleToCvnfc.setConfigurationRole( + toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role")); + vfModuleToCvnfc.setConfigurationType( + toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type")); + + return vfModuleToCvnfc; + } + + protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) { + ConfigurationResource configResource = null; + for (ConfigurationResourceCustomization configurationResourceCustom : service + .getConfigurationCustomizations()) { + if (configurationResourceCustom.getConfigurationResource() != null + && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) { + configResource = configurationResourceCustom.getConfigurationResource(); + } + } + if (configResource == null) { + configResource = configRepo.findResourceByModelUUID(modelUUID); + } + + return configResource; + } + + protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource, + String vfModuleModelCustomizationUUID) { + VfModuleCustomization vfModuleCustomization = null; + for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) { + if (vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)) { + vfModuleCustomization = vfModuleCustom; + } + } + if (vfModuleCustomization == null) { + vfModuleCustomization = vfModuleCustomizationRepo + .findByModelCustomizationUUID(vfModuleModelCustomizationUUID); + } + + return vfModuleCustomization; + } + + protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) { + VfModule vfModule = null; + for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) { + if (vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)) { + vfModule = vfModuleCustom.getVfModule(); + } + } + if (vfModule == null) { + vfModule = vfModuleRepo.findByModelUUID(modelUUID); + } + + return vfModule; + } + + protected VfModuleCustomization createVfModuleCustomization(Group group, + ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) { + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + + vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID()); + + vfModuleCustomization.setVfModule(vfModule); + + String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, + SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT); + if (initialCount != null && initialCount.length() > 0) { + vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount)); + } + + vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper() + .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT))); + + String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, + SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT); + if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) { + vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount)); + } + + vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, + SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL)); + + String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, + SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES); + if (maxInstances != null && maxInstances.length() > 0) { + vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances)); + } + + String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, + SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES); + if (minInstances != null && minInstances.length() > 0) { + vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances)); + } + return vfModuleCustomization; + } + + protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure, + IVfModuleData vfModuleData, Metadata vfMetadata) { + VfModule vfModule = new VfModule(); + String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID(); + + if (vfModuleModelUUID == null) { + vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, + SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); + } else if (vfModuleModelUUID.indexOf('.') > -1) { + vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.')); + } + + vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper() + .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID))); + vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, + SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME))); + vfModule.setModelUUID(vfModuleModelUUID); + vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, + SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION))); + vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, + SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + + String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, + SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE); + if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) { + vfModule.setIsBase(true); + } else { + vfModule.setIsBase(false); + } + return vfModule; + } + + protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure, + VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization, + Metadata vfMetadata) { + + Optional matchingObject = vfResourceStructure.getVfModuleStructure().stream() + .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID() + .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, + SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))) + .findFirst(); + + if (matchingObject.isPresent()) { + List heatFilesList = new ArrayList<>(); + List volumeHeatChildTemplates = new ArrayList(); + List heatChildTemplates = new ArrayList(); + HeatTemplate parentHeatTemplate = new HeatTemplate(); + String parentArtifactType = null; + Set artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts()); + for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { + + List childNestedHeatTemplates = new ArrayList(); + + if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) { + checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact, + childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure); + } + + if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) { + parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact); + + if (!childNestedHeatTemplates.isEmpty()) { + + if (parentArtifactType != null && parentArtifactType + .equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) { + volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0)); + } else { + heatChildTemplates.add(childNestedHeatTemplates.get(0)); + } + } + } + + } + if (!heatFilesList.isEmpty()) { + vfModule.setHeatFiles(heatFilesList); + } + + // Set all Child Templates related to HEAT_VOLUME + if (!volumeHeatChildTemplates.isEmpty()) { + if (vfModule.getVolumeHeatTemplate() != null) { + vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates); + } else { + logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()"); + } + } + + // Set all Child Templates related to HEAT + if (!heatChildTemplates.isEmpty()) { + if (vfModule.getModuleHeatTemplate() != null) { + vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates); + } else { + logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()"); + } + } + } + } + + protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization, + List heatFilesList, VfModuleArtifact vfModuleArtifact, List nestedHeatTemplates, + HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) { + if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) { + vfModuleArtifact.incrementDeployedInDB(); + vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate()); + } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) { + vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate()); + VfModuleArtifact volVfModuleArtifact = this + .getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact); + vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment()); + vfModuleArtifact.incrementDeployedInDB(); + } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) { + if (vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) { + vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment()); + } else { + vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment()); + } + vfModuleArtifact.incrementDeployedInDB(); + } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) { + heatFilesList.add(vfModuleArtifact.getHeatFiles()); + vfModuleArtifact.incrementDeployedInDB(); + } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) { + nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate()); + vfModuleArtifact.incrementDeployedInDB(); + } + } + + protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate, + ToscaResourceStructure toscaResourceStructure, Service service) { + VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID( + vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + if (vnfResourceCustomization == null) { + VnfResource vnfResource = findExistingVnfResource(service, + vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + + if (vnfResource == null) { + vnfResource = createVnfResource(vfNodeTemplate); + } + + vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure, + vnfResource); + vnfResourceCustomization.setVnfResources(vnfResource); + vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization); + + // Fetch VNFC Instance Group Info + List groupList = toscaResourceStructure.getSdcCsarHelper() + .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate, + "org.openecomp.groups.VfcInstanceGroup"); + + for (Group group : groupList) { + + VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate, + group, vnfResourceCustomization, toscaResourceStructure); + + vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization); + } + } + return vnfResourceCustomization; + } + + protected VnfResource findExistingVnfResource(Service service, String modelUUID) { + VnfResource vnfResource = null; + for (VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()) { + if (vnfResourceCustom.getVnfResources() != null + && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) { + vnfResource = vnfResourceCustom.getVnfResources(); + } + } + if (vnfResource == null) { + vnfResource = vnfRepo.findResourceByModelUUID(modelUUID); + } + + return vnfResource; + } + + protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate, + ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) { + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setModelCustomizationUUID( + testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); + vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName()); + + vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION))); + vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code"))); + vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE))); + vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE))); + + vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN)); + + vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME))); + + vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION))); + + vnfResourceCustomization.setVnfResources(vnfResource); + vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger( + vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT))); + + CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper() + .getCapabilitiesOf(vfNodeTemplate); + + if (vnfCustomizationCapability != null) { + CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE); + + if (capAssign != null) { + vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper() + .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); + vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper() + .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); + } + + } + + toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization); + + return vnfResourceCustomization; + } + + protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) { + VnfResource vnfResource = new VnfResource(); + vnfResource.setModelInvariantUUID( + testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + + vnfResource.setModelVersion( + testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + vnfResource.setDescription( + testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + vnfResource.setOrchestrationMode(HEAT); + vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType())); + vnfResource.setAicVersionMax( + testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); + vnfResource.setAicVersionMin( + testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); + vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); + vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)); + + return vnfResource; + } + + protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate, + ToscaResourceStructure toscaResourceStructure, Service service) { + AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo + .findOneByModelCustomizationUUID( + nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); + + if (allottedResourceCustomization == null) { + AllottedResource allottedResource = findExistingAllottedResource(service, + nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + + if (allottedResource == null) { + allottedResource = createAR(nodeTemplate); + } + + toscaResourceStructure.setAllottedResource(allottedResource); + allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure); + allottedResourceCustomization.setAllottedResource(allottedResource); + allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization); + } + return allottedResourceCustomization; + } + + protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) { + AllottedResource allottedResource = null; + for (AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()) { + if (allottedResourceCustom.getAllottedResource() != null + && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) { + allottedResource = allottedResourceCustom.getAllottedResource(); + } + } + if (allottedResource == null) { + allottedResource = allottedRepo.findResourceByModelUUID(modelUUID); + } + + return allottedResource; + } + + protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate, + ToscaResourceStructure toscaResourceStructure) { + AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization(); + allottedResourceCustomization.setModelCustomizationUUID( + testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); + allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName()); + + allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION))); + allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code"))); + allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE))); + allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE))); + + List vfcNodes = toscaResourceStructure.getSdcCsarHelper() + .getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID()); + + if (vfcNodes != null) { + for (NodeTemplate vfcNode : vfcNodes) { + + allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid")); + allottedResourceCustomization.setProvidingServiceModelInvariantUUID( + toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid")); + allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper() + .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name")); + } + } + + CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper() + .getCapabilitiesOf(nodeTemplate); + + if (arCustomizationCapability != null) { + CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE); + + if (capAssign != null) { + allottedResourceCustomization.setMinInstances( + Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue( + capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); + allottedResourceCustomization.setMaxInstances( + Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue( + capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); + } + } + return allottedResourceCustomization; + } + + protected AllottedResource createAR(NodeTemplate nodeTemplate) { + AllottedResource allottedResource = new AllottedResource(); + allottedResource + .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + allottedResource.setModelInvariantUUID( + testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + allottedResource + .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + allottedResource + .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + allottedResource.setToscaNodeType(testNull(nodeTemplate.getType())); + allottedResource.setSubcategory( + testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY))); + allottedResource + .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + return allottedResource; + } + + protected Set extractHeatTemplateParameters(String yamlFile, String artifactUUID) { + // Scan the payload downloadResult and extract the HeatTemplate + // parameters + YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes()); + return yamlEditor.getParameterList(artifactUUID); + } + + protected String testNull(Object object) { + + if (object == null) { + return null; + } else if (object.equals("NULL")) { + return null; + } else if (object instanceof Integer) { + return object.toString(); + } else if (object instanceof String) { + return (String) object; + } else { + return "Type not recognized"; + } + } + + protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure, + VfModuleArtifact heatNestedArtifact) { + + if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure + .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) { + for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0) + .getArtifactInfo().getRelatedArtifacts()) { + if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) { + return ASDCConfiguration.HEAT; + } + + } + } + + if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null + && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo() + .getRelatedArtifacts() != null) { + for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) + .get(0).getArtifactInfo().getRelatedArtifacts()) { + if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) { + return ASDCConfiguration.HEAT_VOL; + } + + } + } + + // Does not belong to anything + return null; + + } + + protected static String createVNFName(VfResourceStructure vfResourceStructure) { + + return vfResourceStructure.getNotification().getServiceName() + "/" + + vfResourceStructure.getResourceInstance().getResourceInstanceName(); + } + + protected static String createVfModuleName(VfModuleStructure vfModuleStructure) { + + return createVNFName(vfModuleStructure.getParentVfResource()) + "::" + + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName(); + } + + protected String getPropertyInput(String propertyName) { + + String inputName = new String(); + + if (propertyName != null) { + int getInputIndex = propertyName.indexOf("{get_input="); + if (getInputIndex > -1) { + inputName = propertyName.substring(getInputIndex + 11, propertyName.length() - 1); + } + } + + return inputName; + } + + + protected static Timestamp getCurrentTimeStamp() { + + return new Timestamp(new Date().getTime()); + } } diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java new file mode 100644 index 0000000000..c0c66123eb --- /dev/null +++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java @@ -0,0 +1,442 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.asdc.client; + +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import javax.persistence.EntityNotFoundException; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.onap.so.asdc.BaseTest; +import org.onap.so.asdc.client.exceptions.ASDCControllerException; +import org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl; +import org.onap.so.asdc.client.test.emulators.DistributionClientEmulator; +import org.onap.so.asdc.client.test.emulators.NotificationDataImpl; +import org.onap.so.asdc.client.test.emulators.ResourceInfoImpl; +import org.onap.so.db.catalog.beans.PnfResource; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ToscaCsar; +import org.onap.so.db.catalog.beans.VnfResource; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.data.repository.PnfCustomizationRepository; +import org.onap.so.db.catalog.data.repository.PnfResourceRepository; +import org.onap.so.db.catalog.data.repository.ServiceRepository; +import org.onap.so.db.catalog.data.repository.ToscaCsarRepository; +import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository; +import org.onap.so.db.catalog.data.repository.VnfResourceRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +/** + * This is used to run some basic integration test(BIT) for ASDC controller. It will test the csar install and all the + * testing csar files are located underneath src/main/resources/download folder, + * + * PNF csar: service-Testservice140-csar.csar VNF csar: service-Svc140-VF-csar.csar + */ +@Transactional +public class ASDCControllerITTest extends BaseTest { + + private Logger logger = LoggerFactory.getLogger(ASDCControllerITTest.class); + + @Rule + public TestName testName = new TestName(); + + private String serviceUuid; + private String serviceInvariantUuid; + + /** + * Random UUID served as distribution UUID. + */ + private String distributionId; + private String artifactUuid; + + @Autowired + private ASDCController asdcController; + + @Autowired + private PnfResourceRepository pnfResourceRepository; + + @Autowired + private PnfCustomizationRepository pnfCustomizationRepository; + + @Autowired + private VnfResourceRepository vnfResourceRepository; + + @Autowired + private VnfCustomizationRepository vnfCustomizationRepository; + + @Autowired + private ToscaCsarRepository toscaCsarRepository; + + @Autowired + private ServiceRepository serviceRepository; + + private DistributionClientEmulator distributionClient; + + @Before + public void setUp() { + distributionId = UUID.randomUUID().toString(); + artifactUuid = UUID.randomUUID().toString(); + logger.info("Using distributionId: {}, artifactUUID: {} for testcase: {}", distributionId, artifactUuid, + testName.getMethodName()); + + distributionClient = new DistributionClientEmulator(); + distributionClient.setResourcePath("src/test/resources"); + asdcController.setDistributionClient(distributionClient); + try { + asdcController.initASDC(); + } catch (ASDCControllerException e) { + logger.error(e.getMessage(), e); + fail(e.getMessage()); + } + } + + @After + public void shutDown() { + try { + asdcController.closeASDC(); + } catch (ASDCControllerException e) { + logger.error(e.getMessage(), e); + fail(e.getMessage()); + } + } + + /** + * Mock the AAI using wireshark. + */ + private void initMockAaiServer(final String serviceUuid, final String serviceInvariantUuid) { + String modelEndpoint = "/aai/v15/service-design-and-creation/models/model/" + serviceInvariantUuid + + "/model-vers/model-ver/" + serviceUuid + "?depth=0"; + + stubFor(post(urlEqualTo(modelEndpoint)).willReturn(ok())); + } + + /** + * Test with service-Testservice140-csar.csar. + */ + @Test + public void treatNotification_ValidPnfResource_ExpectedOutput() { + + /** + * service UUID/invariantUUID from global metadata in service-Testservice140-template.yml. + */ + String serviceUuid = "efaea486-561f-4159-9191-a8d3cb346728"; + String serviceInvariantUuid = "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23"; + + initMockAaiServer(serviceUuid, serviceInvariantUuid); + + NotificationDataImpl notificationData = new NotificationDataImpl(); + notificationData.setServiceUUID(serviceUuid); + notificationData.setDistributionID(distributionId); + notificationData.setServiceInvariantUUID(serviceInvariantUuid); + notificationData.setServiceVersion("1.0"); + + ResourceInfoImpl resourceInfo = constructPnfResourceInfo(); + List resourceInfoList = new ArrayList<>(); + resourceInfoList.add(resourceInfo); + notificationData.setResources(resourceInfoList); + + ArtifactInfoImpl artifactInfo = constructPnfServiceArtifact(); + List artifactInfoList = new ArrayList<>(); + artifactInfoList.add(artifactInfo); + notificationData.setServiceArtifacts(artifactInfoList); + + try { + asdcController.treatNotification(notificationData); + logger.info("Checking the database for PNF ingestion"); + + /** + * Check the tosca csar entity, it should be the same as provided from NotficationData. + */ + ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid) + .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found")); + assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID()); + assertEquals("tosca csar name", "service-Testservice140-csar.csar", toscaCsar.getName()); + assertEquals("tosca csar version", "1.0", toscaCsar.getVersion()); + assertNull("tosca csar descrption", toscaCsar.getDescription()); + assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum()); + assertEquals("toscar csar URL", "/download/service-Testservice140-csar.csar", toscaCsar.getUrl()); + + /** + * Check the service entity, it should be the same as global metadata information in service-Testservice140-template.yml inside csar. + */ + Service service = serviceRepository.findById(serviceUuid) + .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found")); + assertEquals("model UUID", "efaea486-561f-4159-9191-a8d3cb346728", service.getModelUUID()); + assertEquals("model name", "TestService140", service.getModelName()); + assertEquals("model invariantUUID", "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23", + service.getModelInvariantUUID()); + assertEquals("model version", "1.0", service.getModelVersion()); + assertEquals("description", "Test Service for extended attributes of PNF resource", + service.getDescription().trim()); + assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID()); + assertEquals("service type", "Network", service.getServiceType()); + assertEquals("service role", "nfv", service.getServiceRole()); + assertEquals("environment context", "General_Revenue-Bearing", service.getEnvironmentContext()); + assertEquals("service category", "Network Service", service.getCategory()); + assertNull("workload context", service.getWorkloadContext()); + assertEquals("resource order", "Test140PNF", service.getResourceOrder()); + + /** + * Check PNF resource, it should be the same as metadata in the topology template in service-Testservice140-template.yml + * OR + * global metadata in the resource-Test140pnf-template.yml + */ + String pnfResourceKey = "9c54e269-122b-4e8a-8b2a-6eac849b441a"; + PnfResource pnfResource = pnfResourceRepository.findById(pnfResourceKey) + .orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found")); + assertNull("orchestration mode", pnfResource.getOrchestrationMode()); + assertEquals("Description", "Oracle", pnfResource.getDescription().trim()); + assertEquals("model UUID", pnfResourceKey, pnfResource.getModelUUID()); + assertEquals("model invariant UUID", "d832a027-75f3-455d-9de4-f02fcdee7e7e", + pnfResource.getModelInvariantUUID()); + assertEquals("model version", "1.0", pnfResource.getModelVersion()); + assertEquals("model name", "Test140PNF", pnfResource.getModelName()); + assertEquals("tosca node type", "org.openecomp.resource.pnf.Test140pnf", pnfResource.getToscaNodeType()); + assertEquals("resource category", "Application L4+", pnfResource.getCategory()); + assertEquals("resource sub category", "Call Control", pnfResource.getSubCategory()); + + /** + * Check PNF resource customization, it should be the same as metadata in the topology template in service-Testservice140-template.yml + * OR + * global metadata in the resource-Test140pnf-template.yml + */ + String pnfCustomizationKey = "428a3d73-f962-4cc2-ba62-2483c45d6b12"; + PnfResourceCustomization pnfCustomization = pnfCustomizationRepository + .findById(pnfCustomizationKey).orElseThrow( + () -> new EntityNotFoundException( + "PNF resource customization: " + pnfCustomizationKey + " not found")); + assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID()); + assertEquals("model instance name", "Test140PNF 0", pnfCustomization.getModelInstanceName()); + assertEquals("NF type", "", pnfCustomization.getNfType()); + assertEquals("NF Role", "nf", pnfCustomization.getNfRole()); + assertEquals("NF function", "nf", pnfCustomization.getNfFunction()); + assertEquals("NF naming code", "", pnfCustomization.getNfNamingCode()); + assertEquals("PNF resource model UUID", pnfResourceKey, pnfCustomization.getPnfResources().getModelUUID()); + assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign()); + assertNull("resource input", pnfCustomization.getResourceInput()); + assertEquals("cds blueprint name(sdnc_model_name property)", pnfCustomization.getBlueprintName(), + pnfCustomization.getBlueprintName()); + assertEquals("cds blueprint version(sdnc_model_version property)", pnfCustomization.getBlueprintVersion(), + pnfCustomization.getBlueprintVersion()); + + /** + * Check the pnf resource customization with service mapping + */ + List pnfCustList = service.getPnfCustomizations(); + assertEquals("PNF resource customization entity", 1, pnfCustList.size()); + assertEquals(pnfCustomizationKey, pnfCustList.get(0).getModelCustomizationUUID()); + + } catch (Exception e) { + logger.info(e.getMessage(), e); + fail(e.getMessage()); + } + } + + private ArtifactInfoImpl constructPnfServiceArtifact() { + ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl(); + artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR); + artifactInfo.setArtifactURL("/download/service-Testservice140-csar.csar"); + artifactInfo.setArtifactName("service-Testservice140-csar.csar"); + artifactInfo.setArtifactVersion("1.0"); + artifactInfo.setArtifactUUID(artifactUuid); + return artifactInfo; + } + + /** + * Construct the PnfResourceInfo based on the resource-Test140Pnf-template.yml from + * service-Testservice140-csar.csar. + */ + private ResourceInfoImpl constructPnfResourceInfo() { + ResourceInfoImpl resourceInfo = new ResourceInfoImpl(); + resourceInfo.setResourceInstanceName("Test140PNF"); + resourceInfo.setResourceInvariantUUID("d832a027-75f3-455d-9de4-f02fcdee7e7e"); + resourceInfo.setResoucreType("PNF"); + resourceInfo.setCategory("Application L4+"); + resourceInfo.setSubcategory("Call Control"); + resourceInfo.setResourceUUID("9c54e269-122b-4e8a-8b2a-6eac849b441a"); + resourceInfo.setResourceCustomizationUUID("428a3d73-f962-4cc2-ba62-2483c45d6b12"); + resourceInfo.setResourceVersion("1.0"); + return resourceInfo; + } + + /** + * Testing with the service-Svc140-VF-csar.csar. + */ + @Test + public void treatNotification_ValidVnfResource_ExpectedOutput() { + + /** + * service UUID/invariantUUID from global metadata in resource-Testvf140-template.yml. + */ + String serviceUuid = "28944a37-de3f-46ec-9c60-b57036fbd26d"; + String serviceInvariantUuid = "9e900d3e-1e2e-4124-a5c2-4345734dc9de"; + + initMockAaiServer(serviceUuid, serviceInvariantUuid); + + NotificationDataImpl notificationData = new NotificationDataImpl(); + notificationData.setServiceUUID(serviceUuid); + notificationData.setDistributionID(distributionId); + notificationData.setServiceInvariantUUID(serviceInvariantUuid); + notificationData.setServiceVersion("1.0"); + + ResourceInfoImpl resourceInfo = constructVnfResourceInfo(); + List resourceInfoList = new ArrayList<>(); + resourceInfoList.add(resourceInfo); + notificationData.setResources(resourceInfoList); + + ArtifactInfoImpl artifactInfo = constructVnfServiceArtifact(); + List artifactInfoList = new ArrayList<>(); + artifactInfoList.add(artifactInfo); + notificationData.setServiceArtifacts(artifactInfoList); + + try { + asdcController.treatNotification(notificationData); + logger.info("Checking the database for VNF ingestion"); + + /** + * Check the tosca csar entity, it should be the same as provided from NotficationData. + */ + ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid) + .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found")); + assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID()); + assertEquals("tosca csar name", "service-Svc140-VF-csar.csar", toscaCsar.getName()); + assertEquals("tosca csar version", "1.0", toscaCsar.getVersion()); + assertNull("tosca csar descrption", toscaCsar.getDescription()); + assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum()); + assertEquals("toscar csar URL", "/download/service-Svc140-VF-csar.csar", toscaCsar.getUrl()); + + /** + * Check the service entity, it should be the same as global metadata information in service-Testservice140-template.yml inside csar. + */ + Service service = serviceRepository.findById(serviceUuid) + .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found")); + assertEquals("model UUID", serviceUuid, service.getModelUUID()); + assertEquals("model name", "SVC140", service.getModelName()); + assertEquals("model invariantUUID", serviceInvariantUuid, + service.getModelInvariantUUID()); + assertEquals("model version", "1.0", service.getModelVersion()); + assertEquals("description", "SVC140", + service.getDescription().trim()); + assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID()); + assertEquals("service type", "ST", service.getServiceType()); + assertEquals("service role", "Sr", service.getServiceRole()); + assertEquals("environment context", "General_Revenue-Bearing", service.getEnvironmentContext()); + assertEquals("service category", "Network Service", service.getCategory()); + assertNull("workload context", service.getWorkloadContext()); + assertEquals("resource order", "TestVF140", service.getResourceOrder()); + + /** + * Check VNF resource, it should be the same as metadata in the topology template in service-Testservice140-template.yml + * OR + * global metadata in the resource-Testservice140-template.yml + */ + String vnfResourceKey = "d20d3ea9-2f54-4071-8b5c-fd746dde245e"; + VnfResource vnfResource = vnfResourceRepository.findById(vnfResourceKey) + .orElseThrow(() -> new EntityNotFoundException("VNF resource:" + vnfResourceKey + " not found")); + assertEquals("orchestration mode", "HEAT", vnfResource.getOrchestrationMode()); + assertEquals("Description", "TestPNF140", vnfResource.getDescription().trim()); + assertEquals("model UUID", vnfResourceKey, vnfResource.getModelUUID()); + assertEquals("model invariant UUID", "7a4bffa2-fac5-4b8b-b348-0bdf313a1aeb", + vnfResource.getModelInvariantUUID()); + assertEquals("model version", "1.0", vnfResource.getModelVersion()); + assertEquals("model name", "TestVF140", vnfResource.getModelName()); + assertEquals("tosca node type", "org.openecomp.resource.vf.Testvf140", vnfResource.getToscaNodeType()); + assertEquals("resource category", "Application L4+", vnfResource.getCategory()); + assertEquals("resource sub category", "Database", vnfResource.getSubCategory()); + + /** + * Check VNF resource customization, it should be the same as metadata in the topology template in service-Testservice140-template.yml + * OR + * global metadata in the resource-Testservice140-template.yml + */ + String vnfCustomizationKey = "ca1c8455-8ce2-4a76-a037-3f4cf01cffa0"; + VnfResourceCustomization vnfCustomization = vnfCustomizationRepository + .findById(vnfCustomizationKey).orElseThrow( + () -> new EntityNotFoundException( + "VNF resource customization: " + vnfCustomizationKey + " not found")); + assertEquals("model customizationUUID", vnfCustomizationKey, vnfCustomization.getModelCustomizationUUID()); + assertEquals("model instance name", "TestVF140 0", vnfCustomization.getModelInstanceName()); + assertNull("NF type", vnfCustomization.getNfType()); + assertNull("NF Role", vnfCustomization.getNfRole()); + assertNull("NF function", vnfCustomization.getNfFunction()); + assertNull("NF naming code", vnfCustomization.getNfNamingCode()); + assertEquals("VNF resource model UUID", vnfResourceKey, vnfCustomization.getVnfResources().getModelUUID()); + assertEquals("Multi stage design", "false", vnfCustomization.getMultiStageDesign()); + assertNull("resource input", vnfCustomization.getResourceInput()); + assertEquals("cds blueprint name(sdnc_model_name property)", vnfCustomization.getBlueprintName(), + vnfCustomization.getBlueprintName()); + assertEquals("cds blueprint version(sdnc_model_version property)", vnfCustomization.getBlueprintVersion(), + vnfCustomization.getBlueprintVersion()); + /** + * Check the vnf resource customization with service mapping + */ + List vnfCustList = service.getVnfCustomizations(); + assertEquals("VNF resource customization entity", 1, vnfCustList.size()); + assertEquals(vnfCustomizationKey, vnfCustList.get(0).getModelCustomizationUUID()); + } catch (Exception e) { + logger.info(e.getMessage(), e); + fail(e.getMessage()); + } + } + + private ArtifactInfoImpl constructVnfServiceArtifact() { + ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl(); + artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR); + artifactInfo.setArtifactURL("/download/service-Svc140-VF-csar.csar"); + artifactInfo.setArtifactName("service-Svc140-VF-csar.csar"); + artifactInfo.setArtifactVersion("1.0"); + artifactInfo.setArtifactUUID(artifactUuid); + return artifactInfo; + } + + /** + * Construct the PnfResourceInfo based on the resource-Testvf140-template.yml from service-Svc140-VF-csar.csar. + */ + private ResourceInfoImpl constructVnfResourceInfo() { + ResourceInfoImpl resourceInfo = new ResourceInfoImpl(); + resourceInfo.setResourceInstanceName("TestVF140"); + resourceInfo.setResourceInvariantUUID("7a4bffa2-fac5-4b8b-b348-0bdf313a1aeb"); + resourceInfo.setResoucreType("VF"); + resourceInfo.setCategory("Application L4+"); + resourceInfo.setSubcategory("Database"); + resourceInfo.setResourceUUID("d20d3ea9-2f54-4071-8b5c-fd746dde245e"); + resourceInfo.setResourceCustomizationUUID("ca1c8455-8ce2-4a76-a037-3f4cf01cffa0"); + resourceInfo.setResourceVersion("1.0"); + resourceInfo.setArtifacts(Collections.EMPTY_LIST); + return resourceInfo; + } +} diff --git a/asdc-controller/src/test/resources/ASDC/.gitignore b/asdc-controller/src/test/resources/ASDC/.gitignore index e54786bc77..836e68d117 100644 --- a/asdc-controller/src/test/resources/ASDC/.gitignore +++ b/asdc-controller/src/test/resources/ASDC/.gitignore @@ -1 +1 @@ -/*.csar +*.*/*.csar diff --git a/asdc-controller/src/test/resources/application-test.yaml b/asdc-controller/src/test/resources/application-test.yaml index caaa5dd3b4..5ba8521b3c 100644 --- a/asdc-controller/src/test/resources/application-test.yaml +++ b/asdc-controller/src/test/resources/application-test.yaml @@ -14,7 +14,7 @@ spring: initialization-mode: always jpa: generate-ddl: false - show-sql: false + show-sql: true hibernate: ddl-auto: none naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy @@ -97,3 +97,5 @@ mso: enabled: false aai: endpoint: http://localhost:${wiremock.server.port} + config: + defaultpath: src/test/resources diff --git a/asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csar b/asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csar new file mode 100644 index 0000000000000000000000000000000000000000..0de1b0b0a015231fe1504aa557646f5d77ff987f GIT binary patch literal 35636 zcma&NV~i+W(=I%oJ+^Jzwr$(CXOC^$_Uy53+qP|g`@X;P<2_IEJ~^GNq&uDT>a|jJ zT~({leVVt&J?e|F|Ij-Wxd?IMUjfI2%B@IxNH7!MVCFKFQEXEV@ig zN-V)h(NIoL&NL{}FEZ^yhEUl{$V^O5Py>!56D6qwB?AD+OM(9yeF<@ymX#WnE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R>lKP_UndDHF*Ra;_lR`d8*A= zw+IAbHUi0Y-%Zbtu%D$6Q4=5B0}eHZ%=?4NI0| zww5^3YjVxCi2gw3yb@kE7XDR0;^ASI^zV9b-(P%R-Ok-_s3B}sC2BNVwdA)S4yK*N z-2pGz7|+Q%dx9zhjUCB*6Zs^8Mnne?)_4_yrRq6 z6w1ac%MjbZ;}Vqzya9;R6d7rnTUXL^epL-)JxRRnhf}hhnr{zUFLM(~rXxPHQa*AP zrM9~iyl=f`GK*1gdESo6(b&ppq0ENYvex!fee}Xti8gn^XV$mbwPHoB&p$i8x;B@t z-EPSO0HPj8o{|SQTDejGwS%TC>%y(ChgqdVE>@Mr(*Tf$aH#V#6lCY0SVIX!dn z>|4H{`Ly0hXJ~I&XSSFvGdb)WdV{){yxj9p#rzZsQwaEt$X9+n%rC*s1q*uMU~WiJo@PD~GcdzU)?(zDwhEbqyL)DWToyqA}mu~%D+%&zmgDG8NABTBFx4*vkf$XVSoJ*NL zWCwAl?dj0W;AdA5t$HY+`p<;rn&Zcfm!rLRs$a5Bym3c*p1WnGs=31jJ+_qdoN2~W zX0w*cH*+monXJF>X0zQ59wn^J@Le|J zREx^EfM?Ad3&n(9&g0Ub6z>_BvEOF#forE{bu4k|3^~Gkku_LDszY>924-EFh(X31`!4h4i1Kv>KwmQKb0FyLED0Xm=lOm zL2_|okzQ_UNg}$ogSVU5dx2`V12O1)F$Bl~GDG}>ogH<3f%-s~jq8KCSdD3o){6QG zJb&{W@DMY7gc(4V1MpsRd5J`H%B5DA8(-d>Mx4a2qc_pCrahyc&g){H{m7BLZ|&JOUgCCI@8K!|sho_doI(;-I@E5a78g zstJgjCD6@4KK2)M+BgDm0)rIU7073gqnmR-6-VKt57q_31FH;_8H2teCWm?AEE&|>IwnY+MybQe()8#NysM!fDYY2 wfLu3JlTeS~KsV T extractByKey(BuildingBlockExecution execution, ResourceKey key) throws BBObjectNotFoundException { return extractByKey(execution, key, execution.getLookupMap().get(key)); } - protected T extractByKey(BuildingBlockExecution execution, ResourceKey key, String value) + public T extractByKey(BuildingBlockExecution execution, ResourceKey key, String value) throws BBObjectNotFoundException { Optional result = Optional.empty(); diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepository.java index 8252b2427e..7527a79842 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepository.java @@ -21,11 +21,8 @@ package org.onap.so.db.catalog.data.repository; import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import java.util.List; - @RepositoryRestResource(collectionResourceRel = "pnfResourceCustomization", path = "pnfResourceCustomization") public interface PnfCustomizationRepository extends JpaRepository { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java index 17ae017da4..525c628e1c 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java @@ -7,9 +7,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. @@ -21,7 +21,6 @@ package org.onap.so.db.catalog.data.repository; import java.util.List; - import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -29,11 +28,13 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "vnfResourceCustomization", path = "vnfResourceCustomization") public interface VnfCustomizationRepository extends JpaRepository { - List findByModelCustomizationUUID(String modelCustomizationUUID); - VnfResourceCustomization findOneByModelCustomizationUUID(String modelCustomizationUuid); + List findByModelCustomizationUUID(String modelCustomizationUUID); + + VnfResourceCustomization findOneByModelCustomizationUUID(String modelCustomizationUuid); - @Query(value = "SELECT * FROM vnf_resource_customization WHERE MODEL_INSTANCE_NAME = ?1 AND VNF_RESOURCE_MODEL_UUID = ?2 LIMIT 1;", nativeQuery = true) - VnfResourceCustomization findByModelInstanceNameAndVnfResources(String modelInstanceName, String vnfResourceModelUUID); + @Query(value = "SELECT * FROM vnf_resource_customization WHERE MODEL_INSTANCE_NAME = ?1 AND VNF_RESOURCE_MODEL_UUID = ?2 LIMIT 1;", nativeQuery = true) + VnfResourceCustomization findByModelInstanceNameAndVnfResources(String modelInstanceName, + String vnfResourceModelUUID); } \ No newline at end of file diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java index c5e95fcfbc..7ac80e222f 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java @@ -20,7 +20,6 @@ package org.onap.so.db.catalog.data.repository; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import org.junit.Test; @@ -29,9 +28,6 @@ import org.onap.so.db.catalog.beans.PnfResource; import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.exceptions.NoEntityFoundException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.CollectionUtils; - -import java.util.List; public class PnfCustomizationRepositoryTest extends BaseTest { diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepositoryTest.java index 8e2e1e0446..be21ea9b35 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepositoryTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import java.util.List; import org.junit.Test; import org.onap.so.db.catalog.BaseTest; import org.onap.so.db.catalog.beans.VnfResource; @@ -30,8 +31,6 @@ import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; -import java.util.List; - public class VnfCustomizationRepositoryTest extends BaseTest { diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index d53d8925e2..7068ef9ba5 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -956,7 +956,7 @@ CREATE TABLE IF NOT EXISTS vnf_vfmodule_cvnfc_configuration_customization ( ) ENGINE = INNODB AUTO_INCREMENT = 20654 DEFAULT CHARACTER SET = LATIN1; CREATE TABLE IF NOT EXISTS `pnf_resource` ( - `ORCHESTRATION_MODE` varchar(20) NOT NULL DEFAULT 'HEAT', + `ORCHESTRATION_MODE` varchar(20) DEFAULT NULL, `DESCRIPTION` varchar(1200) DEFAULT NULL, `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `MODEL_UUID` varchar(200) NOT NULL, -- 2.16.6