X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=asdc-controller%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fso%2Fasdc%2Fclient%2FASDCController.java;h=ca1d0331fde8d261f1cb99328a2830c09e573751;hb=fe91155454a27401e8c23780fa247c0ede196747;hp=7ead6cbb7fb2cb11d278b8dcc0b0a9ea8d3a8a07;hpb=35d4ded98df1d5603c173118fa648bc38967825a;p=so.git diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 7ead6cbb7f..ca1d0331fd 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -26,7 +26,7 @@ import java.io.File; 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; @@ -46,7 +46,6 @@ import org.onap.so.asdc.client.exceptions.ASDCParametersException; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.asdc.installer.IVfResourceInstaller; import org.onap.so.asdc.installer.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; @@ -56,7 +55,7 @@ import org.onap.so.asdc.util.ASDCNotificationLogging; 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; @@ -66,7 +65,7 @@ public class ASDCController { protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC,ASDCController.class); - protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + protected boolean isAsdcClientAutoManaged = false; @@ -357,7 +356,7 @@ public class ASDCController { + 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(); @@ -596,7 +595,7 @@ public class ASDCController { 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); } @@ -628,7 +627,7 @@ public class ASDCController { 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()); @@ -660,7 +659,7 @@ public class ASDCController { 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()); } @@ -682,35 +681,20 @@ public class ASDCController { 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); @@ -721,11 +705,14 @@ public class ASDCController { 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()))); @@ -733,20 +720,37 @@ public class ASDCController { 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);