- protected void processResourceNotification (INotificationData iNotif) {
- // For each artifact, create a structure describing the VFModule in a ordered flat level
- VfResourceStructure resourceStructure = null;
- ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
- boolean deploySuccessful = true;
- boolean hasVFResource = false;
- String errorMessage = null;
-
- try {
-
- this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
- 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);
- }
-
- for (IResourceInstance resource : iNotif.getResources()){
-
- resourceStructure = new VfResourceStructure(iNotif,resource);
-
- String resourceType = resourceStructure.getResourceInstance().getResourceType();
- String category = resourceStructure.getResourceInstance().getCategory();
-
- 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());
-
- 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);
-
- } catch (ASDCDownloadException | UnsupportedEncodingException e) {
- LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG,
- "Exception caught during Installation of artifact", "ASDC", "processResourceNotification", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processResourceNotification", e);
- }
+ 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();
+ boolean hasVFResource = false;
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(msoConfigPath);
+ DistributionStatusEnum deployStatus = DistributionStatusEnum.DEPLOY_OK;
+ String errorMessage = null;
+ boolean serviceDeployed = false;
+
+ try {
+ this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
+ IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact();
+ String filePath =
+ msoConfigPath + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact.getArtifactName();
+ File csarFile = new File(filePath);
+
+
+ if (isCsarAlreadyDeployed(iNotif, toscaResourceStructure)) {
+ return;
+ }
+
+ for (IResourceInstance resource : iNotif.getResources()) {
+
+ String resourceType = resource.getResourceType();
+
+
+ logger.info("Processing Resource Type: {}, Model UUID: {}", resourceType, resource.getResourceUUID());
+
+ if ("VF".equals(resourceType) && resource.getArtifacts() != null
+ && !resource.getArtifacts().isEmpty()) {
+ resourceStructure = new VfResourceStructure(iNotif, resource);
+ } else if ("PNF".equals(resourceType)) {
+ resourceStructure = new PnfResourceStructure(iNotif, resource);
+ } else {
+ // There are cases where the Service has no VF resources, those are handled here
+ logger.info("No resources found for Service: {}", iNotif.getServiceUUID());
+ resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
+ resourceStructure.setResourceType(ResourceType.OTHER);
+ }
+
+ try {
+
+ if (!this.checkResourceAlreadyDeployed(resourceStructure, serviceDeployed)) {
+
+ logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: "
+ + resourceStructure.getResourceInstance().getResourceUUID());
+
+ if ("VF".equals(resourceType) && resource.getArtifacts() != null
+ && !resource.getArtifacts().isEmpty()) {
+ 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(((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);
+ } catch (ArtifactInstallerException e) {
+ deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
+ errorMessage = e.getMessage();
+ logger.error("Exception occurred", e);
+ }
+ }
+ this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deployStatus,
+ errorMessage);
+ }
+
+
+ } catch (ASDCDownloadException | UnsupportedEncodingException e) {
+ logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception caught during Installation of artifact", "ASDC", "processResourceNotification",
+ ErrorCode.BusinessProcesssError.getValue(), "Exception in processResourceNotification", e);
+ }
+ }
+
+ private String getMsoConfigPath() {
+ String msoConfigPath = System.getProperty("mso.config.path");
+ if (msoConfigPath == null) {
+ logger.info("Unable to find the system property mso.config.path, use the default configuration");
+ msoConfigPath = asdcConfig.getPropertyOrNull("mso.config.defaultpath");
+ }
+ if (msoConfigPath == null) {
+ logger.info("Unable to find the property: {} from configuration.", "mso.config.defaultpath");
+ msoConfigPath = "";
+ }
+ logger.info("MSO config path is: {}", msoConfigPath);
+ return msoConfigPath;