From 5223788222fd78c9e50680471eb0529361645230 Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Mon, 15 Apr 2019 22:59:18 -0400 Subject: Use distribution json for workflow install Use distribution json for workflow install Change-Id: I2eec3700d0ba92794b6ca11bd43683d91fb480ee Issue-ID: SO-1726 Signed-off-by: Kuleshov, Elena --- .../org/onap/so/asdc/client/ASDCConfiguration.java | 2 +- .../org/onap/so/asdc/client/ASDCController.java | 28 +-- .../so/asdc/installer/PnfResourceStructure.java | 6 + .../onap/so/asdc/installer/ResourceStructure.java | 13 ++ .../so/asdc/installer/VfResourceStructure.java | 6 + .../onap/so/asdc/installer/WorkflowArtifact.java | 65 +++++++ .../onap/so/asdc/installer/bpmn/BpmnInstaller.java | 12 +- .../so/asdc/installer/bpmn/WorkflowResource.java | 215 +++++++++++++++++++++ .../installer/heat/ToscaResourceInstaller.java | 5 + 9 files changed, 333 insertions(+), 19 deletions(-) create mode 100644 asdc-controller/src/main/java/org/onap/so/asdc/installer/WorkflowArtifact.java create mode 100644 asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java (limited to 'asdc-controller/src/main/java/org/onap') diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java index e2c358aa53..2eace7587f 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java @@ -55,7 +55,7 @@ public class ASDCConfiguration implements IConfiguration { public static final String HEAT_VOL = "HEAT_VOL"; public static final String OTHER = "OTHER"; public static final String TOSCA_CSAR = "TOSCA_CSAR"; - public static final String WORKFLOWS = "Workflows"; + public static final String WORKFLOW = "WORKFLOW"; public static final String VF_MODULES_METADATA = "VF_MODULES_METADATA"; private static final String[] SUPPORTED_ARTIFACT_TYPES = 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 f2e875fc0c..9b838c4d98 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 @@ -47,6 +47,7 @@ import org.onap.sdc.api.results.IDistributionClientResult; import org.onap.sdc.impl.DistributionClientFactory; import org.onap.sdc.utils.DistributionActionResultEnum; import org.onap.sdc.utils.DistributionStatusEnum; +import org.onap.so.asdc.activity.DeployActivitySpecs; import org.onap.so.asdc.client.exceptions.ASDCControllerException; import org.onap.so.asdc.client.exceptions.ASDCDownloadException; import org.onap.so.asdc.client.exceptions.ASDCParametersException; @@ -57,7 +58,6 @@ import org.onap.so.asdc.installer.ResourceStructure; import org.onap.so.asdc.installer.ResourceType; import org.onap.so.asdc.installer.ToscaResourceStructure; 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.asdc.tenantIsolation.DistributionStatus; import org.onap.so.asdc.tenantIsolation.WatchdogDistribution; @@ -88,9 +88,6 @@ public class ASDCController { @Autowired private ToscaResourceInstaller toscaInstaller; - @Autowired - private BpmnInstaller bpmnInstaller; - @Autowired private WatchdogDistributionStatusRepository wdsRepo; @@ -110,6 +107,9 @@ public class ASDCController { @Autowired private WatchdogDistribution wd; + @Autowired + DeployActivitySpecs deployActivitySpecs; + public int getNbOfNotificationsOngoing() { return nbOfNotificationsOngoing; } @@ -668,9 +668,6 @@ public class ASDCController { msoConfigPath + "/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()) { @@ -679,7 +676,7 @@ public class ASDCController { logger.info("Processing Resource Type: {}, Model UUID: {}", resourceType, resource.getResourceUUID()); - if ("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)) { + if ("VF".equals(resourceType)) { resourceStructure = new VfResourceStructure(iNotif, resource); } else if ("PNF".equals(resourceType)) { resourceStructure = new PnfResourceStructure(iNotif, resource); @@ -697,7 +694,7 @@ public class ASDCController { logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: " + resourceStructure.getResourceInstance().getResourceUUID()); - if ("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)) { + if ("VF".equals(resourceType)) { hasVFResource = true; for (IArtifactInfo artifact : resource.getArtifacts()) { IDistributionClientDownloadResult resultArtifact = @@ -711,8 +708,15 @@ public class ASDCController { .dumpVfModuleMetaDataList(((VfResourceStructure) resourceStructure) .decodeVfModuleArtifact(resultArtifact.getArtifactPayload()))); } - resourceStructure.addArtifactToStructure(distributionClient, artifact, - resultArtifact); + 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); + } } } @@ -801,7 +805,7 @@ public class ASDCController { "processCsarServiceArtifacts", ErrorCode.BusinessProcesssError.getValue(), "Exception in processCsarServiceArtifacts", e); } - } else if (artifact.getArtifactType().equals(ASDCConfiguration.WORKFLOWS)) { + } else if (artifact.getArtifactType().equals(ASDCConfiguration.WORKFLOW)) { try { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java index 8aa9684426..2a6e77ed40 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java @@ -38,6 +38,12 @@ public class PnfResourceStructure extends ResourceStructure { } + @Override + public void addWorkflowArtifactToStructure(IArtifactInfo artifactinfo, + IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { + + } + @Override public void prepareInstall() throws ArtifactInstallerException { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java index 9965a05294..8be3d6ba06 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java @@ -68,10 +68,16 @@ public abstract class ResourceStructure { */ protected final Map artifactsMapByUUID; + /** + * The list of workflow artifacts existing in this resource + */ + protected final Map workflowArtifactsMapByUUID; + public ResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) { this.notificationData = notificationData; this.resourceInstance = resourceInstance; artifactsMapByUUID = new HashMap<>(); + workflowArtifactsMapByUUID = new HashMap<>(); } /** @@ -85,6 +91,9 @@ public abstract class ResourceStructure { public abstract void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException; + public abstract void addWorkflowArtifactToStructure(IArtifactInfo artifactinfo, + IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException; + /** * Prepare the resource for installation. * @@ -144,4 +153,8 @@ public abstract class ResourceStructure { return artifactsMapByUUID; } + public Map getWorkflowArtifactsMapByUUID() { + return workflowArtifactsMapByUUID; + } + } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java index 62408be922..16e9fda7c4 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java @@ -98,6 +98,12 @@ public class VfResourceStructure extends ResourceStructure { } } + public void addWorkflowArtifactToStructure(IArtifactInfo artifactinfo, + IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { + WorkflowArtifact workflowArtifact = new WorkflowArtifact(artifactinfo, clientResult); + workflowArtifactsMapByUUID.put(artifactinfo.getArtifactUUID(), workflowArtifact); + } + protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult, VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/WorkflowArtifact.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/WorkflowArtifact.java new file mode 100644 index 0000000000..83b5614104 --- /dev/null +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/WorkflowArtifact.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.asdc.installer; + + +import java.io.UnsupportedEncodingException; +import org.onap.so.db.catalog.beans.HeatEnvironment; +import org.onap.so.db.catalog.beans.HeatFiles; +import org.onap.so.db.catalog.beans.HeatTemplate; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.results.IDistributionClientDownloadResult; + +/** + * The structure that contains the artifactInfo and its associated DownloadedResult. + * + */ +public final class WorkflowArtifact { + private final IArtifactInfo artifactInfo; + private int deployedInDb = 0; + private final String result; + + public WorkflowArtifact(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult) + throws UnsupportedEncodingException { + result = new String(clientResult.getArtifactPayload(), "UTF-8"); + artifactInfo = artifactinfo; + + } + + public IArtifactInfo getArtifactInfo() { + return artifactInfo; + } + + public String getResult() { + return result; + } + + public int getDeployedInDb() { + return deployedInDb; + } + + public void incrementDeployedInDB() { + ++deployedInDb; + } + + + +} diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java index c98fb9b619..7945ad0174 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java @@ -58,7 +58,7 @@ public class BpmnInstaller { protected static final Logger logger = LoggerFactory.getLogger(BpmnInstaller.class); private static final String BPMN_SUFFIX = ".bpmn"; private static final String CAMUNDA_URL = "mso.camundaURL"; - private static final String CREATE_DEPLOYMENT_PATH = "/sobpmnengine/deployment/create"; + private static final String CREATE_DEPLOYMENT_PATH = "sobpmnengine/deployment/create"; @Autowired private Environment env; @@ -78,7 +78,7 @@ public class BpmnInstaller { Path p = Paths.get(name); String fileName = p.getFileName().toString(); extractBpmnFileFromCsar(csarFile, fileName); - HttpResponse response = sendDeploymentRequest(fileName); + HttpResponse response = sendDeploymentRequest(fileName, ""); logger.debug("Response status line: {}", response.getStatusLine()); logger.debug("Response entity: {}", response.getEntity().toString()); if (response.getStatusLine().getStatusCode() != 200) { @@ -125,21 +125,21 @@ public class BpmnInstaller { return workflowsInCsar; } - protected HttpResponse sendDeploymentRequest(String bpmnFileName) throws Exception { + protected HttpResponse sendDeploymentRequest(String bpmnFileName, String version) throws Exception { HttpClient client = HttpClientBuilder.create().build(); URI deploymentUri = new URI(this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH); HttpPost post = new HttpPost(deploymentUri); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(1000000).setConnectTimeout(1000) .setConnectionRequestTimeout(1000).build(); post.setConfig(requestConfig); - HttpEntity requestEntity = buildMimeMultipart(bpmnFileName); + HttpEntity requestEntity = buildMimeMultipart(bpmnFileName, version); post.setEntity(requestEntity); return client.execute(post); } - protected HttpEntity buildMimeMultipart(String bpmnFileName) throws Exception { + protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws Exception { FileInputStream bpmnFileStream = new FileInputStream( - Paths.get(System.getProperty("mso.config.path"), "ASDC", bpmnFileName).normalize().toString()); + Paths.get(System.getProperty("mso.config.path"), "ASDC", version, bpmnFileName).normalize().toString()); byte[] bytesToSend = IOUtils.toByteArray(bpmnFileStream); HttpEntity requestEntity = diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java new file mode 100644 index 0000000000..daeda2f976 --- /dev/null +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java @@ -0,0 +1,215 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.asdc.installer.bpmn; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.http.HttpResponse; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.so.asdc.installer.VfResourceStructure; +import org.onap.so.asdc.installer.WorkflowArtifact; +import org.onap.so.db.catalog.beans.ActivitySpec; +import org.onap.so.db.catalog.beans.VnfResourceWorkflow; +import org.onap.so.db.catalog.beans.Workflow; +import org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence; +import org.onap.so.db.catalog.data.repository.ActivitySpecRepository; +import org.onap.so.db.catalog.data.repository.WorkflowRepository; +import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.MessageEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class WorkflowResource { + protected static final Logger logger = LoggerFactory.getLogger(WorkflowResource.class); + + private static final String pattern = ".*\\\"activity:(.*)\\\" .*"; + private static final String TARGET_RESOURCE_VNF = "vnf"; + private static final String SOURCE_SDC = "sdc"; + private static final String BPMN_SUFFIX = ".bpmn"; + + @Autowired + protected WorkflowRepository workflowRepo; + + @Autowired + protected ActivitySpecRepository activityRepo; + + @Autowired + private BpmnInstaller bpmnInstaller; + + public void processWorkflows(VfResourceStructure vfResourceStructure) throws Exception { + Map artifactsMapByUUID = vfResourceStructure.getWorkflowArtifactsMapByUUID(); + String vfResourceModelUuid = vfResourceStructure.getResourceInstance().getResourceUUID(); + for (String uuid : artifactsMapByUUID.keySet()) { + WorkflowArtifact artifactToInstall = artifactsMapByUUID.get(uuid); + if (isLatestVersionAvailable(artifactsMapByUUID, artifactToInstall)) { + logger.debug("Installing the BPMN: " + artifactToInstall.getArtifactInfo().getArtifactName()); + deployWorkflowResourceToCamunda(artifactToInstall); + installWorkflowResource(artifactToInstall, vfResourceModelUuid); + } else { + logger.debug("Skipping installing - not the latest version: " + + artifactToInstall.getArtifactInfo().getArtifactName()); + } + } + } + + protected void deployWorkflowResourceToCamunda(WorkflowArtifact artifact) throws Exception { + String bpmnName = artifact.getArtifactInfo().getArtifactName(); + String version = artifact.getArtifactInfo().getArtifactVersion(); + logger.debug("BPMN Name: " + bpmnName); + try { + HttpResponse response = bpmnInstaller.sendDeploymentRequest(bpmnName, version); + logger.debug("Response status line: {}", response.getStatusLine()); + logger.debug("Response entity: {}", response.getEntity().toString()); + if (response.getStatusLine().getStatusCode() != 200) { + logger.debug("Failed deploying BPMN {}", bpmnName); + logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), bpmnName, + bpmnName, Integer.toString(response.getStatusLine().getStatusCode()), + ErrorCode.DataError.getValue(), "ASDC BPMN deploy failed"); + throw (new Exception("Error from Camunda on deploying the BPMN: " + bpmnName)); + } else { + logger.debug("Successfully deployed to Camunda: {}", bpmnName); + } + } catch (Exception e) { + logger.debug("Exception :", e); + logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), bpmnName, + e.getMessage(), ErrorCode.DataError.getValue(), "ASDC BPMN deploy failed"); + throw e; + } + } + + protected void installWorkflowResource(WorkflowArtifact artifact, String vfResourceModelUuid) throws Exception { + IArtifactInfo artifactInfo = artifact.getArtifactInfo(); + + Workflow workflow = new Workflow(); + + workflow.setArtifactChecksum(artifactInfo.getArtifactChecksum()); + workflow.setArtifactName(artifactInfo.getArtifactName()); + workflow.setArtifactUUID(artifactInfo.getArtifactUUID()); + workflow.setBody(artifact.getResult()); + workflow.setDescription(artifactInfo.getArtifactDescription()); + workflow.setName(getWorkflowNameFromArtifactName(artifactInfo.getArtifactName())); + workflow.setResourceTarget(TARGET_RESOURCE_VNF); + workflow.setSource(SOURCE_SDC); + workflow.setTimeoutMinutes(artifactInfo.getArtifactTimeout()); + workflow.setOperationName(getWorkflowNameFromArtifactName(artifactInfo.getArtifactName())); + workflow.setVersion(getWorkflowVersionFromArtifactName(artifactInfo.getArtifactName())); + + VnfResourceWorkflow vnfResourceWorkflow = new VnfResourceWorkflow(); + vnfResourceWorkflow.setVnfResourceModelUUID(vfResourceModelUuid); + List vnfResourceWorkflows = new ArrayList(); + vnfResourceWorkflows.add(vnfResourceWorkflow); + + workflow.setVnfResourceWorkflow(vnfResourceWorkflows); + + List activityNames = getActivityNameList(artifact.getResult()); + List wfss = getWorkflowActivitySpecSequence(activityNames); + workflow.setWorkflowActivitySpecSequence(wfss); + + workflowRepo.save(workflow); + + } + + protected boolean isLatestVersionAvailable(Map artifactsMapByUUID, + WorkflowArtifact artifact) { + String workflowName = getWorkflowNameFromArtifactName(artifact.getArtifactInfo().getArtifactName()); + Double workflowVersion = getWorkflowVersionFromArtifactName(artifact.getArtifactInfo().getArtifactName()); + if (workflowVersion == null) { + workflowVersion = 0.0; + } + for (WorkflowArtifact artifactInMap : artifactsMapByUUID.values()) { + Double versionInMap = getWorkflowVersionFromArtifactName(artifactInMap.getArtifactInfo().getArtifactName()); + if (versionInMap == null) { + versionInMap = 0.0; + } + if (workflowName.equals(getWorkflowNameFromArtifactName(artifactInMap.getArtifactInfo().getArtifactName())) + && Double.compare(workflowVersion, versionInMap) < 0) { + return false; + } + } + return true; + } + + protected List getActivityNameList(String bpmnContent) { + List activityNameList = new ArrayList(); + + Pattern p = Pattern.compile(pattern); + Matcher m = p.matcher(bpmnContent); + while (m.find()) { + activityNameList.add(m.group(1)); + } + return activityNameList; + } + + protected List getWorkflowActivitySpecSequence(List activityNames) + throws Exception { + if (activityNames == null || activityNames.size() == 0) { + return null; + } + List workflowActivitySpecs = new ArrayList(); + for (String activityName : activityNames) { + ActivitySpec activitySpec = activityRepo.findByName(activityName); + if (activitySpec != null) { + WorkflowActivitySpecSequence workflowActivitySpec = new WorkflowActivitySpecSequence(); + workflowActivitySpec.setActivitySpec(activitySpec); + workflowActivitySpecs.add(workflowActivitySpec); + } + } + return workflowActivitySpecs; + } + + public String getWorkflowNameFromArtifactName(String artifactName) { + if (artifactName == null) { + return null; + } else { + if (artifactName.contains(BPMN_SUFFIX)) { + return artifactName.substring(0, artifactName.lastIndexOf(BPMN_SUFFIX)).split("-")[0]; + } else { + return artifactName.split("-")[0]; + } + } + } + + public Double getWorkflowVersionFromArtifactName(String artifactName) { + if (artifactName == null) { + return null; + } else { + String[] workflowNameParts = null; + if (artifactName.contains(BPMN_SUFFIX)) { + workflowNameParts = artifactName.substring(0, artifactName.lastIndexOf(BPMN_SUFFIX)).split("-"); + } else { + workflowNameParts = artifactName.split("-"); + } + if (workflowNameParts.length < 2) { + return null; + } else { + return Double.valueOf(workflowNameParts[1].replaceAll("_", ".")); + } + } + } +} diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index d3eab9a3fd..23c31f3298 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -70,6 +70,7 @@ import org.onap.so.asdc.installer.ToscaResourceStructure; import org.onap.so.asdc.installer.VfModuleArtifact; import org.onap.so.asdc.installer.VfModuleStructure; import org.onap.so.asdc.installer.VfResourceStructure; +import org.onap.so.asdc.installer.bpmn.WorkflowResource; import org.onap.so.asdc.util.YamlEditor; import org.onap.so.db.catalog.beans.AllottedResource; import org.onap.so.db.catalog.beans.AllottedResourceCustomization; @@ -246,6 +247,9 @@ public class ToscaResourceInstaller { @Autowired protected PnfCustomizationRepository pnfCustomizationRepository; + @Autowired + protected WorkflowResource workflowResource; + protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class); public boolean isResourceAlreadyDeployed(ResourceStructure vfResourceStruct, boolean serviceDeployed) @@ -400,6 +404,7 @@ public class ToscaResourceInstaller { vfCustomizationCategory); } + workflowResource.processWorkflows(vfResourceStructure); processResourceSequence(toscaResourceStruct, service); List allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources(); processAllottedResources(toscaResourceStruct, service, allottedResourceList); -- cgit 1.2.3-korg