use of org.onap.sdc.utils.DistributionStatusEnum in project so by onap.
the class ASDCController method processResourceNotification.
protected void processResourceNotification(INotificationData iNotif) {
// For each artifact, create a structure describing the VFModule in a ordered flat level
ResourceStructure resourceStructure = null;
String msoConfigPath = getMsoConfigPath();
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(msoConfigPath);
DistributionStatusEnum deployStatus = DistributionStatusEnum.DEPLOY_OK;
String errorMessage = null;
boolean serviceDeployed = false;
try {
this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
if (isCsarAlreadyDeployed(iNotif, toscaResourceStructure)) {
return;
}
// process NsstResource
this.processNsstNotification(iNotif, toscaResourceStructure);
if (iNotif.getResources().isEmpty()) {
logger.error("Service Model contains no resources.");
return;
}
for (IResourceInstance resource : iNotif.getResources()) {
String resourceType = resource.getResourceType();
boolean hasVFResource = false;
logger.info("Processing Resource Type: {}, Model UUID: {}", resourceType, resource.getResourceUUID());
resourceStructure = getResourceStructure(iNotif, resource, resourceType);
try {
if (!this.checkResourceAlreadyDeployed(resourceStructure, serviceDeployed)) {
logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: " + resourceStructure.getResourceInstance().getResourceUUID());
if ("VF".equals(resourceType)) {
hasVFResource = true;
for (IArtifactInfo artifact : resource.getArtifacts()) {
IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact, iNotif.getDistributionID());
if (resultArtifact == null) {
continue;
}
if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) {
logger.debug("VF_MODULE_ARTIFACT: " + new String(resultArtifact.getArtifactPayload(), StandardCharsets.UTF_8));
logger.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(((VfResourceStructure) resourceStructure).decodeVfModuleArtifact(resultArtifact.getArtifactPayload())));
}
if (!ASDCConfiguration.WORKFLOW.equals(artifact.getArtifactType())) {
resourceStructure.addArtifactToStructure(distributionClient, artifact, resultArtifact);
} else {
writeArtifactToFile(artifact, resultArtifact);
logger.debug("Adding workflow artifact to structure: " + artifact.getArtifactName());
resourceStructure.addWorkflowArtifactToStructure(artifact, resultArtifact);
}
}
// Deploy VF resource and artifacts
logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID());
this.deployResourceStructure(resourceStructure, toscaResourceStructure);
serviceDeployed = true;
}
}
} catch (ArtifactInstallerException e) {
deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
errorMessage = e.getMessage();
logger.error("Exception occurred", e);
}
if (!hasVFResource) {
logger.debug("No resources found for Service: " + iNotif.getServiceUUID());
logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID());
try {
this.deployResourceStructure(resourceStructure, toscaResourceStructure);
serviceDeployed = true;
} catch (ArtifactInstallerException e) {
deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
errorMessage = e.getMessage();
logger.error("Exception occurred", e);
}
}
}
this.sendCsarDeployNotification(resourceStructure, toscaResourceStructure, deployStatus, errorMessage);
} catch (ASDCDownloadException | UnsupportedEncodingException e) {
logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(), "Exception caught during Installation of artifact", "ASDC", "processResourceNotification", ErrorCode.BusinessProcessError.getValue(), "Exception in processResourceNotification", e);
}
}
use of org.onap.sdc.utils.DistributionStatusEnum in project so by onap.
the class ASDCController method isCsarAlreadyDeployed.
protected boolean isCsarAlreadyDeployed(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
VfResourceStructure resourceStructure = null;
String errorMessage = "";
boolean csarAlreadyDeployed = false;
DistributionStatusEnum deployStatus = DistributionStatusEnum.DEPLOY_OK;
WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(iNotif.getDistributionID(), MSO);
try {
csarAlreadyDeployed = toscaInstaller.isCsarAlreadyDeployed(toscaResourceStructure);
if (csarAlreadyDeployed) {
deployStatus = DistributionStatusEnum.ALREADY_DEPLOYED;
resourceStructure = new VfResourceStructure(iNotif, null);
errorMessage = String.format("Csar with UUID: %s already exists", toscaResourceStructure.getToscaArtifact().getArtifactUUID());
wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
watchdogCDStatusRepository.saveAndFlush(wdStatus);
logger.error(errorMessage);
}
} catch (ArtifactInstallerException e) {
deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
resourceStructure = new VfResourceStructure(iNotif, null);
errorMessage = e.getMessage();
wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
watchdogCDStatusRepository.saveAndFlush(wdStatus);
logger.warn("Tosca Checksums don't match, Tosca validation check failed", e);
}
if (deployStatus != DistributionStatusEnum.DEPLOY_OK) {
notifyErrorToAsdc(iNotif, toscaResourceStructure, deployStatus, resourceStructure, errorMessage);
}
return csarAlreadyDeployed;
}
Aggregations