summaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main/java
diff options
context:
space:
mode:
authorArthur Martella <amartell@research.att.com>2017-09-08 13:27:46 -0400
committerArthur Martella <amartell@research.att.com>2017-09-08 13:32:24 -0400
commit62cd6aaaf74aa91ee0037c0e155c8e7284f07567 (patch)
tree68c0c53c9156f5aa3c6b3599ac940770f986633d /asdc-controller/src/main/java
parentfa1a211d28a912892fcd888569df033900eb01ee (diff)
1710 Rebase - Second Attempt
This commit rebases changes from openecomp-mso/internal-staging-1710 up to and including this codecloud commit: 54483fc6606ddb1591a2e9da61bff8712325f924 Wed Sep 6 18:12:56 2017 -0400 Rebasing was done on a branch on top of this commit in so/master in ONAP: 93fbdfbe46104f8859d4754040f979cb7997c157 Thu Sep 7 16:42:59 2017 +0000 Change-Id: I4ad9abf40da32bf5bdca43e868b8fa2dbcd9dc59 Issue-id: SO-107 Signed-off-by: Arthur Martella <amartell@research.att.com>
Diffstat (limited to 'asdc-controller/src/main/java')
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java14
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java108
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java20
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java412
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java9
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java1130
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java97
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java199
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java4
9 files changed, 1927 insertions, 66 deletions
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java
index 61ca698678..bb4b9655c4 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java
@@ -30,13 +30,13 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
-import org.codehaus.jackson.JsonNode;
-
-import org.openecomp.sdc.api.consumer.IConfiguration;
import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException;
import org.openecomp.mso.properties.MsoJsonProperties;
import org.openecomp.mso.properties.MsoPropertiesException;
import org.openecomp.mso.properties.MsoPropertiesFactory;
+import org.openecomp.sdc.api.consumer.IConfiguration;
+
+import com.fasterxml.jackson.databind.JsonNode;
public class ASDCConfiguration implements IConfiguration {
@@ -74,6 +74,7 @@ public class ASDCConfiguration implements IConfiguration {
public static final String HEAT_NET="HEAT_NET";
public static final String HEAT_VOL="HEAT_VOL";
public static final String OTHER="OTHER";
+ public static final String TOSCA_CSAR="TOSCA_CSAR";
public static final String VF_MODULES_METADATA="VF_MODULES_METADATA";
@@ -84,6 +85,7 @@ public class ASDCConfiguration implements IConfiguration {
HEAT_NET,
HEAT_VOL,
OTHER,
+ TOSCA_CSAR,
VF_MODULES_METADATA};
public static final List<String> SUPPORTED_ARTIFACT_TYPES_LIST = Collections.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES));
@@ -110,6 +112,10 @@ public class ASDCConfiguration implements IConfiguration {
refreshASDCConfig ();
}
+
+ public java.lang.Boolean isUseHttpsWithDmaap() {
+ return false;
+ }
public String getAsdcControllerName () {
return asdcControllerName;
@@ -399,7 +405,7 @@ public class ASDCConfiguration implements IConfiguration {
if (msoProp.getJsonRootNode ().get (PARAMETER_PATTERN) != null) {
Iterator <Entry <String, JsonNode>> it = msoProp.getJsonRootNode ()
.get (PARAMETER_PATTERN)
- .getFields ();
+ .fields();
Entry <String, JsonNode> entry;
while (it.hasNext ()) {
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java
index a95d25fcbb..736cd1a7f6 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java
@@ -21,8 +21,12 @@
package org.openecomp.mso.asdc.client;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.util.List;
+
import org.openecomp.sdc.api.IDistributionClient;
import org.openecomp.sdc.api.consumer.IDistributionStatusMessage;
import org.openecomp.sdc.api.consumer.INotificationCallback;
@@ -39,7 +43,9 @@ import org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException;
import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException;
import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
import org.openecomp.mso.asdc.installer.IVfResourceInstaller;
+import org.openecomp.mso.asdc.installer.ToscaResourceStructure;
import org.openecomp.mso.asdc.installer.VfResourceStructure;
+import org.openecomp.mso.asdc.installer.heat.ToscaResourceInstaller;
import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller;
import org.openecomp.mso.asdc.util.ASDCNotificationLogging;
import org.openecomp.mso.logger.MessageEnum;
@@ -57,6 +63,9 @@ public class ASDCController {
protected String controllerName;
+ protected ToscaResourceInstaller toscaInstaller;
+
+
/**
* Inner class for Notification callback
*
@@ -135,6 +144,7 @@ public class ASDCController {
isAsdcClientAutoManaged = true;
this.controllerName = controllerConfigName;
this.resourceInstaller = new VfResourceInstaller();
+ toscaInstaller = new ToscaResourceInstaller();
}
public ASDCController (String controllerConfigName, IDistributionClient asdcClient, IVfResourceInstaller resourceinstaller) {
@@ -148,6 +158,7 @@ public class ASDCController {
distributionClient = asdcClient;
this.controllerName = controllerConfigName;
this.resourceInstaller = new VfResourceInstaller();
+ toscaInstaller = new ToscaResourceInstaller();
}
/**
@@ -272,7 +283,7 @@ public class ASDCController {
private boolean checkResourceAlreadyDeployed (VfResourceStructure resource) throws ArtifactInstallerException {
- if (this.resourceInstaller.isResourceAlreadyDeployed (resource)) {
+ if (toscaInstaller.isResourceAlreadyDeployed (resource)) {
LOGGER.info (MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST,
resource.getResourceInstance().getResourceInstanceName(),
resource.getResourceInstance().getResourceUUID(),
@@ -366,6 +377,36 @@ public class ASDCController {
}
+ private void writeArtifactToFile (IArtifactInfo artifact,
+ IDistributionClientDownloadResult resultArtifact) throws ASDCDownloadException {
+
+ LOGGER.debug ("Trying to download the artifact : " + artifact.getArtifactURL ()
+ + UUID_PARAM
+ + artifact.getArtifactUUID ()
+ + ")");
+
+ File spoolFile = new File(System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactName());
+
+
+ byte[] payloadBytes = resultArtifact.getArtifactPayload();
+
+ try {
+ LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***WRITE FILE ARTIFACT NAME", "ASDC", artifact.getArtifactName());
+
+ FileOutputStream outFile = new FileOutputStream(System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactName());
+ outFile.write(payloadBytes, 0, payloadBytes.length);
+ outFile.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ LOGGER.error(MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL,
+ artifact.getArtifactName (),
+ artifact.getArtifactURL (),
+ artifact.getArtifactUUID (),
+ resultArtifact.getDistributionMessageResult (), "", "", MsoLogger.ErrorCode.DataError, "ASDC write to file failed");
+ }
+
+ }
+
private void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) {
@@ -394,7 +435,7 @@ public class ASDCController {
}
}
- private void deployResourceStructure (VfResourceStructure resourceStructure) throws ArtifactInstallerException {
+ private void deployResourceStructure (VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
LOGGER.info (MessageEnum.ASDC_START_DEPLOY_ARTIFACT, resourceStructure.getResourceInstance().getResourceInstanceName(), resourceStructure.getResourceInstance().getResourceUUID(), "ASDC", "deployResourceStructure");
try {
@@ -403,10 +444,27 @@ public class ASDCController {
if(resourceType.equals("VF") && !category.equalsIgnoreCase("Allotted Resource")){
resourceStructure.createVfModuleStructures();
}
- resourceInstaller.installTheResource (resourceStructure);
+ //resourceInstaller.installTheResource (resourceStructure);
+
+ //ToscaResourceInstaller tri = new ToscaResourceInstaller();
+ toscaInstaller.installTheResource(toscaResourceStructure, resourceStructure);
+
+ /* if(toscaResourceStructure.isVnfAlreadyInstalled()){
+ LOGGER.info (MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST,
+ toscaResourceStructure.getCatalogVnfResource().getModelName(),
+ toscaResourceStructure.getCatalogVnfResource().getModelUuid(),
+ toscaResourceStructure.getCatalogVnfResource().getModelUuid(),"","");
+
+
+ this.sendDeployNotificationsForResource(resourceStructure,DistributionStatusEnum.ALREADY_DOWNLOADED,null);
+ this.sendDeployNotificationsForResource(resourceStructure,DistributionStatusEnum.ALREADY_DEPLOYED,null);
+ } */
} catch (ArtifactInstallerException e) {
-
+ LOGGER.info (MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL,
+ resourceStructure.getResourceInstance().getResourceName(),
+ resourceStructure.getResourceInstance().getResourceUUID(),
+ String.valueOf (resourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure");
sendDeployNotificationsForResource(resourceStructure,DistributionStatusEnum.DEPLOY_ERROR,e.getMessage());
throw e;
}
@@ -497,6 +555,9 @@ public class ASDCController {
LOGGER.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif));
LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, iNotif.getServiceUUID(), "ASDC", "treatNotification");
this.changeControllerStatus(ASDCControllerStatus.BUSY);
+
+
+
// Process only the Resource artifacts in MSO
for (IResourceInstance resource : iNotif.getResources()) {
@@ -505,6 +566,7 @@ public class ASDCController {
if ("VF".equals(resource.getResourceType()) || "VL".equals(resource.getResourceType())) {
this.processResourceNotification(iNotif,resource);
}
+
}
@@ -522,6 +584,7 @@ public class ASDCController {
private void processResourceNotification (INotificationData iNotif,IResourceInstance resource) {
// For each artifact, create a structure describing the VFModule in a ordered flat level
VfResourceStructure resourceStructure = new VfResourceStructure(iNotif,resource);
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
try {
@@ -542,7 +605,9 @@ public class ASDCController {
}
- this.deployResourceStructure(resourceStructure);
+ this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
+
+ this.deployResourceStructure(resourceStructure, toscaResourceStructure);
}
} catch (ArtifactInstallerException | ASDCDownloadException | UnsupportedEncodingException e) {
@@ -551,6 +616,39 @@ public class ASDCController {
}
}
+ private void processCsarServiceArtifacts (INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
+
+ List<IArtifactInfo> 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){
+ System.out.println("Whats the error " + e.getMessage());
+ LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG,
+ "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processCsarServiceArtifacts", e);
+ }
+ }
+
+ }
+ }
+
private static final String UNKNOWN="Unknown";
/**
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java
index f0b6ec4853..05c049a1ed 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java
@@ -21,16 +21,6 @@
package org.openecomp.mso.asdc.healthcheck;
-import org.openecomp.mso.MsoStatusUtil;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJsonProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.HealthCheckUtils;
-import org.openecomp.mso.utils.UUIDChecker;
-import org.apache.http.HttpStatus;
-
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.Path;
@@ -38,6 +28,14 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
+import org.openecomp.mso.HealthCheckUtils;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.properties.MsoJsonProperties;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+import org.openecomp.mso.utils.UUIDChecker;
+
@Path("/")
public class HealthCheckHandler {
@@ -87,7 +85,7 @@ import javax.ws.rs.core.Response;
return null;
}
- if (msoProperties !=null && msoProperties.getJsonRootNode().getElements().hasNext()) {
+ if (msoProperties !=null && msoProperties.getJsonRootNode().elements().hasNext()) {
return msoProperties;
} else {
msoLogger.error (MessageEnum.ASDC_PROPERTIES_NOT_FOUND , MSO_PROP_ASDC, "", "", MsoLogger.ErrorCode.DataError, "ASDC properties not found");
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java
new file mode 100644
index 0000000000..edba81ac00
--- /dev/null
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java
@@ -0,0 +1,412 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.asdc.installer;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+
+import java.util.List;
+
+import org.openecomp.sdc.api.notification.IArtifactInfo;
+import org.openecomp.sdc.api.notification.INotificationData;
+//import org.openecomp.generic.tosca.parser.model.Metadata;
+//import org.openecomp.sdc.tosca.parser.factory.SdcCsarHelperFactory;
+//import org.openecomp.sdc.tosca.parser.factory.SdcCsarHelperFactory;
+///import org.openecomp.generic.tosca.parser.model.Metadata;
+import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcCsarHelperImpl;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+
+
+import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
+
+
+
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.elements.Metadata;
+
+import org.openecomp.mso.db.catalog.beans.AllottedResource;
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.NetworkResource;
+import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;
+import org.openecomp.mso.db.catalog.beans.ToscaCsar;
+import org.openecomp.mso.db.catalog.beans.VfModule;
+import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles;
+import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
+import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+public class ToscaResourceStructure {
+
+ Metadata serviceMetadata;
+ private Service catalogService;
+ ISdcCsarHelper sdcCsarHelper;
+ List<NodeTemplate> allottedList;
+ List<NodeTemplate> networkTypes;
+ List<NodeTemplate> vfTypes;
+ String heatTemplateUUID;
+ String volHeatTemplateUUID;
+ String volHeatEnvTemplateUUID;
+ String envHeatTemplateUUID;
+ String heatFilesUUID;
+ boolean isVnfAlreadyInstalled = false;
+ String serviceVersion;
+
+ private NetworkResourceCustomization catalogNetworkResourceCustomization;
+
+ private NetworkResource catalogNetworkResource;
+
+ private AllottedResourceCustomization catalogResourceCustomization;
+
+ private VfModule vfModule;
+
+ private VfModuleCustomization vfModuleCustomization;
+
+ private VnfResource vnfResource;
+
+ private VnfResourceCustomization vnfResourceCustomization;
+
+ private ServiceToResourceCustomization serviceToResourceCustomization;
+
+ private AllottedResource allottedResource;
+
+ private AllottedResourceCustomization allottedResourceCustomization;
+
+ private VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom;
+
+ private TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup;
+
+ private VfModuleToHeatFiles vfModuleToHeatFiles;
+
+ private IArtifactInfo toscaArtifact;
+
+ private ToscaCsar toscaCsar;
+
+ private ServiceToResourceCustomization vfServiceToResourceCustomization;
+
+ private ServiceToResourceCustomization allottedServiceToResourceCustomization;
+
+ private ServiceToResourceCustomization vlServiceToResourceCustomization;
+
+ protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC);
+
+
+ public ToscaResourceStructure(){
+ }
+
+ public void updateResourceStructure(IArtifactInfo artifact){
+
+
+ try {
+
+ SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();//Autoclosable
+
+
+ File spoolFile = new File(System.getProperty("mso.config.path") + "ASDC/" + artifact.getArtifactName());
+
+
+
+ System.out.println("PATH IS " + spoolFile.getAbsolutePath());
+ LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***PATH", "ASDC", spoolFile.getAbsolutePath());
+
+
+ sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath());
+
+ }catch(Exception e){
+ System.out.println("System out " + e.getMessage());
+ LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG,
+ "Exception caught during parser *****LOOK********* " + artifact.getArtifactName(), "ASDC", "processResourceNotification", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processResourceNotification", e);
+ }
+
+
+ serviceMetadata = sdcCsarHelper.getServiceMetadata();
+
+
+ }
+
+ public String getHeatTemplateUUID() {
+ return heatTemplateUUID;
+ }
+
+ public void setHeatTemplateUUID(String heatTemplateUUID) {
+ this.heatTemplateUUID = heatTemplateUUID;
+ }
+
+ public List<NodeTemplate> getAllottedList() {
+ return allottedList;
+ }
+
+ public void setAllottedList(List<NodeTemplate> allottedList) {
+ this.allottedList = allottedList;
+ }
+
+ public ISdcCsarHelper getSdcCsarHelper() {
+ return sdcCsarHelper;
+ }
+
+ public void setSdcCsarHelper(ISdcCsarHelper sdcCsarHelper) {
+ this.sdcCsarHelper = sdcCsarHelper;
+ }
+
+ public Metadata getServiceMetadata() {
+ return serviceMetadata;
+ }
+
+ public Service getCatalogService() {
+ return catalogService;
+ }
+
+ public void setServiceMetadata(Metadata serviceMetadata) {
+ this.serviceMetadata = serviceMetadata;
+ }
+
+ public void setCatalogService(Service catalogService) {
+ this.catalogService = catalogService;
+ }
+
+ public List<NodeTemplate> getNetworkTypes() {
+ return networkTypes;
+ }
+
+ public void setNetworkTypes(List<NodeTemplate> networkTypes) {
+ this.networkTypes = networkTypes;
+ }
+
+ public List<NodeTemplate> getVfTypes() {
+ return vfTypes;
+ }
+
+ public void setVfTypes(List<NodeTemplate> vfTypes) {
+ this.vfTypes = vfTypes;
+ }
+
+ public AllottedResourceCustomization getCatalogResourceCustomization() {
+ return catalogResourceCustomization;
+ }
+
+ public void setCatalogResourceCustomization(
+ AllottedResourceCustomization catalogResourceCustomization) {
+ this.catalogResourceCustomization = catalogResourceCustomization;
+ }
+
+ // Network Only
+ public NetworkResourceCustomization getCatalogNetworkResourceCustomization() {
+ return catalogNetworkResourceCustomization;
+ }
+ // Network Only
+ public void setCatalogNetworkResourceCustomization(NetworkResourceCustomization catalogNetworkResourceCustomization) {
+ this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization;
+ }
+
+ public NetworkResource getCatalogNetworkResource() {
+ return catalogNetworkResource;
+ }
+
+ public void setCatalogNetworkResource(NetworkResource catalogNetworkResource) {
+ this.catalogNetworkResource = catalogNetworkResource;
+ }
+
+ public VfModule getCatalogVfModule() {
+ return vfModule;
+ }
+
+ public void setCatalogVfModule(VfModule vfModule) {
+ this.vfModule = vfModule;
+ }
+
+ public VnfResource getCatalogVnfResource() {
+ return vnfResource;
+ }
+
+ public void setCatalogVnfResource(VnfResource vnfResource) {
+ this.vnfResource = vnfResource;
+ }
+
+ public VnfResourceCustomization getCatalogVnfResourceCustomization() {
+ return vnfResourceCustomization;
+ }
+
+ public void setCatalogVnfResourceCustomization(
+ VnfResourceCustomization vnfResourceCustomization) {
+ this.vnfResourceCustomization = vnfResourceCustomization;
+ }
+
+ public VfModuleCustomization getCatalogVfModuleCustomization() {
+ return vfModuleCustomization;
+ }
+
+ public void setCatalogVfModuleCustomization(VfModuleCustomization vfModuleCustomization) {
+ this.vfModuleCustomization = vfModuleCustomization;
+ }
+
+ public ServiceToResourceCustomization getServiceToResourceCustomization() {
+ return serviceToResourceCustomization;
+ }
+
+ public void setServiceToResourceCustomization(
+ ServiceToResourceCustomization serviceToResourceCustomization) {
+ this.serviceToResourceCustomization = serviceToResourceCustomization;
+ }
+
+ public AllottedResource getAllottedResource() {
+ return allottedResource;
+ }
+
+ public void setAllottedResource(AllottedResource allottedResource) {
+ this.allottedResource = allottedResource;
+ }
+
+ public AllottedResourceCustomization getCatalogAllottedResourceCustomization() {
+ return allottedResourceCustomization;
+ }
+
+ public void setCatalogAllottedResourceCustomization(
+ AllottedResourceCustomization allottedResourceCustomization) {
+ this.allottedResourceCustomization = allottedResourceCustomization;
+ }
+
+ public VnfResCustomToVfModuleCustom getCatalogVnfResCustomToVfModuleCustom() {
+ return vnfResCustomToVfModuleCustom;
+ }
+
+ public void setCatalogVnfResCustomToVfModuleCustom(
+ VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom) {
+ this.vnfResCustomToVfModuleCustom = vnfResCustomToVfModuleCustom;
+ }
+
+ public TempNetworkHeatTemplateLookup getCatalogTempNetworkHeatTemplateLookup() {
+ return tempNetworkHeatTemplateLookup;
+ }
+
+ public void setCatalogTempNetworkHeatTemplateLookup(
+ TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) {
+ this.tempNetworkHeatTemplateLookup = tempNetworkHeatTemplateLookup;
+ }
+
+ public String getHeatFilesUUID() {
+ return heatFilesUUID;
+ }
+
+ public void setHeatFilesUUID(String heatFilesUUID) {
+ this.heatFilesUUID = heatFilesUUID;
+ }
+
+ public VfModuleToHeatFiles getCatalogVfModuleToHeatFiles() {
+ return vfModuleToHeatFiles;
+ }
+
+ public void setCatalogVfModuleToHeatFiles(VfModuleToHeatFiles vfModuleToHeatFiles) {
+ this.vfModuleToHeatFiles = vfModuleToHeatFiles;
+ }
+
+ public IArtifactInfo getToscaArtifact() {
+ return toscaArtifact;
+ }
+
+ public void setToscaArtifact(IArtifactInfo toscaArtifact) {
+ this.toscaArtifact = toscaArtifact;
+ }
+
+ public ToscaCsar getCatalogToscaCsar() {
+ return toscaCsar;
+ }
+
+ public void setCatalogToscaCsar(ToscaCsar toscaCsar) {
+ this.toscaCsar = toscaCsar;
+ }
+
+ public boolean isVnfAlreadyInstalled() {
+ return isVnfAlreadyInstalled;
+ }
+
+ public void setVnfAlreadyInstalled(boolean isVnfAlreadyInstalled) {
+ this.isVnfAlreadyInstalled = isVnfAlreadyInstalled;
+ }
+
+ public ServiceToResourceCustomization getCatalogVfServiceToResourceCustomization() {
+ return vfServiceToResourceCustomization;
+ }
+
+ public void setCatalogVfServiceToResourceCustomization(
+ ServiceToResourceCustomization vfServiceToResourceCustomization) {
+ this.vfServiceToResourceCustomization = vfServiceToResourceCustomization;
+ }
+
+ public ServiceToResourceCustomization getCatalogAllottedServiceToResourceCustomization() {
+ return allottedServiceToResourceCustomization;
+ }
+
+ public void setCatalogAllottedServiceToResourceCustomization(
+ ServiceToResourceCustomization allottedServiceToResourceCustomization) {
+ this.allottedServiceToResourceCustomization = allottedServiceToResourceCustomization;
+ }
+
+ public ServiceToResourceCustomization getCatalogVlServiceToResourceCustomization() {
+ return vlServiceToResourceCustomization;
+ }
+
+ public void setCatalogVlServiceToResourceCustomization(
+ ServiceToResourceCustomization vlServiceToResourceCustomization) {
+ this.vlServiceToResourceCustomization = vlServiceToResourceCustomization;
+ }
+
+ public String getVolHeatTemplateUUID() {
+ return volHeatTemplateUUID;
+ }
+
+ public void setVolHeatTemplateUUID(String volHeatTemplateUUID) {
+ this.volHeatTemplateUUID = volHeatTemplateUUID;
+ }
+
+ public String getEnvHeatTemplateUUID() {
+ return envHeatTemplateUUID;
+ }
+
+ public void setEnvHeatTemplateUUID(String envHeatTemplateUUID) {
+ this.envHeatTemplateUUID = envHeatTemplateUUID;
+ }
+
+ public String getVolHeatEnvTemplateUUID() {
+ return volHeatEnvTemplateUUID;
+ }
+
+ public void setVolHeatEnvTemplateUUID(String volHeatEnvTemplateUUID) {
+ this.volHeatEnvTemplateUUID = volHeatEnvTemplateUUID;
+ }
+
+ public String getServiceVersion() {
+ return serviceVersion;
+ }
+
+ public void setServiceVersion(String serviceVersion) {
+ this.serviceVersion = serviceVersion;
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java
index d27819bb38..a93b065dbe 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java
@@ -86,6 +86,8 @@ public final class VfResourceStructure {
private Service catalogService;
+ private List<String> vfArtifactUUIDList;
+
/**
* The list of artifacts existing in this resource hashed by UUID.
*/
@@ -118,6 +120,13 @@ public final class VfResourceStructure {
case ASDCConfiguration.VF_MODULES_METADATA:
vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload());
+
+ for(IVfModuleData moduleData : vfModulesMetadataList){
+
+ }
+
+ //vfArtifactUUIDList.add(artifactinfo.getArtifactUUID());
+ //vfModulesMetadataList = distributionClient.decodeVfModuleArtifact(clientResult.getArtifactPayload());
break;
default:
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java
new file mode 100644
index 0000000000..eff3a7849b
--- /dev/null
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java
@@ -0,0 +1,1130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.asdc.installer.heat;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.Collections;
+import java.util.regex.Matcher;
+import java.util.Comparator;
+
+import org.hibernate.exception.ConstraintViolationException;
+import org.hibernate.exception.LockAcquisitionException;
+//import org.openecomp.generic.tosca.parser.model.Metadata;
+//import org.openecomp.generic.tosca.parser.model.NodeTemplate;
+import org.openecomp.sdc.api.notification.IArtifactInfo;
+import org.openecomp.sdc.api.notification.IVfModuleMetadata;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.toscaparser.api.Group;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.Property;
+import org.openecomp.sdc.toscaparser.api.elements.Metadata;
+import org.openecomp.sdc.toscaparser.api.parameters.Input;
+import org.openecomp.mso.asdc.client.ASDCConfiguration;
+import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
+import org.openecomp.mso.asdc.installer.ASDCElementInfo;
+import org.openecomp.mso.asdc.installer.BigDecimalVersion;
+import org.openecomp.mso.asdc.installer.IVfModuleData;
+import org.openecomp.mso.asdc.installer.IVfResourceInstaller;
+import org.openecomp.mso.asdc.installer.ToscaResourceStructure;
+import org.openecomp.mso.asdc.installer.VfModuleArtifact;
+import org.openecomp.mso.asdc.installer.VfModuleStructure;
+import org.openecomp.mso.asdc.installer.VfResourceStructure;
+import org.openecomp.mso.asdc.util.YamlEditor;
+import org.openecomp.mso.db.catalog.CatalogDatabase;
+import org.openecomp.mso.db.catalog.beans.AllottedResource;
+import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
+import org.openecomp.mso.db.catalog.beans.HeatFiles;
+import org.openecomp.mso.db.catalog.beans.HeatTemplate;
+import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
+import org.openecomp.mso.db.catalog.beans.NetworkResource;
+import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
+import org.openecomp.mso.db.catalog.beans.ServiceToNetworks;
+import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;
+import org.openecomp.mso.db.catalog.beans.ToscaCsar;
+import org.openecomp.mso.db.catalog.beans.VfModule;
+import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles;
+import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
+import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+public class ToscaResourceInstaller {// implements IVfResourceInstaller {
+
+ private MsoLogger logger;
+
+ private Service catalogService;
+
+ private static final Pattern lastDigit = Pattern.compile("(\\d+)$");
+
+ public ToscaResourceInstaller() {
+ logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.ASDC);
+ }
+
+ //@Override
+ public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct)
+ throws ArtifactInstallerException {
+ CatalogDatabase db = CatalogDatabase.getInstance();
+ boolean status = false;
+ VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct;
+
+ try {
+
+ String serviceUUID = vfResourceStruct.getNotification().getServiceUUID();
+
+ if (status) {
+ logger.info(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL,
+ vfResourceStructure.getResourceInstance().getResourceInstanceName(),
+ vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
+ vfResourceStructure.getNotification().getServiceName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ vfResourceStructure.getNotification().getServiceVersion()),
+ vfResourceStructure.getNotification().getServiceUUID(),
+ vfResourceStructure.getResourceInstance().getResourceName(),"", "");
+ } else {
+ logger.info(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL,
+ 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, "", "", MsoLogger.ErrorCode.SchemaError, "Exception - isResourceAlreadyDeployed");
+ throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
+ }
+ }
+
+ //@Override
+ public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
+
+ logger.debug("installTheResource is called");
+
+ VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct;
+
+ for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
+ case ASDCConfiguration.HEAT:
+ case ASDCConfiguration.HEAT_VOL:
+ case ASDCConfiguration.HEAT_NESTED:
+ ToscaResourceInstaller.createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, vfModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_ENV:
+ ToscaResourceInstaller.createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_ARTIFACT:
+ ToscaResourceInstaller.createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact, toscaResourceStruct);
+ break;
+ case ASDCConfiguration.HEAT_NET:
+ case ASDCConfiguration.OTHER:
+ logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT, vfModuleArtifact.getArtifactInfo().getArtifactType()+"(Artifact Name:"+vfModuleArtifact.getArtifactInfo().getArtifactName()+")", "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported");
+ break;
+ default:
+ break;
+
+ }
+ }
+ // Those objects could be reused by different VfModule
+
+
+
+ // PCLO: in case of deployment failure, use a string that will represent the type of artifact that failed...
+ List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
+
+ CatalogDatabase catalogDB = CatalogDatabase.getInstance();
+ // 2. Create the VFModules/VNFResource objects by linking them to the
+ // objects created before and store them in Resource/module structure
+ // Opening a DB transaction, starting from here
+ try {
+
+
+ String vfModuleModelUUID = null;
+
+ createToscaCsar(toscaResourceStruct);
+
+ catalogDB.saveToscaCsar(toscaResourceStruct.getCatalogToscaCsar());
+
+ ToscaResourceInstaller.createService(toscaResourceStruct);
+
+ catalogDB.saveService(toscaResourceStruct.getCatalogService());
+
+
+ /* VNF POPULATION
+ * ************************************************************************************************************
+ */
+
+ // Ingest (VNF) Data - 1707
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+ int outerLoop = 0;
+ logger.debug("**vfMondeTEmplatesList.size()=" + vfNodeTemplatesList.size());
+ for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+ logger.debug("nodeTemplate outerLoop=" + outerLoop++);
+ // extract VF metadata
+
+ Metadata metadata = nodeTemplate.getMetaData();
+
+ String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ logger.debug("vfCustomizationUUID=" + vfCustomizationUUID);
+
+
+ /* HEAT TABLE POPULATION
+ * *******************************************************************************************************
+ */
+
+ int nextLoop = 0;
+ for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
+ logger.debug("vfResourceStructure.getVfMOduleStructure() loop, nextLoop = " + nextLoop++);
+ logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
+
+ // Here we set the right db structure according to the Catalog
+ // DB
+
+ // We expect only one MAIN HEAT per VFMODULE
+ // we can also obtain from it the Env ArtifactInfo, that's why
+ // we
+ // get the Main IArtifactInfo
+
+ HeatTemplate heatMainTemplate = null;
+ HeatEnvironment heatEnv = null;
+
+ HeatTemplate heatVolumeTemplate = null;
+ HeatEnvironment heatVolumeEnv = null;
+
+
+ IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
+
+
+ if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT)) {
+
+ List<VfModuleArtifact> artifacts = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT);
+ logger.debug("there are " + artifacts.size() + " artifacts");
+ IArtifactInfo mainEnvArtifactInfo = null;
+ for (VfModuleArtifact vfma : artifacts) {
+ logger.debug("vmfa=" + vfma.toString());
+ mainEnvArtifactInfo =
+ vfma.getArtifactInfo().getGeneratedArtifact();
+
+ // MAIN HEAT
+ heatMainTemplate = (HeatTemplate) vfma.getCatalogObject();
+
+ // Set HeatTemplateArtifactUUID to use later when setting the VfModule and NetworkResource
+ toscaResourceStruct.setHeatTemplateUUID(heatMainTemplate.getArtifactUuid());
+
+ // Add this one for logging
+ artifactListForLogging.add(ASDCElementInfo
+ .createElementFromVfArtifactInfo(vfma.getArtifactInfo()));
+
+ catalogDB.saveHeatTemplate(heatMainTemplate, heatMainTemplate.getParameters());
+ // Indicate we have deployed it in the DB
+ vfma.incrementDeployedInDB();
+ }
+
+
+ // VOLUME HEAT
+ // We expect only one VOL HEAT per VFMODULE
+ // we can also obtain from it the Env ArtifactInfo, that's why
+ // we get the Volume IArtifactInfo
+
+ if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_VOL)) {
+ IArtifactInfo volEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0)
+ .getArtifactInfo().getGeneratedArtifact();
+
+ heatVolumeTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap()
+ .get(ASDCConfiguration.HEAT_VOL).get(0).getCatalogObject();
+
+ // Set VolHeatTemplate ArtifactUUID to use later when setting the VfModule
+ toscaResourceStruct.setVolHeatTemplateUUID(heatVolumeTemplate.getArtifactUuid());
+
+
+ // Add this one for logging
+ artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()));
+
+ catalogDB.saveHeatTemplate(heatVolumeTemplate, heatVolumeTemplate.getParameters());
+ // Indicate we have deployed it in the DB
+ vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).incrementDeployedInDB();
+
+ if (volEnvArtifactInfo != null) {
+ heatVolumeEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID()
+ .get(volEnvArtifactInfo.getArtifactUUID()).getCatalogObject();
+
+ // Set VolHeatTemplate ArtifactUUID to use later when setting the VfModule
+ toscaResourceStruct.setVolHeatEnvTemplateUUID(heatVolumeEnv.getArtifactUuid());
+
+ // Add this one for logging
+ artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(volEnvArtifactInfo));
+
+ catalogDB.saveHeatEnvironment(heatVolumeEnv);
+ // Indicate we have deployed it in the DB
+ vfResourceStructure.getArtifactsMapByUUID().get(volEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB();
+ }
+
+ }
+
+ // NESTED HEAT
+ // Here we expect many HEAT_NESTED template to be there
+ // XXX FIX BY PCLO: Defect# -36643 -US666034 - check first if we really have nested heat templates
+ if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_NESTED)) {
+ for (VfModuleArtifact heatNestedArtifact : vfModuleStructure.getArtifactsMap()
+ .get(ASDCConfiguration.HEAT_NESTED)) {
+
+ // Check if this nested is well referenced by the MAIN HEAT
+ String parentArtifactType = ToscaResourceInstaller.identifyParentOfNestedTemplate(vfModuleStructure,heatNestedArtifact);
+ HeatTemplate heatNestedTemplate = (HeatTemplate) heatNestedArtifact.getCatalogObject();
+
+ if (parentArtifactType != null) {
+
+ switch (parentArtifactType) {
+ case ASDCConfiguration.HEAT:
+
+ // Add this one for logging
+ artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
+
+ catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
+ // Indicate we have deployed it in the DB
+ heatNestedArtifact.incrementDeployedInDB();
+ break;
+ case ASDCConfiguration.HEAT_VOL:
+
+ // Add this one for logging
+ artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
+ catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
+ // Indicate we have deployed it in the DB
+ heatNestedArtifact.incrementDeployedInDB();
+ break;
+
+ default:
+ break;
+
+ }
+ } else { // Assume it belongs to HEAT MAIN
+ // Add this one for logging
+ artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
+
+ catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
+ // Indicate we have deployed it in the DB
+ heatNestedArtifact.incrementDeployedInDB();
+ }
+ }
+ }
+
+ if (mainEnvArtifactInfo != null) {
+ heatEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID()
+ .get(mainEnvArtifactInfo.getArtifactUUID()).getCatalogObject();
+
+ // Set HeatEnvironmentArtifactUUID to use later when setting the VfModule
+ toscaResourceStruct.setEnvHeatTemplateUUID(heatEnv.getArtifactUuid());
+
+ // Add this one for logging
+ artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(mainEnvArtifactInfo));
+
+ catalogDB.saveHeatEnvironment(heatEnv);
+ // Indicate we have deployed it in the DB
+ vfResourceStructure.getArtifactsMapByUUID().get(mainEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB();
+ }
+
+ // here we expect one VFModule to be there
+ //VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv);
+ //VfModule vfModule = vfModuleStructure.getCatalogVfModule();
+
+ // Add this one for logging
+ //artifactListForLogging.add(ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure));
+
+ //catalogDB.saveOrUpdateVfModule(vfModule);
+
+
+ // extract VF metadata
+ createVnfResource(nodeTemplate, toscaResourceStruct);
+
+ // check for duplicate record already in the database
+ VnfResource vnfResource = catalogDB.getVnfResource(toscaResourceStruct.getCatalogVnfResource().getModelName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ toscaResourceStruct.getCatalogVnfResource().getVersion()));
+
+ if (vnfResource != null) {
+ toscaResourceStruct.setVnfAlreadyInstalled(true);
+ }
+
+
+ if(!toscaResourceStruct.isVnfAlreadyInstalled()) {
+
+ catalogDB.saveOrUpdateVnfResource(toscaResourceStruct.getCatalogVnfResource());
+
+ }
+
+
+ boolean saveVnfCustomization = catalogDB.saveVnfResourceCustomization(toscaResourceStruct.getCatalogVnfResourceCustomization());
+
+ if(saveVnfCustomization){
+ catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogVfServiceToResourceCustomization());
+ }
+
+ List<org.openecomp.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
+ logger.debug("vfGroups:" + vfGroups.toString());
+
+ Collections.sort(vfGroups, new Comparator<org.openecomp.sdc.toscaparser.api.Group>() {
+ @Override
+ public int compare(org.openecomp.sdc.toscaparser.api.Group group1, org.openecomp.sdc.toscaparser.api.Group group2) {
+
+ //Field name1Field = group1.class.getDeclaredField("name");
+ //name1Field.setAccessible(true);
+ String thisName = group1.getName(); //(String) name1Field.get(group1);
+ String thatName = group2.getName(); // (String) name1Field.get(group2);
+
+ Matcher m = lastDigit.matcher(thisName);
+ Matcher m2 = lastDigit.matcher(thatName);
+
+ String thisDigit = "0";
+ String thatDigit = "0";
+ if (m.find()) {
+ thisDigit = m.group();
+ } else {
+ return -1;
+ }
+ if (m2.find()) {
+ thatDigit = m2.group();
+ } else {
+ return 1;
+ }
+
+ return new Integer(thisDigit).compareTo(new Integer(thatDigit));
+
+ }
+ });
+
+ logger.debug("vfGroupsAfter:" + vfGroups.toString());
+
+
+ for(Group group : vfGroups){
+
+
+ //boolean saveVFModule = createVFModule(group, nodeTemplate, toscaResourceStruct, vfMetadata);
+ if (vfMetadata.getVfModuleModelCustomizationUUID() == null) {
+ logger.debug("NULL 1");
+ } else {
+ logger.debug("vfMetadata.getMCU=" + vfMetadata.getVfModuleModelCustomizationUUID());
+ }
+ if (group.getMetadata() == null) {
+ logger.debug("NULL 3");
+ } else {
+ logger.debug("group.getMetadata().getValue() = " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"));
+ }
+ if (vfMetadata.getVfModuleModelCustomizationUUID().equals(group.getMetadata().getValue("vfModuleModelCustomizationUUID"))) {
+ logger.debug("Found a match at " + vfMetadata.getVfModuleModelCustomizationUUID());
+ createVFModule(group, nodeTemplate, toscaResourceStruct, vfResourceStructure, vfMetadata);
+
+ catalogDB.saveOrUpdateVfModule(toscaResourceStruct.getCatalogVfModule());
+
+ catalogDB.saveOrUpdateVfModuleCustomization(toscaResourceStruct.getCatalogVfModuleCustomization());
+
+ catalogDB.saveVnfResourceToVfModuleCustomization(toscaResourceStruct.getCatalogVnfResourceCustomization(), toscaResourceStruct.getCatalogVfModuleCustomization());
+
+
+ } else {
+ if(toscaResourceStruct.getCatalogVfModuleCustomization() != null){
+ logger.debug("No match for " + toscaResourceStruct.getCatalogVfModuleCustomization().getModelCustomizationUuid());
+ } else {
+ logger.debug("No match for vfModuleModelCustomizationUUID");
+ }
+ }
+
+ }
+
+ } //Commented out to process VFModules each time
+
+
+
+ // Here we expect many HEAT_TEMPLATE files to be there
+ if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_ARTIFACT)) {
+ for (VfModuleArtifact heatArtifact : vfModuleStructure.getArtifactsMap()
+ .get(ASDCConfiguration.HEAT_ARTIFACT)) {
+
+ HeatFiles heatFile = (HeatFiles) heatArtifact.getCatalogObject();
+
+ // Add this one for logging
+ artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatArtifact.getArtifactInfo()));
+
+ if(toscaResourceStruct.getCatalogVfModule() != null && heatFile != null){
+ catalogDB.saveVfModuleToHeatFiles (toscaResourceStruct.getCatalogVfModule().getModelUUID(), heatFile);
+ }
+ // Indicate we will deploy it in the DB
+ heatArtifact.incrementDeployedInDB();
+ }
+ }
+
+ }
+
+ }
+
+ /* END OF HEAT TABLE POPULATION
+ * ***************************************************************************************************
+ */
+
+
+ // throw new ArtifactInstallerException("TESTING");
+
+
+ List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
+
+ if(allottedResourceList != null){
+
+ for(NodeTemplate allottedNode : allottedResourceList){
+
+ createAllottedResource(allottedNode, toscaResourceStruct);
+
+ catalogDB.saveAllottedResource(toscaResourceStruct.getAllottedResource());
+
+ catalogDB.saveAllottedResourceCustomization(toscaResourceStruct.getCatalogAllottedResourceCustomization());
+
+ catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogAllottedServiceToResourceCustomization());
+
+ }
+ }
+
+
+ List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
+
+ if(nodeTemplatesVLList != null){
+
+ for(NodeTemplate vlNode : nodeTemplatesVLList){
+
+ String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim();
+
+ List<TempNetworkHeatTemplateLookup> networkHeatTemplateLookup = catalogDB.getTempNetworkHeatTemplateLookup(networkResourceModelName);
+
+ if(networkHeatTemplateLookup != null && networkHeatTemplateLookup.size() > 0 ){
+
+ createNetworkResource(vlNode, toscaResourceStruct, networkHeatTemplateLookup.get(0));
+
+ } else {
+ throw new ArtifactInstallerException("No NetworkResourceName found in TempNetworkHeatTemplateLookup for " + networkResourceModelName);
+ }
+
+
+ catalogDB.saveNetworkResource(toscaResourceStruct.getCatalogNetworkResource());
+
+ catalogDB.saveNetworkResourceCustomization(toscaResourceStruct.getCatalogNetworkResourceCustomization());
+
+ catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogVlServiceToResourceCustomization());
+
+ }
+ }
+
+
+ //createServiceToResourceCustomization(toscaResourceStruct.getCatalogService(), toscaResourceStruct.getCatalogVnfResourceCustomization(), toscaResourceStruct);
+
+ // catalogDB.saveToscaCsar(toscaResourceStruct.getCatalogToscaCsar());
+
+
+ catalogDB.commit();
+ vfResourceStructure.setSuccessfulDeployment();
+
+ }catch(Exception e){
+ System.out.println("Exception" + e.getMessage());
+ e.printStackTrace();
+
+ 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, vfResourceStructure.getResourceInstance().getResourceName(),
+ vfResourceStructure.getNotification().getServiceVersion(), "", "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);
+ } else {
+ String endEvent = "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.";
+ String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed");
+ logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback", e);
+ catalogDB.rollback();
+ throw new ArtifactInstallerException(
+ "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
+ }
+
+ }
+
+ }
+
+
+ public static String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure, List<String> 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 static 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;
+ }
+
+ StringBuffer sb = new StringBuffer(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();
+ }
+
+
+ private static void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,ToscaResourceStructure toscaResourceStruct,
+ VfModuleArtifact vfModuleArtifact) {
+ HeatTemplate heatTemplate = new HeatTemplate();
+
+ // TODO Set the label
+// heatTemplate.setAsdcLabel("label");
+ // Use the ResourceName of the ASDC template because the HEAT could be
+ // reused
+// heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
+ heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ List<String> typeList = new ArrayList<String>();
+ 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);
+ }
+
+ //toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ 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<HeatTemplateParam> heatParam = ToscaResourceInstaller
+ .extractHeatTemplateParameters(vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ heatTemplate.setParameters(heatParam);
+ //heatTemplate.setCreated(getCurrentTimeStamp());
+
+ vfModuleArtifact.setCatalogObject(heatTemplate);
+ }
+
+ private static void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact) {
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+
+ heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+ // TODO Set the label
+// heatEnvironment.setAsdcLabel("Label");
+
+ List<String> typeList = new ArrayList<String>();
+ typeList.add(ASDCConfiguration.HEAT);
+ typeList.add(ASDCConfiguration.HEAT_VOL);
+
+ heatEnvironment.setEnvironment(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList));
+// heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatEnvironment.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+// heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure));
+ heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
+ heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else{
+ heatEnvironment.setArtifactChecksum("MANUAL_RECORD");
+ }
+ //heatEnvironment.setCreated(getCurrentTimeStamp());
+
+ vfModuleArtifact.setCatalogObject(heatEnvironment);
+
+ }
+
+ private static void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
+
+ HeatFiles heatFile = new HeatFiles();
+ // TODO Set the label
+// heatFile.setAsdcLabel("Label");
+ 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());
+ //heatFile.setCreated(getCurrentTimeStamp());
+
+// heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
+
+
+ if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
+ heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatFile.setArtifactChecksum("MANUAL_RECORD");
+ }
+
+ vfModuleArtifact.setCatalogObject(heatFile);
+
+ }
+
+ private static void createService(ToscaResourceStructure toscaResourceStructure) {
+
+ toscaResourceStructure.getServiceMetadata();
+
+ Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
+
+ Service service = new Service();
+
+ // Service
+ if(serviceMetadata != null){
+
+ if(toscaResourceStructure.getServiceVersion() != null){
+ service.setVersion(toscaResourceStructure.getServiceVersion());
+ }
+
+ service.setServiceType(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(serviceMetadata, "serviceType"));
+ service.setServiceRole(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(serviceMetadata, "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.setVersion(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ service.setToscaCsarArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
+ //service.setCreated(getCurrentTimeStamp());
+ }
+
+ toscaResourceStructure.setCatalogService(service);
+ }
+
+ private static 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);
+ }
+
+ private static void createNetworkResource(NodeTemplate networkNodeTemplate, ToscaResourceStructure toscaResourceStructure, TempNetworkHeatTemplateLookup networkHeatTemplateLookup) {
+ NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
+
+ NetworkResource networkResource = new NetworkResource();
+
+ String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+
+ if(providerNetwork != null && providerNetwork.equalsIgnoreCase("true")){
+ networkResource.setNeutronNetworkType("PROVIDER");
+ } else {
+ networkResource.setNeutronNetworkType("BASIC");
+ }
+
+ networkResource.setModelName(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim()));
+
+ 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(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ networkResource.setAicVersionMin(networkHeatTemplateLookup.getAicVersionMin());
+ networkResource.setToscaNodeType(networkNodeTemplate.getType());
+ networkResource.setDescription(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ networkResource.setOrchestrationMode("HEAT");
+ networkResource.setHeatTemplateArtifactUUID(networkHeatTemplateLookup.getHeatTemplateArtifactUuid());
+
+ toscaResourceStructure.setCatalogNetworkResource(networkResource);
+
+ networkResourceCustomization.setModelInstanceName(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim()));
+ networkResourceCustomization.setModelCustomizationUuid(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim()));
+ networkResourceCustomization.setNetworkResourceModelUuid(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim()));
+
+
+ networkResourceCustomization.setNetworkTechnology(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)).trim());
+ networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)).trim());
+ networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)).trim());
+ networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)).trim());
+
+ toscaResourceStructure.setCatalogNetworkResourceCustomization(networkResourceCustomization);
+
+ ServiceToResourceCustomization serviceToResourceCustomization = new ServiceToResourceCustomization();
+ serviceToResourceCustomization.setServiceModelUUID(toscaResourceStructure.getCatalogService().getModelUUID());
+ serviceToResourceCustomization.setResourceModelCustomizationUUID(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim()));
+ serviceToResourceCustomization.setModelType("network");
+
+ toscaResourceStructure.setCatalogVlServiceToResourceCustomization(serviceToResourceCustomization);
+
+
+ }
+
+ private static void createVFModule(Group group, NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, IVfModuleData vfModuleData) {
+ VfModule vfModule = new VfModule();
+ boolean isBase = false;
+
+ Metadata vfMetadata = group.getMetadata();
+
+ String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
+
+
+ if(vfModuleModelUUID != null && vfModuleModelUUID.indexOf(".") > -1){
+ vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf("."));
+ }
+
+
+ for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()){
+
+ String vfModelUUID = vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID();
+
+ if(vfModelUUID != null && vfModelUUID.equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))){
+
+ List<String> artifacts = vfModuleStructure.getVfModuleMetadata().getArtifacts();
+
+ for(String artifact: artifacts){
+
+
+ for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+
+ if(artifact.equals(vfModuleArtifact.getArtifactInfo().getArtifactUUID())){
+ //if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)){
+ if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)){
+ vfModule.setHeatTemplateArtifactUUId(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ }
+
+ if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)){
+ vfModule.setVolHeatTemplateArtifactUUId(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ }
+ }
+
+ }
+
+
+ }
+
+
+ }
+
+
+ }
+
+ vfModule.setModelInvariantUuid(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
+ vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
+ vfModule.setModelUUID(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)));
+ vfModule.setVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
+ vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ //vfModule.setHeatTemplateArtifactUUId(toscaResourceStructure.getHeatTemplateUUID());
+ //vfModule.setVolHeatTemplateArtifactUUId(toscaResourceStructure.getVolHeatTemplateUUID());
+
+ vfModule.setVnfResourceModelUUId(toscaResourceStructure.getCatalogVnfResource().getModelUuid());
+
+ String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
+ if(vfModuleType != null && vfModuleType.equalsIgnoreCase("Base")){
+ vfModule.setIsBase(1);
+ }else {
+ vfModule.setIsBase(0);
+ }
+
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setModelCustomizationUuid(vfModuleData.getVfModuleModelCustomizationUUID());
+
+
+ vfModuleCustomization.setVfModuleModelUuid(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+
+ vfModuleCustomization.setHeatEnvironmentArtifactUuid(toscaResourceStructure.getEnvHeatTemplateUUID());
+
+
+ vfModuleCustomization.setVolEnvironmentArtifactUuid(toscaResourceStructure.getVolHeatEnvTemplateUUID());
+
+ 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));
+ }
+
+ toscaResourceStructure.setCatalogVfModule(vfModule);
+
+ toscaResourceStructure.setCatalogVfModuleCustomization(vfModuleCustomization);
+
+ }
+
+ private static void createVnfResourceToVfModuleCustomization(VnfResourceCustomization vnfResourceCustomization,
+ VfModuleCustomization vfModuleCustomization,
+ ToscaResourceStructure toscaResourceStructure) {
+
+ VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom = new VnfResCustomToVfModuleCustom();
+
+ vnfResCustomToVfModuleCustom.setVfModuleCustModelCustomizationUuid(vfModuleCustomization.getModelCustomizationUuid());
+ vnfResCustomToVfModuleCustom.setVnfResourceCustModelCustomizationUuid(vnfResourceCustomization.getModelCustomizationUuid());
+
+ toscaResourceStructure.setCatalogVnfResCustomToVfModuleCustom(vnfResCustomToVfModuleCustom);
+
+
+
+ }
+
+
+ private static void createTempNetworkHeatTemplateLookup(NetworkResource networkResource,
+ VfModule vfModule,
+ ToscaResourceStructure toscaResourceStructure) {
+
+ TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup();
+
+ tempNetworkHeatTemplateLookup.setNetworkResourceModelName(networkResource.getModelName());
+ tempNetworkHeatTemplateLookup.setHeatTemplateArtifactUuid(vfModule.getHeatTemplateArtifactUUId());
+ tempNetworkHeatTemplateLookup.setAicVersionMin("1");
+
+ toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(tempNetworkHeatTemplateLookup);
+
+
+
+ }
+
+ private static void createVnfResource(NodeTemplate vfNodeTemplate, ToscaResourceStructure toscaResourceStructure) {
+ VnfResource vnfResource = new VnfResource();
+
+
+ //toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)
+
+ vnfResource.setModelInvariantUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim()));
+ vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim()));
+ vnfResource.setModelUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim()));
+
+ vnfResource.setVersion(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim()));
+ vnfResource.setDescription(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION).trim()));
+ vnfResource.setOrchestrationMode("HEAT");
+ vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
+ vnfResource.setAicVersionMax(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES).trim()));
+ vnfResource.setAicVersionMin(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES).trim()));
+ //vnfResource.setHeatTemplateArtifactUUId(toscaResourceStructure.getHeatTemplateUUID());
+
+ // vfNodeTemplate.getProperties()
+ toscaResourceStructure.setCatalogVnfResource(vnfResource);
+
+ VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
+ vnfResourceCustomization.setModelCustomizationUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim()));
+ vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
+
+ vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)).trim());
+ vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFCODE)).trim());
+ vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)).trim());
+ vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)).trim());
+
+
+ vnfResourceCustomization.setVnfResourceModelUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim()));
+ vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT).trim()));
+
+ vnfResourceCustomization.setMaxInstances(Integer.getInteger(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES).trim()));
+ vnfResourceCustomization.setMinInstances(Integer.getInteger(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES).trim()));
+
+
+
+ toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
+
+
+ ServiceToResourceCustomization serviceToResourceCustomization = new ServiceToResourceCustomization();
+ serviceToResourceCustomization.setServiceModelUUID(toscaResourceStructure.getCatalogService().getModelUUID());
+ serviceToResourceCustomization.setResourceModelCustomizationUUID(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim());
+ serviceToResourceCustomization.setModelType("vnf");
+
+ toscaResourceStructure.setCatalogVfServiceToResourceCustomization(serviceToResourceCustomization);
+
+
+ }
+
+ private static void createAllottedResource(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
+ AllottedResource allottedResource = new AllottedResource();
+
+ allottedResource.setModelUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim()));
+ allottedResource.setModelInvariantUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim()));
+ allottedResource.setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim()));
+ allottedResource.setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim()));
+ allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
+
+ toscaResourceStructure.setAllottedResource(allottedResource);
+
+ AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
+ allottedResourceCustomization.setModelCustomizationUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim()));
+ allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
+ allottedResourceCustomization.setArModelUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim()));
+
+ allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)).trim());
+ allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFCODE)).trim());
+ allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)).trim());
+ allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)).trim());
+
+ toscaResourceStructure.setCatalogAllottedResourceCustomization(allottedResourceCustomization);
+
+ ServiceToResourceCustomization serviceToResourceCustomization = new ServiceToResourceCustomization();
+ serviceToResourceCustomization.setServiceModelUUID(toscaResourceStructure.getCatalogService().getModelUUID());
+ serviceToResourceCustomization.setResourceModelCustomizationUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim()));
+ serviceToResourceCustomization.setModelType("allottedResource");
+
+ toscaResourceStructure.setCatalogAllottedServiceToResourceCustomization(serviceToResourceCustomization);
+
+ }
+
+ private static Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
+
+ // Scan the payload downloadResult and extract the HeatTemplate
+ // parameters
+ YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
+ return yamlEditor.getParameterList(artifactUUID);
+
+ }
+
+ private 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;
+
+ }
+
+ private static String testNull(Object object) {
+ if (object == null) {
+ return "";
+ } 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";
+ }
+ }
+
+ private static String createVNFName(VfResourceStructure vfResourceStructure) {
+
+ return vfResourceStructure.getNotification().getServiceName() + "/" + vfResourceStructure.getResourceInstance().getResourceInstanceName();
+ }
+
+ private static String createVfModuleName(VfModuleStructure vfModuleStructure) {
+
+ return createVNFName(vfModuleStructure.getParentVfResource())+"::"+vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
+ }
+
+
+ private static Timestamp getCurrentTimeStamp() {
+
+ return new Timestamp(new Date().getTime());
+ }
+
+} \ No newline at end of file
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java
index 5f28cb48f2..63f5e3f04b 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java
@@ -72,7 +72,7 @@ public class VfResourceInstaller implements IVfResourceInstaller {
boolean status = false;
VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct;
- try(CatalogDatabase db = new CatalogDatabase()) {
+ try(CatalogDatabase db = CatalogDatabase.getInstance()) {
String resourceType = vfResourceStruct.getResourceInstance().getResourceType();
String category = vfResourceStruct.getResourceInstance().getCategory();
@@ -209,7 +209,7 @@ public class VfResourceInstaller implements IVfResourceInstaller {
// in case of deployment failure, use a string that will represent the type of artifact that failed...
List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
- CatalogDatabase catalogDB = new CatalogDatabase();
+ CatalogDatabase catalogDB = CatalogDatabase.getInstance();
// 2. Create the VFModules/VNFResource objects by linking them to the
// objects created before and store them in Resource/module structure
// Opening a DB transaction, starting from here
@@ -337,7 +337,7 @@ public class VfResourceInstaller implements IVfResourceInstaller {
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
- catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
+ catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
// Indicate we have deployed it in the DB
heatNestedArtifact.incrementDeployedInDB();
break;
@@ -345,7 +345,7 @@ public class VfResourceInstaller implements IVfResourceInstaller {
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
- catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
+ catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
// Indicate we have deployed it in the DB
heatNestedArtifact.incrementDeployedInDB();
break;
@@ -358,7 +358,7 @@ public class VfResourceInstaller implements IVfResourceInstaller {
// Add this one for logging
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
- catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
+ catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
// Indicate we have deployed it in the DB
heatNestedArtifact.incrementDeployedInDB();
}
@@ -381,7 +381,7 @@ public class VfResourceInstaller implements IVfResourceInstaller {
// here we expect one VFModule to be there
- VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv);
+/* VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv);
VfModule vfModule = vfModuleStructure.getCatalogVfModule();
// Add this one for logging
@@ -400,11 +400,11 @@ public class VfResourceInstaller implements IVfResourceInstaller {
artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatArtifact.getArtifactInfo()));
- catalogDB.saveVfModuleToHeatFiles (vfModule.getId(), heatFile);
+ catalogDB.saveVfModuleToHeatFiles (vfModule.getArtifactUuid(), heatFile);
// Indicate we will deploy it in the DB
heatArtifact.incrementDeployedInDB();
}
- }
+ } */
}
@@ -470,22 +470,24 @@ public class VfResourceInstaller implements IVfResourceInstaller {
private static void createVnfResource(VfResourceStructure vfResourceStructure) {
VnfResource vnfResource = new VnfResource();
- vnfResource.setAsdcUuid(vfResourceStructure.getResourceInstance().getResourceUUID());
+ vnfResource.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID());
vnfResource.setDescription(vfResourceStructure.getNotification().getServiceDescription());
vnfResource.setOrchestrationMode("HEAT");
// Set the version but Version is stored into ASDC_SERVICE_MODEL_VERSION
vnfResource.setVersion(BigDecimalVersion
.castAndCheckNotificationVersionToString(vfResourceStructure.getNotification().getServiceVersion()));
- vnfResource.setVnfType(VfResourceInstaller.createVNFName(vfResourceStructure));
+// vnfResource.setVnfType(VfResourceInstaller.createVNFName(vfResourceStructure));
vnfResource.setModelVersion(BigDecimalVersion
.castAndCheckNotificationVersionToString(vfResourceStructure.getResourceInstance().getResourceVersion()));
vnfResource.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID());
- vnfResource.setModelCustomizationName(vfResourceStructure.getResourceInstance().getResourceInstanceName());
- vnfResource.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID());
+ vnfResource.setModelVersion(vfResourceStructure.getResourceInstance().getResourceVersion());
+// vnfResource.setModelCustomizationName(vfResourceStructure.getResourceInstance().getResourceInstanceName());
+// vnfResource.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID());
vnfResource.setModelName(vfResourceStructure.getResourceInstance().getResourceName());
- vnfResource.setServiceModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID());
+// vnfResource.setServiceModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID());
+
//vnfResource.setCreated(getCurrentTimeStamp());
vfResourceStructure.setCatalogVnfResource(vnfResource);
@@ -495,11 +497,11 @@ public class VfResourceInstaller implements IVfResourceInstaller {
NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
networkResourceCustomization.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID().trim());
- networkResourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim());
+// networkResourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim());
networkResourceCustomization.setModelInstanceName(vfResourceStructure.getResourceInstance().getResourceInstanceName().trim());
- networkResourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim());
- networkResourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim());
- networkResourceCustomization.setModelVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim());
+// networkResourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim());
+// networkResourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim());
+// networkResourceCustomization.setModelVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim());
//networkResourceCustomization.setCreated(getCurrentTimeStamp());
vfResourceStructure.setCatalogNetworkResourceCustomization(networkResourceCustomization);
@@ -516,10 +518,10 @@ public class VfResourceInstaller implements IVfResourceInstaller {
AllottedResourceCustomization resourceCustomization = new AllottedResourceCustomization();
resourceCustomization.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID().trim());
- resourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim());
+// resourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim());
resourceCustomization.setModelInstanceName(vfResourceStructure.getResourceInstance().getResourceInstanceName().trim());
- resourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim());
- resourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim());
+// resourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim());
+// resourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim());
resourceCustomization.setVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim());
//resourceCustomization.setCreated(getCurrentTimeStamp());
@@ -535,8 +537,8 @@ public class VfResourceInstaller implements IVfResourceInstaller {
private static void createVfModule(VfModuleStructure vfModuleStructure,HeatTemplate heatMain, HeatTemplate heatVolume,HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) {
VfModule vfModule = new VfModule();
- vfModule.setType(createVfModuleName(vfModuleStructure));
- vfModule.setAsdcUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID());
+// vfModule.setType(createVfModuleName(vfModuleStructure));
+// vfModule.setAsdcUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID());
vfModule.setDescription(vfModuleStructure.getVfModuleMetadata().getVfModuleModelDescription());
if (vfModuleStructure.getVfModuleMetadata().isBase()) {
@@ -545,7 +547,7 @@ public class VfResourceInstaller implements IVfResourceInstaller {
vfModule.setIsBase(0);
}
- vfModule.setModelCustomizationUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelCustomizationUUID());
+// vfModule.setModelCustomizationUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelCustomizationUUID());
vfModule.setModelInvariantUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelInvariantUUID());
vfModule.setModelName(vfModuleStructure.getVfModuleMetadata().getVfModuleModelName());
@@ -558,16 +560,16 @@ public class VfResourceInstaller implements IVfResourceInstaller {
if(map != null){
if(map.get("vf_module_label") != null){
- vfModule.setLabel(map.get("vf_module_label"));
+// vfModule.setLabel(map.get("vf_module_label"));
}
if(map.get("initial_count") != null && map.get("initial_count").length() > 0){
- vfModule.setInitialCount(Integer.parseInt(map.get("initial_count")));
+// vfModule.setInitialCount(Integer.parseInt(map.get("initial_count")));
}
if(map.get("min_vf_module_instances") != null && map.get("min_vf_module_instances").length() > 0){
- vfModule.setMinInstances(Integer.parseInt(map.get("min_vf_module_instances")));
+// vfModule.setMinInstances(Integer.parseInt(map.get("min_vf_module_instances")));
}
if(map.get("max_vf_module_instances") != null && map.get("max_vf_module_instances").length() > 0){
- vfModule.setMaxInstances(Integer.parseInt(map.get("max_vf_module_instances")));
+// vfModule.setMaxInstances(Integer.parseInt(map.get("max_vf_module_instances")));
}
}
@@ -581,28 +583,29 @@ public class VfResourceInstaller implements IVfResourceInstaller {
HeatTemplate heatVolume, HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) {
if (heatMain !=null) {
- vfModule.setTemplateId(heatMain.getId());
+// vfModule.setTemplateId(heatMain.getId());
}
if (heatEnv != null) {
- vfModule.setEnvironmentId(heatEnv.getId());
+// vfModule.setEnvironmentId(heatEnv.getId());
}
if (heatVolume != null) {
- vfModule.setVolTemplateId(heatVolume.getId());
+// vfModule.setVolTemplateId(heatVolume.getId());
}
if (heatVolumeEnv != null) {
- vfModule.setVolEnvironmentId(heatVolumeEnv.getId());
+// vfModule.setVolEnvironmentId(heatVolumeEnv.getId());
}
- vfModule.setVnfResourceId(vnfResource.getId());
+// vfModule.setVnfResourceId(vnfResource.getId());
}
- private static Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile) {
+
+ private static Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
// Scan the payload downloadResult and extract the HeatTemplate
// parameters
YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
- return yamlEditor.getParameterList();
+ return yamlEditor.getParameterList(artifactUUID);
}
@@ -658,10 +661,10 @@ public class VfResourceInstaller implements IVfResourceInstaller {
HeatTemplate heatTemplate = new HeatTemplate();
// TODO Set the label
- heatTemplate.setAsdcLabel("label");
+// heatTemplate.setAsdcLabel("label");
// Use the ResourceName of the ASDC template because the HEAT could be
// reused
- heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
+// heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
List<String> typeList = new ArrayList<String>();
@@ -680,6 +683,7 @@ public class VfResourceInstaller implements IVfResourceInstaller {
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());
@@ -688,8 +692,9 @@ public class VfResourceInstaller implements IVfResourceInstaller {
}
Set<HeatTemplateParam> heatParam = VfResourceInstaller
- .extractHeatTemplateParameters(vfModuleArtifact.getResult());
+ .extractHeatTemplateParameters(vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
heatTemplate.setParameters(heatParam);
+ //heatTemplate.setCreated(getCurrentTimeStamp());
vfModuleArtifact.setCatalogObject(heatTemplate);
}
@@ -700,24 +705,26 @@ public class VfResourceInstaller implements IVfResourceInstaller {
heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
// TODO Set the label
- heatEnvironment.setAsdcLabel("Label");
+// heatEnvironment.setAsdcLabel("Label");
List<String> typeList = new ArrayList<String>();
typeList.add(ASDCConfiguration.HEAT);
typeList.add(ASDCConfiguration.HEAT_VOL);
heatEnvironment.setEnvironment(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList));
- heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+// heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
heatEnvironment.setVersion(BigDecimalVersion
.castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure));
+// heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure));
+ heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
} else{
heatEnvironment.setArtifactChecksum("MANUAL_RECORD");
}
+ //heatEnvironment.setCreated(getCurrentTimeStamp());
vfModuleArtifact.setCatalogObject(heatEnvironment);
@@ -728,15 +735,16 @@ public class VfResourceInstaller implements IVfResourceInstaller {
HeatFiles heatFile = new HeatFiles();
// TODO Set the label
- heatFile.setAsdcLabel("Label");
+// heatFile.setAsdcLabel("Label");
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()));
+ //heatFile.setCreated(getCurrentTimeStamp());
- heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
+// heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
@@ -752,10 +760,11 @@ public class VfResourceInstaller implements IVfResourceInstaller {
Service service = new Service();
service.setDescription(vfResourceStructure.getNotification().getServiceDescription());
- service.setServiceName(vfResourceStructure.getNotification().getServiceName());
- service.setServiceNameVersionId(vfResourceStructure.getNotification().getServiceUUID());
+ service.setModelName(vfResourceStructure.getNotification().getServiceName());
+ service.setModelUUID(vfResourceStructure.getNotification().getServiceUUID());
service.setVersion(vfResourceStructure.getNotification().getServiceVersion());
service.setModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID());
+ //service.setCreated(getCurrentTimeStamp());
vfResourceStructure.setCatalogService(service);
}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java
index a355f0547a..085d761c0a 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java
@@ -27,8 +27,13 @@ import java.util.Map;
import org.openecomp.sdc.api.notification.IArtifactInfo;
import org.openecomp.sdc.api.notification.INotificationData;
import org.openecomp.sdc.api.notification.IResourceInstance;
-
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.openecomp.sdc.toscaparser.api.Group;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.elements.Metadata;
import org.openecomp.mso.asdc.installer.IVfModuleData;
+import org.openecomp.mso.asdc.installer.ToscaResourceStructure;
public class ASDCNotificationLogging {
@@ -84,6 +89,198 @@ public class ASDCNotificationLogging {
return buffer.toString();
}
+ public static String dumpCSARNotification(INotificationData asdcNotification, ToscaResourceStructure toscaResourceStructure) {
+
+ if (asdcNotification == null) {
+ return "NULL";
+ }
+
+
+ StringBuffer buffer = new StringBuffer("CSAR Notification:");
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+
+
+ ISdcCsarHelper csarHelper = toscaResourceStructure.getSdcCsarHelper();
+
+
+ buffer.append("Service Level Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("Name:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Version:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model InvariantUuid:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("VNF Level Properties:");
+ buffer.append(System.lineSeparator());
+
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStructure.getSdcCsarHelper().getServiceVfList();
+ for (NodeTemplate vfNodeTemplate : vfNodeTemplatesList) {
+
+ buffer.append("Model Name:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Type:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Max Instances:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Min Instances:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES).trim()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append(System.lineSeparator());
+ buffer.append("VNF Customization Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Customization UUID:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFFunction:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFCode:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NFCODE).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFRole:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NFROLE).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFType:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NFTYPE).trim()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append(System.lineSeparator());
+ buffer.append("VF Module Properties:");
+ buffer.append(System.lineSeparator());
+ List<Group> vfGroups = toscaResourceStructure.getSdcCsarHelper().getVfModulesByVf(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim()));
+
+ for(Group group : vfGroups){
+
+ Metadata vfMetadata = group.getMetadata();
+
+ buffer.append("ModelInvariantUuid:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelName:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelUuid:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelVersion:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION).trim()));
+ buffer.append(System.lineSeparator());
+ }
+
+ }
+
+
+ List<NodeTemplate> nodeTemplatesVLList = toscaResourceStructure.getSdcCsarHelper().getServiceVlList();
+
+ if(nodeTemplatesVLList != null){
+
+ buffer.append(System.lineSeparator());
+ buffer.append("NETWORK Level Properties:");
+ buffer.append(System.lineSeparator());
+
+ for(NodeTemplate vlNode : nodeTemplatesVLList){
+
+ buffer.append("Model Name:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model InvariantUuid:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Version:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("AIC Max Version:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("AIC Min Version:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Tosca Node Type:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION).trim()));
+ buffer.append(System.lineSeparator());
+
+ }
+
+ }
+
+ List<NodeTemplate> allottedResourceList = toscaResourceStructure.getSdcCsarHelper().getAllottedResources();
+
+ if(allottedResourceList != null){
+
+ buffer.append(System.lineSeparator());
+ buffer.append("Allotted Resource Properties:");
+ buffer.append(System.lineSeparator());
+
+ for(NodeTemplate allottedNode : allottedResourceList){
+
+ buffer.append("Model Name:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Name:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model InvariantUuid:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Version:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim()));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim()));
+ buffer.append(System.lineSeparator());
+
+
+ buffer.append("Allotted Resource Customization Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Cutomization UUID:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim()));
+ buffer.append(System.lineSeparator());
+
+
+ }
+ }
+
+
+ return buffer.toString();
+ }
+
public static String dumpVfModuleMetaDataList(List<IVfModuleData> moduleMetaDataList) {
if (moduleMetaDataList == null ) {
return null;
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java
index 773ff86444..f7a0916f3b 100644
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java
+++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java
@@ -96,7 +96,7 @@ public class YamlEditor {
// Based on the email from Ella Kvetny:
// Within Heat Template, under parameters catalog, it might indicate the default value of the parameter
// If default value exist, the parameter is not mandatory, otherwise its value should be set
- public synchronized Set <HeatTemplateParam> getParameterList () {
+ public synchronized Set <HeatTemplateParam> getParameterList (String artifactUUID) {
Set <HeatTemplateParam> paramSet = new HashSet <HeatTemplateParam> ();
@SuppressWarnings("unchecked")
Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters");
@@ -118,6 +118,8 @@ public class YamlEditor {
// Now set the type
String value = resourceEntry.get ("type");
param.setParamType (value);
+
+ param.setHeatTemplateArtifactUuid(artifactUUID);
paramSet.add (param);