use of org.onap.so.asdc.client.exceptions.ArtifactInstallerException in project so by onap.
the class ToscaResourceInstaller method isResourceAlreadyDeployed.
public boolean isResourceAlreadyDeployed(ResourceStructure vfResourceStruct, boolean serviceDeployed) throws ArtifactInstallerException {
boolean status = false;
ResourceStructure vfResourceStructure = vfResourceStruct;
try {
status = vfResourceStructure.isDeployedSuccessfully();
} catch (RuntimeException e) {
status = false;
logger.debug("Exception :", e);
}
try {
Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
if (existingService != null && !serviceDeployed)
status = true;
if (status) {
logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(), vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), vfResourceStructure.getNotification().getServiceName(), BigDecimalVersion.castAndCheckNotificationVersionToString(vfResourceStructure.getNotification().getServiceVersion()), vfResourceStructure.getNotification().getServiceUUID(), vfResourceStructure.getResourceInstance().getResourceName(), "", "");
WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
watchdogCDStatusRepository.saveAndFlush(wdStatus);
} else {
logger.info(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(LoggingAnchor.THREE, MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(), "Exception - isResourceAlreadyDeployed");
throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
}
}
use of org.onap.so.asdc.client.exceptions.ArtifactInstallerException in project so by onap.
the class ToscaResourceInstaller method installTheComponentStatus.
public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}", iStatus.getDistributionID(), iStatus.getComponentName());
try {
WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(), iStatus.getComponentName());
cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
watchdogCDStatusRepository.save(cdStatus);
} catch (Exception e) {
logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
}
}
use of org.onap.so.asdc.client.exceptions.ArtifactInstallerException in project so by onap.
the class ToscaResourceInstaller method isCsarAlreadyDeployed.
public boolean isCsarAlreadyDeployed(ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
boolean deployed = false;
if (toscaResourceStructure == null) {
return deployed;
}
IArtifactInfo inputToscaCsar = toscaResourceStructure.getToscaArtifact();
String checkSum = inputToscaCsar.getArtifactChecksum();
String artifactUuid = inputToscaCsar.getArtifactUUID();
Optional<ToscaCsar> toscaCsarObj = toscaCsarRepo.findById(artifactUuid);
if (toscaCsarObj.isPresent()) {
ToscaCsar toscaCsar = toscaCsarObj.get();
if (!toscaCsar.getArtifactChecksum().equalsIgnoreCase(checkSum)) {
String errorMessage = String.format("Csar with UUID: %s already exists.Their checksums don't match", artifactUuid);
throw new ArtifactInstallerException(errorMessage);
} else if (toscaCsar.getArtifactChecksum().equalsIgnoreCase(checkSum)) {
deployed = true;
}
}
return deployed;
}
use of org.onap.so.asdc.client.exceptions.ArtifactInstallerException in project so by onap.
the class ASDCStatusCallBack method activateCallback.
@Override
public void activateCallback(IStatusData iStatus) {
String event = "Receive a callback componentStatus in ASDC, for componentName: " + iStatus.getComponentName() + " and status of " + iStatus.getStatus() + " distributionID of " + iStatus.getDistributionID();
try {
if (iStatus.getStatus() == null) {
logger.info("Missing status on Status Object. ");
return;
}
if (!iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK) && !iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) {
logger.info("Status is not 'Component Done OK' or 'Component Done Error'");
return;
}
WatchdogDistributionStatus watchdogDistributionStatus = watchdogDistributionStatusRepository.findById(iStatus.getDistributionID()).orElseGet(() -> null);
if (watchdogDistributionStatus == null) {
watchdogDistributionStatus = new WatchdogDistributionStatus();
watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID());
watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
}
logger.debug(event);
toscaInstaller.installTheComponentStatus(iStatus);
} catch (ArtifactInstallerException e) {
logger.error("Error in ASDCStatusCallback {}", e.getMessage(), e);
logger.debug("Error in ASDCStatusCallback {}", e.getMessage());
}
}
use of org.onap.so.asdc.client.exceptions.ArtifactInstallerException 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);
}
}
Aggregations