diff options
52 files changed, 1999 insertions, 406 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index 8ccf40eff5..e15311eb0e 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -111,7 +111,7 @@ public class CatalogDBRestTest { assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); for(ILoggingEvent logEvent : TestAppender.events) if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") && - logEvent.getMarker().getName().equals("ENTRY") + logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY") ){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java index 02aa0843ae..a9aa50f654 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java @@ -22,6 +22,8 @@ package org.onap.so.adapters.openstack; import java.util.concurrent.Executor; +import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -38,6 +40,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @EntityScan({ "org.onap.so.db.catalog.beans", "org.onap.so.db.request.beans"}) public class MsoOpenstackAdaptersApplication { + @Value("${mso.async.core-pool-size}") private int corePoolSize; @@ -63,6 +66,7 @@ public class MsoOpenstackAdaptersApplication { @Bean public Executor asyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setTaskDecorator(new MDCTaskDecorator()); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java index 5cce4dd35f..2f688dbf48 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java @@ -50,6 +50,8 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; import org.springframework.stereotype.Component; @@ -108,13 +110,11 @@ public class ValetClient { URI uri = builder.build(); ValetCreateRequest vcr = this.createValetCreateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest); - RestTemplate restTemplate = new RestTemplate(); String body = mapper.writeValueAsString(vcr); HttpHeaders headers = generateHeaders(requestId); - HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet create req: " + uri.toString() + HEADERS + headers.toString() + BODY + body); + HttpEntity<String> entity = new HttpEntity<>(body, headers); - response = restTemplate.exchange(uri, HttpMethod.POST, entity, ValetCreateResponse.class); + response = getRestTemplate().exchange(uri, HttpMethod.POST, entity, ValetCreateResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetCreateRequest", e); @@ -123,6 +123,12 @@ public class ValetClient { return gvr; } + private RestTemplate getRestTemplate(){ + RestTemplate restTemplate = new RestTemplate(); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); + return restTemplate; + } + /* * This method will be invoked to send an Update request to Valet. */ @@ -135,14 +141,13 @@ public class ValetClient { UriBuilder builder = UriBuilder.fromPath(baseUrl).path(basePath).queryParam(REQUEST_ID, requestId); URI uri = builder.build(); - ValetUpdateRequest vur = this.createValetUpdateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest); - RestTemplate restTemplate = new RestTemplate(); + ValetUpdateRequest vur = this.createValetUpdateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest); String body = mapper.writeValueAsString(vur); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet update req: " + uri.toString() + HEADERS + headers.toString() + BODY + body); + - response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetUpdateResponse.class); + response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetUpdateResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetUpdateRequest", e); @@ -163,13 +168,13 @@ public class ValetClient { URI uri = builder.build(); ValetDeleteRequest vdr = this.createValetDeleteRequest(regionId, tenantId, vfModuleId, vfModuleName); - RestTemplate restTemplate = new RestTemplate(); + String body = mapper.writeValueAsString(vdr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet delete req: " + uri.toString() + HEADERS + headers.toString() + ", body=" + body); - response = restTemplate.exchange(uri, HttpMethod.DELETE, entity, ValetDeleteResponse.class); + + response = getRestTemplate().exchange(uri, HttpMethod.DELETE, entity, ValetDeleteResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetDeleteRequest", e); @@ -190,13 +195,13 @@ public class ValetClient { URI uri = builder.build(requestId); ValetConfirmRequest vcr = this.createValetConfirmRequest(stackId); - RestTemplate restTemplate = new RestTemplate(); + String body = mapper.writeValueAsString(vcr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); LOGGER.debug("valet confirm req: " + uri.toString() + HEADERS + headers.toString() + BODY + body); - response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetConfirmResponse.class); + response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetConfirmResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetConfirmRequest", e); @@ -217,13 +222,13 @@ public class ValetClient { URI uri = builder.build(requestId); ValetRollbackRequest vrr = this.createValetRollbackRequest(stackId, suppressRollback, errorMessage); - RestTemplate restTemplate = new RestTemplate(); + String body = mapper.writeValueAsString(vrr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet rollback req: " + uri.toString() + HEADERS + headers.toString() + BODY + body); - response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetRollbackResponse.class); + + response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetRollbackResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetRollbackRequest", e); diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java index 21ec8f7518..fc12120166 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java @@ -68,7 +68,7 @@ public class HealthCheckHandlerTest { assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); for(ILoggingEvent logEvent : TestAppender.events) if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") && - logEvent.getMarker().getName().equals("ENTRY") + logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY") ){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); @@ -78,7 +78,7 @@ public class HealthCheckHandlerTest { assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") && - logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){ + logEvent.getMarker() != null && logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java index 3d88a1467a..f88aab08a6 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java @@ -22,6 +22,8 @@ package org.onap.so.adapters.sdnc; import java.util.concurrent.Executor; +import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -35,6 +37,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @EntityScan({ "org.onap.so.db.request.beans"}) public class SDNCAdapterApplication { + @Value("${mso.async.core-pool-size}") private int corePoolSize; @@ -61,7 +64,7 @@ public class SDNCAdapterApplication { @Bean public Executor asyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - + executor.setTaskDecorator(new MDCTaskDecorator()); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/Application.java b/asdc-controller/src/main/java/org/onap/so/asdc/Application.java index a365d0740d..bd3b2d1c54 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/Application.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/Application.java @@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication(scanBasePackages = { "org.onap.so" }) public class Application { + private static final String MSO_CONFIG_PATH = "mso.config.path"; private static final String LOGS_DIR = "logs_dir"; private static void setLogsDir() { @@ -33,11 +34,16 @@ public class Application { System.getProperties().setProperty(LOGS_DIR, "./logs/asdc/"); } } + + private static void setConfigPath() { + if(System.getProperty(MSO_CONFIG_PATH) == null) + System.getProperties().setProperty(MSO_CONFIG_PATH, "."); + } public static void main(String[] args) { SpringApplication.run(Application.class, args); System.getProperties().setProperty("mso.db", "MARIADB"); - System.getProperties().setProperty("mso.config.path", "."); + System.getProperties().setProperty("server.name", "Springboot"); setLogsDir(); } 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 85e3e9e747..8276826456 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 @@ -70,6 +70,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 VF_MODULES_METADATA="VF_MODULES_METADATA"; private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.ASDC,ASDCConfiguration.class); 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 ee329ced3c..7ead6cbb7f 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 @@ -48,6 +48,7 @@ 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; import org.onap.so.asdc.tenantIsolation.DistributionStatus; import org.onap.so.asdc.tenantIsolation.WatchdogDistribution; @@ -79,6 +80,9 @@ public class ASDCController { private ToscaResourceInstaller toscaInstaller; @Autowired + private BpmnInstaller bpmnInstaller; + + @Autowired private WatchdogDistributionStatusRepository wdsRepo; @Autowired @@ -684,6 +688,13 @@ public class ASDCController { 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(); + bpmnInstaller.installBpmn(csarFilePath); + } + // Install a service with no resources, only the service itself if (iNotif.getResources() == null || iNotif.getResources().size() < 1) { @@ -772,6 +783,26 @@ public class ASDCController { "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processCsarServiceArtifacts", e); } } + else if(artifact.getArtifactType().equals(ASDCConfiguration.WORKFLOWS)){ + + try{ + + IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,iNotif.getDistributionID()); + + writeArtifactToFile(artifact, resultArtifact); + + toscaResourceStructure.setToscaArtifact(artifact); + + LOGGER.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif)); + + + } catch(Exception e){ + System.out.println("Whats the error " + e.getMessage()); + LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG, + "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processCsarServiceArtifacts", e); + } + } + } } 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 new file mode 100644 index 0000000000..f131b73175 --- /dev/null +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java @@ -0,0 +1,165 @@ +/*- + * ============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.bpmn; + +import java.io.*; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.zip.*; + +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.HttpClientBuilder; + +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.ByteArrayBody; +import org.apache.http.entity.mime.content.StringBody; +import org.apache.http.entity.mime.FormBodyPartBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class BpmnInstaller { + protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC,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"; + + @Autowired + private Environment env; + + public void installBpmn(String csarFilePath) { + LOGGER.info("Deploying BPMN files from " + csarFilePath); + try { + ZipInputStream csarFile = new ZipInputStream(new FileInputStream(csarFilePath)); + ZipEntry entry = csarFile.getNextEntry(); + + while (entry != null) { + String name = entry.getName(); + if (name.endsWith(BPMN_SUFFIX)) { + LOGGER.debug("Attempting to deploy BPMN file: " + name); + try { + Path p = Paths.get(name); + String fileName = p.getFileName().toString(); + extractBpmnFileFromCsar(csarFile, fileName); + HttpResponse response = sendDeploymentRequest(fileName); + LOGGER.debug("Response status line: " + response.getStatusLine()); + LOGGER.debug("Response entity: " + response.getEntity().toString()); + if (response.getStatusLine().getStatusCode() != 200) { + LOGGER.debug("Failed deploying BPMN " + name); + LOGGER.error(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, + name, + fileName, + "", + Integer.toString(response.getStatusLine().getStatusCode()), "", "", MsoLogger.ErrorCode.DataError, "ASDC BPMN deploy failed"); + } + else { + LOGGER.debug("Successfully deployed to Camunda: " + name); + } + } + catch (Exception e) { + LOGGER.debug("Exception :",e); + LOGGER.error(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, + name, + "", + "", + e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "ASDC BPMN deploy failed"); + } + } + entry = csarFile.getNextEntry(); + } + csarFile.close(); + } catch (IOException ex) { + LOGGER.debug("Exception :",ex); + LOGGER.error(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, + csarFilePath, + "", + "", + ex.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "ASDC reading CSAR with workflows failed"); + } + return; + } + + protected HttpResponse sendDeploymentRequest(String bpmnFileName) throws Exception { + HttpClient client = HttpClientBuilder.create().build(); + String deploymentUri = 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); + post.setEntity(requestEntity); + return client.execute(post); + } + + protected HttpEntity buildMimeMultipart(String bpmnFileName) throws Exception { + FileInputStream bpmnFileStream = new FileInputStream (System.getProperty("mso.config.path") + "/ASDC" + "/" + bpmnFileName); + + byte[] bytesToSend = IOUtils.toByteArray(bpmnFileStream); + HttpEntity requestEntity = MultipartEntityBuilder.create() + .addPart(FormBodyPartBuilder.create() + .setName("deployment-name") + .setBody(new StringBody("MSO Sample 1", ContentType.TEXT_PLAIN)) + .setField("Content-Disposition", String.format("form-data; name=\"%s\"", "deployment-name")) + .build()) + .addPart(FormBodyPartBuilder.create() + .setName("enable-duplicate-filtering") + .setBody(new StringBody("false", ContentType.TEXT_PLAIN)) + .setField("Content-Disposition", String.format("form-data; name=\"%s\"", "enable-duplicate-filtering")) + .build()) + .addPart(FormBodyPartBuilder.create() + .setName("deplpy-changed-only") + .setBody(new StringBody("false", ContentType.TEXT_PLAIN)) + .setField("Content-Disposition", String.format("form-data; name=\"%s\"", "deploy-changed-only")) + .build()) + .addPart(FormBodyPartBuilder.create() + .setName("deployment-source") + .setBody(new StringBody("local", ContentType.TEXT_PLAIN)) + .setField("Content-Disposition", String.format("form-data; name=\"%s\"", "deployment-source")) + .build()) + .addPart(FormBodyPartBuilder.create() + .setName(bpmnFileName) + .setBody(new ByteArrayBody(bytesToSend, ContentType.create("octet"), bpmnFileName)) + .setField("Content-Disposition", String.format("form-data; name=\"%s\"; filename=\"%s\"; size=%d", bpmnFileName, bpmnFileName, bytesToSend.length)) + .build()) + .build(); + return requestEntity; + } + + protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) throws IOException { + String filePath = System.getProperty("mso.config.path") + "/ASDC" + "/" + fileName; + BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath)); + byte[] bytesIn = new byte[4096]; + int read = 0; + while ((read = zipIn.read(bytesIn)) != -1) { + outputStream.write(bytesIn, 0, read); + } + outputStream.close(); + } +} diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java new file mode 100644 index 0000000000..535434db32 --- /dev/null +++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java @@ -0,0 +1,80 @@ +/*- + * ============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.bpmn; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import javax.transaction.Transactional; + +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.ProtocolVersion; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.message.BasicHttpResponse; +import org.apache.http.message.BasicStatusLine; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.asdc.BaseTest; +import org.onap.so.asdc.installer.bpmn.BpmnInstaller; +import org.springframework.beans.factory.annotation.Autowired; + +@Transactional +public class BpmnInstallerTest extends BaseTest { + + @Autowired + private BpmnInstaller bpmnInstaller; + + @Before + public void init() throws Exception { + System.setProperty("mso.config.path", "src/test/resources"); + } + + @Test + public void buildMimeMultiPart_Test() throws Exception { + + HttpEntity entity = bpmnInstaller.buildMimeMultipart("TestBB.bpmn"); + String mimeMultipartBodyFilePath = System.getProperty("mso.config.path") + "/mime-multipart-body.txt"; + + File mimeMultipartBody = new File(mimeMultipartBodyFilePath); + InputStream expectedContent = new FileInputStream(mimeMultipartBody); + + assertThat(IOUtils.contentEquals(expectedContent, entity.getContent())); + } + + @Test + public void installBpmn_Test() throws Exception { + HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "")); + HttpClient httpClient = mock(HttpClient.class); + String csarPath = System.getProperty("mso.config.path") + "/resource-examples/WorkflowBpmn/service-CxSvc-csar.csar"; + doReturn(response).when(httpClient).execute(any(HttpPost.class)); + bpmnInstaller.installBpmn(csarPath); + } + +} diff --git a/asdc-controller/src/test/resources/ASDC/TestBB.bpmn b/asdc-controller/src/test/resources/ASDC/TestBB.bpmn new file mode 100644 index 0000000000..47d1f6e649 --- /dev/null +++ b/asdc-controller/src/test/resources/ASDC/TestBB.bpmn @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> + <bpmn:process id="TestBB" name="TestBB" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>SequenceFlow_1owu825</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_06wodhm" name="End"> + <bpmn:incoming>SequenceFlow_1gwcdup</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1owu825" sourceRef="StartEvent_1" targetRef="FisrtTask" /> + <bpmn:sequenceFlow id="SequenceFlow_1gwcdup" sourceRef="FisrtTask" targetRef="EndEvent_06wodhm" /> + <bpmn:scriptTask id="FisrtTask" name="FirstTask" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1owu825</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1gwcdup</bpmn:outgoing> + <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +DoCreateVnf createVnf = new DoCreateVnf() +createVnf.preProcessRequest(execution)]]></bpmn:script> + </bpmn:scriptTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="TestBB"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="217" y="171" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="223" y="207" width="23" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_06wodhm_di" bpmnElement="EndEvent_06wodhm"> + <dc:Bounds x="630" y="171" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="638" y="207" width="19" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1owu825_di" bpmnElement="SequenceFlow_1owu825"> + <di:waypoint xsi:type="dc:Point" x="253" y="189" /> + <di:waypoint xsi:type="dc:Point" x="390" y="189" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="322" y="174" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1gwcdup_di" bpmnElement="SequenceFlow_1gwcdup"> + <di:waypoint xsi:type="dc:Point" x="490" y="189" /> + <di:waypoint xsi:type="dc:Point" x="630" y="189" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="560" y="174" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0u50zcm_di" bpmnElement="FisrtTask"> + <dc:Bounds x="390" y="149" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/asdc-controller/src/test/resources/mime-multipart-body.txt b/asdc-controller/src/test/resources/mime-multipart-body.txt new file mode 100644 index 0000000000..09d3aa7696 --- /dev/null +++ b/asdc-controller/src/test/resources/mime-multipart-body.txt @@ -0,0 +1,84 @@ +--Oz34MbsoUcF5cyWT62NuPjcHb9SU_GIfNHI +Content-Disposition: form-data; name="deployment-name" +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit + +MSO Sample 1 +--Oz34MbsoUcF5cyWT62NuPjcHb9SU_GIfNHI +Content-Disposition: form-data; name="enable-duplicate-filtering" +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit + +false +--Oz34MbsoUcF5cyWT62NuPjcHb9SU_GIfNHI +Content-Disposition: form-data; name="deploy-changed-only" +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit + +false +--Oz34MbsoUcF5cyWT62NuPjcHb9SU_GIfNHI +Content-Disposition: form-data; name="deployment-source" +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit + +local +--Oz34MbsoUcF5cyWT62NuPjcHb9SU_GIfNHI +Content-Disposition: form-data; name="testBB.bpmn"; filename="testBB.bpmn"; size=2990 +Content-Type: octet +Content-Transfer-Encoding: binary + +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> + <bpmn:process id="TestBB" name="TestBB" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>SequenceFlow_1owu825</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_06wodhm" name="End"> + <bpmn:incoming>SequenceFlow_1gwcdup</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1owu825" sourceRef="StartEvent_1" targetRef="FisrtTask" /> + <bpmn:sequenceFlow id="SequenceFlow_1gwcdup" sourceRef="FisrtTask" targetRef="EndEvent_06wodhm" /> + <bpmn:scriptTask id="FisrtTask" name="FirstTask" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1owu825</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1gwcdup</bpmn:outgoing> + <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.* +DoCreateVnf createVnf = new DoCreateVnf() +createVnf.preProcessRequest(execution)]]></bpmn:script> + </bpmn:scriptTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="TestBB"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="217" y="171" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="223" y="207" width="23" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_06wodhm_di" bpmnElement="EndEvent_06wodhm"> + <dc:Bounds x="630" y="171" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="638" y="207" width="19" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1owu825_di" bpmnElement="SequenceFlow_1owu825"> + <di:waypoint xsi:type="dc:Point" x="253" y="189" /> + <di:waypoint xsi:type="dc:Point" x="390" y="189" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="322" y="174" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1gwcdup_di" bpmnElement="SequenceFlow_1gwcdup"> + <di:waypoint xsi:type="dc:Point" x="490" y="189" /> + <di:waypoint xsi:type="dc:Point" x="630" y="189" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="560" y="174" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0u50zcm_di" bpmnElement="FisrtTask"> + <dc:Bounds x="390" y="149" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> + +--Oz34MbsoUcF5cyWT62NuPjcHb9SU_GIfNHI-- diff --git a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/Notification_MultipleModules.txt b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/Notification_MultipleModules.txt new file mode 100644 index 0000000000..5b6d9e4eaf --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/Notification_MultipleModules.txt @@ -0,0 +1,302 @@ +DistributionID:a2872f55-8628-4486-8548-7b132c9a47db +ServiceName:Vf zrdm5bpxmc02092017-Service +ServiceVersion:1.0 +ServiceUUID:bad955c3-29b2-4a27-932e-28e942cc6480 +ServiceInvariantUUID:b16a9398-ffa3-4041-b78c-2956b8ad9c7b +ServiceDescription:Demo + + + +Service Artifacts List: +{ +Service Artifacts Info: +ArtifactName:service-VfZrdm5bpxmc02092017Service-csar.csar +ArtifactVersion:1 +ArtifactType:TOSCA_CSAR +ArtifactDescription:TOSCA definition package of the asset +ArtifactTimeout:0 +ArtifactURL:service-VfZrdm5bpxmc02092017Service-csar.csar +ArtifactUUID:396cfd49-0f4b-4fec-9f33-0fd7e90d5a22 +ArtifactChecksum:MWQ3Y2FmMWExNDQyYWI2N2YwNjEwZGUzN2IzMzI3NjE= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + + +} + +Resource Instances List: +{ +Resource Instance Info: +ResourceInstanceName:Vf zrdm5bpxmc02092017-VF 0 +ResourceCustomizationUUID:96c23a4a-6887-4b2c-9cce-1e4ea35eaade +ResourceInvariantUUID:23122c9b-dd7f-483f-bf0a-e069303db2f7 +ResourceName:Vf zrdm5bpxmc02092017-VF +ResourceType:VF +ResourceUUID:14ba5d1e-3862-407c-a236-1cbaebccce77 +ResourceVersion:1.0 +Category:Generic +SubCategory:Network Elements +Resource Artifacts List: +{ +Service Artifacts Info: +ArtifactName:pxmc_mmn_volume.env +ArtifactVersion:2 +ArtifactType:HEAT_ENV +ArtifactDescription:Auto-generated HEAT Environment deployment artifact +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_mmn_volume.env +ArtifactUUID:c1ae6284-48d9-4437-a195-b2cf2ba23070 +ArtifactChecksum:NmEyZjc1Y2UwZDMwYjFhNGRlMTMzN2JhNzdiMThjMGU= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} +, +Service Artifacts Info: +ArtifactName:pxmc_base.env +ArtifactVersion:2 +ArtifactType:HEAT_ENV +ArtifactDescription:Auto-generated HEAT Environment deployment artifact +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_base.env +ArtifactUUID:6dd99c31-c52e-4c45-b99b-d223c877a296 +ArtifactChecksum:OGM2MWIzZTA2OTc5YjQwNTM1NGVhODA0YTFkNzM4ZTg= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + +, +Service Artifacts Info: +ArtifactName:vfzrdm5bpxmc02092017vf0_modules.json +ArtifactVersion:1 +ArtifactType:VF_MODULES_METADATA +ArtifactDescription:Auto-generated VF Modules information artifact +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/vfzrdm5bpxmc02092017vf0_modules.json +ArtifactUUID:e3b82cd6-485e-4d56-8d2c-17ccf6a59533 +ArtifactChecksum:MjY0NzcxMjJkZGI4YzQ1MDU2NjhkNWYyM2IwNmYzYmU= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + +, +Service Artifacts Info: +ArtifactName:pxmc_vmt.yaml +ArtifactVersion:1 +ArtifactType:HEAT +ArtifactDescription:created from csar +ArtifactTimeout:120 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_vmt.yaml +ArtifactUUID:ad12ab80-5419-4346-a5d7-dac2fc15575f +ArtifactChecksum:ODE0YTRiYzc2YzkxOTliZjJhNjc0M2RhMWU4M2VlZmE= +GeneratedArtifact:{Service Artifacts Info: +ArtifactName:pxmc_vmt.env +ArtifactVersion:2 +ArtifactType:HEAT_ENV +ArtifactDescription:Auto-generated HEAT Environment deployment artifact +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_vmt.env +ArtifactUUID:bc1640f1-69f0-4760-8fc3-3318ec2ff129 +ArtifactChecksum:MjdkYzY5ZGU0ZTlkZDlhNzI2ZGVhMjk1ODVhZTg1NTY= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} +} +RelatedArtifacts:{ +Service Artifacts Info: +ArtifactName:user_data_zrdm5bpxmc02vmt001.txt +ArtifactVersion:1 +ArtifactType:HEAT_ARTIFACT +ArtifactDescription:created from csar +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/user_data_zrdm5bpxmc02vmt001.txt +ArtifactUUID:53acdabe-689f-45e5-8578-f1514d3529da +ArtifactChecksum:MzJmZjgyZWYwOTBjMTg5M2ExNWZhMmMwNzc1NWY1YjQ= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + + +} + + +, +Service Artifacts Info: +ArtifactName:pxmc_mmn.yaml +ArtifactVersion:1 +ArtifactType:HEAT +ArtifactDescription:created from csar +ArtifactTimeout:120 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_mmn.yaml +ArtifactUUID:b8bca13b-811f-44ab-9d27-45b842c664d8 +ArtifactChecksum:YmNiYTU5YTM4ODVhYTlhODc5NGMwNWZkZjI5MTRmNTE= +GeneratedArtifact:{Service Artifacts Info: +ArtifactName:pxmc_mmn.env +ArtifactVersion:2 +ArtifactType:HEAT_ENV +ArtifactDescription:Auto-generated HEAT Environment deployment artifact +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_mmn.env +ArtifactUUID:e88ce0b9-1496-4d03-ab1d-6d8d79bfc737 +ArtifactChecksum:ZGI1NzI2Y2FmYjFhOTM2ZDYwNzg1YWRhZjBmMTk2OTQ= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} +} +RelatedArtifacts:{ +Service Artifacts Info: +ArtifactName:user_data_zrdm5bpxmc02mmn001.txt +ArtifactVersion:1 +ArtifactType:HEAT_ARTIFACT +ArtifactDescription:created from csar +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/user_data_zrdm5bpxmc02mmn001.txt +ArtifactUUID:5bc62c72-5f7a-40bc-a167-1a4fed9afdef +ArtifactChecksum:OTMxMjk5Mzc1YmIxMzRlYmRlZWJhMjg0MWQ4YTI1NWU= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + + +} + + +, +Service Artifacts Info: +ArtifactName:pxmc_mmn.env +ArtifactVersion:2 +ArtifactType:HEAT_ENV +ArtifactDescription:Auto-generated HEAT Environment deployment artifact +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_mmn.env +ArtifactUUID:e88ce0b9-1496-4d03-ab1d-6d8d79bfc737 +ArtifactChecksum:ZGI1NzI2Y2FmYjFhOTM2ZDYwNzg1YWRhZjBmMTk2OTQ= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + +, +Service Artifacts Info: +ArtifactName:pxmc_vmt.env +ArtifactVersion:2 +ArtifactType:HEAT_ENV +ArtifactDescription:Auto-generated HEAT Environment deployment artifact +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_vmt.env +ArtifactUUID:bc1640f1-69f0-4760-8fc3-3318ec2ff129 +ArtifactChecksum:MjdkYzY5ZGU0ZTlkZDlhNzI2ZGVhMjk1ODVhZTg1NTY= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} +, +Service Artifacts Info: +ArtifactName:user_data_zrdm5bpxmc02mmn001.txt +ArtifactVersion:1 +ArtifactType:HEAT_ARTIFACT +ArtifactDescription:created from csar +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/user_data_zrdm5bpxmc02mmn001.txt +ArtifactUUID:5bc62c72-5f7a-40bc-a167-1a4fed9afdef +ArtifactChecksum:OTMxMjk5Mzc1YmIxMzRlYmRlZWJhMjg0MWQ4YTI1NWU= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + +, +Service Artifacts Info: +ArtifactName:pxmc_base.yaml +ArtifactVersion:1 +ArtifactType:HEAT +ArtifactDescription:created from csar +ArtifactTimeout:120 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_base.yaml +ArtifactUUID:7e7f7356-11bd-4f2f-bbbc-5c10954e3189 +ArtifactChecksum:YThkNGFhZjAwNmM4NzMzODc0YzNhYTUxOTljNGQwNmM= +GeneratedArtifact:{Service Artifacts Info: +ArtifactName:pxmc_base.env +ArtifactVersion:2 +ArtifactType:HEAT_ENV +ArtifactDescription:Auto-generated HEAT Environment deployment artifact +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_base.env +ArtifactUUID:6dd99c31-c52e-4c45-b99b-d223c877a296 +ArtifactChecksum:OGM2MWIzZTA2OTc5YjQwNTM1NGVhODA0YTFkNzM4ZTg= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + +} +RelatedArtifacts:{ +} +, +Service Artifacts Info: +ArtifactName:user_data_zrdm5bpxmc02vmt001.txt +ArtifactVersion:1 +ArtifactType:HEAT_ARTIFACT +ArtifactDescription:created from csar +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/user_data_zrdm5bpxmc02vmt001.txt +ArtifactUUID:53acdabe-689f-45e5-8578-f1514d3529da +ArtifactChecksum:MzJmZjgyZWYwOTBjMTg5M2ExNWZhMmMwNzc1NWY1YjQ= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + +, +Service Artifacts Info: +ArtifactName:pxmc_mmn_volume.yaml +ArtifactVersion:2 +ArtifactType:HEAT_VOL +ArtifactDescription:created from csar +ArtifactTimeout:120 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_mmn_volume.yaml +ArtifactUUID:2f372a02-df1b-46ca-b81e-822e3f406965 +ArtifactChecksum:MzA5MGY5ODQ0NDY5MDhiMDM3YjFlNGIwNzJkNjFhOTI= +GeneratedArtifact:{Service Artifacts Info: +ArtifactName:pxmc_mmn_volume.env +ArtifactVersion:2 +ArtifactType:HEAT_ENV +ArtifactDescription:Auto-generated HEAT Environment deployment artifact +ArtifactTimeout:0 +ArtifactURL:/sdc/v1/catalog/services/VfZrdm5bpxmc02092017Service/1.0/resourceInstances/vfzrdm5bpxmc02092017vf0/artifacts/pxmc_mmn_volume.env +ArtifactUUID:c1ae6284-48d9-4437-a195-b2cf2ba23070 +ArtifactChecksum:NmEyZjc1Y2UwZDMwYjFhNGRlMTMzN2JhNzdiMThjMGU= +GeneratedArtifact:{NULL +} +RelatedArtifacts:{ +} + + +} +RelatedArtifacts:{ +} + + + +} + + + +} diff --git a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/ServiceResponse.json b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/ServiceResponse.json new file mode 100644 index 0000000000..37b7987f46 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/ServiceResponse.json @@ -0,0 +1,458 @@ +{ + "modelName": "Vf zrdm5bpxmc02092017-Service", + "description": "Demo", + "modelUUID": "bad955c3-29b2-4a27-932e-28e942cc6480", + "modelInvariantUUID": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b", + "serviceType": "", + "serviceRole": "", + "environmentContext": "General_Revenue-Bearing", + "networkCustomizations": [], + "vnfCustomizations": [ + { + "modelCustomizationUuid": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade", + "modelInstanceName": "Vf zrdm5bpxmc02092017-VF 0", + "multiStageDesign": "false", + "vnfResources": { + "modelUuid": "d326f424-2312-4dd6-b7fe-364fadbd1ef5", + "modelInvariantUuid": "23122c9b-dd7f-483f-bf0a-e069303db2f7", + "modelName": "Vf zrdm5bpxmc02092017-VF", + "toscaNodeType": "org.openecomp.resource.vf.VfZrdm5bpxmc02092017Vf", + "description": "Demo", + "orchestrationMode": "HEAT", + "modelVersion": "1.0", + "modelInvariantId": "23122c9b-dd7f-483f-bf0a-e069303db2f7" + }, + "vfModuleCustomizations": [ + { + "modelCustomizationUuid": "074c64d0-7e13-4bcc-8bdb-ea922331102d", + "label": "pxmc_base", + "minInstances": 1, + "maxInstances": 1, + "initialCount": 1, + "heatEnvironment": { + "artifactUuid": "6dd99c31-c52e-4c45-b99b-d223c877a296", + "name": "pxmc_base.env", + "description": "Auto-generated HEAT Environment deployment artifact", + "environment": "parameters:\n vnf_name: \n", + "artifactChecksum": "OGM2MWIzZTA2OTc5YjQwNTM1NGVhODA0YTFkNzM4ZTg=", + "version": "2" + }, + "vfModule": { + "modelUUID": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46", + "modelInvariantUUID": "f7a867f2-596b-4f4a-a128-421e825a6190", + "modelName": "VfZrdm5bpxmc02092017Vf..pxmc_base..module-0", + "modelVersion": "1", + "isBase": 1, + "moduleHeatTemplate": { + "artifactUuid": "7e7f7356-11bd-4f2f-bbbc-5c10954e3189", + "templateName": "pxmc_base.yaml", + "templateBody": "heat_template_version: 2015-04-30\n\nparameters:\n\n## GLOBAL//Basic Parameters\n vnf_name:\n type: string\n description: Unique name for this VF instance\n# For manual spinups, value must be in the ENV file. Must be removed from ENV before uploading to ASDC\n\nresources:\n\n## MSP RSG//Resource:SecurityGroup\n sec_grp_msp_0:\n type: OS::Neutron::SecurityGroup\n properties:\n description: Security Group for PXMC\n name:\n str_replace:\n template: VF_NAME_sec_grp_msp\n params:\n VF_NAME: { get_param: vnf_name }\n rules:\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"tcp\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"udp\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"132\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"icmp\", \"ethertype\": \"IPv4\"}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"tcp\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"udp\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"132\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"58\", \"ethertype\": \"IPv6\"}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"tcp\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"udp\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"132\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"icmp\", \"ethertype\": \"IPv4\"}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"tcp\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"udp\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"132\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"58\", \"ethertype\": \"IPv6\"}\n\noutputs:\n\n sec_grp_msp_id:\n description: uuid of the security group\n value: {get_resource: sec_grp_msp_0 }\n", + "timeoutMinutes": 120, + "version": "1", + "description": "created from csar", + "artifactChecksum": "YThkNGFhZjAwNmM4NzMzODc0YzNhYTUxOTljNGQwNmM=", + "parameters": [ + { + "heatTemplateArtifactUuid": "7e7f7356-11bd-4f2f-bbbc-5c10954e3189", + "paramName": "vnf_name", + "required": true, + "paramType": "string" + } + ], + "childTemplates": [], + "heatTemplate": "heat_template_version: 2015-04-30\n\nparameters:\n\n## GLOBAL//Basic Parameters\n vnf_name:\n type: string\n description: Unique name for this VF instance\n# For manual spinups, value must be in the ENV file. Must be removed from ENV before uploading to ASDC\n\nresources:\n\n## MSP RSG//Resource:SecurityGroup\n sec_grp_msp_0:\n type: OS::Neutron::SecurityGroup\n properties:\n description: Security Group for PXMC\n name:\n str_replace:\n template: VF_NAME_sec_grp_msp\n params:\n VF_NAME: { get_param: vnf_name }\n rules:\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"tcp\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"udp\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"132\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"icmp\", \"ethertype\": \"IPv4\"}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"tcp\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"udp\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"132\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"egress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"58\", \"ethertype\": \"IPv6\"}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"tcp\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"udp\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"132\", \"ethertype\": \"IPv4\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"0.0.0.0/0\", \"protocol\": \"icmp\", \"ethertype\": \"IPv4\"}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"tcp\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"udp\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"132\", \"ethertype\": \"IPv6\", \"port_range_max\": 65535, \"port_range_min\": 0}\n - {\"direction\": \"ingress\", \"remote_ip_prefix\": \"::/0\", \"protocol\": \"58\", \"ethertype\": \"IPv6\"}\n\noutputs:\n\n sec_grp_msp_id:\n description: uuid of the security group\n value: {get_resource: sec_grp_msp_0 }\n" + }, + "heatFiles": [], + "vnfResources": { + "modelUuid": "d326f424-2312-4dd6-b7fe-364fadbd1ef5", + "modelInvariantUuid": "23122c9b-dd7f-483f-bf0a-e069303db2f7", + "modelName": "Vf zrdm5bpxmc02092017-VF", + "toscaNodeType": "org.openecomp.resource.vf.VfZrdm5bpxmc02092017Vf", + "description": "Demo", + "orchestrationMode": "HEAT", + "modelVersion": "1.0", + "modelInvariantId": "23122c9b-dd7f-483f-bf0a-e069303db2f7" + }, + "modelInvariantUuid": "f7a867f2-596b-4f4a-a128-421e825a6190", + "base": true + } + }, + { + "modelCustomizationUuid": "5336a98e-0966-4e59-b6e6-c8162804a024", + "label": "pxmc_vmt", + "minInstances": 0, + "initialCount": 0, + "heatEnvironment": { + "artifactUuid": "bc1640f1-69f0-4760-8fc3-3318ec2ff129", + "name": "pxmc_vmt.env", + "description": "Auto-generated HEAT Environment deployment artifact", + "environment": "parameters:\n cinder_delete_on_termination_false: \n cinder_delete_on_termination_true: \n oam_protected_net_name: \n sec_grp_msp_id: \n vf_module_id: \n vmt_block_device_names: \n vmt_flavor_name: \n vmt_name_0: \n vmt_oam_protected_ip_0: \n vmt_volume_image_name_0: \n vmt_volume_image_name_1: \n vmt_volume_name_0: \n vmt_volume_name_1: \n vmt_volume_size_0: \n vmt_volume_size_1: \n vnf_id: \n", + "artifactChecksum": "MjdkYzY5ZGU0ZTlkZDlhNzI2ZGVhMjk1ODVhZTg1NTY=", + "version": "2" + }, + "vfModule": { + "modelUUID": "4d4423e2-17e8-455a-b9ae-7e4ab71b9cdc", + "modelInvariantUUID": "1e099992-6222-41a9-acde-5a8abb690775", + "modelName": "VfZrdm5bpxmc02092017Vf..pxmc_vmt..module-1", + "modelVersion": "1", + "isBase": 0, + "moduleHeatTemplate": { + "artifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "templateName": "pxmc_vmt.yaml", + "templateBody": "heat_template_version: 2015-04-30\n\ndescription: HOT creates Nimbus MSP VMT stack under MobiSupport Tenant\n\nparameters:\n vmt_name_0:\n type: string\n label: MSP VMT server names\n description: name of the MSP VMT instances\n# vmt_image_name:\n# type: string\n# label: MSP VMT image name\n# description: MSP VMT image name\n vmt_flavor_name:\n type: string\n label: MSP VMT flavor name\n description: MSP VMT flavor name\n# availability_zone_0:\n# type: string\n# label: MSP VMT availability zones\n# description: MSP VMT availability zones\n sec_grp_msp_id:\n type: string\n label: security group id\n description: the id of security group\n vmt_oam_protected_ip_0:\n type: string\n label: MSP VMT OAM IP Addresses\n description: MSP VMT OAM IP Addresses\n oam_protected_net_name:\n type: string\n label: MSP VMT OAM net name\n description: MSP VMT OAM net name\n vmt_block_device_names:\n type: comma_delimited_list\n label: MSP VMT Block Device Names\n description: MSP VMT Block Device Names\n vmt_volume_name_0:\n type: string\n label: Mobisupport MSP VMT Cinder Volume names\n description: Mobisupport MSP VMT Cinder Volume names\n vmt_volume_name_1:\n type: string\n label: Mobisupport MSP VMT Cinder Volume names\n description: Mobisupport MSP VMT Cinder Volume names\n vmt_volume_size_0:\n type: number\n label: Mobisupport MSP VMT Cinder Volume sizes\n description: Mobisupport MSP VMT Cinder Volume sizes\n vmt_volume_size_1:\n type: number\n label: Mobisupport MSP VMT Cinder Volume sizes\n description: Mobisupport MSP VMT Cinder Volume sizes\n vmt_volume_image_name_0:\n type: string\n label: Mobisupport MSP VMT VDA Cinder Volume image name\n description: Mobisupport MSP VMT VDA Cinder Volume image name\n vmt_volume_image_name_1:\n type: string\n label: Mobisupport MSP VMT VDB Cinder Volume image name\n description: Mobisupport MSP VMT VDB Cinder Volume image name\n cinder_delete_on_termination_true:\n type: boolean\n description: delete cinder volume upon instances termination\n cinder_delete_on_termination_false:\n type: boolean\n description: keep cinder volume upon instances termination\n vnf_id:\n type: string\n label: MSP VMT VNF ID\n description: MSP VMT VNF ID\n vf_module_id:\n type: string\n description: Unique ID for this VF Module instance\n\nresources:\n################ Cinder Volumes ##############################\n vmt_volume_0:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: vmt_volume_name_0}\n size: {get_param: vmt_volume_size_0}\n image: {get_param: vmt_volume_image_name_0}\n\n vmt_volume_1:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: vmt_volume_name_1}\n size: {get_param: vmt_volume_size_1}\n image: {get_param: vmt_volume_image_name_1}\n\n################ Ports ##############################\n vmt_oam_protected_0_port:\n type: OS::Neutron::Port\n properties:\n network: {get_param: oam_protected_net_name}\n fixed_ips: [{\"ip_address\": {get_param: vmt_oam_protected_ip_0}}]\n security_groups: [{get_param: sec_grp_msp_id}]\n replacement_policy: AUTO\n\n################### Servers #########################\n vmt_zrdm5bpxmc02vmt_0:\n type: OS::Nova::Server\n properties:\n name: {get_param: vmt_name_0}\n# image: {get_param: vmt_image_name}\n flavor: {get_param: vmt_flavor_name}\n# availability_zone: {get_param: availability_zone_0}\n block_device_mapping_v2: \n - device_name: {get_param: [vmt_block_device_names, 0]}\n volume_id: {get_resource: vmt_volume_0}\n delete_on_termination: {get_param: cinder_delete_on_termination_true}\n boot_index: 0\n - device_name: {get_param: [vmt_block_device_names, 1]}\n volume_id: {get_resource: vmt_volume_1}\n delete_on_termination: {get_param: cinder_delete_on_termination_true}\n boot_index: -1\n networks:\n - port: {get_resource: vmt_oam_protected_0_port}\n config_drive: \"True\"\n user_data_format: RAW\n user_data:\n get_file: user_data_zrdm5bpxmc02vmt001.txt\n\n metadata:\n vnf_id: {get_param: vnf_id}\n vf_module_id {get_param: vf_module_id}\n \"evacuation_policy\": \"Evacuation\"\n", + "timeoutMinutes": 120, + "version": "1", + "description": "created from csar", + "artifactChecksum": "ODE0YTRiYzc2YzkxOTliZjJhNjc0M2RhMWU4M2VlZmE=", + "parameters": [ + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_name_0", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vf_module_id", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "sec_grp_msp_id", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_volume_name_1", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_volume_name_0", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_block_device_names", + "required": true, + "paramType": "comma_delimited_list" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_flavor_name", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vnf_id", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "oam_protected_net_name", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_volume_image_name_1", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_volume_image_name_0", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_oam_protected_ip_0", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_volume_size_0", + "required": true, + "paramType": "number" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "cinder_delete_on_termination_false", + "required": true, + "paramType": "boolean" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "vmt_volume_size_1", + "required": true, + "paramType": "number" + }, + { + "heatTemplateArtifactUuid": "ad12ab80-5419-4346-a5d7-dac2fc15575f", + "paramName": "cinder_delete_on_termination_true", + "required": true, + "paramType": "boolean" + } + ], + "childTemplates": [], + "heatTemplate": "heat_template_version: 2015-04-30\n\ndescription: HOT creates Nimbus MSP VMT stack under MobiSupport Tenant\n\nparameters:\n vmt_name_0:\n type: string\n label: MSP VMT server names\n description: name of the MSP VMT instances\n# vmt_image_name:\n# type: string\n# label: MSP VMT image name\n# description: MSP VMT image name\n vmt_flavor_name:\n type: string\n label: MSP VMT flavor name\n description: MSP VMT flavor name\n# availability_zone_0:\n# type: string\n# label: MSP VMT availability zones\n# description: MSP VMT availability zones\n sec_grp_msp_id:\n type: string\n label: security group id\n description: the id of security group\n vmt_oam_protected_ip_0:\n type: string\n label: MSP VMT OAM IP Addresses\n description: MSP VMT OAM IP Addresses\n oam_protected_net_name:\n type: string\n label: MSP VMT OAM net name\n description: MSP VMT OAM net name\n vmt_block_device_names:\n type: comma_delimited_list\n label: MSP VMT Block Device Names\n description: MSP VMT Block Device Names\n vmt_volume_name_0:\n type: string\n label: Mobisupport MSP VMT Cinder Volume names\n description: Mobisupport MSP VMT Cinder Volume names\n vmt_volume_name_1:\n type: string\n label: Mobisupport MSP VMT Cinder Volume names\n description: Mobisupport MSP VMT Cinder Volume names\n vmt_volume_size_0:\n type: number\n label: Mobisupport MSP VMT Cinder Volume sizes\n description: Mobisupport MSP VMT Cinder Volume sizes\n vmt_volume_size_1:\n type: number\n label: Mobisupport MSP VMT Cinder Volume sizes\n description: Mobisupport MSP VMT Cinder Volume sizes\n vmt_volume_image_name_0:\n type: string\n label: Mobisupport MSP VMT VDA Cinder Volume image name\n description: Mobisupport MSP VMT VDA Cinder Volume image name\n vmt_volume_image_name_1:\n type: string\n label: Mobisupport MSP VMT VDB Cinder Volume image name\n description: Mobisupport MSP VMT VDB Cinder Volume image name\n cinder_delete_on_termination_true:\n type: boolean\n description: delete cinder volume upon instances termination\n cinder_delete_on_termination_false:\n type: boolean\n description: keep cinder volume upon instances termination\n vnf_id:\n type: string\n label: MSP VMT VNF ID\n description: MSP VMT VNF ID\n vf_module_id:\n type: string\n description: Unique ID for this VF Module instance\n\nresources:\n################ Cinder Volumes ##############################\n vmt_volume_0:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: vmt_volume_name_0}\n size: {get_param: vmt_volume_size_0}\n image: {get_param: vmt_volume_image_name_0}\n\n vmt_volume_1:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: vmt_volume_name_1}\n size: {get_param: vmt_volume_size_1}\n image: {get_param: vmt_volume_image_name_1}\n\n################ Ports ##############################\n vmt_oam_protected_0_port:\n type: OS::Neutron::Port\n properties:\n network: {get_param: oam_protected_net_name}\n fixed_ips: [{\"ip_address\": {get_param: vmt_oam_protected_ip_0}}]\n security_groups: [{get_param: sec_grp_msp_id}]\n replacement_policy: AUTO\n\n################### Servers #########################\n vmt_zrdm5bpxmc02vmt_0:\n type: OS::Nova::Server\n properties:\n name: {get_param: vmt_name_0}\n# image: {get_param: vmt_image_name}\n flavor: {get_param: vmt_flavor_name}\n# availability_zone: {get_param: availability_zone_0}\n block_device_mapping_v2: \n - device_name: {get_param: [vmt_block_device_names, 0]}\n volume_id: {get_resource: vmt_volume_0}\n delete_on_termination: {get_param: cinder_delete_on_termination_true}\n boot_index: 0\n - device_name: {get_param: [vmt_block_device_names, 1]}\n volume_id: {get_resource: vmt_volume_1}\n delete_on_termination: {get_param: cinder_delete_on_termination_true}\n boot_index: -1\n networks:\n - port: {get_resource: vmt_oam_protected_0_port}\n config_drive: \"True\"\n user_data_format: RAW\n user_data:\n get_file: user_data_zrdm5bpxmc02vmt001.txt\n\n metadata:\n vnf_id: {get_param: vnf_id}\n vf_module_id {get_param: vf_module_id}\n \"evacuation_policy\": \"Evacuation\"\n" + }, + "heatFiles": [], + "vnfResources": { + "modelUuid": "d326f424-2312-4dd6-b7fe-364fadbd1ef5", + "modelInvariantUuid": "23122c9b-dd7f-483f-bf0a-e069303db2f7", + "modelName": "Vf zrdm5bpxmc02092017-VF", + "toscaNodeType": "org.openecomp.resource.vf.VfZrdm5bpxmc02092017Vf", + "description": "Demo", + "orchestrationMode": "HEAT", + "modelVersion": "1.0", + "modelInvariantId": "23122c9b-dd7f-483f-bf0a-e069303db2f7" + }, + "modelInvariantUuid": "1e099992-6222-41a9-acde-5a8abb690775", + "base": false + } + }, + { + "modelCustomizationUuid": "e38906fa-717c-49b0-b391-e6ec12b50c4a", + "label": "pxmc_mmn", + "minInstances": 0, + "initialCount": 0, + "heatEnvironment": { + "artifactUuid": "e88ce0b9-1496-4d03-ab1d-6d8d79bfc737", + "name": "pxmc_mmn.env", + "description": "Auto-generated HEAT Environment deployment artifact", + "environment": "parameters:\n cinder_delete_on_termination_false: \n cinder_delete_on_termination_true: \n mmn_arch_volume_id_2: \n mmn_backup_volume_id_3: \n mmn_block_device_names: \n mmn_data_volume_id_1: \n mmn_flavor_name: \n mmn_misc_volume_id_4: \n mmn_name_0: \n mmn_oam_protected_ip_0: \n mmn_volume_image_name_0: \n mmn_volume_name_0: \n mmn_volume_size_0: \n oam_protected_net_name: \n sec_grp_msp_id: \n vf_module_id: \n vnf_id: \n", + "artifactChecksum": "ZGI1NzI2Y2FmYjFhOTM2ZDYwNzg1YWRhZjBmMTk2OTQ=", + "version": "2" + }, + "vfModule": { + "modelUUID": "a8cb1182-9b6d-46f8-b06b-ded4fe69e10d", + "modelInvariantUUID": "8e53c069-b2f0-437a-9c00-21cbc5c8f081", + "modelName": "VfZrdm5bpxmc02092017Vf..pxmc_mmn..module-2", + "modelVersion": "1", + "isBase": 0, + "volumeHeatTemplate": { + "artifactUuid": "2f372a02-df1b-46ca-b81e-822e3f406965", + "templateName": "pxmc_mmn_volume.yaml", + "templateBody": "heat_template_version: 2015-04-30\n\ndescription: HOT creates MSP MMN Cinder Volumes under MobiSupport Tenant\n\nparameters:\n mmn_volume_name_1:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n\n mmn_volume_name_2:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n\n mmn_volume_name_3:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n\n mmn_volume_name_4:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n\n mmn_volume_size_1:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n\n mmn_volume_size_2:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n\n mmn_volume_size_3:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n\n mmn_volume_size_4:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n\nresources:\n mmn_data_volume_1:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_1}\n size: {get_param: mmn_volume_size_1}\n \n mmn_arch_volume_2:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_2}\n size: {get_param: mmn_volume_size_2}\n \n mmn_backup_volume_3:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_3}\n size: {get_param: mmn_volume_size_3}\n \n mmn_misc_volume_4:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_4}\n size: {get_param: mmn_volume_size_4}\n\noutputs:\n mmn_data_volume_id_1:\n description: msp mmn data volume 1\n value: {get_resource: mmn_data_volume_1}\n \n mmn_arch_volume_id_2:\n description: msp mn arch volume 2\n value: {get_resource: mmn_arch_volume_2}\n \n mmn_backup_volume_id_3:\n description: msp mn backup volume 3\n value: {get_resource: mmn_backup_volume_3}\n \n mmn_misc_volume_id_4:\n description: msp mn volume 4\n value: {get_resource: mmn_misc_volume_4}\n", + "timeoutMinutes": 120, + "version": "2", + "description": "created from csar", + "artifactChecksum": "MzA5MGY5ODQ0NDY5MDhiMDM3YjFlNGIwNzJkNjFhOTI=", + "parameters": [ + { + "heatTemplateArtifactUuid": "2f372a02-df1b-46ca-b81e-822e3f406965", + "paramName": "mmn_volume_name_2", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "2f372a02-df1b-46ca-b81e-822e3f406965", + "paramName": "mmn_volume_size_2", + "required": true, + "paramType": "number" + }, + { + "heatTemplateArtifactUuid": "2f372a02-df1b-46ca-b81e-822e3f406965", + "paramName": "mmn_volume_name_1", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "2f372a02-df1b-46ca-b81e-822e3f406965", + "paramName": "mmn_volume_size_1", + "required": true, + "paramType": "number" + }, + { + "heatTemplateArtifactUuid": "2f372a02-df1b-46ca-b81e-822e3f406965", + "paramName": "mmn_volume_name_4", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "2f372a02-df1b-46ca-b81e-822e3f406965", + "paramName": "mmn_volume_name_3", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "2f372a02-df1b-46ca-b81e-822e3f406965", + "paramName": "mmn_volume_size_4", + "required": true, + "paramType": "number" + }, + { + "heatTemplateArtifactUuid": "2f372a02-df1b-46ca-b81e-822e3f406965", + "paramName": "mmn_volume_size_3", + "required": true, + "paramType": "number" + } + ], + "childTemplates": [], + "heatTemplate": "heat_template_version: 2015-04-30\n\ndescription: HOT creates MSP MMN Cinder Volumes under MobiSupport Tenant\n\nparameters:\n mmn_volume_name_1:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n\n mmn_volume_name_2:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n\n mmn_volume_name_3:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n\n mmn_volume_name_4:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n\n mmn_volume_size_1:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n\n mmn_volume_size_2:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n\n mmn_volume_size_3:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n\n mmn_volume_size_4:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n\nresources:\n mmn_data_volume_1:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_1}\n size: {get_param: mmn_volume_size_1}\n \n mmn_arch_volume_2:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_2}\n size: {get_param: mmn_volume_size_2}\n \n mmn_backup_volume_3:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_3}\n size: {get_param: mmn_volume_size_3}\n \n mmn_misc_volume_4:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_4}\n size: {get_param: mmn_volume_size_4}\n\noutputs:\n mmn_data_volume_id_1:\n description: msp mmn data volume 1\n value: {get_resource: mmn_data_volume_1}\n \n mmn_arch_volume_id_2:\n description: msp mn arch volume 2\n value: {get_resource: mmn_arch_volume_2}\n \n mmn_backup_volume_id_3:\n description: msp mn backup volume 3\n value: {get_resource: mmn_backup_volume_3}\n \n mmn_misc_volume_id_4:\n description: msp mn volume 4\n value: {get_resource: mmn_misc_volume_4}\n" + }, + "moduleHeatTemplate": { + "artifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "templateName": "pxmc_mmn.yaml", + "templateBody": "heat_template_version: 2015-04-30\n\ndescription: HOT creates Nimbus vMSP MMN stack.\n\nparameters:\n mmn_name_0:\n type: string\n label: MSP MMN server names\n description: name of the MSP MMN instances\n mmn_flavor_name:\n type: string\n label: MSP MMN flavor name\n description: MSP MMN flavor name\n# mmn_image_name:\n# type: string\n# label: MSP MMN image name\n# description: MSP MMN image name\n# availability_zone_0:\n# type: string\n# label: MSP MMN availability zones\n# description: MSP MMN availability zones\n sec_grp_msp_id:\n type: string\n label: security group id\n description: the id of security group\n mmn_oam_protected_ip_0:\n type: string\n label: MSP MMN OAM IP Addresses\n description: MSP MMN OAM IP Addresses\n oam_protected_net_name:\n type: string\n label: MSP MMN OAM net name\n description: MSP MMN OAM net name\n mmn_volume_name_0:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n mmn_volume_size_0:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n mmn_volume_image_name_0:\n type: string\n label: Mobisupport MSP MMN Cinder Volume image name\n description: Mobisupport MSP MMN Cinder Volume image name\n mmn_data_volume_id_1:\n type: string\n label: MSP MMN Volume id 1\n description: MSP MMN Volume id 1\n mmn_arch_volume_id_2:\n type: string\n label: MSP MMN Volume id 2\n description: MSP MMN Volume id 2\n mmn_backup_volume_id_3:\n type: string\n label: MSP MMN Volume id 3\n description: MSP MMN Volume id 3\n mmn_misc_volume_id_4:\n type: string\n label: MSP MMN Volume id 4\n description: MSP MMN Volume id 4\n mmn_block_device_names:\n type: comma_delimited_list\n label: MSP MMN Block Device Names\n description: MSP MMN Block Device Names\n cinder_delete_on_termination_true:\n type: boolean\n description: delete cinder volume upon instances termination\n cinder_delete_on_termination_false:\n type: boolean\n description: keep cinder volume upon instances termination\n vnf_id:\n type: string\n label: MSP MMN VNF ID\n description: MSP MMN VNF ID\n vf_module_id:\n type: string\n description: Unique ID for this VF module instance\n\nresources:\n################ Cinder Volume ########################\n mmn_volume_0:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_0}\n size: {get_param: mmn_volume_size_0}\n image: {get_param: mmn_volume_image_name_0}\n\n################ Server ##############################\n mmn_zrdm5bpxmc02mmn_0:\n type: OS::Nova::Server\n properties:\n name: {get_param: mmn_name_0}\n# image: {get_param: mmn_image_name}\n flavor: {get_param: mmn_flavor_name}\n# availability_zone: {get_param: availability_zone_0}\n block_device_mapping_v2:\n - device_name: { get_param: [mmn_block_device_names, 0] }\n volume_id: { get_resource: mmn_volume_0 }\n delete_on_termination: {get_param: cinder_delete_on_termination_true}\n networks:\n - port: { get_resource: mmn_oam_protected_0_port }\n config_drive: \"True\"\n user_data_format: RAW\n user_data:\n get_file: user_data_zrdm5bpxmc02mmn001.txt\n metadata:\n vnf_id: {get_param: vnf_id}\n vf_module_id {get_param: vf_module_id}\n \"evacuation_policy\": \"Evacuation\"\n\n################ Ports ##############################\n mmn_oam_protected_0_port:\n type: OS::Neutron::Port\n properties:\n network: {get_param: oam_protected_net_name}\n fixed_ips: [{\"ip_address\": {get_param: mmn_oam_protected_ip_0}}]\n security_groups: [{ get_param: sec_grp_msp_id }]\n replacement_policy: AUTO\n\n################ Volume Attachment ##############################\n volume_attachment_vdb:\n type: OS::Cinder::VolumeAttachment\n depends_on: mmn_zrdm5bpxmc02mmn_0\n properties:\n volume_id: { get_param: mmn_data_volume_id_1 }\n instance_uuid: { get_resource: mmn_zrdm5bpxmc02mmn_0}\n mountpoint: /dev/vdb\n\n volume_attachment_vdc:\n type: OS::Cinder::VolumeAttachment\n depends_on: volume_attachment_vdb\n properties:\n volume_id: { get_param: mmn_arch_volume_id_2 }\n instance_uuid: { get_resource: mmn_zrdm5bpxmc02mmn_0}\n mountpoint: /dev/vdc\n\n volume_attachment_vdd:\n type: OS::Cinder::VolumeAttachment\n depends_on: volume_attachment_vdc\n properties:\n volume_id: { get_param: mmn_backup_volume_id_3 }\n instance_uuid: { get_resource: mmn_zrdm5bpxmc02mmn_0}\n mountpoint: /dev/vdd\n\n volume_attachment_vde:\n type: OS::Cinder::VolumeAttachment\n depends_on: volume_attachment_vdd\n properties:\n volume_id: { get_param: mmn_misc_volume_id_4 }\n instance_uuid: { get_resource: mmn_zrdm5bpxmc02mmn_0}\n mountpoint: /dev/vde\n", + "timeoutMinutes": 120, + "version": "1", + "description": "created from csar", + "artifactChecksum": "YmNiYTU5YTM4ODVhYTlhODc5NGMwNWZkZjI5MTRmNTE=", + "parameters": [ + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "vnf_id", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_block_device_names", + "required": true, + "paramType": "comma_delimited_list" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_name_0", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_arch_volume_id_2", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_volume_image_name_0", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "cinder_delete_on_termination_false", + "required": true, + "paramType": "boolean" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_oam_protected_ip_0", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_data_volume_id_1", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_backup_volume_id_3", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "vf_module_id", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "sec_grp_msp_id", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_volume_size_0", + "required": true, + "paramType": "number" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "cinder_delete_on_termination_true", + "required": true, + "paramType": "boolean" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_volume_name_0", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "oam_protected_net_name", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_misc_volume_id_4", + "required": true, + "paramType": "string" + }, + { + "heatTemplateArtifactUuid": "b8bca13b-811f-44ab-9d27-45b842c664d8", + "paramName": "mmn_flavor_name", + "required": true, + "paramType": "string" + } + ], + "childTemplates": [], + "heatTemplate": "heat_template_version: 2015-04-30\n\ndescription: HOT creates Nimbus vMSP MMN stack.\n\nparameters:\n mmn_name_0:\n type: string\n label: MSP MMN server names\n description: name of the MSP MMN instances\n mmn_flavor_name:\n type: string\n label: MSP MMN flavor name\n description: MSP MMN flavor name\n# mmn_image_name:\n# type: string\n# label: MSP MMN image name\n# description: MSP MMN image name\n# availability_zone_0:\n# type: string\n# label: MSP MMN availability zones\n# description: MSP MMN availability zones\n sec_grp_msp_id:\n type: string\n label: security group id\n description: the id of security group\n mmn_oam_protected_ip_0:\n type: string\n label: MSP MMN OAM IP Addresses\n description: MSP MMN OAM IP Addresses\n oam_protected_net_name:\n type: string\n label: MSP MMN OAM net name\n description: MSP MMN OAM net name\n mmn_volume_name_0:\n type: string\n label: Mobisupport MSP MMN Cinder Volume names\n description: Mobisupport MSP MMN Cinder Volume names\n mmn_volume_size_0:\n type: number\n label: Mobisupport MSP MMN Cinder Volume sizes\n description: Mobisupport MSP MMN Cinder Volume sizes\n mmn_volume_image_name_0:\n type: string\n label: Mobisupport MSP MMN Cinder Volume image name\n description: Mobisupport MSP MMN Cinder Volume image name\n mmn_data_volume_id_1:\n type: string\n label: MSP MMN Volume id 1\n description: MSP MMN Volume id 1\n mmn_arch_volume_id_2:\n type: string\n label: MSP MMN Volume id 2\n description: MSP MMN Volume id 2\n mmn_backup_volume_id_3:\n type: string\n label: MSP MMN Volume id 3\n description: MSP MMN Volume id 3\n mmn_misc_volume_id_4:\n type: string\n label: MSP MMN Volume id 4\n description: MSP MMN Volume id 4\n mmn_block_device_names:\n type: comma_delimited_list\n label: MSP MMN Block Device Names\n description: MSP MMN Block Device Names\n cinder_delete_on_termination_true:\n type: boolean\n description: delete cinder volume upon instances termination\n cinder_delete_on_termination_false:\n type: boolean\n description: keep cinder volume upon instances termination\n vnf_id:\n type: string\n label: MSP MMN VNF ID\n description: MSP MMN VNF ID\n vf_module_id:\n type: string\n description: Unique ID for this VF module instance\n\nresources:\n################ Cinder Volume ########################\n mmn_volume_0:\n type: OS::Cinder::Volume\n properties:\n name: {get_param: mmn_volume_name_0}\n size: {get_param: mmn_volume_size_0}\n image: {get_param: mmn_volume_image_name_0}\n\n################ Server ##############################\n mmn_zrdm5bpxmc02mmn_0:\n type: OS::Nova::Server\n properties:\n name: {get_param: mmn_name_0}\n# image: {get_param: mmn_image_name}\n flavor: {get_param: mmn_flavor_name}\n# availability_zone: {get_param: availability_zone_0}\n block_device_mapping_v2:\n - device_name: { get_param: [mmn_block_device_names, 0] }\n volume_id: { get_resource: mmn_volume_0 }\n delete_on_termination: {get_param: cinder_delete_on_termination_true}\n networks:\n - port: { get_resource: mmn_oam_protected_0_port }\n config_drive: \"True\"\n user_data_format: RAW\n user_data:\n get_file: user_data_zrdm5bpxmc02mmn001.txt\n metadata:\n vnf_id: {get_param: vnf_id}\n vf_module_id {get_param: vf_module_id}\n \"evacuation_policy\": \"Evacuation\"\n\n################ Ports ##############################\n mmn_oam_protected_0_port:\n type: OS::Neutron::Port\n properties:\n network: {get_param: oam_protected_net_name}\n fixed_ips: [{\"ip_address\": {get_param: mmn_oam_protected_ip_0}}]\n security_groups: [{ get_param: sec_grp_msp_id }]\n replacement_policy: AUTO\n\n################ Volume Attachment ##############################\n volume_attachment_vdb:\n type: OS::Cinder::VolumeAttachment\n depends_on: mmn_zrdm5bpxmc02mmn_0\n properties:\n volume_id: { get_param: mmn_data_volume_id_1 }\n instance_uuid: { get_resource: mmn_zrdm5bpxmc02mmn_0}\n mountpoint: /dev/vdb\n\n volume_attachment_vdc:\n type: OS::Cinder::VolumeAttachment\n depends_on: volume_attachment_vdb\n properties:\n volume_id: { get_param: mmn_arch_volume_id_2 }\n instance_uuid: { get_resource: mmn_zrdm5bpxmc02mmn_0}\n mountpoint: /dev/vdc\n\n volume_attachment_vdd:\n type: OS::Cinder::VolumeAttachment\n depends_on: volume_attachment_vdc\n properties:\n volume_id: { get_param: mmn_backup_volume_id_3 }\n instance_uuid: { get_resource: mmn_zrdm5bpxmc02mmn_0}\n mountpoint: /dev/vdd\n\n volume_attachment_vde:\n type: OS::Cinder::VolumeAttachment\n depends_on: volume_attachment_vdd\n properties:\n volume_id: { get_param: mmn_misc_volume_id_4 }\n instance_uuid: { get_resource: mmn_zrdm5bpxmc02mmn_0}\n mountpoint: /dev/vde\n" + }, + "heatFiles": [], + "vnfResources": { + "modelUuid": "d326f424-2312-4dd6-b7fe-364fadbd1ef5", + "modelInvariantUuid": "23122c9b-dd7f-483f-bf0a-e069303db2f7", + "modelName": "Vf zrdm5bpxmc02092017-VF", + "toscaNodeType": "org.openecomp.resource.vf.VfZrdm5bpxmc02092017Vf", + "description": "Demo", + "orchestrationMode": "HEAT", + "modelVersion": "1.0", + "modelInvariantId": "23122c9b-dd7f-483f-bf0a-e069303db2f7" + }, + "modelInvariantUuid": "8e53c069-b2f0-437a-9c00-21cbc5c8f081", + "base": false + } + } + ], + "vnfResource": { + "modelUuid": "d326f424-2312-4dd6-b7fe-364fadbd1ef5", + "modelInvariantUuid": "23122c9b-dd7f-483f-bf0a-e069303db2f7", + "modelName": "Vf zrdm5bpxmc02092017-VF", + "toscaNodeType": "org.openecomp.resource.vf.VfZrdm5bpxmc02092017Vf", + "description": "Demo", + "orchestrationMode": "HEAT", + "modelVersion": "1.0", + "modelInvariantId": "23122c9b-dd7f-483f-bf0a-e069303db2f7" + } + } + ], + "allotedCustomizations": [], + "recipes": { + + }, + "csar": { + "artifactUUID": "396cfd49-0f4b-4fec-9f33-0fd7e90d5a22", + "name": "service-VfZrdm5bpxmc02092017Service-csar.csar", + "artifactChecksum": "MWQ3Y2FmMWExNDQyYWI2N2YwNjEwZGUzN2IzMzI3NjE=", + "url": "service-VfZrdm5bpxmc02092017Service-csar.csar", + "description": "TOSCA definition package of the asset", + "version": "1" + } +} diff --git a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/WorkflowBpmn.json b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/WorkflowBpmn.json new file mode 100644 index 0000000000..68204ac350 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/WorkflowBpmn.json @@ -0,0 +1,20 @@ +{ + "serviceName": "Vf zrdm5bpxmc02092017-Service", + "serviceInvariantUUID": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b", + "serviceUUID": "bad955c3-29b2-4a27-932e-28e942cc6480", + "serviceVersion": "1.0", + "serviceArtifacts": + [{ + "artifactName": "service-CxSvc-csar.csar", + "artifactType": "Workflow", + "artifactURL": "service-CxSvc-csar.csar", + "artifactChecksum": "MWQ3Y2FmMWExNDQyYWI2N2YwNjEwZGUzN2IzMzI3NjE=", + "artifactDescription": "TOSCA definition package of the asset", + "artifactTimeout": 0, + "artifactUUID": "396cfd49-0f4b-4fec-9f33-0fd7e90d5a22", + "artifactVersion": "1" + }] + , + "serviceDescription": "Demo", + "distributionID": "a2872f55-8628-4486-8548-7b132c9a47db" +}
\ No newline at end of file diff --git a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-CxSvc-csar.csar b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-CxSvc-csar.csar Binary files differnew file mode 100644 index 0000000000..9add57f1dd --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-CxSvc-csar.csar diff --git a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-VfZrdm5bpxmc02092017Service-csar.csar b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-VfZrdm5bpxmc02092017Service-csar.csar Binary files differnew file mode 100644 index 0000000000..69b1c23404 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-VfZrdm5bpxmc02092017Service-csar.csar diff --git a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/testStructure.json b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/testStructure.json new file mode 100644 index 0000000000..db95690064 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/testStructure.json @@ -0,0 +1,20 @@ +{ + "distributionID": "a2872f55-8628-4486-8548-7b132c9a47db", + "serviceName": "Service-CxSvc", + "serviceVersion": "1.0", + "serviceUUID": "bad955c3-29b2-4a27-932e-28e942cc6480", + "serviceInvariantUUID": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b", + "serviceDescription": "Demo", + "serviceArtifacts": [ + { + "artifactName": "service-CxSvc-csar.csar", + "artifactVersion": "1", + "artifactType": "Workflows", + "artifactDescription": "Workflows Container", + "artifactTimeout": "0", + "artifactURL": "service-CxSvc-csar.csar", + "artifactUUID": "396cfd49-0f4b-4fec-9f33-0fd7e90d5a22", + "artifactChecksum": "MWQ3Y2FmMWExNDQyYWI2N2YwNjEwZGUzN2IzMzI3NjE=" + } + ] +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index 1e2a703e70..0692e5022a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -755,8 +755,6 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess public void setBasicDBAuthHeader(DelegateExecution execution, isDebugLogEnabled) { try { String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution) - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) - def encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution)) execution.setVariable("BasicAuthHeaderValueDB",encodedString) } catch (IOException ex) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java index c3511e69a4..78f3e96978 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java @@ -20,13 +20,14 @@ package org.onap.so.bpmn.common.baseclient; +import org.onap.so.logging.jaxrs.filter.SpringClientFilter; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; @@ -59,11 +60,12 @@ public class BaseClient<I,O> { public O post(I data, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { return run(data, HttpMethod.POST, typeRef, uriVariables); } - + public O run(I data, HttpMethod method, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { HttpEntity<I> requestEntity = new HttpEntity<I>(data, getHttpHeader()); RestTemplate restTemplate = new RestTemplate(); - restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory())); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); + restTemplate.getInterceptors().add(new SpringClientFilter()); ResponseEntity<O> responseEntity = restTemplate.exchange(getTargetUrl(), method, requestEntity, typeRef, uriVariables); return responseEntity.getBody(); diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn index 67bd961844..63c867f3c7 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_EsMs0HcuEeW2U_kkOHX1ZQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_EsMs0HcuEeW2U_kkOHX1ZQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="CompleteMsoProcess" name="CompleteMsoProcess" isExecutable="true"> <bpmn2:scriptTask id="preProcessRequest" name="Pre-Process Request" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> @@ -56,6 +56,7 @@ completeMsoProcess.setUpdateDBstatustoSuccessPayload(execution)]]></bpmn2:script <camunda:map> <camunda:entry key="content-type">application/soap+xml</camunda:entry> <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + <camunda:entry key="X-ONAP-RequestID">#{CMSO_request_id}</camunda:entry> </camunda:map> </camunda:inputParameter> <camunda:inputParameter name="method">POST</camunda:inputParameter> @@ -88,7 +89,7 @@ buildDataErrorMessage.buildDataError(execution, "Complete MSO -- Update DB stat <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="ExclusiveGateway_7" targetRef="BuildErrorMessage" /> <bpmn2:boundaryEvent id="BoundaryEvent_7" name="" attachedToRef="updateInfraRequest"> <bpmn2:outgoing>SequenceFlow_0mipf25</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_84" errorRef="Error_1" /> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_84" errorRef="Error_1" camunda:errorCodeVariable="gJavaErrorCode" camunda:errorMessageVariable="gJavaErrorMessage" /> </bpmn2:boundaryEvent> <bpmn2:endEvent id="EndEvent_1"> <bpmn2:incoming>SequenceFlow_1pzb94j</bpmn2:incoming> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn index c59564b1e3..990863ec93 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_3SPHsLr9EeWak-hhutJWuQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_3SPHsLr9EeWak-hhutJWuQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="FalloutHandler" name="Fallout Handler" isExecutable="true"> <bpmn2:parallelGateway id="ParallelGateway_1"> <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> @@ -139,6 +139,7 @@ falloutHandler.buildDBWorkflowException(execution, "FH_updateRequestInfraRespons <camunda:map> <camunda:entry key="content-type">application/soap+xml</camunda:entry> <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + <camunda:entry key="X-ONAP-RequestID">#{FH_request_id}</camunda:entry> </camunda:map> </camunda:inputParameter> <camunda:inputParameter name="payload"> @@ -168,7 +169,7 @@ return updateRequestInfra.updateRequestInfraPayload(execution)]]></camunda:scrip </bpmn2:sequenceFlow> <bpmn2:boundaryEvent id="BoundaryEvent_3" name="Connect Fault" attachedToRef="ServiceTask_2"> <bpmn2:outgoing>SequenceFlow_80</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_90" errorRef="Error_2" /> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_90" errorRef="Error_2" camunda:errorCodeVariable="gJavaErrorCode" camunda:errorMessageVariable="gJavaErrorMessage" /> </bpmn2:boundaryEvent> <bpmn2:sequenceFlow id="SequenceFlow_80" name="" sourceRef="BoundaryEvent_3" targetRef="ScriptTask_7" /> <bpmn2:subProcess id="SubProcess_1" name="Event Handler" triggeredByEvent="true"> diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index da24ba14fd..9ea97258ef 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -31,7 +31,6 @@ import org.camunda.bpm.engine.variable.impl.VariableMapImpl; import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.logger.MsoLogger; import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; -import org.slf4j.MDC; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -46,19 +45,14 @@ public class WorkflowProcessor extends ProcessEngineAwareService { @Async public void startProcess( String processKey, VariableMapImpl variableMap) throws InterruptedException { - MDC.getCopyOfContextMap(); + long startTime = System.currentTimeMillis(); Map<String, Object> inputVariables = null; String processInstanceId = null; try { inputVariables = getInputVariables(variableMap); - setLogContext(processKey, inputVariables); - // This variable indicates that the flow was invoked asynchronously inputVariables.put("isAsyncProcess", "true"); - - - setLogContext(processKey, inputVariables); // Note: this creates a random businessKey if it wasn't specified. String businessKey = getBusinessKey(inputVariables); @@ -87,14 +81,6 @@ public class WorkflowProcessor extends ProcessEngineAwareService { } } - protected static void setLogContext(String processKey, - Map<String, Object> inputVariables) { - MsoLogger.setServiceName("MSO." + processKey); - if (inputVariables != null) { - MsoLogger.setLogContext(getKeyValueFromInputVariables(inputVariables,"mso-request-id"), getKeyValueFromInputVariables(inputVariables,"mso-service-instance-id")); - } - } - protected static String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) { if (inputVariables == null) { return ""; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 00ee6eb235..9b65cca6c9 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -70,9 +70,7 @@ import org.springframework.stereotype.Component; * Plugin for MSO logging and URN mapping. */ @Component -public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, LoggingAndURNMappingPlugin.class); - private static final String FSPROPKEY = "URNMapping.FileSystemLoading.Enabled"; +public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { @Autowired private LoggingParseListener loggingParseListener; @@ -198,7 +196,6 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { @Override public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) { - //injectLogExecutionListener(activity); } @Override @@ -216,9 +213,9 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { injectLogExecutionListener(timerActivity); } - @Override + @Override public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) { - //injectLogExecutionListener(activity); + } @Override @@ -298,17 +295,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { } @Override - public void notify(DelegateExecution execution) throws Exception { - logger.trace("Logging for activity---------------:" + event + ":" - + execution.getCurrentActivityName() - + ", processDefinitionId=" - + execution.getProcessDefinitionId() + ", activtyId=" - + execution.getCurrentActivityId() + ", activtyName='" - + execution.getCurrentActivityName() + "'" - + ", processInstanceId=" - + execution.getProcessInstanceId() + ", businessKey=" - + execution.getProcessBusinessKey() + ", executionId=" - + execution.getId()); + public void notify(DelegateExecution execution) throws Exception { //required for legacy groovy processing in camunda execution.setVariable("isDebugLogEnabled", "true"); if (!isBlank(execution.getCurrentActivityName())) { @@ -322,20 +309,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { .singleResult() .getName(); - if (execution.getBpmnModelElementInstance() instanceof StartEvent) { - logger.debug("Starting process: " + processName); - } - if (execution.getBpmnModelElementInstance() instanceof EndEvent) { - logger.debug("Ending process: " + processName); - } - - String serviceName = MDC.get(MsoLogger.SERVICE_NAME); - - if(serviceName != null && !serviceName.contains(processName)) - MsoLogger.setServiceName( serviceName + "." + processName); - else if(serviceName == null) - MsoLogger.setServiceName(processName); - + MsoLogger.setServiceName(processName); String requestId = (String) execution.getVariable("mso-request-id"); String svcid = (String) execution.getVariable("mso-service-instance-id"); MsoLogger.setLogContext(requestId, svcid); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java index db2304d6b7..efd73ba4f2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java @@ -30,6 +30,8 @@ import org.camunda.bpm.engine.ProcessEngine; import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; import org.onap.so.logger.MsoLogger; +import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -102,7 +104,7 @@ public class MSOInfrastructureApplication { @Primary public Executor asyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - + executor.setTaskDecorator(new MDCTaskDecorator()); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json new file mode 100644 index 0000000000..e031c85501 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json @@ -0,0 +1,14 @@ +{ + "name": "FlowCompleteActivity", + "description": "Activity to Complete the BPMN Flow", + "categoryList": [ + "VNF" + ], + "inputParameters": [ + { + "name": "WorkflowException", + "type": "WorkflowException" + } + ], + "outputParameters": [] +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn new file mode 100644 index 0000000000..e255689e75 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> + <bpmn:process id="FlowCompleteActivity" name="FlowCompleteActivity" isExecutable="true"> + <bpmn:startEvent id="FlowCompleteActivity_Start"> + <bpmn:outgoing>SequenceFlow_1tbhm2c</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="FlowCompleteActivity_End"> + <bpmn:incoming>SequenceFlow_10spt85</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1tbhm2c" sourceRef="FlowCompleteActivity_Start" targetRef="TaskUpdateRequestDB" /> + <bpmn:sequenceFlow id="SequenceFlow_10spt85" sourceRef="TaskUpdateRequestDB" targetRef="FlowCompleteActivity_End" /> + <bpmn:serviceTask id="TaskUpdateRequestDB" name="Update Request DB with Status" camunda:expression="${FlowCompletionTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1tbhm2c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_10spt85</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="FlowCompleteActivity"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="FlowCompleteActivity_Start"> + <dc:Bounds x="173" y="102" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0uee341_di" bpmnElement="FlowCompleteActivity_End"> + <dc:Bounds x="428" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="446" y="138" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1tbhm2c_di" bpmnElement="SequenceFlow_1tbhm2c"> + <di:waypoint xsi:type="dc:Point" x="209" y="120" /> + <di:waypoint xsi:type="dc:Point" x="264" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="237" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_10spt85_di" bpmnElement="SequenceFlow_10spt85"> + <di:waypoint xsi:type="dc:Point" x="364" y="120" /> + <di:waypoint xsi:type="dc:Point" x="394" y="120" /> + <di:waypoint xsi:type="dc:Point" x="394" y="120" /> + <di:waypoint xsi:type="dc:Point" x="428" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="409" y="120" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0f1gnqq_di" bpmnElement="TaskUpdateRequestDB"> + <dc:Bounds x="264" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn index 67ee5d0f74..344b7d8761 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="_vwRmIBsREeeIQtzUKIjH4g" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.16.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> - <bpmn2:process id="Homing" name="Homing" isExecutable="true"> + <bpmn2:process id="HomingBB" name="Homing" isExecutable="true"> <bpmn2:startEvent id="StartEvent_1"> <bpmn2:outgoing>SequenceFlow_1x9usa6</bpmn2:outgoing> </bpmn2:startEvent> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java index 8bd4aeb387..ac62af2e9d 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java @@ -63,6 +63,7 @@ import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCChangeAssignTasks; import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCDeactivateTasks; import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCQueryTasks; import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCUnassignTasks; +import org.onap.so.bpmn.infrastructure.workflow.tasks.FlowCompletionTasks; import org.onap.so.bpmn.infrastructure.workflow.tasks.OrchestrationStatusValidator; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowAction; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBTasks; @@ -199,6 +200,9 @@ public abstract class BaseBPMNTest { @MockBean protected ConfigurationScaleOut configurationScaleOut; + @MockBean + protected FlowCompletionTasks flowCompletionTasks; + @LocalServerPort private int port; diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java new file mode 100644 index 0000000000..50184a535d --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java @@ -0,0 +1,56 @@ +/*- + * ============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.bpmn.infrastructure.bpmn.subprocess; + +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doThrow; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Test; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.BaseBPMNTest; + +public class FlowCompleteActivity extends BaseBPMNTest{ + @Test + public void sunnyDayFlowCompleteActivity_Test() throws InterruptedException { + ProcessInstance pi = runtimeService.startProcessInstanceByKey("FlowCompleteActivity", variables); + assertThat(pi).isNotNull(); + assertThat(pi).isStarted().hasPassedInOrder("FlowCompleteActivity_Start", + "TaskUpdateRequestDB", + "FlowCompleteActivity_End"); + assertThat(pi).isEnded(); + } + + @Test + public void rainyDayFlowCompleteActivity_Test() throws Exception { + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(flowCompletionTasks) + .updateRequestDbStatus(any(BuildingBlockExecution.class)); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("FlowCompleteActivity", variables); + assertThat(pi).isNotNull(); + assertThat(pi).isStarted().hasPassedInOrder("FlowCompleteActivity_Start", + "TaskUpdateRequestDB").hasNotPassed( + "FlowCompleteActivity_End"); + assertThat(pi).isEnded(); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index 86c5f65e8c..dd135f3af5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -232,6 +232,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } if ("Homing_Solution".equals(userParam?.name)) { execution.setVariable("homingService", userParam.value) + execution.setVariable("callHoming", true) inputMap.put("Homing_Solution", userParam.value) } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java new file mode 100644 index 0000000000..ec2ccdf202 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.bpmn.infrastructure.workflow.tasks; + +import java.util.ArrayList; +import java.util.List; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse; +import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; +import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.serviceinstancebeans.RequestReferences; +import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class FlowCompletionTasks { + + private static final Logger logger = LoggerFactory.getLogger(FlowCompletionTasks.class); + + @Autowired + private RequestsDbClient requestDbclient; + + public void updateRequestDbStatus(BuildingBlockExecution execution) { + try { + String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId(); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + + WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); + if (workflowException == null) { + request.setStatusMessage("RequestCompletedSuccessfully"); + request.setRequestStatus("COMPLETE"); + + } + else { + request.setStatusMessage(workflowException.getErrorMessage()); + request.setRequestStatus("FAILED"); + } + request.setProgress(100L); + request.setLastModifiedBy("CamundaBPMN"); + + requestDbclient.updateInfraActiveRequests(request); + } catch (Exception e) { + logger.error("Unable to save the updated request status to the DB",e); + } + } + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index a998f6934f..2d5638c2b7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -35,6 +35,7 @@ import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; +import org.slf4j.LoggerFactory; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.Relationship; @@ -61,8 +62,6 @@ import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.Networks; @@ -71,6 +70,7 @@ import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.VfModules; import org.onap.so.serviceinstancebeans.Vnfs; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -79,6 +79,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; @Component public class WorkflowAction { + private static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage"; + private static final String SERVICE_INSTANCES = "serviceInstances"; + private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI = "WorkflowAction was unable to verify if the instance name already exist in AAI."; private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; private static final String G_ACTION = "requestAction"; private static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; @@ -100,7 +103,8 @@ public class WorkflowAction { private static final String CREATEINSTANCE = "createInstance"; private static final String USERPARAMSERVICE = "service"; private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances"; - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, WorkflowAction.class); + private static final String HOMINGSOLUTION = "Homing_Solution"; + private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @Autowired protected BBInputSetup bbInputSetup; @@ -157,6 +161,18 @@ public class WorkflowAction { execution.setVariable("resourceId", resourceId); execution.setVariable("resourceType", resourceType); + if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { + List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters() + .getUserParams(); + for (Map<String, Object> params : userParams) { + if (params.containsKey(HOMINGSOLUTION)) { + execution.setVariable("homing", true); + execution.setVariable("callHoming", true); + execution.setVariable("homingSolution", params.get(HOMINGSOLUTION)); + } + } + } + if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); @@ -239,7 +255,7 @@ public class WorkflowAction { for(WorkflowType type : WorkflowType.values()){ foundObjects = foundObjects + type + " - " + resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList()).size() + " "; } - msoLogger.info("Found " + foundObjects); + logger.info("Found {}", foundObjects); if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); @@ -247,7 +263,7 @@ public class WorkflowAction { flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceCounter, requestId, apiVersion, resourceId, resourceType, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails); if (!resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()).isEmpty()) { - msoLogger.info("Sorting for Vlan Tagging"); + logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } if (resourceType == WorkflowType.SERVICE @@ -267,9 +283,9 @@ public class WorkflowAction { throw new IllegalStateException("Macro did not come up with a valid execution path."); } - msoLogger.info("List of BuildingBlocks to execute:"); + logger.info("List of BuildingBlocks to execute:"); for (ExecuteBuildingBlock ebb : flowsToExecute) { - msoLogger.info(ebb.getBuildingBlock().getBpmnFlowName()); + logger.info(ebb.getBuildingBlock().getBpmnFlowName()); } execution.setVariable(G_CURRENT_SEQUENCE, 0); @@ -296,7 +312,7 @@ public class WorkflowAction { private void updateResourceIdsFromAAITraversal(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceCounter, List<Pair<WorkflowType, String>> aaiResourceIds) { for(Pair<WorkflowType,String> pair : aaiResourceIds){ - msoLogger.debug(pair.getValue0() + ", " + pair.getValue1()); + logger.debug(pair.getValue0() + ", " + pair.getValue1()); } Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> { @@ -389,12 +405,12 @@ public class WorkflowAction { if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) { List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); if(customizations.isEmpty()) { - msoLogger.debug("No Collections found. CollectionResourceCustomization list is empty."); + logger.debug("No Collections found. CollectionResourceCustomization list is empty."); }else{ CollectionResourceCustomization collectionResourceCustomization = findCatalogNetworkCollection(execution, service); if(collectionResourceCustomization!=null){ resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,collectionResourceCustomization.getModelCustomizationUUID(),false)); - msoLogger.debug("Found a network collection"); + logger.debug("Found a network collection"); if(collectionResourceCustomization.getCollectionResource()!=null){ if(collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null){ String toscaNodeType = collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType(); @@ -413,7 +429,7 @@ public class WorkflowAction { minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); } } - msoLogger.debug("minNetworks: " + minNetworks); + logger.debug("minNetworks: {}" , minNetworks); CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; for(CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup.getCollectionNetworkResourceCustomizations()) { if(collectionNetworkTemp.getNetworkResourceCustomization().getModelCustomizationUUID().equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) { @@ -429,21 +445,21 @@ public class WorkflowAction { } } } else { - msoLogger.debug("Instance Group tosca node type does not contain NetworkCollection: " + toscaNodeType); + logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}" , toscaNodeType); } }else{ - msoLogger.debug("No Instance Group found for network collection."); + logger.debug("No Instance Group found for network collection."); } }else{ - msoLogger.debug("No Network Collection found. collectionResource is null"); + logger.debug("No Network Collection found. collectionResource is null"); } } else { - msoLogger.debug("No Network Collection Customization found"); + logger.debug("No Network Collection Customization found"); } } if (resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()).isEmpty()) { if (service.getNetworkCustomizations() == null) { - msoLogger.debug("No networks were found on this service model"); + logger.debug("No networks were found on this service model"); } else { for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { resourceCounter.add(new Resource(WorkflowType.NETWORK,service.getNetworkCustomizations().get(i).getModelCustomizationUUID(),false)); @@ -491,7 +507,7 @@ public class WorkflowAction { } } if (serviceInstanceMSO.getCollection() != null) { - msoLogger.debug("found networkcollection"); + logger.debug("found networkcollection"); aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId())); resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,serviceInstanceMSO.getCollection().getId(),false)); } @@ -613,9 +629,10 @@ public class WorkflowAction { } } } - msoLogger.debug("found " + configurations.size() + " configurations"); + logger.debug("found {} configurations" , configurations.size() ); return configurations; } catch (Exception ex){ + logger.error("Error in finding configurations", ex); return configurations; } } @@ -649,7 +666,7 @@ public class WorkflowAction { Boolean generated = false; if (m.find()) { - msoLogger.debug("found match on " + uri + ": " + m); + logger.debug("found match on {} : {} " , uri , m); String type = m.group("type"); String id = m.group("id"); String action = m.group("action"); @@ -657,7 +674,7 @@ public class WorkflowAction { throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri); } if (action == null) { - if (type.equals("serviceInstances") && (id == null || id.equals("assign"))) { + if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) { id = UUID.randomUUID().toString(); generated = true; } @@ -727,9 +744,9 @@ public class WorkflowAction { } return generatedResourceId; } catch (Exception ex) { - msoLogger.error(ex); + logger.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex); throw new IllegalStateException( - "WorkflowAction was unable to verify if the instance name already exist in AAI."); + WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI); } } @@ -737,7 +754,7 @@ public class WorkflowAction { if (!type.matches(supportedTypes)) { return type; } else { - if (type.equals("serviceInstances")) { + if (type.equals(SERVICE_INSTANCES)) { return SERVICE; } else { return type.substring(0, 1).toUpperCase() + type.substring(1, type.length() - 1); @@ -948,20 +965,19 @@ public class WorkflowAction { } protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, msg, ex); - execution.setVariable("WorkflowActionErrorMessage", msg); + logger.error(msg, ex); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); } protected void buildAndThrowException(DelegateExecution execution, String msg) { - msoLogger.error(msg); - execution.setVariable("WorkflowActionErrorMessage", msg); + logger.error(msg); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); } public void handleRuntimeException (DelegateExecution execution){ - StringBuffer wfeExpMsg = new StringBuffer("Runtime error "); + StringBuilder wfeExpMsg = new StringBuilder("Runtime error "); String runtimeErrorMessage = null; try{ String javaExpMsg = (String) execution.getVariable("BPMN_javaExpMsg"); @@ -969,10 +985,10 @@ public class WorkflowAction { wfeExpMsg = wfeExpMsg.append(": ").append(javaExpMsg); } runtimeErrorMessage = wfeExpMsg.toString(); - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, runtimeErrorMessage, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, runtimeErrorMessage); - execution.setVariable("WorkflowActionErrorMessage", runtimeErrorMessage); + logger.error(runtimeErrorMessage); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, runtimeErrorMessage); } catch (Exception e){ + logger.error("Runtime error", e); //if runtime message was mulformed runtimeErrorMessage = "Runtime error"; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index a4b40393a3..67843a7ef9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java @@ -64,28 +64,10 @@ public class SDNCClient { STOClient.setTargetUrl(targetUrl); HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); STOClient.setHttpHeader(httpHeader); - msoLogger.info("Running SDNC CLIENT for TargetUrl: " + targetUrl); LinkedHashMap<?, ?> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); - Optional<String> sdncResponse = logSDNCResponse(output); - if(sdncResponse.isPresent()){ - msoLogger.info(sdncResponse.get()); - } - msoLogger.info("Validating output..."); return sdnCommonTasks.validateSDNResponse(output); } - protected Optional<String> logSDNCResponse(LinkedHashMap<?, ?> output) { - ObjectMapper mapper = new ObjectMapper(); - String sdncOutput = ""; - try { - sdncOutput = mapper.writeValueAsString(output); - return Optional.of(sdncOutput); - } catch (JsonProcessingException e) { - msoLogger.debug("Failed to map response from sdnc to json string for logging purposes."); - } - return Optional.empty(); - } - /** * * @param queryLink @@ -102,12 +84,9 @@ public class SDNCClient { String jsonRequest = sdnCommonTasks.buildJsonRequest(request); String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); STOClient.setTargetUrl(targetUrl); - msoLogger.info("TargetUrl: " + targetUrl); HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); STOClient.setHttpHeader(httpHeader); - msoLogger.info("Running SDNC CLIENT..."); LinkedHashMap<?, ?> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); - msoLogger.info("Validating output..."); return sdnCommonTasks.validateSDNGetResponse(output); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java new file mode 100644 index 0000000000..03ed2cb4d4 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.bpmn.infrastructure.workflow.tasks; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.junit.Before; +import org.junit.Test; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.springframework.beans.factory.annotation.Autowired; + +public class FlowCompletionTasksTest extends BaseTaskTest { + + @Autowired + protected FlowCompletionTasks flowCompletionTasks; + + @Before + public void before() { + setRequestContext(); + } + + @Test + public void updateRequestDbStatusComplete_Test() throws Exception{ + InfraActiveRequests mockedRequest = new InfraActiveRequests(); + when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); + doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); + flowCompletionTasks.updateRequestDbStatus(execution); + verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); + assertEquals(mockedRequest.getRequestStatus(), "COMPLETE"); + } + + @Test + public void updateRequestDbStatusFailed_Test() throws Exception{ + WorkflowException workflowException = new WorkflowException("testProcessKey", 7000, "Error"); + execution.setVariable("WorkflowException", workflowException); + InfraActiveRequests mockedRequest = new InfraActiveRequests(); + when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); + doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); + flowCompletionTasks.updateRequestDbStatus(execution); + verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); + assertEquals(mockedRequest.getRequestStatus(), "FAILED"); + } +} diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java index cb2839ae1f..ac4a8d1a7c 100644 --- a/common/src/main/java/org/onap/so/client/RestClientSSL.java +++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java @@ -56,7 +56,7 @@ public abstract class RestClientSSL extends RestClient { KeyStore ks = getKeyStore(); if(ks != null) { client = ClientBuilder.newBuilder().keyStore(ks, System.getProperty(RestClientSSL.SSL_KEY_STORE_PASSWORD_KEY)).build(); - logger.debug("RestClientSSL not using default SSL context - setting keystore here."); + logger.info("RestClientSSL not using default SSL context - setting keystore here."); return client; } } diff --git a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java index ad833208dc..14556f1211 100644 --- a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java +++ b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java @@ -20,8 +20,10 @@ package org.onap.so.client; +import org.onap.so.logging.jaxrs.filter.SpringClientFilter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @@ -30,6 +32,9 @@ public class RestTemplateConfig { @Bean public RestTemplate restTemplate() { - return new RestTemplate( new HttpComponentsClientHttpRequestFactory()); + RestTemplate restTemplate = new RestTemplate(); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); + restTemplate.getInterceptors().add(new SpringClientFilter()); + return restTemplate; } } diff --git a/common/src/main/java/org/onap/so/logger/LogConstants.java b/common/src/main/java/org/onap/so/logger/LogConstants.java new file mode 100644 index 0000000000..ea3c8e2c4a --- /dev/null +++ b/common/src/main/java/org/onap/so/logger/LogConstants.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 ONAP - SO + * ================================================================================ + * 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.logger; + +public class LogConstants { + public static final String TARGET_ENTITY_HEADER="X-Target-Entity"; + public static final String UNKNOWN_TARGET_ENTITY="Unknown-Target-Entity"; +} diff --git a/common/src/main/java/org/onap/so/logger/MsoLogger.java b/common/src/main/java/org/onap/so/logger/MsoLogger.java index 94ffa71169..c4fba671bb 100644 --- a/common/src/main/java/org/onap/so/logger/MsoLogger.java +++ b/common/src/main/java/org/onap/so/logger/MsoLogger.java @@ -207,30 +207,9 @@ public class MsoLogger { private MsoLogger(MsoLogger.Catalog cat, Class<?> clazz) { this.logger = LoggerFactory.getLogger(clazz); this.auditLogger = LoggerFactory.getLogger("AUDIT"); - this.metricsLogger = LoggerFactory.getLogger("METRIC"); - MsoLogger.initialization(); + this.metricsLogger = LoggerFactory.getLogger("METRIC"); setDefaultLogCatalog(cat); } - - private static synchronized void initialization() { - if (instanceUUID == null || ("").equals(instanceUUID)) { - instanceUUID = getInstanceUUID(); - } - - if (serverIP == null || serverName == null || ("").equals(serverIP) || ("").equals(serverName)) { - try { - InetAddress server = InetAddress.getLocalHost(); - serverIP = server.getHostAddress(); - serverName = server.getHostName(); - } catch (UnknownHostException e) { - initLOGGER.error("Could not get local hostname", e); - serverIP = ""; - serverName = ""; - } - } - } - - public static MsoLogger getMsoLogger(MsoLogger.Catalog cat, Class<?> clazz) { return new MsoLogger(cat,clazz); diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java index 49dc71e773..6c2a96c87d 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java @@ -64,7 +64,7 @@ public class JaxRsClientLogging implements ClientRequestFilter,ClientResponseFil private static Logger logger = LoggerFactory.getLogger(JaxRsClientLogging.class); public void setTargetService(TargetEntity targetEntity){ - MDC.put("TargetEntity", targetEntity.toString()); + MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity.toString()); } @Override @@ -90,7 +90,7 @@ public class JaxRsClientLogging implements ClientRequestFilter,ClientResponseFil MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, clientRequest.getUri().toString()); MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); setInvocationId(); - MDC.put("TargetEntity",MDC.get("TargetEntity")); + MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY,MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); } private String extractRequestID(ClientRequestContext clientRequest) { @@ -123,7 +123,7 @@ public class JaxRsClientLogging implements ClientRequestFilter,ClientResponseFil MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseContext.getStatus())); MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION,getStringFromInputStream(responseContext)); MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); - logger.info(MarkerFactory.getMarker("INVOKE_RETURN"), "InvokeReturn"); + logger.info(ONAPLogConstants.Markers.INVOKE_RETURN, "InvokeReturn"); clearClientMDCs(); } catch ( Exception e) { logger.warn("Error in outgoing JAX-RS Inteceptor", e); @@ -136,6 +136,10 @@ public class JaxRsClientLogging implements ClientRequestFilter,ClientResponseFil MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE); + MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY); + MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME); + MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME); + MDC.remove(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP); } private static String getStringFromInputStream(ClientResponseContext clientResponseContext) { diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java index 7d02136860..85a6498748 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java @@ -76,7 +76,7 @@ public class JaxRsFilterLogging implements ContainerRequestFilter,ContainerRespo mdcSetup.setClientIPAddress(httpServletRequest); mdcSetup.setInstanceUUID(); mdcSetup.setEntryTimeStamp(); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, "INPROGRESS"); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); } catch (Exception e) { logger.warn("Error in incoming JAX-RS Inteceptor", e); @@ -163,6 +163,16 @@ public class JaxRsFilterLogging implements ContainerRequestFilter,ContainerRespo MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, containerRequest.getUriInfo().getPath()); } + private void clearClientMDCs() { + MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE); + MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY); + MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME); + MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME); + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientLogResponseTest.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java index e28c465437..cc2ccb5c2e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientLogResponseTest.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java @@ -18,26 +18,25 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc; +package org.onap.so.logging.jaxrs.filter; -import static org.junit.Assert.*; +import java.util.Map; -import java.util.LinkedHashMap; -import java.util.Optional; +import org.slf4j.MDC; +import org.springframework.core.task.TaskDecorator; -import org.junit.Test; - -public class SDNCClientLogResponseTest { - - private SDNCClient sdncClient = new SDNCClient(); - - @Test - public void logSDNCResponseTest() { - LinkedHashMap<String, String> output = new LinkedHashMap<>(); - output.put("response-code", "404"); - output.put("response-message", "not found"); - Optional<String> response = sdncClient.logSDNCResponse(output); - assertEquals(true, response.isPresent()); - assertEquals("{\"response-code\":\"404\",\"response-message\":\"not found\"}",response.get()); - } -} +public class MDCTaskDecorator implements TaskDecorator { + + @Override + public Runnable decorate(Runnable runnable) { + Map<String, String> contextMap = MDC.getCopyOfContextMap(); + return () -> { + try { + MDC.setContextMap(contextMap); + runnable.run(); + } finally { + MDC.clear(); + } + }; + } +}
\ No newline at end of file diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java index 6af7a916d0..cecef1945b 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java @@ -20,8 +20,12 @@ package org.onap.so.logging.jaxrs.filter; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.logger.LogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpRequest; import org.springframework.http.client.ClientHttpRequestExecution; import org.springframework.http.client.ClientHttpRequestInterceptor; @@ -30,20 +34,31 @@ import org.springframework.util.StreamUtils; import java.io.IOException; import java.nio.charset.Charset; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.UUID; +import javax.ws.rs.core.Response; public class SpringClientFilter implements ClientHttpRequestInterceptor { private final Logger log = LoggerFactory.getLogger(this.getClass()); + + private static final String TRACE = "trace-#"; + private static final String SO = "SO"; @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { - logRequest(request, body); + processRequest(request, body); ClientHttpResponse response = execution.execute(request, body); - logResponse(response); + processResponse(response); return response; } - private void logRequest(HttpRequest request, byte[] body) throws IOException { + private void processRequest(HttpRequest request, byte[] body) throws IOException { + setupHeaders(request); + setupMDC(request); if (log.isDebugEnabled()) { log.debug("===========================request begin================================================"); log.debug("URI : {}", request.getURI()); @@ -53,8 +68,60 @@ public class SpringClientFilter implements ClientHttpRequestInterceptor { log.debug("==========================request end================================================"); } } + + private void setupHeaders(HttpRequest clientRequest) { + HttpHeaders headers = clientRequest.getHeaders(); + headers.add(ONAPLogConstants.Headers.REQUEST_ID, extractRequestID(clientRequest)); + headers.add(ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); + headers.add(ONAPLogConstants.Headers.PARTNER_NAME, SO); + } + + private String extractRequestID(HttpRequest clientRequest) { + String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID); + if(requestId == null || requestId.isEmpty() || requestId.equals(TRACE)){ + requestId = UUID.randomUUID().toString(); + log.warn("Could not Find Request ID Generating New One: {}",clientRequest.getURI()); + } + return requestId; + } + + private void setupMDC(HttpRequest clientRequest) { + MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)); + MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, clientRequest.getURI().toString()); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); + setInvocationId(); + MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY,extractTargetEntity(clientRequest)); + } + + private String extractTargetEntity(HttpRequest clientRequest) { + HttpHeaders headers = clientRequest.getHeaders(); + String headerTargetEntity = null; + List<String> headerTargetEntityList = headers.get(LogConstants.TARGET_ENTITY_HEADER); + if(headerTargetEntityList!= null && !headerTargetEntityList.isEmpty()) + headerTargetEntity = headerTargetEntityList.get(0); + String targetEntity = MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY); + if(targetEntity != null && + !targetEntity.isEmpty() ){ + return targetEntity; + }else if(headerTargetEntity != null && + !headerTargetEntity.isEmpty()){ + targetEntity = headerTargetEntity; + }else{ + targetEntity = LogConstants.UNKNOWN_TARGET_ENTITY; + log.warn("Could not Target Entity: {}",clientRequest.getURI()); + } + return targetEntity; + } + + private void setInvocationId() { + String invocationId = MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID); + if(invocationId == null || invocationId.isEmpty()) + invocationId =UUID.randomUUID().toString(); + MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); + } + - private void logResponse(ClientHttpResponse response) throws IOException { + private void processResponse(ClientHttpResponse response) throws IOException { if (log.isDebugEnabled()) { log.debug("============================response begin=========================================="); log.debug("Status code : {}", response.getStatusCode()); @@ -63,5 +130,28 @@ public class SpringClientFilter implements ClientHttpRequestInterceptor { log.debug("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset())); log.debug("=======================response end================================================="); } + String statusCode; + if(Response.Status.Family.familyOf(response.getRawStatusCode()).equals(Response.Status.Family.SUCCESSFUL)){ + statusCode=ONAPLogConstants.ResponseStatus.COMPLETED.toString(); + }else{ + statusCode=ONAPLogConstants.ResponseStatus.ERROR.toString(); + } + MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(response.getRawStatusCode())); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION,""); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); + log.info(ONAPLogConstants.Markers.INVOKE_RETURN, "InvokeReturn"); + clearClientMDCs(); + } + + private void clearClientMDCs() { + MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE); + MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY); + MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME); + MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME); + MDC.remove(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP); } } diff --git a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java b/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java index 194a445ce2..4084ad3ff0 100644 --- a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java +++ b/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java @@ -45,7 +45,7 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { Logger logger = LoggerFactory.getLogger(LoggingInterceptor.class); @Autowired - MDCSetup mdcSetup; + private MDCSetup mdcSetup; @Context private Providers providers; @@ -53,7 +53,8 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - Map<String, String> headers = Collections.list(((HttpServletRequest) request).getHeaderNames()) + + Map<String, String> headers = Collections.list((request).getHeaderNames()) .stream() .collect(Collectors.toMap(h -> h, request::getHeader)); setRequestId(headers); @@ -64,12 +65,27 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { mdcSetup.setEntryTimeStamp(); mdcSetup.setInstanceUUID(); mdcSetup.setServerFQDN(); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, "INPROGRESS"); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); + if (logger.isDebugEnabled()) + logRequestInformation(request); return true; } - @Override + protected void logRequestInformation(HttpServletRequest request) { + Map<String, String> headers = Collections.list((request).getHeaderNames()) + .stream() + .collect(Collectors.toMap(h -> h, request::getHeader)); + + logger.debug("===========================request begin================================================"); + logger.debug("URI : {}", request.getRequestURI()); + logger.debug("Method : {}", request.getMethod()); + logger.debug("Headers : {}", headers); + logger.debug("==========================request end================================================"); + + } + + @Override public void postHandle( HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { @@ -80,7 +96,7 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { MDC.clear(); } - private void setResponseStatusCode(HttpServletResponse response) { + protected void setResponseStatusCode(HttpServletResponse response) { String statusCode; if(Response.Status.Family.familyOf(response.getStatus()).equals(Response.Status.Family.SUCCESSFUL)){ statusCode=ONAPLogConstants.ResponseStatus.COMPLETED.toString(); @@ -90,26 +106,26 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); } - private void setServiceName(HttpServletRequest request) { + protected void setServiceName(HttpServletRequest request) { MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI()); } - private void setRequestId(Map<String, String> headers) { - String requestId=headers.get(ONAPLogConstants.Headers.REQUEST_ID); + protected void setRequestId(Map<String, String> headers) { + String requestId=headers.get(ONAPLogConstants.Headers.REQUEST_ID.toLowerCase()); if(requestId == null || requestId.isEmpty()) - requestId = UUID.randomUUID().toString(); + requestId = UUID.randomUUID().toString(); MDC.put(ONAPLogConstants.MDCs.REQUEST_ID,requestId); } - private void setInvocationId(Map<String, String> headers) { - String invocationId = headers.get(ONAPLogConstants.Headers.INVOCATION_ID); + protected void setInvocationId(Map<String, String> headers) { + String invocationId = headers.get(ONAPLogConstants.Headers.INVOCATION_ID.toLowerCase()); if(invocationId == null || invocationId.isEmpty()) invocationId =UUID.randomUUID().toString(); MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); } - private void setMDCPartnerName(Map<String, String> headers) { - String partnerName=headers.get(ONAPLogConstants.Headers.PARTNER_NAME); + protected void setMDCPartnerName(Map<String, String> headers) { + String partnerName=headers.get(ONAPLogConstants.Headers.PARTNER_NAME.toLowerCase()); if(partnerName == null || partnerName.isEmpty()) partnerName = ""; MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME,partnerName); diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java index e9062effad..3ebad8b02c 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java @@ -24,6 +24,7 @@ package org.onap.so.apihandler.common; import java.io.IOException; +import java.util.UUID; import javax.xml.bind.DatatypeConverter; @@ -32,6 +33,7 @@ import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandler.camundabeans.CamundaBooleanInput; import org.onap.so.apihandler.camundabeans.CamundaInput; import org.onap.so.apihandler.camundabeans.CamundaIntegerInput; @@ -39,6 +41,7 @@ import org.onap.so.apihandler.camundabeans.CamundaRequest; import org.onap.so.apihandler.camundabeans.CamundaVIDRequest; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.MDC; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -63,6 +66,22 @@ public class CamundaClient extends RequestClient{ StringEntity input = new StringEntity(jsonReq); input.setContentType(CommonConstants.CONTENT_TYPE_JSON); msoLogger.info("Camunda Request Content: " + jsonReq); + + + post.setEntity(input); + setupHeaders(post); + + HttpResponse response = client.execute(post); + msoLogger.debug("Response is: " + response); + + return response; + } + + + private void setupHeaders(HttpPost post) { + post.addHeader(ONAPLogConstants.Headers.REQUEST_ID, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); + post.addHeader(ONAPLogConstants.Headers.INVOCATION_ID, UUID.randomUUID().toString()); + String encryptedCredentials = null; if(props!=null){ encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH); @@ -73,12 +92,6 @@ public class CamundaClient extends RequestClient{ } } } - - post.setEntity(input); - HttpResponse response = client.execute(post); - msoLogger.debug("Response is: " + response); - - return response; } @Override @@ -86,10 +99,10 @@ public class CamundaClient extends RequestClient{ throws ClientProtocolException, IOException{ HttpPost post = new HttpPost(url); msoLogger.debug(CAMUNDA_URL_MESAGE + url); - //String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion); StringEntity input = new StringEntity(jsonReq); input.setContentType(CommonConstants.CONTENT_TYPE_JSON); + setupHeaders(post); String encryptedCredentials = null; if(props!=null){ @@ -102,6 +115,7 @@ public class CamundaClient extends RequestClient{ } } + post.setEntity(input); HttpResponse response = client.execute(post); msoLogger.debug("Response is: " + response); @@ -120,6 +134,9 @@ public class CamundaClient extends RequestClient{ StringEntity input = new StringEntity(jsonReq); input.setContentType(CommonConstants.CONTENT_TYPE_JSON); + + setupHeaders(post); + String encryptedCredentials = null; if(props!=null){ encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java index afe55a23a7..f3f98f3f2a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java @@ -22,17 +22,19 @@ package org.onap.so.apihandlerinfra; import java.util.concurrent.Executor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; @SpringBootApplication(scanBasePackages = { "org.onap"}) @EnableAsync public class ApiHandlerApplication { - + @Value("${mso.async.core-pool-size}") private int corePoolSize; @@ -64,6 +66,7 @@ public class ApiHandlerApplication { executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); executor.setThreadNamePrefix("mso-apihandler-infra-"); + executor.setTaskDecorator(new MDCTaskDecorator()); executor.initialize(); return executor; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java index 2427dd2734..7ad7e6626d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java @@ -35,6 +35,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.scheduling.annotation.Async; @@ -61,6 +62,7 @@ public class TenantIsolationRunnable { @Async public void run(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws ApiException { + msoLogger.debug ("Starting threadExecution in TenantIsolationRunnable for Action " + action.name() + " and OperationalEnvType: " + operationalEnvType); try { diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java index eec68d8079..f4fede15e1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java @@ -107,7 +107,7 @@ public class ManualTasksTest extends BaseTest{ for(ILoggingEvent logEvent : TestAppender.events) if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && - logEvent.getMarker().getName().equals("ENTRY") + logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY") ){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); @@ -117,7 +117,7 @@ public class ManualTasksTest extends BaseTest{ assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME)); assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE)); }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && - logEvent.getMarker().getName().equals("EXIT")){ + logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); assertNotNull(mdc.get(MsoLogger.ENDTIME)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index f726194fb7..464d5e6bba 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -197,7 +197,7 @@ public class ServiceInstancesTest extends BaseTest{ for(ILoggingEvent logEvent : TestAppender.events) if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && - logEvent.getMarker().getName().equals("ENTRY") + logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY") ){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); @@ -207,7 +207,7 @@ public class ServiceInstancesTest extends BaseTest{ assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME)); assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE)); }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && - logEvent.getMarker().getName().equals("EXIT")){ + logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); assertNotNull(mdc.get(MsoLogger.ENDTIME)); diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index e29d88cb89..84e4156efa 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -27,6 +27,7 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkRecipe; @@ -47,6 +48,7 @@ import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; +import org.onap.so.logger.LogConstants; import org.onap.so.logging.jaxrs.filter.SpringClientFilter; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; @@ -118,6 +120,8 @@ public class CatalogDbClient { private static final String WORK_STEP = "workStep"; private static final String CLLI = "clli"; private static final String CLOUD_VERSION = "cloudVersion"; + + private static final String TARGET_ENTITY = "SO:CatalogDB"; private String findFirstByModelNameURI = "/findFirstByModelNameOrderByModelVersionDesc"; private String findFirstByServiceModelUUIDAndActionURI = "/findFirstByServiceModelUUIDAndAction"; @@ -255,6 +259,7 @@ public class CatalogDbClient { restTemplate.getInterceptors().add((request, body, execution) -> { request.getHeaders().add(HttpHeaders.AUTHORIZATION, msoAdaptersAuth); + request.getHeaders().add(LogConstants.TARGET_ENTITY_HEADER,TARGET_ENTITY); return execution.execute(request, body); }); }).build().buildClientFactory(); diff --git a/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml index 5c8894300f..89482fdcda 100644 --- a/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml +++ b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml @@ -10,32 +10,36 @@ language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> <configuration scan="true" debug="false"> - <contextListener class="org.onap.so.logger.LoggerStartupListener" /> - <include resource="org/springframework/boot/logging/logback/base.xml" /> + <contextListener class="org.onap.so.logger.LoggerStartupListener" /> + <include resource="org/springframework/boot/logging/logback/defaults.xml" /> - <property name="queueSize" value="256" /> - <property name="maxFileSize" value="200MB" /> - <property name="maxHistory" value="30" /> - <property name="totalSizeCap" value="10GB" /> + <property name="queueSize" value="256" /> + <property name="maxFileSize" value="200MB" /> + <property name="maxHistory" value="30" /> + <property name="totalSizeCap" value="10GB" /> - <!-- log file names --> - <property name="errorLogName" value="error" /> - <property name="metricsLogName" value="metrics" /> - <property name="auditLogName" value="audit" /> - <property name="debugLogName" value="debug" /> - <property name="saneLogName" value="sane" /> + <!-- log file names --> + <property name="errorLogName" value="error" /> + <property name="metricsLogName" value="metrics" /> + <property name="auditLogName" value="audit" /> + <property name="debugLogName" value="debug" /> + + <property name="currentTimeStamp" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX",UTC}"/> - <property name="errorPattern" - value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode}|%X{ErrorDesc}|%msg%n" /> + <property name="errorPattern" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode}|%X{ErrorDesc}|%msg%n" /> - <property name="auditPattern" - value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||||||%msg%n" /> + <property name="debugPattern" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}| %logger{50} - %msg%n" /> - <property name="metricPattern" - value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|||||%msg%n" /> + <property name="auditPattern" + value="%X{EntryTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||||||%msg%n" /> - <property name="defaultPattern" - value="%nopexception%logger + <property name="metricPattern" + value="%X{InvokeTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|||||%msg%n" /> + + <property name="defaultPattern" + value="%nopexception%logger \t%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} \t%level \t%replace(%replace(%message){'\t','\\\\t'}){'\n','\\\\n'} @@ -45,123 +49,151 @@ \t%thread \t%n" /> - <appender name="Audit" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logs_dir:-.}/${auditLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${auditPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncAudit" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Audit" /> - </appender> - - <appender name="Metric" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logs_dir:-.}/${metricsLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${metricPattern}</pattern> - </encoder> - </appender> - - - <appender name="asyncMetric" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Metric" /> - </appender> - - <appender name="Error" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>ERROR</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <file>${logs_dir:-.}/${errorLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${errorPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncError" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Error" /> - </appender> - - <appender name="Debug" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logs_dir:-.}/${debugLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncDebug" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Debug" /> - <includeCallerData>true</includeCallerData> - </appender> - - <!-- Spring related loggers --> - <logger name="org.springframework" level="WARN" /> - - <!-- Camunda related loggers --> - <logger name="org.camunda.bpm.engine.jobexecutor.level" level="WARN" /> - <logger - name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level" - level="WARN" /> - - <logger name="db.migration" level="DEBUG" /> - <logger name="org.apache.wire" level="DEBUG" /> - <logger name="org.onap" level="DEBUG" /> - <logger name="com.att.ecomp" level="DEBUG" /> - <logger name="org.apache.cxf" level="INFO" /> - - <logger name="AUDIT" level="INFO" additivity="false"> - <appender-ref ref="asyncAudit" /> - </logger> - - <logger name="METRIC" level="INFO" additivity="false"> - <appender-ref ref="asyncMetric" /> - </logger> - - <root level="WARN"> - <appender-ref ref="asyncDebug" /> - <appender-ref ref="asyncError" /> - </root> - -</configuration> + <appender name="Audit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>EXIT</marker> + </evaluator> + <onMismatch>DENY</onMismatch> + <onMatch>ACCEPT</onMatch> + </filter> + <file>${logs_dir:-.}/${auditLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${auditPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncAudit" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Audit" /> + </appender> + + <appender name="Metric" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>INVOKE_RETURN</marker> + </evaluator> + <onMismatch>DENY</onMismatch> + <onMatch>ACCEPT</onMatch> + </filter> + <file>${logs_dir:-.}/${metricsLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${metricPattern}</pattern> + </encoder> + </appender> + + + <appender name="asyncMetric" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Metric" /> + </appender> + + <appender name="Error" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <level>ERROR</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + <file>${logs_dir:-.}/${errorLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${errorPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncError" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Error" /> + </appender> + + <appender name="Debug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>INVOKE</marker> + <marker>INVOKE_RETURN</marker> + <marker>ENTRY</marker> + <marker>EXIT</marker> + </evaluator> + <onMismatch>ACCEPT</onMismatch> + <onMatch>DENY</onMatch> + </filter> + <file>${logs_dir:-.}/${debugLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${debugPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncDebug" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Debug" /> + <includeCallerData>true</includeCallerData> + </appender> + + <!-- Spring related loggers --> + <logger name="org.springframework" level="WARN" /> + <logger + name="org.springframework.security.authentication.dao.DaoAuthenticationProvider" + level="DEBUG" /> + + <!-- Camunda related loggers --> + <logger name="org.camunda.bpm.engine.jobexecutor.level" level="WARN" /> + <logger + name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level" + level="WARN" /> + + <logger name="org.apache.wire" level="DEBUG" /> + <logger name="org.onap" level="DEBUG" /> + <logger name="com.att.ecomp" level="DEBUG" /> + <logger name="org.apache.cxf.interceptor" level="DEBUG" /> + + <logger name="AUDIT" level="INFO" additivity="false"> + <appender-ref ref="asyncAudit" /> + </logger> + + <logger name="METRIC" level="INFO" additivity="false"> + <appender-ref ref="asyncMetric" /> + </logger> + + <root level="WARN"> + <appender-ref ref="asyncDebug" /> + <appender-ref ref="asyncError" /> + <appender-ref ref="asyncAudit" /> + <appender-ref ref="asyncMetric" /> + </root> + +</configuration>
\ No newline at end of file diff --git a/packages/docker/src/main/docker/docker-files/scripts/start-jboss-server.sh b/packages/docker/src/main/docker/docker-files/scripts/start-jboss-server.sh deleted file mode 100755 index 1a38fff899..0000000000 --- a/packages/docker/src/main/docker/docker-files/scripts/start-jboss-server.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# Copyright 2015 AT&T Intellectual Properties -############################################################################## -# Script to initialize the chef-repo branch and.chef -# -############################################################################## -# Copy the certificates -echo 'Copying the *.crt provided in /shared folder' -cp --verbose /shared/*.crt /usr/local/share/ca-certificates -update-ca-certificates --fresh - -echo 'Running in JBOSS' -su - jboss - -#Start the chef-solo if mso-docker.json contains some data. -if [ -s /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json ] -then - echo "mso-docker.json has some configuration, replay the recipes." - chef-solo -c /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -o recipe[mso-config::apih],recipe[mso-config::bpmn],recipe[mso-config::jra] -else - echo "mso-docker.json is empty, do not replay the recipes." -fi - -JBOSS_PIDFILE=/tmp/jboss-standalone.pid -$JBOSS_HOME/bin/standalone.sh -c standalone-full-ha-mso.xml & -JBOSS_PID=$! -# Trap common signals and relay them to the jboss process -trap "kill -HUP $JBOSS_PID" HUP -trap "kill -TERM $JBOSS_PID" INT -trap "kill -QUIT $JBOSS_PID" QUIT -trap "kill -PIPE $JBOSS_PID" PIPE -trap "kill -TERM $JBOSS_PID" TERM -if [ "x$JBOSS_PIDFILE" != "x" ]; then - echo $JBOSS_PID > $JBOSS_PIDFILE -fi -# Wait until the background process exits -WAIT_STATUS=128 -while [ "$WAIT_STATUS" -ge 128 ]; do - wait $JBOSS_PID 2>/dev/null - WAIT_STATUS=$? - if [ "$WAIT_STATUS" -gt 128 ]; then - SIGNAL=`expr $WAIT_STATUS - 128` - SIGNAL_NAME=`kill -l $SIGNAL` - echo "*** JBossAS process ($JBOSS_PID) received $SIGNAL_NAME signal ***" >&2 - fi -done -if [ "$WAIT_STATUS" -lt 127 ]; then - JBOSS_STATUS=$WAIT_STATUS -else - JBOSS_STATUS=0 -fi -if [ "$JBOSS_STATUS" -ne 10 ]; then - # Wait for a complete shudown - wait $JBOSS_PID 2>/dev/null -fi -if [ "x$JBOSS_PIDFILE" != "x" ]; then - grep "$JBOSS_PID" $JBOSS_PIDFILE && rm $JBOSS_PIDFILE -fi |