diff options
author | 2017-09-08 13:27:46 -0400 | |
---|---|---|
committer | 2017-09-08 13:32:24 -0400 | |
commit | 62cd6aaaf74aa91ee0037c0e155c8e7284f07567 (patch) | |
tree | 68c0c53c9156f5aa3c6b3599ac940770f986633d /asdc-controller/src/main/java/org/openecomp/mso/asdc/client | |
parent | fa1a211d28a912892fcd888569df033900eb01ee (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/org/openecomp/mso/asdc/client')
-rw-r--r-- | asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java | 14 | ||||
-rw-r--r-- | asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java | 108 |
2 files changed, 113 insertions, 9 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";
/**
|