import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
+import java.nio.file.Paths;
import java.util.List;
import org.onap.sdc.api.IDistributionClient;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.asdc.installer.IVfResourceInstaller;
import org.onap.so.asdc.installer.ToscaResourceStructure;
-import org.onap.so.asdc.installer.VfModuleStructure;
import org.onap.so.asdc.installer.VfResourceStructure;
import org.onap.so.asdc.installer.bpmn.BpmnInstaller;
import org.onap.so.asdc.installer.heat.ToscaResourceInstaller;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
import org.onap.so.logger.MessageEnum;
-import org.onap.so.logger.MsoAlarmLogger;
+
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC,ASDCController.class);
- protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+
protected boolean isAsdcClientAutoManaged = false;
+ artifact.getArtifactUUID ()
+ ")");
- String filePath = System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactVersion() + "/" + artifact.getArtifactName();
+ String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize().toString();
// make parent directory
File file = new File(filePath);
File fileParent = file.getParentFile();
distributionStatus = wd.getOverallDistributionStatus(iNotif.getDistributionID());
Thread.sleep(watchDogTimeout / 10);
}catch(Exception e){
- LOGGER.debug ("Exception in Watchdog Loop " + e.getMessage());
+ LOGGER.debug ("Exception in Watchdog Loop " + e);
Thread.sleep(watchDogTimeout / 10);
}
LOGGER.debug ("A&AI Updated succefully with Distribution Status!");
}
catch(Exception e) {
- LOGGER.debug ("Exception in Watchdog executePatchAAI(): " + e.getMessage());
+ LOGGER.debug ("Exception in Watchdog executePatchAAI(): " + e);
watchdogError = "Error calling A&AI " + e.getMessage();
if(e.getCause() != null) {
LOGGER.debug ("Exception caused by: " + e.getCause().getMessage());
LOGGER.debug ("A&AI Updated succefully with Distribution Status of " + DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name());
}
catch(Exception aaiException) {
- LOGGER.debug ("Exception in executePatchAAI(): " + aaiException.getMessage());
+ LOGGER.debug ("Exception in executePatchAAI(): " + aaiException);
if(aaiException.getCause() != null) {
LOGGER.debug ("Exception caused by: " + aaiException.getCause().getMessage());
}
VfResourceStructure resourceStructure = null;
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
boolean deploySuccessful = true;
+ boolean hasVFResource = false;
String errorMessage = null;
try {
this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
-
- if (toscaResourceStructure.getServiceVersion() == null) {
- LOGGER.debug("Deploy the workflow");
- IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact();
- String csarFilePath = System.getProperty("mso.config.path") + "/ASDC" + "/" + iArtifact.getArtifactName();
+ IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact();
+ String filePath = System.getProperty("mso.config.path") + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact.getArtifactName();
+ File csarFile = new File(filePath);
+ String csarFilePath = csarFile.getAbsolutePath();
+ if (bpmnInstaller.containsWorkflows(csarFilePath)) {
bpmnInstaller.installBpmn(csarFilePath);
- }
-
- // Install a service with no resources, only the service itself
- if (iNotif.getResources() == null || iNotif.getResources().size() < 1) {
-
- LOGGER.debug("No resources found for Service: " + iNotif.getServiceUUID());
-
- try{
- resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance());
-
- this.deployResourceStructure(resourceStructure, toscaResourceStructure);
-
- } catch(ArtifactInstallerException e){
- deploySuccessful = false;
- errorMessage = e.getMessage();
- }
- } else { // Services with resources
-
+ }
+
for (IResourceInstance resource : iNotif.getResources()){
resourceStructure = new VfResourceStructure(iNotif,resource);
LOGGER.debug("Processing Resource Type: " + resourceType + " and Model UUID: " + resourceStructure.getResourceInstance().getResourceUUID());
if("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)){
+
+ hasVFResource = true;
for (IArtifactInfo artifact : resource.getArtifacts()) {
IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,
iNotif.getDistributionID());
if (resultArtifact != null) {
+
if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) {
LOGGER.debug("VF_MODULE_ARTIFACT: "+new String(resultArtifact.getArtifactPayload(),"UTF-8"));
LOGGER.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(resourceStructure.decodeVfModuleArtifact(resultArtifact.getArtifactPayload())));
resourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact);
}
}
+
+ //Deploy VF resource and artifacts
+ LOGGER.debug("Preparing to deploy Service: " + iNotif.getServiceUUID());
+ try{
+
+ this.deployResourceStructure(resourceStructure, toscaResourceStructure);
+
+ } catch(ArtifactInstallerException e){
+ deploySuccessful = false;
+ errorMessage = e.getMessage();
+ LOGGER.error(e);
+ }
}
+
+ }
+
+ // There are cases where the Service has no VF resources, those are handled here
+ if (!hasVFResource) {
+
+ LOGGER.debug("No resources found for Service: " + iNotif.getServiceUUID());
- //Deploy All resources and artifacts
- LOGGER.debug("Preparing to deploy Service: " + iNotif.getServiceUUID());
- try{
-
+ try{
+ resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance());
+
this.deployResourceStructure(resourceStructure, toscaResourceStructure);
} catch(ArtifactInstallerException e){
deploySuccessful = false;
errorMessage = e.getMessage();
- }
-
- }
+ LOGGER.error(e);
+ }
}
this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful, errorMessage);