diff options
510 files changed, 46747 insertions, 9865 deletions
diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml index 8359fd3829..6ed9afcc75 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml @@ -105,5 +105,10 @@ <artifactId>junit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-pkgm-adapter</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> </project> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/SdcPackageProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/EtsiPackageProvider.java index 497de2874c..c5164c1833 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/SdcPackageProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/EtsiPackageProvider.java @@ -24,38 +24,25 @@ package org.onap.so.adapters.etsisol003adapter.lcm.extclients; import static com.google.common.base.Splitter.on; import static com.google.common.collect.Iterables.filter; -import static com.google.common.io.ByteStreams.toByteArray; -import static java.lang.String.format; -import static org.apache.http.HttpHeaders.ACCEPT; -import static org.apache.http.HttpHeaders.AUTHORIZATION; import static org.onap.so.adapters.etsisol003adapter.lcm.NvfmAdapterUtils.abortOperation; import static org.onap.so.adapters.etsisol003adapter.lcm.NvfmAdapterUtils.child; import static org.onap.so.adapters.etsisol003adapter.lcm.NvfmAdapterUtils.childElement; import static org.onap.so.adapters.etsisol003adapter.lcm.NvfmAdapterUtils.children; import static org.slf4j.LoggerFactory.getLogger; -import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.nio.charset.StandardCharsets; import java.util.HashSet; -import java.util.Iterator; -import java.util.List; import java.util.NoSuchElementException; +import java.util.Optional; import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import javax.net.ssl.SSLContext; -import org.apache.commons.codec.binary.Base64; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.onap.so.utils.CryptoUtils; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.EtsiCatalogServiceProviderImpl; +import org.onap.so.adapters.etsisol003adapter.pkgm.rest.exceptions.EtsiCatalogManagerRequestFailureException; import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.yaml.snakeyaml.Yaml; import com.google.common.io.ByteStreams; @@ -63,21 +50,13 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; @Component -public class SdcPackageProvider { - private static final String GET_PACKAGE_URL = "%s/sdc/v1/catalog/resources/%s/toscaModel"; - @Value("${sdc.toscametapath:TOSCA-Metadata/TOSCA.meta}") - private List<String> toscaMetaPaths; +public class EtsiPackageProvider { + private static final String TOCSA_METADATA_FILE_PATH = "TOSCA-Metadata/TOSCA.meta"; private static final String TOSCA_VNFD_KEY = "Entry-Definitions"; - private static Logger logger = getLogger(SdcPackageProvider.class); + private static Logger logger = getLogger(EtsiPackageProvider.class); - @Value("${sdc.username}") - private String sdcUsername; - @Value("${sdc.password}") - private String sdcPassword; - @Value("${sdc.key}") - private String sdcKey; - @Value("${sdc.endpoint}") - private String baseUrl; + @Autowired + private EtsiCatalogServiceProviderImpl etsiCatalogServiceProviderImpl; public String getVnfdId(final String csarId) { return getVnfNodeProperty(csarId, "descriptor_id"); @@ -133,35 +112,25 @@ public class SdcPackageProvider { } private byte[] getPackage(final String csarId) { - final String SERVICE_NAME = "vnfm-adapter"; - try (CloseableHttpClient client = HttpClients.custom().setSSLContext(SSLContext.getDefault()).build()) { - final HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId)); - httpget.setHeader(ACCEPT, APPLICATION_OCTET_STREAM_VALUE); - httpget.setHeader("X-ECOMP-InstanceID", SERVICE_NAME); - httpget.setHeader("X-FromAppId", SERVICE_NAME); - final String auth = sdcUsername + ":" + CryptoUtils.decrypt(sdcPassword, sdcKey); - final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); - final String authHeader = "Basic " + new String(encodedAuth); - httpget.setHeader(AUTHORIZATION, authHeader); - logger.debug("Fetching from SDC: " + httpget); - final CloseableHttpResponse response = client.execute(httpget); - final HttpEntity entity = response.getEntity(); - final InputStream is = entity.getContent(); - return toByteArray(is); - } catch (final Exception e) { - throw abortOperation("Unable to download " + csarId + " package from SDC", e); + try { + final Optional<byte[]> optional = etsiCatalogServiceProviderImpl.getVnfPackageContent(csarId); + if (optional.isPresent()) { + return optional.get(); + } + } catch (final Exception exception) { + logger.error("Unable to retrieve package from ETSI Catalog Manager using pkgId: {}", csarId); + throw new EtsiCatalogManagerRequestFailureException("Value is not present", exception); } + logger.error("Unable to retrieve package from ETSI Catalog Manager using pkgId: {}", csarId); + throw new EtsiCatalogManagerRequestFailureException("Value is not present"); } private String getVnfdLocation(final InputStream stream) throws IOException { - final Iterator<String> pathIterator = toscaMetaPaths.iterator(); - while (pathIterator.hasNext()) { - final String toscaMetadata = new String(getFileInZip(stream, pathIterator.next()).toByteArray()); - if (!toscaMetadata.isEmpty()) { - final String toscaVnfdLine = - filter(on("\n").split(toscaMetadata), line -> line.contains(TOSCA_VNFD_KEY)).iterator().next(); - return toscaVnfdLine.replace(TOSCA_VNFD_KEY + ":", "").trim(); - } + final String toscaMetadata = new String(getFileInZip(stream, TOCSA_METADATA_FILE_PATH).toByteArray()); + if (!toscaMetadata.isEmpty()) { + final String toscaVnfdLine = + filter(on("\n").split(toscaMetadata), line -> line.contains(TOSCA_VNFD_KEY)).iterator().next(); + return toscaVnfdLine.replace(TOSCA_VNFD_KEY + ":", "").trim(); } throw abortOperation("Unable to find valid Tosca Path"); } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmRestTemplateConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmRestTemplateConfiguration.java new file mode 100644 index 0000000000..2c7ddd1d49 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmRestTemplateConfiguration.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm; + +import org.onap.logging.filter.spring.SpringClientPayloadFilter; +import org.onap.so.configuration.rest.HttpComponentsClientConfiguration; +import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +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; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Configuration +public class VnfmRestTemplateConfiguration { + + public static final String SOL003_LCM_REST_TEMPLATE = "Sol003LcmRestTemplate"; + + @Autowired + private HttpComponentsClientConfiguration httpComponentsClientConfiguration; + + @Bean + @Qualifier(SOL003_LCM_REST_TEMPLATE) + public RestTemplate sol003LcmRestTemplate() { + final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = + httpComponentsClientConfiguration.httpComponentsClientHttpRequestFactory(); + final RestTemplate restTemplate = + new RestTemplate(new BufferingClientHttpRequestFactory(clientHttpRequestFactory)); + restTemplate.getInterceptors().add(new SOSpringClientFilter()); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); + return restTemplate; + } +} diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java index da727b395a..1ed3ec9ff2 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java @@ -20,7 +20,6 @@ package org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStore; @@ -83,7 +82,7 @@ public class VnfmServiceProviderConfiguration extends AbstractServiceProviderCon @Value("${vnfmadapter.temp.vnfm.oauth.endpoint:#{null}}") private String oauthEndpoint; - @Qualifier(CONFIGURABLE_REST_TEMPLATE) + @Qualifier(VnfmRestTemplateConfiguration.SOL003_LCM_REST_TEMPLATE) @Autowired private RestTemplate defaultRestTemplate; diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java index 8ba56c5051..a2af1a4580 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java @@ -24,7 +24,7 @@ import java.util.Map; import org.onap.aai.domain.yang.EsrVnfm; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Relationship; -import org.onap.so.adapters.etsisol003adapter.lcm.extclients.SdcPackageProvider; +import org.onap.so.adapters.etsisol003adapter.lcm.extclients.EtsiPackageProvider; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.aai.AaiHelper; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.aai.AaiServiceProvider; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.aai.OamIpAddressSource; @@ -48,6 +48,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.google.common.base.Optional; +import static org.apache.commons.lang3.StringUtils.isNotBlank; /** * Manages lifecycle operations towards the VNFMs. @@ -60,12 +61,12 @@ public class LifecycleManager { private final AaiHelper aaiHelper; private final VnfmHelper vnfmHelper; private final JobManager jobManager; - private final SdcPackageProvider packageProvider; + private final EtsiPackageProvider packageProvider; @Autowired LifecycleManager(final AaiServiceProvider aaiServiceProvider, final AaiHelper aaiHelper, final VnfmHelper vnfmHelper, final VnfmServiceProvider vnfmServiceProvider, final JobManager jobManager, - final SdcPackageProvider packageProvider) { + final EtsiPackageProvider packageProvider) { this.aaiServiceProvider = aaiServiceProvider; this.vnfmServiceProvider = vnfmServiceProvider; this.aaiHelper = aaiHelper; @@ -152,15 +153,16 @@ public class LifecycleManager { } } - private InlineResponse201 sendCreateRequestToVnfm(final CreateVnfRequest aaiRequest, final GenericVnf genericVnf, - final String vnfIdInAai, final EsrVnfm vnfm) { - logger.debug("Sending a create request to SVNFM " + aaiRequest); + private InlineResponse201 sendCreateRequestToVnfm(final CreateVnfRequest createVnfRequest, + final GenericVnf genericVnf, final String vnfIdInAai, final EsrVnfm vnfm) { + logger.debug("Sending a create request to SVNFM {}", createVnfRequest); final org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.model.CreateVnfRequest vnfmRequest = new org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.model.CreateVnfRequest(); - final String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId()); + final String pkgId = getPackageId(createVnfRequest, genericVnf); + final String vnfdId = packageProvider.getVnfdId(pkgId); vnfmRequest.setVnfdId(vnfdId); - vnfmRequest.setVnfInstanceName(aaiRequest.getName().replaceAll(" ", "_")); + vnfmRequest.setVnfInstanceName(createVnfRequest.getName().replaceAll(" ", "_")); vnfmRequest.setVnfInstanceDescription(vnfIdInAai); final Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfm, vnfmRequest); @@ -174,6 +176,15 @@ public class LifecycleManager { } } + private String getPackageId(final CreateVnfRequest createVnfRequest, final GenericVnf genericVnf) { + if (isNotBlank(createVnfRequest.getPkgId())) { + logger.info("Found createVnfRequest pkgId: {}", createVnfRequest.getPkgId()); + return createVnfRequest.getPkgId(); + } + logger.info("Found genericVnf modelVersionId: {}", genericVnf.getModelVersionId()); + return genericVnf.getModelVersionId(); + } + private void createNotificationSubscription(final EsrVnfm vnfm, final String vnfId) { try { final LccnSubscriptionRequest subscriptionRequest = vnfmHelper.createNotificationSubscriptionRequest(vnfId); diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/EtsiSol003AdapterControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/EtsiSol003AdapterControllerTest.java index eaf40b546f..9aed675324 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/EtsiSol003AdapterControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/EtsiSol003AdapterControllerTest.java @@ -27,7 +27,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; +import org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.VnfmRestTemplateConfiguration; import static org.springframework.test.web.client.match.MockRestRequestMatchers.content; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest; @@ -54,7 +54,8 @@ import org.onap.aai.domain.yang.RelationshipList; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAIVersion; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.so.adapters.etsisol003adapter.lcm.extclients.SdcPackageProvider; +import org.onap.so.adapters.etsisol003adapter.lcm.extclients.EtsiPackageProvider; +import org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.VnfmRestTemplateConfiguration; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.model.InlineResponse200; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.model.InlineResponse2001; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.model.InlineResponse201; @@ -106,7 +107,7 @@ public class EtsiSol003AdapterControllerTest { @LocalServerPort private int port; @Autowired - @Qualifier(CONFIGURABLE_REST_TEMPLATE) + @Qualifier(VnfmRestTemplateConfiguration.SOL003_LCM_REST_TEMPLATE) private RestTemplate testRestTemplate; private MockRestServiceServer mockRestServer; @@ -114,7 +115,7 @@ public class EtsiSol003AdapterControllerTest { AAIResourcesClient aaiResourcesClient; @MockBean - SdcPackageProvider sdcPackageProvider; + EtsiPackageProvider etsiPackageProvider; @Autowired EtsiSol003AdapterController controller; diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003LcnControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003LcnControllerTest.java index ab6ae83896..86eda0abfa 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003LcnControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003LcnControllerTest.java @@ -26,7 +26,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; +import org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.VnfmRestTemplateConfiguration; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; @@ -99,7 +99,7 @@ public class Sol003LcnControllerTest { @LocalServerPort private int port; @Autowired - @Qualifier(CONFIGURABLE_REST_TEMPLATE) + @Qualifier(VnfmRestTemplateConfiguration.SOL003_LCM_REST_TEMPLATE) private RestTemplate testRestTemplate; private MockRestServiceServer mockRestServer; diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/etsisol003adapter.yaml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/etsisol003adapter.yaml index 9d0a5283af..578708ded8 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/etsisol003adapter.yaml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/etsisol003adapter.yaml @@ -168,6 +168,9 @@ definitions: description: The name to be applied to the VNF. tenant: $ref: '#/definitions/Tenant' + pkgId: + type: string + description: An identifier for the vnf package. additionalParams: type: object description: >- @@ -519,4 +522,4 @@ definitions: description: > Type of the resource in the scope of the VIM or the resource provider. - type: string
\ No newline at end of file + type: string diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/rest/exceptions/EtsiCatalogManagerRequestFailureException.java b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/rest/exceptions/EtsiCatalogManagerRequestFailureException.java index a07732f3fa..110826a6d3 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/rest/exceptions/EtsiCatalogManagerRequestFailureException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/rest/exceptions/EtsiCatalogManagerRequestFailureException.java @@ -36,6 +36,10 @@ public class EtsiCatalogManagerRequestFailureException extends RuntimeException super(message); } + public EtsiCatalogManagerRequestFailureException(final String message, final Throwable cause) { + super(message, cause); + } + @Override public synchronized Throwable fillInStackTrace() { return this; diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index 6346983f96..2453c18f1a 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -103,11 +103,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.onap.so</groupId> - <artifactId>cloudify-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java index 59c6becfbd..ab0239057a 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java @@ -89,4 +89,32 @@ public final class AuthenticationMethodFactory { v3Auth.setScope(scope); return v3Auth; } + + public final com.woorea.openstack.keystone.v3.model.Authentication getAuthenticationForV3ByName( + CloudIdentity cloudIdentity, String name) { + Identity identity = new Identity(); + Password password = new Password(); + User user = new User(); + Domain userDomain = new Domain(); + Scope scope = new Scope(); + Project project = new Project(); + Project.Domain projectDomain = new Project.Domain(); + userDomain.setName(cloudIdentity.getUserDomainName()); + projectDomain.setName(cloudIdentity.getProjectDomainName()); + user.setName(cloudIdentity.getMsoId()); + user.setPassword(CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass())); + user.setDomain(userDomain); + password.setUser(user); + project.setDomain(projectDomain); + project.setName(name); + scope.setProject(project); + identity.setPassword(password); + identity.setMethods(Collections.singletonList("password")); + com.woorea.openstack.keystone.v3.model.Authentication v3Auth = + new com.woorea.openstack.keystone.v3.model.Authentication(); + v3Auth.setIdentity(identity); + v3Auth.setScope(scope); + return v3Auth; + } + } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java index 16906957a7..3564b8f0a7 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java @@ -107,7 +107,7 @@ public class KeystoneV3Authentication { return policy; } - protected String findEndpointURL(List<Service> serviceCatalog, String type, String region, String facing) { + public String findEndpointURL(List<Service> serviceCatalog, String type, String region, String facing) { for (Service service : serviceCatalog) { if (type.equals(service.getType())) { for (Service.Endpoint endpoint : service.getEndpoints()) { diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java deleted file mode 100644 index 42b77baeeb..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Nokia. - * ================================================================================ - * 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.cloudify.beans; - -import java.util.Map; - -/* - * This Java bean class relays Heat stack status information to ActiveVOS processes. - * - * This bean is returned by all Heat-specific adapter operations (create, query, delete) - */ - -public final class DeploymentInfo { - - private final String id; - private final DeploymentStatus status; - private final Map<String, Object> outputs; - private final Map<String, Object> inputs; - private final String lastAction; - private final String actionStatus; - private final String errorMessage; - - DeploymentInfo(String id, DeploymentStatus deploymentStatus, Map<String, Object> deploymentOutputs, - Map<String, Object> deploymentInputs, String lastAction, String actionStatus, String errorMessage) { - - this.id = id; - this.status = deploymentStatus; - this.outputs = deploymentOutputs; - this.inputs = deploymentInputs; - this.lastAction = lastAction; - this.actionStatus = actionStatus; - this.errorMessage = errorMessage; - } - - public String getId() { - return id; - } - - public DeploymentStatus getStatus() { - return status; - } - - public Map<String, Object> getOutputs() { - return outputs; - } - - public Map<String, Object> getInputs() { - return inputs; - } - - public String getLastAction() { - return lastAction; - } - - public String getActionStatus() { - return actionStatus; - } - - public String getErrorMessage() { - return errorMessage; - } - - @Override - public String toString() { - return "DeploymentInfo {" + "id='" + id + '\'' + ", inputs='" + inputs + '\'' + ", outputs='" + outputs + '\'' - + ", lastAction='" + lastAction + '\'' + ", status='" + status + '\'' + ", errorMessage='" - + errorMessage + '\'' + '}'; - } - -} - diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java deleted file mode 100644 index 072bf404e7..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 Nokia. - * ============================================================================= 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.cloudify.beans; - -import java.util.HashMap; -import java.util.Map; -import org.onap.so.cloudify.v3.model.Execution; - -public final class DeploymentInfoBuilder { - - private String id = ""; - private DeploymentStatus deploymentStatus = DeploymentStatus.NOTFOUND; - private Map<String, Object> deploymentOutputs = new HashMap<>(); - private Map<String, Object> deploymentInputs = new HashMap<>(); - private String lastAction; - private String actionStatus; - private String errorMessage; - - public DeploymentInfoBuilder withId(String id) { - this.id = id; - return this; - } - - public DeploymentInfoBuilder withStatus(DeploymentStatus deploymentStatus) { - this.deploymentStatus = deploymentStatus; - return this; - } - - public DeploymentInfoBuilder withDeploymentOutputs(Map<String, Object> deploymentOutputs) { - if (deploymentOutputs != null) { - this.deploymentOutputs = deploymentOutputs; - } - return this; - } - - public DeploymentInfoBuilder withDeploymentInputs(Map<String, Object> deploymentInputs) { - this.deploymentInputs = deploymentInputs; - return this; - } - - public DeploymentInfoBuilder withLastAction(String lastAction) { - this.lastAction = lastAction; - return this; - } - - public DeploymentInfoBuilder withActionStatus(String actionStatus) { - this.actionStatus = actionStatus; - return this; - } - - public DeploymentInfoBuilder withErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - return this; - } - - public DeploymentInfoBuilder fromExecution(Execution execution) { - if (execution != null) { - this.lastAction = execution.getWorkflowId(); - this.actionStatus = execution.getStatus(); - this.errorMessage = execution.getError(); - - // Compute the status based on the last workflow - if (("install").equals(lastAction)) { - if (("terminated").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.INSTALLED; - } else if (("failed").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.FAILED; - } else if (("started").equals(actionStatus) || ("pending").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.INSTALLING; - } else { - this.deploymentStatus = DeploymentStatus.UNKNOWN; - } - } else if (("uninstall").equals(lastAction)) { - if (("terminated").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.CREATED; - } else if (("failed").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.FAILED; - } else if (("started").equals(actionStatus) || ("pending").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.UNINSTALLING; - } else { - this.deploymentStatus = DeploymentStatus.UNKNOWN; - } - } else { - // Could have more cases in the future for different actions. - this.deploymentStatus = DeploymentStatus.UNKNOWN; - } - } else { - this.deploymentStatus = DeploymentStatus.CREATED; - } - - return this; - } - - public DeploymentInfo build() { - return new DeploymentInfo(id, deploymentStatus, deploymentOutputs, deploymentInputs, lastAction, actionStatus, - errorMessage); - } -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoBlueprintAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoBlueprintAlreadyExists.java deleted file mode 100644 index 95912994bc..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoBlueprintAlreadyExists.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============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.cloudify.exceptions; - -public class MsoBlueprintAlreadyExists extends MsoCloudifyException { - - private static final long serialVersionUID = 1L; - - // Constructor to create a new MsoCloudifyException instance - public MsoBlueprintAlreadyExists(String blueprintId, String cloud) { - // Set the detailed error as the Exception 'message' - super(409, "Conflict", - "Blueprint " + blueprintId + " already exists in Cloudify Manager supporting cloud site + " + cloud); - } - -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyException.java deleted file mode 100644 index 441bd4dc07..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyException.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============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.cloudify.exceptions; - -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; - -/** - * OpenStack exception. - */ -public class MsoCloudifyException extends MsoException { - - /** - * Serialization id. - */ - private static final long serialVersionUID = 3313636124141766495L; - - private int statusCode; - private String statusMessage; - private String errorDetail; - private boolean pendingWorkflow; - - /** - * Constructor to create a new MsoOpenstackException instance - * - * @param code the error code - * @param message the error message - * @param detail error details - */ - public MsoCloudifyException(int code, String message, String detail) { - // Set the detailed error as the Exception 'message' - super(detail); - super.category = MsoExceptionCategory.OPENSTACK; - - this.statusCode = code; - this.statusMessage = message; - this.errorDetail = detail; - this.pendingWorkflow = false; - } - - /** - * Constructor to propagate the caught exception (mostly for stack trace) - * - * @param code the error code - * @param message the error message - * @param detail error details - * @param e the cause - */ - public MsoCloudifyException(int code, String message, String detail, Exception e) { - // Set the detailed error as the Exception 'message' - super(detail, e); - super.category = MsoExceptionCategory.OPENSTACK; - - this.statusCode = code; - this.statusMessage = message; - this.errorDetail = detail; - this.pendingWorkflow = false; - } - - public void setPendingWorkflow(boolean pendingWorkflow) { - this.pendingWorkflow = pendingWorkflow; - } - - @Override - public String toString() { - String error = "" + statusCode + " " + statusMessage + ": " + errorDetail - + (pendingWorkflow ? " [workflow pending]" : ""); - return error; - } -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeout.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeout.java deleted file mode 100644 index 99b6ade326..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeout.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============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.cloudify.exceptions; - -import org.onap.so.cloudify.v3.model.Execution; -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; - -/** - * MSO Exception when a Cloudify workflow execution times out waiting for completion. Exception includes the last known - * state of the workflow execution. - */ -public class MsoCloudifyTimeout extends MsoException { - - /** - * Serialization id. - */ - private static final long serialVersionUID = 3313636124141766495L; - - private Execution execution; - - /** - * Constructor to create a new MsoOpenstackException instance - * - * @param code the error code - * @param message the error message - * @param detail error details - */ - public MsoCloudifyTimeout(Execution execution) { - // Set the detailed error as the Exception 'message' - super("Cloudify Workflow Timeout for workflow " + execution.getWorkflowId() + " on deployment " - + execution.getDeploymentId()); - super.category = MsoExceptionCategory.OPENSTACK; - - this.execution = execution; - } - - public Execution getExecution() { - return this.execution; - } - - @Override - public String toString() { - String error = "Workflow timeout: workflow=" + execution.getWorkflowId() + ",deployment=" - + execution.getDeploymentId(); - return error; - } -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java deleted file mode 100644 index 2251575671..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============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.cloudify.exceptions; - -/** - * Reports an error with a Cloudify Workflow execution. - * - * @author JC1348 - * - */ -public class MsoCloudifyWorkflowException extends MsoCloudifyException { - - private static final long serialVersionUID = 1L; - - private String workflowStatus; - private boolean workflowStillRunning = false; - - // Constructor to create a new MsoCloudifyException instance - public MsoCloudifyWorkflowException(String message, String deploymentId, String workflowId, String workflowStatus) { - super(0, "Workflow Exception", - "Workflow " + workflowId + " failed on deployment " + deploymentId + ": " + message); - this.workflowStatus = workflowStatus; - if (("pending").equals(workflowStatus) || ("started").equals(workflowStatus) - || ("cancelling").equals(workflowStatus) || ("force_cancelling").equals(workflowStatus)) { - workflowStillRunning = true; - } - } - - public String getWorkflowStatus() { - return workflowStatus; - } - - public boolean isWorkflowStillRunning() { - return workflowStillRunning; - } -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java deleted file mode 100644 index 446c725e48..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ /dev/null @@ -1,1356 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Nokia. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.utils; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; -import org.onap.so.adapters.vdu.CloudInfo; -import org.onap.so.adapters.vdu.PluginAction; -import org.onap.so.adapters.vdu.VduArtifact; -import org.onap.so.adapters.vdu.VduArtifact.ArtifactType; -import org.onap.so.adapters.vdu.VduException; -import org.onap.so.adapters.vdu.VduInstance; -import org.onap.so.adapters.vdu.VduModelInfo; -import org.onap.so.adapters.vdu.VduPlugin; -import org.onap.so.adapters.vdu.VduStateType; -import org.onap.so.adapters.vdu.VduStatus; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloudify.base.client.CloudifyBaseException; -import org.onap.so.cloudify.base.client.CloudifyClientTokenProvider; -import org.onap.so.cloudify.base.client.CloudifyConnectException; -import org.onap.so.cloudify.base.client.CloudifyRequest; -import org.onap.so.cloudify.base.client.CloudifyResponseException; -import org.onap.so.cloudify.beans.DeploymentInfo; -import org.onap.so.cloudify.beans.DeploymentInfoBuilder; -import org.onap.so.cloudify.beans.DeploymentStatus; -import org.onap.so.cloudify.exceptions.MsoCloudifyException; -import org.onap.so.cloudify.exceptions.MsoCloudifyManagerNotFound; -import org.onap.so.cloudify.exceptions.MsoDeploymentAlreadyExists; -import org.onap.so.cloudify.v3.client.BlueprintsResource.GetBlueprint; -import org.onap.so.cloudify.v3.client.BlueprintsResource.UploadBlueprint; -import org.onap.so.cloudify.v3.client.Cloudify; -import org.onap.so.cloudify.v3.client.DeploymentsResource.CreateDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.DeleteDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeploymentOutputs; -import org.onap.so.cloudify.v3.client.ExecutionsResource.CancelExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.GetExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.ListExecutions; -import org.onap.so.cloudify.v3.client.ExecutionsResource.StartExecution; -import org.onap.so.cloudify.v3.model.AzureConfig; -import org.onap.so.cloudify.v3.model.Blueprint; -import org.onap.so.cloudify.v3.model.CancelExecutionParams; -import org.onap.so.cloudify.v3.model.CloudifyError; -import org.onap.so.cloudify.v3.model.CreateDeploymentParams; -import org.onap.so.cloudify.v3.model.Deployment; -import org.onap.so.cloudify.v3.model.DeploymentOutputs; -import org.onap.so.cloudify.v3.model.Execution; -import org.onap.so.cloudify.v3.model.Executions; -import org.onap.so.cloudify.v3.model.OpenstackConfig; -import org.onap.so.cloudify.v3.model.StartExecutionParams; -import org.onap.so.config.beans.PoConfig; -import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.db.catalog.beans.CloudifyManager; -import org.onap.so.db.catalog.beans.HeatTemplateParam; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.exceptions.MsoAdapterException; -import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.onap.so.openstack.exceptions.MsoIOException; -import org.onap.so.openstack.exceptions.MsoOpenstackException; -import org.onap.so.openstack.utils.MsoCommonUtils; -import org.onap.so.utils.CryptoUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -@Component -public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { - - private static final String CLOUDIFY = "Cloudify"; - private static final String CREATE_DEPLOYMENT = "CreateDeployment"; - private static final String DELETE_DEPLOYMENT = "DeleteDeployment"; - private static final String TERMINATED = "terminated"; - private static final String CANCELLED = "cancelled"; - private static final String UNINSTALL = "uninstall"; - private static final String UPLOAD_BLUEPRINT = "UPLOAD_BLUEPRINT"; - - // Fetch cloud configuration each time (may be cached in CloudConfig class) - @Autowired - protected CloudConfig cloudConfig; - - @Autowired - private Environment environment; - - @Autowired - private PoConfig poConfig; - - private static final Logger logger = LoggerFactory.getLogger(MsoCloudifyUtils.class); - - // Properties names and variables (with default values) - protected String createPollIntervalProp = "org.onap.so.adapters.po.pollInterval"; - private String deletePollIntervalProp = "org.onap.so.adapters.po.pollInterval"; - - protected String createPollIntervalDefault = "15"; - private String deletePollIntervalDefault = "15"; - - private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); - - /** - * Create a new Deployment from a specified blueprint, and install it in the specified cloud location and tenant. - * The blueprint identifier and parameter map are passed in as arguments, along with the cloud access credentials. - * The blueprint should have been previously uploaded to Cloudify. - * - * It is expected that parameters have been validated and contain at minimum the required parameters for the given - * template with no extra (undefined) parameters.. - * - * The deployment ID supplied by the caller must be unique in the scope of the Cloudify tenant (not the Openstack - * tenant). However, it should also be globally unique, as it will be the identifier for the resource going forward - * in Inventory. This latter is managed by the higher levels invoking this function. - * - * This function executes the "install" workflow on the newly created workflow. Cloudify will be polled for - * completion unless the client requests otherwise. - * - * An error will be thrown if the requested Deployment already exists in the specified Cloudify instance. - * - * @param cloudSiteId The cloud (may be a region) in which to create the stack. - * @param tenantId The Openstack ID of the tenant in which to create the Stack - * @param deploymentId The identifier (name) of the deployment to create - * @param blueprintId The blueprint from which to create the deployment. - * @param inputs A map of key/value inputs - * @param pollForCompletion Indicator that polling should be handled in Java vs. in the client - * @param timeoutMinutes Timeout after which the "install" will be cancelled - * @param backout Flag to delete deployment on install Failure - defaulted to True - * @return A DeploymentInfo object - * @throws MsoCloudifyException Thrown if the Cloudify API call returns an exception. - * @throws MsoIOException Thrown on Cloudify connection errors. - */ - - public DeploymentInfo createAndInstallDeployment(String cloudSiteId, String tenantId, String deploymentId, - String blueprintId, Map<String, ? extends Object> inputs, boolean pollForCompletion, int timeoutMinutes, - boolean backout) throws MsoException { - // Obtain the cloud site information where we will create the stack - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - logger.debug("Ready to Create Deployment ({}) with input params: {}", deploymentId, inputs); - - // Build up the inputs, including: - // - from provided "environment" file - // - passed in by caller - // - special input for cloud-specific Credentials - Map<String, Object> expandedInputs = new HashMap<>(inputs); - - String platform = cloudSite.get().getPlatform(); - if (platform == null || platform.isEmpty() || ("OPENSTACK").equalsIgnoreCase(platform)) { - // Create the Cloudify OpenstackConfig with the credentials - OpenstackConfig openstackConfig = getOpenstackConfig(cloudSite.get(), tenantId); - expandedInputs.put("openstack_config", openstackConfig); - } else if (("AZURE").equalsIgnoreCase(platform)) { - // Create Cloudify AzureConfig with the credentials - AzureConfig azureConfig = getAzureConfig(cloudSite.get(), tenantId); - expandedInputs.put("azure_config", azureConfig); - } - - // Build up the parameters to create a new deployment - CreateDeploymentParams deploymentParams = new CreateDeploymentParams(); - deploymentParams.setBlueprintId(blueprintId); - deploymentParams.setInputs(expandedInputs); - - Deployment deployment = null; - try { - CreateDeployment createDeploymentRequest = cloudify.deployments().create(deploymentId, deploymentParams); - logger.debug(createDeploymentRequest.toString()); - - deployment = executeAndRecordCloudifyRequest(createDeploymentRequest); - } catch (CloudifyResponseException e) { - // Since this came on the 'Create Deployment' command, nothing was changed - // in the cloud. Return the error as an exception. - if (e.getStatus() == 409) { - // Deployment already exists. Return a specific error for this case - MsoException me = new MsoDeploymentAlreadyExists(deploymentId, cloudSiteId); - me.addContext(CREATE_DEPLOYMENT); - throw me; - } else { - // Convert the CloudifyResponseException to an MsoException - logger.debug("ERROR STATUS = {},\n{}\n{}", e.getStatus(), e.getMessage(), e.getLocalizedMessage()); - MsoException me = cloudifyExceptionToMsoException(e, CREATE_DEPLOYMENT); - me.setCategory(MsoExceptionCategory.OPENSTACK); - throw me; - } - } catch (CloudifyConnectException e) { - // Error connecting to Cloudify instance. Convert to an MsoException - throw cloudifyExceptionToMsoException(e, CREATE_DEPLOYMENT); - } catch (RuntimeException e) { - // Catch-all - throw runtimeExceptionToMsoException(e, CREATE_DEPLOYMENT); - } - - /* - * It can take some time for Cloudify to be ready to execute a workflow on the deployment. Sleep 30 seconds - * based on observation of behavior in a Cloudify VM instance (delay due to "create_deployment_environment"). - */ - sleep(30000); - - /* - * Next execute the "install" workflow. Note - this assumes there are no additional parameters required for the - * workflow. - */ - int createPollInterval = - Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault)); - int pollTimeout = (timeoutMinutes * 60) + createPollInterval; - - Execution installWorkflow = null; - - try { - installWorkflow = executeWorkflow(cloudify, deploymentId, "install", null, pollForCompletion, pollTimeout, - createPollInterval); - - if (installWorkflow.getStatus().equals(TERMINATED)) { - // Success! - // Create and return a DeploymentInfo structure. Include the Runtime outputs - return new DeploymentInfoBuilder().withId(deployment.getId()) - .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) - .fromExecution(installWorkflow).build(); - } else { - // The workflow completed with errors. Must try to back it out. - if (!backout) { - logger.warn("{} Deployment installation failed, backout deletion suppressed {} {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), - "Exception in Deployment Installation, backout suppressed"); - } else { - // Poll on delete if we rollback - use same values for now - int deletePollInterval = createPollInterval; - int deletePollTimeout = pollTimeout; - - try { - // Run the uninstall to undo the install - Execution uninstallWorkflow = executeWorkflow(cloudify, deploymentId, UNINSTALL, null, - pollForCompletion, deletePollTimeout, deletePollInterval); - - if (uninstallWorkflow.getStatus().equals(TERMINATED)) { - // The uninstall completed. Delete the deployment itself - DeleteDeployment deleteRequest = cloudify.deployments().deleteByName(deploymentId); - executeAndRecordCloudifyRequest(deleteRequest); - } else { - // Didn't uninstall successfully. Log this error - logger.error("{} Create Deployment: Cloudify error rolling back deployment install: {} {}", - MessageEnum.RA_CREATE_STACK_ERR, installWorkflow.getError(), - ErrorCode.BusinessProcessError.getValue()); - } - } catch (Exception e) { - // Catch-all for backout errors trying to uninstall/delete - // Log this error, and return the original exception - logger.error("{} Create Stack: Nested exception rolling back deployment install: {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), e); - } - } - - MsoCloudifyException me = - new MsoCloudifyException(0, "Workflow Execution Failed", installWorkflow.getError()); - me.addContext(CREATE_DEPLOYMENT); - - throw me; - } - } catch (MsoException me) { - // Install failed. Unless requested otherwise, back out the deployment - - if (!backout) { - logger.warn("{} Deployment installation failed, backout deletion suppressed {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue()); - } else { - // Poll on delete if we rollback - use same values for now - int deletePollInterval = createPollInterval; - int deletePollTimeout = pollTimeout; - - try { - // Run the uninstall to undo the install. - // Always try to run it, as it should be idempotent - executeWorkflow(cloudify, deploymentId, UNINSTALL, null, pollForCompletion, deletePollTimeout, - deletePollInterval); - - // Delete the deployment itself - DeleteDeployment deleteRequest = cloudify.deployments().deleteByName(deploymentId); - executeAndRecordCloudifyRequest(deleteRequest); - } catch (Exception e) { - // Catch-all for backout errors trying to uninstall/delete - // Log this error, and return the original exception - logger.error("{} Create Stack: Nested exception rolling back deployment install: {} ", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), e); - } - } - - // Propagate the original exception from Stack Query. - me.addContext(CREATE_DEPLOYMENT); - - throw me; - } - } - - - /* - * Get the runtime Outputs of a deployment. Return the Map of tag/value outputs. - */ - private Optional<Map<String, Object>> getDeploymentOutputs(Cloudify cloudify, String deploymentId) - throws MsoException { - // Build and send the Cloudify request - DeploymentOutputs deploymentOutputs; - try { - GetDeploymentOutputs queryDeploymentOutputs = cloudify.deployments().outputsById(deploymentId); - logger.debug(queryDeploymentOutputs.toString()); - - deploymentOutputs = executeAndRecordCloudifyRequest(queryDeploymentOutputs); - if (deploymentOutputs != null) { - return Optional.ofNullable(deploymentOutputs.getOutputs()); - } else { - return Optional.empty(); - } - } catch (CloudifyConnectException ce) { - // Couldn't connect to Cloudify - logger.error("{} QueryDeploymentOutputs: Cloudify connection failure: {} ", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcessError.getValue(), ce); - throw new MsoIOException(ce.getMessage(), ce); - } catch (CloudifyResponseException re) { - if (re.getStatus() == 404) { - // No Outputs - return Optional.empty(); - } - throw new MsoCloudifyException(re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re); - } catch (Exception e) { - // Catch-all - throw new MsoAdapterException(e.getMessage(), e); - } - } - - /* - * Execute a workflow on a deployment. Handle polling for completion with timeout. Return the final Execution object - * with status. Throw an exception on Errors. Question - how does the client know whether rollback needs to be done? - */ - private Execution executeWorkflow(Cloudify cloudify, String deploymentId, String workflowId, - Map<String, Object> workflowParams, boolean pollForCompletion, int timeout, int pollInterval) - throws MsoCloudifyException { - logger.debug("Executing '{}' workflow on deployment '{}'", workflowId, deploymentId); - - StartExecutionParams executeParams = new StartExecutionParams(); - executeParams.setWorkflowId(workflowId); - executeParams.setDeploymentId(deploymentId); - executeParams.setParameters(workflowParams); - - Execution execution = null; - String executionId = null; - String command = "start"; - Exception savedException = null; - - try { - StartExecution executionRequest = cloudify.executions().start(executeParams); - logger.debug(executionRequest.toString()); - execution = executeAndRecordCloudifyRequest(executionRequest); - executionId = execution.getId(); - - if (!pollForCompletion) { - // Client did not request polling, so just return the Execution object - return execution; - } - - // Enter polling loop - boolean timedOut = false; - int pollTimeout = timeout; - - String status = execution.getStatus(); - - // Create a reusable cloudify query request - GetExecution queryExecution = cloudify.executions().byId(executionId); - command = "query"; - - while (!timedOut && !(status.equals(TERMINATED) || ("failed").equals(status) || status.equals(CANCELLED))) { - // workflow is still running; check for timeout - if (pollTimeout <= 0) { - logger.debug("workflow {} timed out on deployment {}", execution.getWorkflowId(), - execution.getDeploymentId()); - timedOut = true; - continue; - } - - sleep(pollInterval * 1000L); - - pollTimeout -= pollInterval; - logger.debug("pollTimeout remaining: " + pollTimeout); - - execution = queryExecution.execute(); - if (execution != null) { - status = execution.getStatus(); - } else { - status = TERMINATED; - } - } - - // Broke the loop. Check again for a terminal state - if (status.equals(TERMINATED)) { - // Success! - logger.debug("Workflow '{}' completed successfully on deployment '{}'", workflowId, deploymentId); - return execution; - } else if (("failed").equals(status)) { - // Workflow failed. Log it and return the execution object (don't throw exception here) - logger.error("{} Cloudify workflow failure: {} {} Execute Workflow: Failed: {}", - MessageEnum.RA_CREATE_STACK_ERR, execution.getError(), - ErrorCode.BusinessProcessError.getValue(), execution.getError()); - return execution; - } else if (status.equals(CANCELLED)) { - // Workflow was cancelled, leaving the deployment in an indeterminate state. Log it and return the - // execution object (don't throw exception here) - logger.error("{} Cloudify workflow cancelled. Deployment is in an indeterminate state {} {} {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), - "Execute Workflow cancelled: ", workflowId); - return execution; - } else { - // Can only get here after a timeout - logger.error("{} Cloudify workflow timeout {} Execute Workflow: Timed Out", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue()); - } - } catch (CloudifyConnectException ce) { - logger.error("{} {} Execute Workflow ({} {}): Cloudify connection failure {} ", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), command, ce); - savedException = ce; - } catch (CloudifyResponseException re) { - logger.error("{} {} Execute Workflow ({}): Cloudify response error {} ", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcessError.getValue(), command, re.getMessage(), re); - savedException = re; - } catch (RuntimeException e) { - // Catch-all - logger.error("{} {} Execute Workflow ({}): Internal error {}", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcessError.getValue(), command, e.getMessage(), e); - savedException = e; - } - - // Get to this point ONLY on an error or timeout - // The cloudify execution is still running (we've not received a terminal status), - // so try to Cancel it. - CancelExecutionParams cancelParams = new CancelExecutionParams(); - cancelParams.setAction("cancel"); - // TODO: Use force_cancel? - - Execution cancelExecution = null; - - try { - CancelExecution cancelRequest = cloudify.executions().cancel(executionId, cancelParams); - logger.debug(cancelRequest.toString()); - cancelExecution = cancelRequest.execute(); - - // Enter polling loop - boolean timedOut = false; - int cancelTimeout = timeout; // TODO: For now, just use same timeout - - String status = null; - if (cancelExecution != null) { - status = cancelExecution.getStatus(); - } - // Poll for completion. Create a reusable cloudify query request - GetExecution queryExecution = cloudify.executions().byId(executionId); - - while (!timedOut && !CANCELLED.equals(status)) { - // workflow is still running; check for timeout - if (cancelTimeout <= 0) { - logger.debug("Cancel timeout for workflow {} on deployment {}", workflowId, deploymentId); - timedOut = true; - continue; - } - - sleep(pollInterval * 1000L); - - cancelTimeout -= pollInterval; - logger.debug("pollTimeout remaining: {}", cancelTimeout); - - execution = queryExecution.execute(); - if (execution != null) { - status = execution.getStatus(); - } - } - - // Broke the loop. Check again for a terminal state - if (CANCELLED.equals(status)) { - // Finished cancelling. Return the original exception - logger.debug("Cancel workflow {} completed on deployment {}", workflowId, deploymentId); - throw new MsoCloudifyException(-1, "", "", savedException); - } else { - // Can only get here after a timeout - logger.debug("Cancel workflow {} timeout out on deployment {}", workflowId, deploymentId); - MsoCloudifyException exception = new MsoCloudifyException(-1, "", "", savedException); - exception.setPendingWorkflow(true); - throw exception; - } - } catch (Exception e) { - // Catch-all. Log the message and throw the original exception - logger.debug("Cancel workflow {} failed for deployment {} :", workflowId, deploymentId, e); - MsoCloudifyException exception = new MsoCloudifyException(-1, "", "", savedException); - exception.setPendingWorkflow(true); - throw exception; - } - } - - - - /** - * Query for a Cloudify Deployment (by Name). This call will always return a DeploymentInfo object. If the - * deployment does not exist, an "empty" DeploymentInfo will be returned - containing only the deployment ID and a - * special status of NOTFOUND. - * - * @param tenantId The Openstack ID of the tenant in which to query - * @param cloudSiteId The cloud identifier (may be a region) in which to query - * @return A StackInfo object - * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. - */ - public DeploymentInfo queryDeployment(String cloudSiteId, String tenantId, String deploymentId) - throws MsoException { - logger.debug("Query Cloudify Deployment: {} in tenant {}", deploymentId, tenantId); - - // Obtain the cloud site information where we will create the stack - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - // Build and send the Cloudify request - Deployment deployment = new Deployment(); - try { - GetDeployment queryDeployment = cloudify.deployments().byId(deploymentId); - logger.debug(queryDeployment.toString()); - deployment = executeAndRecordCloudifyRequest(queryDeployment); - - // Next look for the latest execution - ListExecutions listExecutions = - cloudify.executions().listFiltered("deployment_id=" + deploymentId, "-created_at"); - Executions executions = listExecutions.execute(); - - // If no executions, does this give NOT_FOUND or empty set? - if (executions == null || executions.getItems().isEmpty()) { - return new DeploymentInfoBuilder().withId(deployment.getId()) - .withDeploymentInputs(deployment.getInputs()).build(); - } else { - return new DeploymentInfoBuilder().withId(deployment.getId()) - .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) - .fromExecution(executions.getItems().get(0)).build(); - } - } catch (CloudifyConnectException ce) { - // Couldn't connect to Cloudify - logger.error("{} QueryDeployment: Cloudify connection failure: {} ", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcessError.getValue(), ce); - throw new MsoIOException(ce.getMessage(), ce); - } catch (CloudifyResponseException re) { - if (re.getStatus() == 404) { - // Got a NOT FOUND error. React differently based on deployment vs. execution - if (deployment != null) { - // Got NOT_FOUND on the executions. Assume this is a valid "empty" set - return new DeploymentInfoBuilder().withId(deployment.getId()) - .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()).build(); - } else { - // Deployment not found. Default status of a DeploymentInfo object is NOTFOUND - return new DeploymentInfoBuilder().withId(deploymentId).build(); - } - } - throw new MsoCloudifyException(re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re); - } catch (Exception e) { - // Catch-all - throw new MsoAdapterException(e.getMessage(), e); - } - } - - - /** - * Delete a Cloudify deployment (by ID). If the deployment is not found, it will be considered a successful - * deletion. The return value is a DeploymentInfo object which contains the last deployment status. - * - * There is no rollback from a successful deletion. A deletion failure will also result in an undefined deployment - * state - the components may or may not have been all or partially deleted, so the resulting deployment must be - * considered invalid. - * - * @param tenantId The Openstack ID of the tenant in which to perform the delete - * @param cloudSiteId The cloud identifier (may be a region) from which to delete the stack. - * @return A StackInfo object - * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. - * @throws MsoCloudSiteNotFound - */ - public DeploymentInfo uninstallAndDeleteDeployment(String cloudSiteId, String tenantId, String deploymentId, - int timeoutMinutes) throws MsoException { - // Obtain the cloud site information where we will create the stack - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - logger.debug("Ready to Uninstall/Delete Deployment ({})", deploymentId); - - // Query first to save the trouble if deployment not found - try { - GetDeployment queryDeploymentRequest = cloudify.deployments().byId(deploymentId); - logger.debug(queryDeploymentRequest.toString()); - - // deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest); - } catch (CloudifyResponseException e) { - // Since this came on the 'Create Deployment' command, nothing was changed - // in the cloud. Return the error as an exception. - if (e.getStatus() == 404) { - // Deployment doesn't exist. Return a "NOTFOUND" DeploymentInfo object - // TODO: Should return NULL? - logger.debug("Deployment requested for deletion does not exist: {}", deploymentId); - return new DeploymentInfoBuilder().withId(deploymentId).withStatus(DeploymentStatus.NOTFOUND).build(); - } else { - // Convert the CloudifyResponseException to an MsoOpenstackException - logger.debug("ERROR STATUS = {}, \n {}\n {}\n {}", e.getStatus(), e.getMessage(), - e.getLocalizedMessage(), e); - MsoException me = cloudifyExceptionToMsoException(e, DELETE_DEPLOYMENT); - me.setCategory(MsoExceptionCategory.INTERNAL); - throw me; - } - } catch (CloudifyConnectException e) { - // Error connecting to Cloudify instance. Convert to an MsoException - throw cloudifyExceptionToMsoException(e, DELETE_DEPLOYMENT); - } catch (RuntimeException e) { - // Catch-all - throw runtimeExceptionToMsoException(e, DELETE_DEPLOYMENT); - } - - /* - * Query the outputs before deleting so they can be returned as well - */ - // DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId); - - /* - * Next execute the "uninstall" workflow. Note - this assumes there are no additional parameters required for - * the workflow. - */ - // TODO: No deletePollInterval that I'm aware of. Use the create interval - int deletePollInterval = - Integer.parseInt(this.environment.getProperty(deletePollIntervalProp, deletePollIntervalDefault)); - int pollTimeout = (timeoutMinutes * 60) + deletePollInterval; - - Execution uninstallWorkflow = null; - - try { - uninstallWorkflow = - executeWorkflow(cloudify, deploymentId, UNINSTALL, null, true, pollTimeout, deletePollInterval); - - if (uninstallWorkflow.getStatus().equals(TERMINATED)) { - // Successful uninstall. - logger.debug("Uninstall successful for deployment {}", deploymentId); - } else { - // The uninstall workflow completed with an error. Must fail the request, but will - // leave the deployment in an indeterminate state, as cloud resources may still exist. - MsoCloudifyException me = - new MsoCloudifyException(0, "Uninstall Workflow Failed", uninstallWorkflow.getError()); - me.addContext(DELETE_DEPLOYMENT); - - throw me; - } - } catch (MsoException me) { - // Uninstall workflow has failed. - // Must fail the deletion... may leave the deployment in an inconclusive state - me.addContext(DELETE_DEPLOYMENT); - - throw me; - } - - // At this point, the deployment has been successfully uninstalled. - // Next step is to delete the deployment itself - Deployment deployment; - try { - DeleteDeployment deleteRequest = cloudify.deployments().deleteByName(deploymentId); - logger.debug(deleteRequest.toString()); - - // The delete request returns the deleted deployment - deployment = deleteRequest.execute(); - - } catch (CloudifyConnectException ce) { - // Failed to delete. Must fail the request, but will leave the (uninstalled) - // deployment in Cloudify DB. - MsoCloudifyException me = new MsoCloudifyException(0, "Deployment Delete Failed", ce.getMessage(), ce); - me.addContext(DELETE_DEPLOYMENT); - - throw me; - } catch (CloudifyResponseException re) { - // Failed to delete. Must fail the request, but will leave the (uninstalled) - // deployment in the Cloudify DB. - MsoCloudifyException me = new MsoCloudifyException(re.getStatus(), re.getMessage(), re.getMessage(), re); - me.addContext(DELETE_DEPLOYMENT); - - throw me; - } catch (Exception e) { - // Catch-all - MsoAdapterException ae = new MsoAdapterException(e.getMessage(), e); - ae.addContext(DELETE_DEPLOYMENT); - - throw ae; - } - - // Return the deleted deployment info (with runtime outputs) along with the completed uninstall workflow status - return new DeploymentInfoBuilder().withId(deployment.getId()).withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) - .fromExecution(uninstallWorkflow).build(); - } - - - /** - * Check if a blueprint is available for use at a targeted cloud site. This requires checking the Cloudify Manager - * which is servicing that cloud site to see if the specified blueprint has been loaded. - * - * @param cloudSiteId The cloud site where the blueprint is needed - * @param blueprintId The ID for the blueprint in Cloudify - */ - public boolean isBlueprintLoaded(String cloudSiteId, String blueprintId) throws MsoException { - // Obtain the cloud site information where we will load the blueprint - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - GetBlueprint getRequest = cloudify.blueprints().getMetadataById(blueprintId); - try { - Blueprint bp = getRequest.execute(); - if (bp != null) { - logger.debug("Blueprint exists: {}", bp.getId()); - return true; - } else { - logger.debug("Null blueprint!"); - return false; - } - } catch (CloudifyResponseException ce) { - if (ce.getStatus() == 404) { - return false; - } else { - throw ce; - } - } - } - - /** - * Upload a blueprint to the Cloudify Manager that is servicing a Cloud Site. The blueprint currently must be - * structured as a single directory with all of the required files. One of those files is designated the "main file" - * for the blueprint. Files are provided as byte arrays, though expect only text files will be distributed from ASDC - * and stored by MSO. - * - * Cloudify requires a single root directory in its blueprint zip files. The requested blueprint ID will also be - * used as the directory. All of the files will be added to this directory in the zip file. - */ - public void uploadBlueprint(String cloudSiteId, String blueprintId, String mainFileName, - Map<String, byte[]> blueprintFiles, boolean failIfExists) throws MsoException { - // Obtain the cloud site information where we will load the blueprint - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - boolean blueprintUploaded = uploadBlueprint(cloudify, blueprintId, mainFileName, blueprintFiles); - - if (!blueprintUploaded && failIfExists) { - throw new MsoAdapterException("Blueprint already exists"); - } - } - - /* - * Common method to load a blueprint. May be called from - */ - protected boolean uploadBlueprint(Cloudify cloudify, String blueprintId, String mainFileName, - Map<String, byte[]> blueprintFiles) throws MsoException { - // Check if it already exists. If so, return false. - GetBlueprint getRequest = cloudify.blueprints().getMetadataById(blueprintId); - try { - Blueprint bp = getRequest.execute(); - if (bp != null) { - logger.debug("Blueprint {} already exists.", bp.getId()); - return false; - } else { - logger.debug("Null blueprint!"); - } - } catch (CloudifyResponseException ce) { - if (ce.getStatus() == 404) { - // This is the expected result. - logger.debug("Verified that Blueprint doesn't exist yet"); - } else { - throw ce; - } - } - - // Create a blueprint ZIP file in memory - ByteArrayOutputStream zipBuffer = new ByteArrayOutputStream(); - ZipOutputStream zipOut = new ZipOutputStream(zipBuffer); - - try { - // Put the root directory - String rootDir = blueprintId + (blueprintId.endsWith("/") ? "" : "/"); - zipOut.putNextEntry(new ZipEntry(rootDir)); - zipOut.closeEntry(); - - for (String fileName : blueprintFiles.keySet()) { - ZipEntry ze = new ZipEntry(rootDir + fileName); - zipOut.putNextEntry(ze); - zipOut.write(blueprintFiles.get(fileName)); - zipOut.closeEntry(); - } - zipOut.close(); - } catch (IOException e) { - // Since we're writing to a byte array, this should never happen - } - logger.debug("Blueprint zip file size: {}", zipBuffer.size()); - - // Ready to upload the blueprint zip - - try (InputStream blueprintStream = new ByteArrayInputStream(zipBuffer.toByteArray())) { - UploadBlueprint uploadRequest = - cloudify.blueprints().uploadFromStream(blueprintId, mainFileName, blueprintStream); - Blueprint blueprint = uploadRequest.execute(); - logger.debug("Successfully uploaded blueprint {}", blueprint.getId()); - } catch (CloudifyResponseException | CloudifyConnectException e) { - throw cloudifyExceptionToMsoException(e, UPLOAD_BLUEPRINT); - } catch (RuntimeException e) { - // Catch-all - throw runtimeExceptionToMsoException(e, UPLOAD_BLUEPRINT); - } catch (IOException e) { - // for try-with-resources - throw ioExceptionToMsoException(e, UPLOAD_BLUEPRINT); - } - - return true; - } - - - - // --------------------------------------------------------------- - // PRIVATE FUNCTIONS FOR USE WITHIN THIS CLASS - - /** - * Get a Cloudify client for the specified cloud site. Everything that is required can be found in the Cloud Config. - * - * @param cloudSite - * @return a Cloudify object - */ - public Cloudify getCloudifyClient(CloudSite cloudSite) throws MsoException { - CloudifyManager cloudifyConfig = cloudConfig.getCloudifyManager(cloudSite.getCloudifyId()); - if (cloudifyConfig == null) { - throw new MsoCloudifyManagerNotFound(cloudSite.getId()); - } - - // Get a Cloudify client - // Set a Token Provider to fetch tokens from Cloudify itself. - String cloudifyUrl = cloudifyConfig.getCloudifyUrl(); - Cloudify cloudify = new Cloudify(cloudifyUrl); - cloudify.setTokenProvider(new CloudifyClientTokenProvider(cloudifyUrl, cloudifyConfig.getUsername(), - CryptoUtils.decryptCloudConfigPassword(cloudifyConfig.getPassword()))); - - return cloudify; - } - - - /* - * Query for a Cloudify Deployment. This function is needed in several places, so a common method is useful. This - * method takes an authenticated CloudifyClient (which internally identifies the cloud & tenant to search), and - * returns a Deployment object if found, Null if not found, or an MsoCloudifyException if the Cloudify API call - * fails. - * - * @param cloudifyClient an authenticated Cloudify client - * - * @param deploymentId the deployment to query - * - * @return a Deployment object or null if the requested deployment doesn't exist. - * - * @throws MsoCloudifyException Thrown if the Cloudify API call returns an exception - */ - protected Deployment queryDeployment(Cloudify cloudify, String deploymentId) throws MsoException { - if (deploymentId == null) { - return null; - } - try { - GetDeployment request = cloudify.deployments().byId(deploymentId); - return executeAndRecordCloudifyRequest(request); - } catch (CloudifyResponseException e) { - if (e.getStatus() == 404) { - logger.debug("queryDeployment - not found: {}", deploymentId); - return null; - } else { - // Convert the CloudifyResponseException to an MsoCloudifyException - throw cloudifyExceptionToMsoException(e, "QueryDeployment"); - } - } catch (CloudifyConnectException e) { - // Connection to Openstack failed - throw cloudifyExceptionToMsoException(e, "QueryDeployment"); - } - } - - - public void copyStringOutputsToInputs(Map<String, String> inputs, Map<String, Object> otherStackOutputs, - boolean overWrite) { - if (inputs == null || otherStackOutputs == null) - return; - - for (Map.Entry<String, Object> entry : otherStackOutputs.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - - if (value instanceof JsonNode) { - // This is a bit of mess - but I think it's the least impacting - // let's convert it BACK to a string - then it will get converted back later - try { - inputs.put(key, this.convertNode((JsonNode) value)); - } catch (Exception e) { - logger.debug("WARNING: unable to convert JsonNode output value for {}", key); - // effect here is this value will not have been copied to the inputs - and therefore will error out - // downstream - } - } else if (value instanceof java.util.LinkedHashMap) { - logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); - try { - inputs.put(key, JSON_MAPPER.writeValueAsString(value)); - } catch (Exception e) { - logger.debug("WARNING: unable to convert LinkedHashMap output value for {}", key); - } - } else { - // just try to cast it - could be an integer or some such - try { - inputs.put(key, (String) value); - } catch (Exception e) { - logger.debug("WARNING: unable to convert output value for {}", key); - // effect here is this value will not have been copied to the inputs - and therefore will error out - // downstream - } - } - } - return; - } - - /* - * Normalize an input value to an Object, based on the target parameter type. If the type is not recognized, it will - * just be returned unchanged (as a string). - */ - public Object convertInputValue(Object inputValue, HeatTemplateParam templateParam) { - String type = templateParam.getParamType(); - logger.debug("Parameter: {} is of type {}", templateParam.getParamName(), type); - - if (("number").equalsIgnoreCase(type)) { - try { - return Integer.valueOf(inputValue.toString()); - } catch (Exception e) { - logger.debug("Unable to convert {} to an integer!", inputValue); - return null; - } - } else if (("json").equalsIgnoreCase(type)) { - try { - if (inputValue instanceof String) { - return JSON_MAPPER.readTree(inputValue.toString()); - } - // will already marshal to json without intervention - return inputValue; - } catch (Exception e) { - logger.debug("Unable to convert {} to a JsonNode!", inputValue); - return null; - } - } else if (("boolean").equalsIgnoreCase(type)) { - return Boolean.valueOf(inputValue.toString()); - } - - // Nothing else matched. Return the original string - return inputValue; - } - - - private String convertNode(final JsonNode node) { - try { - final Object obj = JSON_MAPPER.treeToValue(node, Object.class); - return JSON_MAPPER.writeValueAsString(obj); - } catch (JsonParseException jpe) { - logger.debug("Error converting json to string {}", jpe); - } catch (Exception e) { - logger.debug("Error converting json to string {}", e); - } - return "[Error converting json to string]"; - } - - - /* - * Method to execute a Cloudify command and track its execution time. For the metrics log, a category of "Cloudify" - * is used along with a sub-category that identifies the specific call (using the real cloudify-client classname of - * the CloudifyRequest<T> parameter). - */ - - - protected <T> T executeAndRecordCloudifyRequest(CloudifyRequest<T> request) { - - String requestType; - if (request.getClass().getEnclosingClass() != null) { - requestType = - request.getClass().getEnclosingClass().getSimpleName() + "." + request.getClass().getSimpleName(); - } else { - requestType = request.getClass().getSimpleName(); - } - - int retryDelay = poConfig.getRetryDelay(); - int retryCount = poConfig.getRetryCount(); - String retryCodes = poConfig.getRetryCodes(); - - // Run the actual command. All exceptions will be propagated - while (true) { - try { - return request.execute(); - } catch (CloudifyResponseException e) { - boolean retry = false; - if (retryCodes != null) { - int code = e.getStatus(); - logger.debug("Config values RetryDelay: {} RetryCount:{} RetryCodes:{} ResponseCode:{}", retryDelay, - retryCount, retryCodes, code); - for (String rCode : retryCodes.split(",")) { - try { - if (retryCount > 0 && code == Integer.parseInt(rCode)) { - retryCount--; - retry = true; - logger.debug( - "CloudifyResponseException ResponseCode:{} request:{} Retry indicated. Attempts remaining:{}", - code, requestType, retryCount); - break; - } - } catch (NumberFormatException e1) { - logger.error("{} No retries. Exception in parsing retry code in config:{} {}", - MessageEnum.RA_CONFIG_EXC, rCode, ErrorCode.SchemaError.getValue()); - throw e; - } - } - } - if (retry) { - sleep(retryDelay * 1000L); - } else - throw e; // exceeded retryCount or code is not retryable - } catch (CloudifyConnectException e) { - // Connection to Cloudify failed - if (retryCount > 0) { - retryCount--; - logger.debug(" request: {} Retry indicated. Attempts remaining:{}", requestType, retryCount); - sleep(retryDelay * 1000L); - } else - throw e; - - } - } - } - - /* - * Convert an Exception on a Cloudify call to an MsoCloudifyException. This method supports - * CloudifyResponseException and CloudifyConnectException. - */ - protected MsoException cloudifyExceptionToMsoException(CloudifyBaseException e, String context) { - MsoException me = null; - - if (e instanceof CloudifyResponseException) { - CloudifyResponseException re = (CloudifyResponseException) e; - - try { - // Failed Cloudify calls return an error entity body. - CloudifyError error = re.getResponse().getErrorEntity(CloudifyError.class); - logger.error("{} {} {} Exception - Cloudify Error on {}: {}", MessageEnum.RA_CONNECTION_EXCEPTION, - CLOUDIFY, ErrorCode.DataError.getValue(), context, error.getErrorCode()); - String fullError = error.getErrorCode() + ": " + error.getMessage(); - logger.debug(fullError); - me = new MsoCloudifyException(re.getStatus(), re.getMessage(), fullError); - } catch (Exception e2) { - // Couldn't parse the body as a "CloudifyError". Report the original HTTP error. - logger.error("{} {} {} Exception - HTTP Error on {}: {}, {} ", MessageEnum.RA_CONNECTION_EXCEPTION, - CLOUDIFY, ErrorCode.DataError.getValue(), context, re.getStatus(), e.getMessage(), e2); - me = new MsoCloudifyException(re.getStatus(), re.getMessage(), ""); - } - - // Add the context of the error - me.addContext(context); - - // Generate an alarm for 5XX and higher errors. - if (re.getStatus() >= 500) { - - } - } else if (e instanceof CloudifyConnectException) { - CloudifyConnectException ce = (CloudifyConnectException) e; - - me = new MsoIOException(ce.getMessage()); - me.addContext(context); - - // Generate an alarm for all connection errors. - - logger.error("{} {} {} Cloudify connection error on {}: ", MessageEnum.RA_CONNECTION_EXCEPTION, CLOUDIFY, - ErrorCode.DataError.getValue(), context, e); - } - - return me; - } - - - - /******************************************************************************* - * - * Methods (and associated utilities) to implement the VduPlugin interface - * - *******************************************************************************/ - - /** - * VduPlugin interface for instantiate function. - * - * This one is a bit more complex, in that it will first upload the blueprint if needed, then create the Cloudify - * deployment and execute the install workflow. - * - * This implementation also merges any parameters defined in the ENV file with the other other input parameters for - * any undefined parameters). The basic MsoCloudifyUtils separates blueprint management from deploument actions, but - * the VduPlugin does not declare blueprint management operations. - */ - @Override - public VduInstance instantiateVdu(CloudInfo cloudInfo, String instanceName, Map<String, Object> inputs, - VduModelInfo vduModel, boolean rollbackOnFailure) throws VduException { - String cloudSiteId = cloudInfo.getCloudSiteId(); - String tenantId = cloudInfo.getTenantId(); - - // Translate the VDU ModelInformation structure to that which is needed for - // creating and uploading a blueprint. Use the model customization UUID as - // the blueprint identifier. - - String blueprintId = vduModel.getModelCustomizationUUID(); - - try { - - if (!isBlueprintLoaded(cloudSiteId, blueprintId)) { - logger.debug("Blueprint {} is not loaded. Will upload it now.", blueprintId); - - // Prepare the blueprint inputs. Need the set of blueprint templates and files, - // plus the main blueprint name. - Map<String, byte[]> blueprintFiles = new HashMap<>(); - String mainTemplate = ""; - - // Add all of the blueprint artifacts from the VDU model - List<VduArtifact> vduArtifacts = vduModel.getArtifacts(); - for (VduArtifact vduArtifact : vduArtifacts) { - // Add all artifacts to the blueprint, with one exception. - // ENVIRONMENT files will be processed later as additional parameters. - - ArtifactType artifactType = vduArtifact.getType(); - if (artifactType != ArtifactType.ENVIRONMENT) { - blueprintFiles.put(vduArtifact.getName(), vduArtifact.getContent()); - - if (artifactType == ArtifactType.MAIN_TEMPLATE) { - mainTemplate = vduArtifact.getName(); - } - } - } - - // Upload the blueprint package - uploadBlueprint(cloudSiteId, blueprintId, mainTemplate, blueprintFiles, false); - } - } catch (Exception e) { - throw new VduException("CloudifyUtils (instantiateVDU): blueprint Exception", e); - } - - - // Next, create and install a new deployment based on the blueprint. - // For Cloudify, the deploymentId is specified by the client. Just use the instance name - // as the ID. - - try { - // Query the Cloudify Deployment object and populate a VduInstance - DeploymentInfo deployment = - createAndInstallDeployment(cloudSiteId, tenantId, instanceName, blueprintId, inputs, true, // (poll - // for - // completion) - vduModel.getTimeoutMinutes(), rollbackOnFailure); - - return deploymentInfoToVduInstance(deployment); - } catch (Exception e) { - throw new VduException("CloudifyUtils (instantiateVDU): Create-and-install-deployment Exception", e); - } - } - - - /** - * VduPlugin interface for query function. - */ - @Override - public VduInstance queryVdu(CloudInfo cloudInfo, String instanceId) throws VduException { - String cloudSiteId = cloudInfo.getCloudSiteId(); - String tenantId = cloudInfo.getTenantId(); - - try { - // Query the Cloudify Deployment object and populate a VduInstance - DeploymentInfo deployment = queryDeployment(cloudSiteId, tenantId, instanceId); - - return deploymentInfoToVduInstance(deployment); - } catch (Exception e) { - throw new VduException("Query VDU Exception", e); - } - } - - - /** - * VduPlugin interface for delete function. - */ - @Override - public VduInstance deleteVdu(CloudInfo cloudInfo, String instanceId, int timeoutMinutes) throws VduException { - String cloudSiteId = cloudInfo.getCloudSiteId(); - String tenantId = cloudInfo.getTenantId(); - - try { - // Uninstall and delete the Cloudify Deployment - DeploymentInfo deployment = uninstallAndDeleteDeployment(cloudSiteId, tenantId, instanceId, timeoutMinutes); - - // Populate a VduInstance based on the deleted Cloudify Deployment object - return deploymentInfoToVduInstance(deployment); - } catch (Exception e) { - throw new VduException("Delete VDU Exception", e); - } - } - - - /** - * VduPlugin interface for update function. - * - * Update is currently not supported in the MsoCloudifyUtils implementation. Just return a VduException. - * - */ - @Override - public VduInstance updateVdu(CloudInfo cloudInfo, String instanceId, Map<String, Object> inputs, - VduModelInfo vduModel, boolean rollbackOnFailure) throws VduException { - throw new VduException("CloudifyUtils: updateVDU interface not supported"); - } - - - /* - * Convert the local DeploymentInfo object (Cloudify-specific) to a generic VduInstance object - */ - protected VduInstance deploymentInfoToVduInstance(DeploymentInfo deployment) { - VduInstance vduInstance = new VduInstance(); - - // only one ID in Cloudify, use for both VDU name and ID - vduInstance.setVduInstanceId(deployment.getId()); - vduInstance.setVduInstanceName(deployment.getId()); - - // Copy inputs and outputs - vduInstance.setInputs(deployment.getInputs()); - vduInstance.setOutputs(deployment.getOutputs()); - - // Translate the status elements - vduInstance.setStatus(deploymentStatusToVduStatus(deployment)); - - return vduInstance; - } - - protected VduStatus deploymentStatusToVduStatus(DeploymentInfo deployment) { - VduStatus vduStatus = new VduStatus(); - - // Determine the status based on last action & status - // DeploymentInfo object should be enhanced to report a better status internally. - DeploymentStatus status = deployment.getStatus(); - - if (status == null) { - vduStatus.setState(VduStateType.UNKNOWN); - } else if (status == DeploymentStatus.NOTFOUND) { - vduStatus.setState(VduStateType.NOTFOUND); - } else if (status == DeploymentStatus.INSTALLED) { - vduStatus.setState(VduStateType.INSTANTIATED); - } else if (status == DeploymentStatus.CREATED) { - // Deployment exists but is not installed. This shouldn't really happen, - // since create + install or uninstall + delete are always done together. - // But account for it anyway, assuming the operation is still in progress. - String lastAction = deployment.getLastAction(); - if (lastAction == null) - vduStatus.setState(VduStateType.INSTANTIATING); - else - vduStatus.setState(VduStateType.DELETING); - } else if (status == DeploymentStatus.FAILED) { - vduStatus.setState(VduStateType.FAILED); - } else { - vduStatus.setState(VduStateType.UNKNOWN); - } - - vduStatus.setErrorMessage(deployment.getErrorMessage()); - vduStatus.setLastAction(new PluginAction(deployment.getLastAction(), deployment.getActionStatus(), - deployment.getErrorMessage())); - - return vduStatus; - } - - /* - * Return an OpenstackConfig object as expected by Cloudify Openstack Plug-in. Base the values on the CloudSite - * definition. - */ - protected OpenstackConfig getOpenstackConfig(CloudSite cloudSite, String tenantId) { - OpenstackConfig openstackConfig = new OpenstackConfig(); - openstackConfig.setRegion(cloudSite.getRegionId()); - openstackConfig.setAuthUrl(cloudSite.getIdentityService().getIdentityUrl()); - openstackConfig.setUsername(cloudSite.getIdentityService().getMsoId()); - openstackConfig - .setPassword(CryptoUtils.decryptCloudConfigPassword(cloudSite.getIdentityService().getMsoPass())); - openstackConfig.setTenantName(tenantId); - return openstackConfig; - } - - /* - * Return an Azure object as expected by Cloudify Azure Plug-in. Base the values on the CloudSite definition. - */ - protected AzureConfig getAzureConfig(CloudSite cloudSite, String tenantId) { - AzureConfig azureConfig = new AzureConfig(); - // TODO: Use adminTenant for now, instead of adding another element - azureConfig.setSubscriptionId(cloudSite.getIdentityService().getAdminTenant()); - azureConfig.setTenantId(tenantId); - azureConfig.setClientId(cloudSite.getIdentityService().getMsoId()); - azureConfig.setClientSecret(cloudSite.getIdentityService().getMsoPass()); - return azureConfig; - } - - private void sleep(long time) { - try { - Thread.sleep(time); - } catch (InterruptedException e) { - logger.debug("Thread interrupted while sleeping!", e); - Thread.currentThread().interrupt(); - } - } -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java index 50ebcc66ee..6800428a62 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java @@ -97,7 +97,7 @@ public class MsoCommonUtils { * openstack-java-sdk classname of the OpenStackRequest<T> parameter). */ - protected <T> T executeAndRecordOpenstackRequest(OpenStackRequest<T> request) { + public <T> T executeAndRecordOpenstackRequest(OpenStackRequest<T> request) { return executeAndRecordOpenstackRequest(request, true); } @@ -174,7 +174,7 @@ public class MsoCommonUtils { * Convert an Openstack Exception on a Keystone call to an MsoException. This method supports both * OpenstackResponseException and OpenStackConnectException. */ - protected MsoException keystoneErrorToMsoException(OpenStackBaseException e, String context) { + public MsoException keystoneErrorToMsoException(OpenStackBaseException e, String context) { MsoException me = null; if (e instanceof OpenStackResponseException) { @@ -455,15 +455,16 @@ public class MsoCommonUtils { */ protected KeystoneAuthHolder getKeystoneAuthHolder(String cloudSiteId, String tenantId, String serviceName) throws MsoException { - CloudSite cloudSite = - cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId)); - String cloudId = cloudSite.getId(); - String region = cloudSite.getRegionId(); - CloudIdentity cloudIdentity = cloudSite.getIdentityService(); - MsoTenantUtils tenantUtils = - tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType()); - String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity); + CloudIdentity cloudIdentity = null; try { + CloudSite cloudSite = + cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId)); + String cloudId = cloudSite.getId(); + String region = cloudSite.getRegionId(); + cloudIdentity = cloudSite.getIdentityService(); + MsoTenantUtils tenantUtils = + tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType()); + String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity); if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) { Access access = getKeystone(tenantId, cloudIdentity, keystoneUrl); try { diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java index 16671bbe50..6eb7e3d56d 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java @@ -22,11 +22,11 @@ package org.onap.so.openstack.utils; import java.io.Serializable; import java.util.List; +import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"id", "links"}) diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java index 1f55aa92a2..f9a8093de6 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java @@ -21,11 +21,11 @@ package org.onap.so.openstack.utils; import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java index 9fa4557a45..dcc4f50b45 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java @@ -21,13 +21,13 @@ package org.onap.so.openstack.utils; import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.JsonNode; -import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java index c575304ade..ba5e449034 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java @@ -21,12 +21,12 @@ package org.onap.so.openstack.utils; import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.JsonNode; -import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"template_type", "workload_id", "workload_status", "workload_status_reason"}) diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java index 95dd48caa6..d679b0303e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java @@ -21,12 +21,12 @@ package org.onap.so.openstack.utils; import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.JsonNode; import com.woorea.openstack.heat.model.CreateStackParam; -import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"generic-vnf-id", "vf-module-id", "vf-module-model-invariant-id", "vf-module-model-version-id", diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java index c5eeb34157..968e7864b3 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java @@ -49,4 +49,6 @@ public class NovaClient extends MsoCommonUtils { novaClient.token(keystone.getId()); return novaClient; } + + } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java deleted file mode 100644 index 9fbb45a2c3..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 Nokia. - * ============================================================================= 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.cloudify.beans; - -import static org.assertj.core.api.Assertions.assertThat; -import com.google.common.collect.ImmutableMap; -import org.junit.Test; -import org.onap.so.cloudify.v3.model.Execution; - -public class DeploymentInfoBuilderTest { - - private static final String ERROR_MESSAGE = "something went wrong"; - private static final String INSTALL_WORKFLOW_ID = "install"; - private static final String UNINSTALL_WORKFLOW_ID = "uninstall"; - - @Test - public void shouldConstructDeploymentInfo_withBasicValues() { - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.CREATED) - .withDeploymentOutputs(ImmutableMap.of()).withDeploymentInputs(ImmutableMap.of()) - .withActionStatus("started").withLastAction(INSTALL_WORKFLOW_ID).withErrorMessage(ERROR_MESSAGE) - .build(); - - assertThat(deploymentInfo.getId()).isEqualTo("id"); - assertThat(deploymentInfo.getStatus()).isEqualTo(DeploymentStatus.CREATED); - assertThat(deploymentInfo.getOutputs()).isEqualTo(ImmutableMap.of()); - assertThat(deploymentInfo.getInputs()).isEqualTo(ImmutableMap.of()); - assertThat(deploymentInfo.getActionStatus()).isEqualTo("started"); - assertThat(deploymentInfo.getLastAction()).isEqualTo(INSTALL_WORKFLOW_ID); - assertThat(deploymentInfo.getErrorMessage()).isEqualTo(ERROR_MESSAGE); - } - - @Test - public void shouldConstructDeploymentInfo_withCreateDeploymentStatus_fromNullExecution() { - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().fromExecution(null).build(); - - assertThat(deploymentInfo.getStatus()).isEqualTo(DeploymentStatus.CREATED); - } - - @Test - public void shouldConstructDeploymentInfo_withInstalledDeploymentStatus_fromTerminatedExecution() { - String workflowIdLastAction = INSTALL_WORKFLOW_ID; - String status = "terminated"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.INSTALLED; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withFailedDeploymentStatus_fromFailedInstallExecution() { - String workflowIdLastAction = INSTALL_WORKFLOW_ID; - String status = "failed"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.FAILED; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withInstallingDeploymentStatus_fromStartedExecution() { - String workflowIdLastAction = INSTALL_WORKFLOW_ID; - String status = "started"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.INSTALLING; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withInstallingDeploymentStatus_fromPendingExecution() { - String workflowIdLastAction = INSTALL_WORKFLOW_ID; - String status = "pending"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.INSTALLING; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withUnknownDeploymentStatus_fromUnmappableExecution() { - String workflowIdLastAction = INSTALL_WORKFLOW_ID; - String status = "strangeStatus"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNKNOWN; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withCreatedDeploymentStatus_fromTerminatedExecution() { - String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; - String status = "terminated"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.CREATED; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withFailedDeploymentStatus_fromFailedUninstallExecution() { - String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; - String status = "failed"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.FAILED; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withUninstallingDeploymentStatus_fromStartedUninstallExecution() { - String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; - String status = "started"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNINSTALLING; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withUninstallingDeploymentStatus_fromPendingUninstallExecution() { - String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; - String status = "pending"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNINSTALLING; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withUnknownDeploymentStatus_fromUnmappableUninstallExecution() { - String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; - String status = "strangeStatus"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNKNOWN; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldConstructDeploymentInfo_withUnknownDeploymentStatus_forUnknownExecutionWorkflowId() { - String workflowIdLastAction = "strangeWorkflowIdLastAction"; - String status = "strangeStatus"; - DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNKNOWN; - verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); - } - - @Test - public void shouldSetEmptyOutputsMapWhenInputIsNull() { - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withDeploymentOutputs(null).build(); - assertThat(deploymentInfo.getOutputs()).isEmpty(); - } - - private void verifyDeploymentInfoConstruction(String workflowIdLastAction, String actionStatus, - DeploymentStatus expectedDeploymentStatus) { - - Execution execution = new Execution(); - execution.setWorkflowId(workflowIdLastAction); - execution.setStatus(actionStatus); - execution.setError(ERROR_MESSAGE); - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().fromExecution(execution).build(); - - assertThat(deploymentInfo.getLastAction()).isEqualTo(workflowIdLastAction); - assertThat(deploymentInfo.getActionStatus()).isEqualTo(actionStatus); - assertThat(deploymentInfo.getErrorMessage()).isEqualTo(ERROR_MESSAGE); - assertThat(deploymentInfo.getStatus()).isEqualTo(expectedDeploymentStatus); - } -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java deleted file mode 100644 index 1506fda817..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ 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.cloudify.exceptions; - -import static org.junit.Assert.*; -import org.junit.Test; - -public class MsoCloudifyExceptionTest { - - @Test - public void test() { - Exception e = null; - boolean pendingWorkflow = true; - MsoCloudifyException mce = new MsoCloudifyException(200, "message", "detail"); - MsoCloudifyException mcl = new MsoCloudifyException(200, "message", "detail", e); - mce.setPendingWorkflow(pendingWorkflow); - assert (mcl.toString() != null); - assertNotNull(mce); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java deleted file mode 100644 index 25dcae3c2c..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ 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.cloudify.exceptions; - -import static org.junit.Assert.*; -import org.junit.Test; - -public class MsoCloudifyTest { - - @Test - public void test() { - MsoBlueprintAlreadyExists mbae = new MsoBlueprintAlreadyExists("blueprintId", "cloud"); - MsoCloudifyManagerNotFound mcm = new MsoCloudifyManagerNotFound("cloudSiteId"); - MsoDeploymentAlreadyExists mdae = new MsoDeploymentAlreadyExists("deploymentId", "cloud"); - assertNotNull((mbae)); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java deleted file mode 100644 index dc74d83d04..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ 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.cloudify.exceptions; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import org.junit.Test; -import org.onap.so.cloudify.v3.model.Execution; - -public class MsoCloudifyTimeoutTest { - - @Test - public void test() { - Execution execution = mock(Execution.class); - MsoCloudifyTimeout mct = new MsoCloudifyTimeout(execution); - mct.getExecution(); - assert (mct.toString() != null); - assertNotNull(mct); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java deleted file mode 100644 index b8b2c97a65..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ 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.cloudify.exceptions; - -import static org.junit.Assert.*; -import org.junit.Test; - -public class MsoCloudifyWorkflowExceptionTest { - - @Test - public void test() { - MsoCloudifyWorkflowException mcw = - new MsoCloudifyWorkflowException("message", "id", "workflowId", "workflowStatus"); - mcw.getWorkflowStatus(); - assertFalse(mcw.isWorkflowStillRunning()); - - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java deleted file mode 100644 index d14115971c..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java +++ /dev/null @@ -1,336 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Nokia. - * ================================================================================ - * 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.cloudify.utils; - -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.so.adapters.vdu.CloudInfo; -import org.onap.so.adapters.vdu.PluginAction; -import org.onap.so.adapters.vdu.VduArtifact; -import org.onap.so.adapters.vdu.VduArtifact.ArtifactType; -import org.onap.so.adapters.vdu.VduInstance; -import org.onap.so.adapters.vdu.VduModelInfo; -import org.onap.so.adapters.vdu.VduStateType; -import org.onap.so.adapters.vdu.VduStatus; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloudify.beans.DeploymentInfo; -import org.onap.so.cloudify.beans.DeploymentInfoBuilder; -import org.onap.so.cloudify.beans.DeploymentStatus; -import org.onap.so.cloudify.v3.client.Cloudify; -import org.onap.so.cloudify.v3.model.AzureConfig; -import org.onap.so.db.catalog.beans.CloudIdentity; -import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.db.catalog.beans.CloudifyManager; -import org.onap.so.db.catalog.beans.HeatTemplateParam; -import org.onap.so.openstack.exceptions.MsoAdapterException; -import org.onap.so.openstack.exceptions.MsoException; -import org.skyscreamer.jsonassert.JSONAssert; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class MsoCloudifyUtilsTest { - - private static final String CLOUD_SITE_ID = "cloudSiteIdTest"; - private static final String BLUEPRINT_ID = "bluePrintIdTest"; - private static final String FILE_NAME = "fileName"; - - @Test - public void instantiateVduTest() throws MsoException { - VduInstance expected = new VduInstance(); - expected.setVduInstanceId("id"); - expected.setVduInstanceName("id"); - VduStatus status = new VduStatus(); - status.setState(VduStateType.INSTANTIATED); - status.setLastAction(new PluginAction(null, null, null)); - expected.setStatus(status); - - MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class); - CloudSite site = new CloudSite(); - Optional<CloudSite> opSite = Optional.ofNullable(site); - CloudConfig config = Mockito.mock(CloudConfig.class); - cloudify.cloudConfig = config; - Cloudify cloudifyClient = new Cloudify("cloudSite"); - CloudInfo cloudInfo = new CloudInfo(); - cloudInfo.setCloudSiteId("cloudSiteId"); - cloudInfo.setTenantId("tenantId"); - VduModelInfo vduModel = new VduModelInfo(); - vduModel.setModelCustomizationUUID("blueprintId"); - vduModel.setTimeoutMinutes(1); - VduArtifact artifact = new VduArtifact(); - artifact.setName("name"); - artifact.setType(ArtifactType.MAIN_TEMPLATE); - byte[] content = new byte[1]; - artifact.setContent(content); - List<VduArtifact> artifacts = new ArrayList<>(); - artifacts.add(artifact); - vduModel.setArtifacts(artifacts); - DeploymentInfo deployment = - new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.INSTALLED).build(); - Map<String, byte[]> blueprintFiles = new HashMap<>(); - blueprintFiles.put(artifact.getName(), artifact.getContent()); - String instanceName = "instanceName"; - Map<String, Object> inputs = new HashMap<>(); - boolean rollbackOnFailure = true; - - when(config.getCloudSite(cloudInfo.getCloudSiteId())).thenReturn(opSite); - doReturn(false).when(cloudify).isBlueprintLoaded(cloudInfo.getCloudSiteId(), - vduModel.getModelCustomizationUUID()); - doReturn(cloudifyClient).when(cloudify).getCloudifyClient(site); - doReturn(true).when(cloudify).uploadBlueprint(cloudifyClient, vduModel.getModelCustomizationUUID(), - artifact.getName(), blueprintFiles); - doReturn(deployment).when(cloudify).createAndInstallDeployment(cloudInfo.getCloudSiteId(), - cloudInfo.getTenantId(), instanceName, vduModel.getModelCustomizationUUID(), inputs, true, - vduModel.getTimeoutMinutes(), rollbackOnFailure); - - VduInstance actual = cloudify.instantiateVdu(cloudInfo, instanceName, inputs, vduModel, rollbackOnFailure); - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void queryVduTest() throws MsoException { - VduInstance expected = new VduInstance(); - expected.setVduInstanceId("id"); - expected.setVduInstanceName("id"); - VduStatus status = new VduStatus(); - status.setState(VduStateType.INSTANTIATED); - status.setLastAction(new PluginAction(null, null, null)); - expected.setStatus(status); - - CloudInfo cloudInfo = new CloudInfo(); - cloudInfo.setCloudSiteId("cloudSiteId"); - cloudInfo.setTenantId("tenantId"); - DeploymentInfo deployment = - new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.INSTALLED).build(); - String instanceId = "instanceId"; - - MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class); - - doReturn(deployment).when(cloudify).queryDeployment(cloudInfo.getCloudSiteId(), cloudInfo.getTenantId(), - instanceId); - - VduInstance actual = cloudify.queryVdu(cloudInfo, instanceId); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void deleteVduTest() throws MsoException { - VduInstance expected = new VduInstance(); - expected.setVduInstanceId("id"); - expected.setVduInstanceName("id"); - VduStatus status = new VduStatus(); - status.setState(VduStateType.DELETING); - status.setLastAction(new PluginAction("deleting", null, null)); - expected.setStatus(status); - - CloudInfo cloudInfo = new CloudInfo(); - cloudInfo.setCloudSiteId("cloudSiteId"); - cloudInfo.setTenantId("tenantId"); - String instanceId = "instanceId"; - int timeoutMinutes = 1; - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.CREATED) - .withLastAction("deleting").build(); - MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class); - doReturn(deploymentInfo).when(cloudify).uninstallAndDeleteDeployment(cloudInfo.getCloudSiteId(), - cloudInfo.getTenantId(), instanceId, timeoutMinutes); - - VduInstance actual = cloudify.deleteVdu(cloudInfo, instanceId, timeoutMinutes); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void deploymentInfoToVduInstanceTest() { - VduInstance expected = new VduInstance(); - expected.setVduInstanceId("id"); - expected.setVduInstanceName("id"); - VduStatus status = new VduStatus(); - status.setState(VduStateType.DELETING); - status.setLastAction(new PluginAction("deleting", null, null)); - expected.setStatus(status); - - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.CREATED) - .withLastAction("deleting").build(); - - MsoCloudifyUtils cloudify = new MsoCloudifyUtils(); - - VduInstance actual = cloudify.deploymentInfoToVduInstance(deploymentInfo); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void deploymentStatusToVduStatusTest() { - VduStatus expected = new VduStatus(); - expected.setState(VduStateType.DELETING); - expected.setLastAction(new PluginAction("deleting", null, null)); - - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.CREATED) - .withLastAction("deleting").build(); - - MsoCloudifyUtils cloudify = new MsoCloudifyUtils(); - - VduStatus actual = cloudify.deploymentStatusToVduStatus(deploymentInfo); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void getAzureConfigTest() { - AzureConfig expected = new AzureConfig(); - expected.setSubscriptionId("subscriptionId"); - expected.setTenantId("tenantId"); - expected.setClientId("msoId"); - expected.setClientSecret("msoPass"); - - MsoCloudifyUtils cloudify = new MsoCloudifyUtils(); - CloudSite cloudSite = Mockito.mock(CloudSite.class); - CloudIdentity cloudIdentity = Mockito.mock(CloudIdentity.class); - when(cloudSite.getIdentityService()).thenReturn(cloudIdentity); - when(cloudIdentity.getAdminTenant()).thenReturn("subscriptionId"); - when(cloudIdentity.getMsoId()).thenReturn("msoId"); - when(cloudIdentity.getMsoPass()).thenReturn("msoPass"); - String tenantId = "tenantId"; - AzureConfig actual = cloudify.getAzureConfig(cloudSite, tenantId); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void uploadBlueprintSuccessful() throws MsoException { - // given - MsoCloudifyUtils testedObjectSpy = spy(MsoCloudifyUtils.class); - testedObjectSpy.cloudConfig = mock(CloudConfig.class); - Map<String, byte[]> blueprints = new HashMap<>(); - - mockCloudConfig(testedObjectSpy); - doReturn(true).when(testedObjectSpy).uploadBlueprint(any(Cloudify.class), eq(BLUEPRINT_ID), eq(FILE_NAME), - eq(blueprints)); - // when - testedObjectSpy.uploadBlueprint(CLOUD_SITE_ID, BLUEPRINT_ID, FILE_NAME, blueprints, true); - // then - verify(testedObjectSpy).uploadBlueprint(any(Cloudify.class), eq(BLUEPRINT_ID), eq(FILE_NAME), eq(blueprints)); - } - - @Test - public void uploadBlueprint_exceptionThrown_blueprintExists() throws MsoException { - // given - MsoCloudifyUtils testedObjectSpy = spy(MsoCloudifyUtils.class); - testedObjectSpy.cloudConfig = mock(CloudConfig.class); - Map<String, byte[]> blueprints = new HashMap<>(); - - mockCloudConfig(testedObjectSpy); - doReturn(false).when(testedObjectSpy).uploadBlueprint(any(Cloudify.class), eq(BLUEPRINT_ID), eq(FILE_NAME), - eq(blueprints)); - // when - try { - testedObjectSpy.uploadBlueprint(CLOUD_SITE_ID, BLUEPRINT_ID, FILE_NAME, blueprints, true); - // then - fail("MsoAdapterException should be thrown"); - } catch (MsoAdapterException e) { - Assert.assertEquals(e.getMessage(), "Blueprint already exists"); - } - verify(testedObjectSpy).uploadBlueprint(any(Cloudify.class), eq(BLUEPRINT_ID), eq(FILE_NAME), eq(blueprints)); - } - - @Test - public void convertInputValueTest() throws JsonParseException, JsonMappingException, IOException { - MsoCloudifyUtils utils = new MsoCloudifyUtils(); - ObjectMapper mapper = new ObjectMapper(); - HeatTemplateParam paramNum = new HeatTemplateParam(); - paramNum.setParamType("number"); - paramNum.setParamName("my-number"); - - HeatTemplateParam paramString = new HeatTemplateParam(); - paramString.setParamType("string"); - paramString.setParamName("my-string"); - - HeatTemplateParam paramJson = new HeatTemplateParam(); - paramJson.setParamType("json"); - paramJson.setParamName("my-json"); - - HeatTemplateParam paramJsonEscaped = new HeatTemplateParam(); - paramJsonEscaped.setParamType("json"); - paramJsonEscaped.setParamName("my-json-escaped"); - - Map<String, Object> jsonMap = - mapper.readValue(getJson("free-form.json"), new TypeReference<Map<String, Object>>() {}); - - assertEquals(3, utils.convertInputValue("3", paramNum)); - assertEquals("hello", utils.convertInputValue("hello", paramString)); - assertTrue("expect no change in type", utils.convertInputValue(jsonMap, paramJson) instanceof Map); - assertTrue("expect string to become jsonNode", - utils.convertInputValue(getJson("free-form.json"), paramJsonEscaped) instanceof JsonNode); - - JSONAssert.assertEquals(getJson("free-form.json"), - mapper.writeValueAsString(utils.convertInputValue(getJson("free-form.json"), paramJsonEscaped)), false); - - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/MsoHeatUtils/" + filename))); - } - - private void mockCloudConfig(MsoCloudifyUtils testedObjectSpy) { - CloudifyManager cloudifyManager = createCloudifyManager(); - when(testedObjectSpy.cloudConfig.getCloudSite(CLOUD_SITE_ID)).thenReturn(Optional.of(createCloudSite())); - when(testedObjectSpy.cloudConfig.getCloudifyManager(CLOUD_SITE_ID)).thenReturn(cloudifyManager); - } - - private CloudifyManager createCloudifyManager() { - CloudifyManager cloudifyManager = new CloudifyManager(); - cloudifyManager.setCloudifyUrl("cloudUrlTest"); - cloudifyManager.setPassword("546573746F736973546573746F736973"); - return cloudifyManager; - } - - private CloudSite createCloudSite() { - CloudSite cloudSite = new CloudSite(); - cloudSite.setCloudifyId(CLOUD_SITE_ID); - return cloudSite; - } - -} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java index 305d52a997..89fd9a0147 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -37,10 +37,11 @@ public class QueryServiceMacroHolder extends CatalogQuery { + "\t\t\"modelUuid\" : <SERVICE_MODEL_UUID>,\n" + "\t\t\"modelInvariantUuid\" : <SERVICE_MODEL_INVARIANT_ID>,\n" + "\t\t\"modelVersion\" : <SERVICE_MODEL_VERSION>\n" + "\t},\n" - + "\t\"serviceType\" : <SERVICE_TYPE>,\n" + "\t\"serviceRole\" : <SERVICE_ROLE>,\n" - + "\t\"environmentContext\" : <ENVIRONMENT_CONTEXT>,\n" + "\t\"resourceOrder\" : <RESOURCE_ORDER>,\n" - + "\t\"workloadContext\" : <WORKLOAD_CONTEXT>,\n" + "<_SERVICEVNFS_>,\n" + "<_SERVICENETWORKS_>,\n" - + "<_SERVICEINFO_>,\n" + "<_SERVICEPROXY_>,\n" + "<_SERVICEALLOTTEDRESOURCES_>\n" + "\t}}"; + + "\t\"serviceCategory\" : <SERVICE_CATEGORY>,\n" + "\t\"serviceType\" : <SERVICE_TYPE>,\n" + + "\t\"serviceRole\" : <SERVICE_ROLE>,\n" + "\t\"environmentContext\" : <ENVIRONMENT_CONTEXT>,\n" + + "\t\"resourceOrder\" : <RESOURCE_ORDER>,\n" + "\t\"workloadContext\" : <WORKLOAD_CONTEXT>,\n" + + "<_SERVICEVNFS_>,\n" + "<_SERVICENETWORKS_>,\n" + "<_SERVICEINFO_>,\n" + "<_SERVICEPROXY_>,\n" + + "<_SERVICEALLOTTEDRESOURCES_>\n" + "\t}}"; public QueryServiceMacroHolder() { super(); @@ -80,6 +81,7 @@ public class QueryServiceMacroHolder extends CatalogQuery { put(valueMap, "SERVICE_MODEL_VERSION", service.getModelVersion()); put(valueMap, "SERVICE_TYPE", service.getServiceType()); put(valueMap, "SERVICE_ROLE", service.getServiceRole()); + put(valueMap, "SERVICE_CATEGORY", service.getCategory()); put(valueMap, "ENVIRONMENT_CONTEXT", service.getEnvironmentContext()); put(valueMap, "WORKLOAD_CONTEXT", service.getWorkloadContext()); put(valueMap, "RESOURCE_ORDER", service.getResourceOrder()); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index ea371f54f7..e4810840f1 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -33,6 +33,12 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I ('VNF-InPlaceUpdate', 'inPlaceSoftwareUpdate', 'Vnf', true, true, '7','7', 'DEFAULT', '*'), ('VNF-Config-Update', 'applyUpdatedConfig', 'Vnf', true, true, '7','7', 'DEFAULT', '*'); +-- +-- northbound_request_ref_lookup for updateInstance (Macro Flow) +-- +INSERT INTO northbound_request_ref_lookup(ID, REQUEST_SCOPE, MACRO_ACTION, ACTION, IS_ALACARTE, MIN_API_VERSION, MAX_API_VERSION, IS_TOPLEVELFLOW, CLOUD_OWNER, SERVICE_TYPE) +VALUES (500, 'Vnf', 'VNF-Macro-Modify', 'updateInstance', 0, 7, 7, 1, 'k8scloudowner4', '*'); + INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES ('Service-Create', '1', 'AssignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Create' and CLOUD_OWNER = 'DEFAULT')), @@ -211,6 +217,15 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('VNF-Config-Update', '8', 'VNFUnsetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), ('VNF-Config-Update', '9', 'VNFUnsetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')); +-- +-- orchestration_flow_reference for updateInstance (Macro Flow) +-- +insert into orchestration_flow_reference (id,COMPOSITE_ACTION,SEQ_NO,FLOW_NAME,FLOW_VERSION,NB_REQ_REF_LOOKUP_ID,SCOPE,ACTION) +values (901, 'VNF-Macro-Modify',1,'ControllerExecutionBB',1,500,'vnf','config-assign'); +insert into orchestration_flow_reference (id,COMPOSITE_ACTION,SEQ_NO,FLOW_NAME,FLOW_VERSION,NB_REQ_REF_LOOKUP_ID,SCOPE,ACTION) +values (902, 'VNF-Macro-Modify',2,'ControllerExecutionBB',1,500,'vnf','config-deploy'); + + INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES ('Service-Macro-Create', '10', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT'), 'pnf', 'config-assign'); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql index 1663fdd6a8..c5a3701a82 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql @@ -33,6 +33,8 @@ INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORC INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (2,'deleteInstance','1','VID_DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc36cc-a9fe-11e7-8b4b-0242ac120002'); INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (3,'createInstance','1','DEFAULT recipe to create service-instance if no custom BPMN flow is found','/mso/async/services/CreateGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc3acd-a9fe-11e7-8b4b-0242ac120002'); INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (4,'deleteInstance','1','DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc3acd-a9fe-11e7-8b4b-0242ac120002'); +insert into `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) values (500,'updateInstance','1.0','Gr api recipe to update service-instance', '/mso/async/services/WorkflowActionBB', NULL, 180, NULL, '2017-10-05 18:52:03', 'd88da85c-d9e8-4f73-b837-3a72a431622b'); + -- -- Custom Reciepe for the VoLTE service added temporarily @@ -43,6 +45,16 @@ INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODE INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (11,'createInstance','1','Custom recipe to create E2E service-instance if no custom BPMN flow is found','/mso/async/services/CreateCustomE2EServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (12,'deleteInstance','1','Custom recipe to delete E2E service-instance if no custom BPMN flow is found','/mso/async/services/DeleteCustomE2EServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); +-- Recipe for onap3gppServiceInstances + +INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('3d30a774-e149-11ea-87d0-0242ac130003','COMMON_SS_DEFAULT','3d30a774-e149-11ea-87d0-0242ac130003','1.0','Default service for common NSSMF','2020-08-18 17:40:03',NULL); + +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (17,'createInstance','1','Custom recipe to allocate 3gpp service-instance if no custom BPMN flow is found','/mso/async/services/AllocateSliceSubnet',NULL,180,NULL,'2020-08-18 17:40:03','3d30a774-e149-11ea-87d0-0242ac130003'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (18,'deleteInstance','1','Custom recipe to deallocate 3gpp service-instance if no custom BPMN flow is found','/mso/async/services/DeAllocateSliceSubnet',NULL,180,NULL,'2020-08-18 18:40:03','3d30a774-e149-11ea-87d0-0242ac130003'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (19,'updateInstance','1','Custom recipe to modify 3gpp service-instance if no custom BPMN flow is found','/mso/async/services/ModifySliceSubnet',NULL,180,NULL,'2020-08-18 18:40:03','3d30a774-e149-11ea-87d0-0242ac130003'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (20,'activateInstance','1','Custom recipe to activate/deactivate 3gpp service-instance if no custom BPMN flow is found','/mso/async/services/ActivateSliceSubnet',NULL,180,NULL,'2020-08-18 18:40:03','3d30a774-e149-11ea-87d0-0242ac130003'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (21,'deactivateInstance','1','Custom recipe to activate/deactivate 3gpp service-instance if no custom BPMN flow is found','/mso/async/services/ActivateSliceSubnet',NULL,180,NULL,'2020-08-18 18:40:03','3d30a774-e149-11ea-87d0-0242ac130003'); + -- Recipe for E2E service update (R2 just support adding/deleting network service) INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (15,'updateInstance','1','Custom recipe to update E2E service-instance if no custom BPMN flow is found','/mso/async/services/UpdateCustomE2EServiceInstance',NULL,180,NULL,'2018-03-05 10:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (16,'scaleInstance','1','Custom recipe to scale E2E service-instance if no custom BPMN flow is found','/mso/async/services/ScaleCustomE2EServiceInstance',NULL,180,NULL,'2018-05-15 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); @@ -60,6 +72,7 @@ INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (11,NULL,'vfModule','VID_DEFAULT','deleteInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/DeleteVfModuleInfra',null,180,'2017-10-05 18:52:03'); INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (12,NULL,'vfModule','VID_DEFAULT','updateInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/UpdateVfModuleInfra',null,180,'2017-10-05 18:52:03'); + -- -- Default Reciepe for the VNF componnets added start #SO-334, to unblock the VNF operations -- diff --git a/adapters/mso-cnf-adapter/pom.xml b/adapters/mso-cnf-adapter/pom.xml index fb25157a96..0928da084e 100644 --- a/adapters/mso-cnf-adapter/pom.xml +++ b/adapters/mso-cnf-adapter/pom.xml @@ -110,11 +110,11 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> - <!-- <dependency> + <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> - </dependency> --> + </dependency> <!-- <dependency> <groupId>org.onap.so</groupId> <artifactId>mso-requests-db</artifactId> diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java index e94c283a98..0ba40e2700 100644 --- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java @@ -28,8 +28,10 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; @SpringBootApplication @ComponentScan(basePackages = {"org.onap.so.adapters.cnf"}) @@ -42,4 +44,9 @@ public class MSOCnfApplication { public static void main(String... args) { SpringApplication.run(MSOCnfApplication.class, args); } + + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } } diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/exceptions/ApplicationException.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/exceptions/ApplicationException.java new file mode 100644 index 0000000000..c950cf6b2a --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/exceptions/ApplicationException.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.exceptions; + +import static org.onap.so.adapters.cnf.util.CNfAdapterUtil.marshal; +import org.onap.so.adapters.cnf.model.ErrorResponse; +import org.springframework.http.ResponseEntity; + +public class ApplicationException extends Exception { + + private static final long serialVersionUID = 1L; + + private int errorCode; + + private String errorMsg; + + public ApplicationException(int errorCode, String errorMsg) { + this.errorCode = errorCode; + this.errorMsg = errorMsg; + } + + public int getErrorCode() { + return errorCode; + } + + public void setErrorCode(int errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public ResponseEntity buildErrorResponse() { + String message; + try { + ErrorResponse err = new ErrorResponse(errorCode, errorMsg); + message = marshal(err); + } catch (ApplicationException e) { + return ResponseEntity.status(500).body("Internal Server Error"); + } + return ResponseEntity.status(errorCode).body(message); + } +} diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/BpmnInstanceRequest.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/BpmnInstanceRequest.java new file mode 100644 index 0000000000..2e76d51da2 --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/BpmnInstanceRequest.java @@ -0,0 +1,87 @@ +package org.onap.so.adapters.cnf.model; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonIgnoreProperties(value = "true") +public class BpmnInstanceRequest { + + @JsonProperty(value = "modelInvariantId") + private String modelInvariantId; + + @JsonProperty(value = "modelVersionId") + private String modelVersionId; + + @JsonProperty(value = "k8sRBProfileName") + private String k8sRBProfileName; + + @JsonProperty(value = "cloudRegionId") + private String cloudRegionId; + + @JsonProperty(value = "vfModuleUUID") + private String vfModuleUUID; + + @JsonProperty(value = "labels") + private Map<String, String> labels; + + @JsonProperty(value = "overrideValues") + private Map<String, String> overrideValues; + + public String getModelInvariantId() { + return modelInvariantId; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public String getModelVersionId() { + return modelVersionId; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + public String getK8sRBProfileName() { + return k8sRBProfileName; + } + + public void setK8sRBProfileName(String k8sRBProfileName) { + this.k8sRBProfileName = k8sRBProfileName; + } + + public String getCloudRegionId() { + return cloudRegionId; + } + + public void setCloudRegionId(String cloudRegionId) { + this.cloudRegionId = cloudRegionId; + } + + public String getVfModuleUUID() { + return vfModuleUUID; + } + + public void setVfModuleUUID(String vfModuleUUID) { + this.vfModuleUUID = vfModuleUUID; + } + + public Map<String, String> getLabels() { + return labels; + } + + public void setLabels(Map<String, String> labels) { + this.labels = labels; + } + + public Map<String, String> getOverrideValues() { + return overrideValues; + } + + public void setOverrideValues(Map<String, String> overrideValues) { + this.overrideValues = overrideValues; + } + +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/ErrorResponse.java index 188349c0bf..135adcc143 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/ErrorResponse.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.nssmf.model; +package org.onap.so.adapters.cnf.model; public class ErrorResponse { diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/UpdateNodeInstanceParams.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/GroupVersionKind.java index fabb70a49a..bfa5505ccc 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/UpdateNodeInstanceParams.java +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/GroupVersionKind.java @@ -1,15 +1,16 @@ + /*- * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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. @@ -17,56 +18,49 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +package org.onap.so.adapters.cnf.model; -package org.onap.so.cloudify.v3.model; - +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.Map; - -public class UpdateNodeInstanceParams implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("state") - private String state; - - @JsonProperty("version") +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"Group", "Version", "Kind"}) +public class GroupVersionKind { + @JsonProperty("Group") + private String group; + @JsonProperty("Version") private String version; + @JsonProperty("Kind") + private String kind; - @JsonProperty("runtime_properties") - private Map<String, Object> runtimeProperties; - - - public String getState() { - return state; + @JsonProperty("Group") + public String getGroup() { + return group; } - public void setState(String state) { - this.state = state; + @JsonProperty("Group") + public void setGroup(String group) { + this.group = group; } + @JsonProperty("Version") public String getVersion() { return version; } + @JsonProperty("Version") public void setVersion(String version) { this.version = version; } - public Map<String, Object> getRuntimeProperties() { - return runtimeProperties; - } - - public void setRuntimeProperties(Map<String, Object> runtimeProperties) { - this.runtimeProperties = runtimeProperties; + @JsonProperty("Kind") + public String getKind() { + return kind; } - - @Override - public String toString() { - return "UpdateNodeInstanceParams{" + "state='" + state + '\'' + "version='" + version + '\'' - + ", runtimeProperties=" + runtimeProperties + '}'; + @JsonProperty("Kind") + public void setKind(String kind) { + this.kind = kind; } - } diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponse.java new file mode 100644 index 0000000000..58040826dd --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponse.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(value = "true") +public class InstanceMiniResponse extends Response { + + private String id; + private MulticloudInstanceRequest request; + private String nameSpace; + + public InstanceMiniResponse(String errorMsg) { + super(errorMsg); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public MulticloudInstanceRequest getRequest() { + return request; + } + + public void setRequest(MulticloudInstanceRequest request) { + this.request = request; + } + + public String getNameSpace() { + return nameSpace; + } + + public void setNameSpace(String nameSpace) { + this.nameSpace = nameSpace; + } + +} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprints.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponseList.java index aebf1e5daa..ad70fbb7d0 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprints.java +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponseList.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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. @@ -18,36 +18,28 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.v3.model; +package org.onap.so.adapters.cnf.model; -import java.io.Serializable; import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; -public class Blueprints implements Serializable { +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(value = "true") +public class InstanceMiniResponseList extends Response { - private static final long serialVersionUID = 1L; - - @JsonProperty("items") - private List<Blueprint> items; - - @JsonProperty("metadata") - private Metadata metadata; - - public List<Blueprint> getItems() { - return items; + public InstanceMiniResponseList(String errorMsg) { + super(errorMsg); } - public void setItems(List<Blueprint> items) { - this.items = items; - } + private List<InstanceMiniResponse> instancList; - public Metadata getMetadata() { - return metadata; + public List<InstanceMiniResponse> getInstancList() { + return instancList; } - public void setMetadata(Metadata metadata) { - this.metadata = metadata; + public void setInstancList(List<InstanceMiniResponse> instancList) { + this.instancList = instancList; } } diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java new file mode 100644 index 0000000000..effaaf5f78 --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java @@ -0,0 +1,87 @@ + +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.model; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"id", "request", "namespace", "resources"}) +@JsonIgnoreProperties(value = "true") +public class InstanceResponse extends Response { + + @JsonProperty("id") + private String id; + @JsonProperty("request") + private MulticloudInstanceRequest request; + @JsonProperty("namespace") + private String namespace; + @JsonProperty("resources") + private List<Resource> resources = null; + + public InstanceResponse(String errorMsg) { + super(errorMsg); + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("id") + public void setId(String id) { + this.id = id; + } + + @JsonProperty("request") + public MulticloudInstanceRequest getRequest() { + return request; + } + + @JsonProperty("request") + public void setRequest(MulticloudInstanceRequest request) { + this.request = request; + } + + @JsonProperty("namespace") + public String getNamespace() { + return namespace; + } + + @JsonProperty("namespace") + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + @JsonProperty("resources") + public List<Resource> getResources() { + return resources; + } + + @JsonProperty("resources") + public void setResources(List<Resource> resources) { + this.resources = resources; + } + +} diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceStatusResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceStatusResponse.java new file mode 100644 index 0000000000..2472684bc0 --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceStatusResponse.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.model; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(value = "true") +public class InstanceStatusResponse extends Response { + + public InstanceStatusResponse(String errorMsg) { + super(errorMsg); + } + + private MulticloudInstanceRequest request; + + private boolean ready; + + private String resourceCount; + + private List<PodStatus> podStatuses; + + private List<?> servicesStatuses; + + public MulticloudInstanceRequest getRequest() { + return request; + } + + public void setRequest(MulticloudInstanceRequest request) { + this.request = request; + } + + public boolean isReady() { + return ready; + } + + public void setReady(boolean ready) { + this.ready = ready; + } + + public String getResourceCount() { + return resourceCount; + } + + public void setResourceCount(String resourceCount) { + this.resourceCount = resourceCount; + } + + public List<PodStatus> getPodStatuses() { + return podStatuses; + } + + public void setPodStatuses(List<PodStatus> podStatuses) { + this.podStatuses = podStatuses; + } + + public List<?> getServicesStatuses() { + return servicesStatuses; + } + + public void setServicesStatuses(List<?> servicesStatuses) { + this.servicesStatuses = servicesStatuses; + } + +} diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceEntity.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/MulticloudInstanceRequest.java index 04f2f9d030..b1719cbd7d 100644 --- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceEntity.java +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/MulticloudInstanceRequest.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; @JsonIgnoreProperties(value = "true") -public class InstanceEntity { +public class MulticloudInstanceRequest { @JsonProperty(value = "cloud-region") private String cloudRegion; @@ -25,6 +25,9 @@ public class InstanceEntity { @JsonProperty(value = "override-values") private Map<String, String> overrideValues; + @JsonProperty(value = "release-name") + private String vfModuleUuid; + public String getCloudRegion() { return cloudRegion; } @@ -73,4 +76,12 @@ public class InstanceEntity { this.overrideValues = overrideValues; } + public String getVfModuleUuid() { + return vfModuleUuid; + } + + public void setVfModuleUuid(String vfModuleUuid) { + this.vfModuleUuid = vfModuleUuid; + } + } diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/PodStatus.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/PodStatus.java new file mode 100644 index 0000000000..ed04601b2c --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/PodStatus.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.model; + +public class PodStatus { + + private String name; + private String nameSpace; + private boolean ready; + private String status; + private String[] ipAddresses; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNameSpace() { + return nameSpace; + } + + public void setNameSpace(String nameSpace) { + this.nameSpace = nameSpace; + } + + public boolean isReady() { + return ready; + } + + public void setReady(boolean ready) { + this.ready = ready; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String[] getIpAddresses() { + return ipAddresses; + } + + public void setIpAddresses(String[] ipAddresses) { + this.ipAddresses = ipAddresses; + } + +} diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Resource.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Resource.java new file mode 100644 index 0000000000..d18cd76039 --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Resource.java @@ -0,0 +1,54 @@ + +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"GVK", "Name"}) +public class Resource { + @JsonProperty("GVK") + private GroupVersionKind gVK; + @JsonProperty("Name") + private String name; + + @JsonProperty("GVK") + public GroupVersionKind getGVK() { + return gVK; + } + + @JsonProperty("GVK") + public void setGVK(GroupVersionKind gVK) { + this.gVK = gVK; + } + + @JsonProperty("Name") + public String getName() { + return name; + } + + @JsonProperty("Name") + public void setName(String name) { + this.name = name; + } +} diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Response.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Response.java new file mode 100644 index 0000000000..423022393c --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Response.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.model; + +public class Response { + + private String errorMsg; + + public Response(String errorMsg) { + this.errorMsg = errorMsg; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + +} diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java index 952edef7f6..825778b89a 100644 --- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java @@ -1,27 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.rest; +import java.io.File; +import java.io.IOException; +import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.FileBody; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; +import org.onap.so.adapters.cnf.model.BpmnInstanceRequest; import org.onap.so.adapters.cnf.model.ConfigTemplateEntity; import org.onap.so.adapters.cnf.model.ConfigurationEntity; +import org.onap.so.adapters.cnf.model.ConfigurationRollbackEntity; import org.onap.so.adapters.cnf.model.ConnectivityInfo; -import org.onap.so.adapters.cnf.model.InstanceEntity; +import org.onap.so.adapters.cnf.model.InstanceMiniResponseList; +import org.onap.so.adapters.cnf.model.InstanceResponse; +import org.onap.so.adapters.cnf.model.InstanceStatusResponse; import org.onap.so.adapters.cnf.model.ProfileEntity; import org.onap.so.adapters.cnf.model.ResourceBundleEntity; +import org.onap.so.adapters.cnf.model.Tag; +import org.onap.so.adapters.cnf.service.CnfAdapterService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -31,23 +71,78 @@ public class CnfAdapterRest { private static final Logger logger = LoggerFactory.getLogger(CnfAdapterRest.class); private final CloseableHttpClient httpClient = HttpClients.createDefault(); + @Autowired + private CnfAdapterService cnfAdapterService; + @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/healthcheck"}, method = RequestMethod.GET, + @RequestMapping(value = {"/api/cnf-adapter/v1/healthcheck"}, method = RequestMethod.GET, produces = "application/json") - public String healthCheck() throws Exception { + public ResponseEntity<String> healthCheck() throws Exception { - logger.info("health check called."); + logger.info("healthCheck called."); + return cnfAdapterService.healthCheck(); + + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/instance"}, method = RequestMethod.POST, + produces = "application/json", consumes = "application/json") + public ResponseEntity<InstanceResponse> createInstance(@RequestBody BpmnInstanceRequest bpmnInstanceRequest) + throws JsonParseException, JsonMappingException, IOException { + + logger.info("createInstance called."); + return cnfAdapterService.createInstance(bpmnInstanceRequest); + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instID}"}, method = RequestMethod.GET, + produces = "application/json") + public ResponseEntity<InstanceResponse> getInstanceByInstanceId(@PathVariable("instID") String instanceId) + throws JsonParseException, JsonMappingException, IOException { + + logger.info("getInstanceByInstanceId called."); + + return cnfAdapterService.getInstanceByInstanceId(instanceId); - // TODO - HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/healthcheck"); - try (CloseableHttpResponse response = httpClient.execute(req)) { - logger.info("response:" + response.getEntity()); - return EntityUtils.toString(response.getEntity()); - } } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition"}, method = RequestMethod.POST, + @RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instID}/status"}, method = RequestMethod.GET, + produces = "application/json") + public ResponseEntity<InstanceStatusResponse> getInstanceStatusByInstanceId( + @PathVariable("instID") String instanceId) throws JsonParseException, JsonMappingException, IOException { + + logger.info("getInstanceStatusByInstanceId called."); + + return cnfAdapterService.getInstanceStatusByInstanceId(instanceId); + + } + + @RequestMapping(value = {"/api/cnf-adapter/v1/instance"}, method = RequestMethod.GET, produces = "application/json") + public ResponseEntity<InstanceMiniResponseList> getInstanceByRBNameOrRBVersionOrProfileName( + @RequestParam(value = "rb-name", required = false) String rbName, + @RequestParam(value = "rb-version", required = false) String rbVersion, + @RequestParam(value = "profile-name", required = false) String profileName) + throws JsonParseException, JsonMappingException, IOException { + + logger.info("getInstanceByRBNameOrRBVersionOrProfileName called."); + return cnfAdapterService.getInstanceByRBNameOrRBVersionOrProfileName(rbName, rbVersion, profileName); + + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instID}"}, method = RequestMethod.DELETE, + produces = "application/json") + public ResponseEntity<String> deleteInstanceByInstanceId(@PathVariable("instID") String instanceID) + throws JsonParseException, JsonMappingException, IOException { + + logger.info("deleteInstanceByInstanceId called."); + return cnfAdapterService.deleteInstanceByInstanceId(instanceID); + + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition"}, method = RequestMethod.POST, produces = "application/json") public String createRB(@RequestBody ResourceBundleEntity rB) throws Exception { @@ -55,7 +150,7 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpPost post = new HttpPost("https://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition"); + HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/rb/definition"); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); String requestBody = objectMapper.writeValueAsString(rB); @@ -70,8 +165,8 @@ public class CnfAdapterRest { } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}"}, - method = RequestMethod.GET, produces = "application/json") + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}"}, method = RequestMethod.GET, + produces = "application/json") public String getRB(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion) throws Exception { @@ -79,16 +174,101 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpGet req = new HttpGet( - "https://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/" + rbVersion); + HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion); + try (CloseableHttpResponse response = httpClient.execute(req)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}"}, method = RequestMethod.DELETE, + produces = "application/json") + public String deleteRB(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion) + throws Exception { + + logger.info("delete RB called."); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpDelete req = new HttpDelete("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion); + + try (CloseableHttpResponse response = httpClient.execute(req)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}"}, method = RequestMethod.GET, + produces = "application/json") + public String getListOfRB(@PathVariable("rb-name") String rbName) throws Exception { + + logger.info("getListOfRB called."); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/rb/definition/" + rbName); + + try (CloseableHttpResponse response = httpClient.execute(req)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition"}, method = RequestMethod.GET, + produces = "application/json") + public String getListOfRBWithoutUsingRBName() throws Exception { + + logger.info("getListOfRBWithoutUsingRBName called."); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/rb/definition"); + try (CloseableHttpResponse response = httpClient.execute(req)) { logger.info("response:" + response.getEntity()); return EntityUtils.toString(response.getEntity()); } + } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}/profile"}, + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/content"}, + method = RequestMethod.POST, produces = "multipart/form-data") + public String uploadArtifactForRB(@RequestParam("file") MultipartFile file, @PathVariable("rb-name") String rbName, + @PathVariable("rb-version") String rbVersion) throws Exception { + + logger.info("Upload Artifact For RB called."); + + File convFile = new File(file.getOriginalFilename()); + file.transferTo(convFile); + FileBody fileBody = new FileBody(convFile, ContentType.DEFAULT_BINARY); + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addPart("file", fileBody); + HttpEntity entity = builder.build(); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpPost post = + new HttpPost("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/content"); + post.setHeader("Content-Type", "multipart/form-data"); + logger.info(String.valueOf(post)); + post.setEntity(entity); + + try (CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = httpClient.execute(post)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile"}, method = RequestMethod.POST, produces = "application/json") public String createProfile(@RequestBody ProfileEntity fE, @PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion) throws Exception { @@ -97,8 +277,8 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpPost post = new HttpPost("http://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/" - + rbVersion + "/profile"); + HttpPost post = + new HttpPost("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile"); ObjectMapper objectMapper = new ObjectMapper(); String requestBody = objectMapper.writeValueAsString(fE); StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON); @@ -112,7 +292,7 @@ public class CnfAdapterRest { } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}"}, + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}"}, method = RequestMethod.GET, produces = "application/json") public String getProfile(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion, @PathVariable("pr-name") String prName) throws Exception { @@ -121,8 +301,8 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/" - + rbVersion + "/profile/" + prName); + HttpGet req = new HttpGet( + "http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile/" + prName); try (CloseableHttpResponse response = httpClient.execute(req)) { logger.info("response:" + response.getEntity()); @@ -131,48 +311,79 @@ public class CnfAdapterRest { } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/instance"}, method = RequestMethod.POST, - produces = "application/json") - public String createInstance(@RequestBody InstanceEntity iE) throws Exception { + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile"}, + method = RequestMethod.GET, produces = "application/json") + public String getListOfProfile(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion) + throws Exception { - logger.info("create Instance called."); + logger.info("getListOfProfile called."); // TODO // Below URL should be changed as appropriate multicloud URL. - HttpPost post = new HttpPost("https://localhost:32780/api/multicloud-k8s/v1/v1/instance"); - ObjectMapper objectMapper = new ObjectMapper(); + HttpGet req = + new HttpGet("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile"); - objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - String requestBody = objectMapper.writeValueAsString(iE); - StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON); - post.setEntity(requestEntity); - - try (CloseableHttpClient httpClient = HttpClients.createDefault(); - CloseableHttpResponse response = httpClient.execute(post)) { + try (CloseableHttpResponse response = httpClient.execute(req)) { logger.info("response:" + response.getEntity()); return EntityUtils.toString(response.getEntity()); } } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/instance/{instID}"}, method = RequestMethod.GET, - produces = "application/json") - public String getInstance(@PathVariable("instID") String instanceId) throws Exception { + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}"}, + method = RequestMethod.DELETE, produces = "application/json") + public String deleteProfile(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion, + @PathVariable("pr-name") String prName) throws Exception { + + logger.info("delete Profile called."); - logger.info("get Instance called."); // TODO // Below URL should be changed as appropriate multicloud URL. - HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/v1/instance/" + instanceId); + HttpDelete req = new HttpDelete( + "http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile/" + prName); try (CloseableHttpResponse response = httpClient.execute(req)) { logger.info("response:" + response.getEntity()); return EntityUtils.toString(response.getEntity()); } + } @ResponseBody - @RequestMapping( - value = {"/api/multicloud-k8s/v1/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config"}, + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}/content"}, + method = RequestMethod.POST, produces = "multipart/form-data") + public String uploadArtifactForProfile(@RequestParam("file") MultipartFile file, + @PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion, + @PathVariable("pr-name") String prName) throws Exception { + + logger.info("Upload Artifact For Profile called."); + + File convFile = new File(file.getOriginalFilename()); + file.transferTo(convFile); + FileBody fileBody = new FileBody(convFile, ContentType.DEFAULT_BINARY); + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addPart("file", fileBody); + HttpEntity entity = builder.build(); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + + "/profile/" + prName + "/content"); + post.setHeader("Content-Type", "multipart/form-data"); + + logger.info(String.valueOf(post)); + post.setEntity(entity); + + try (CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = httpClient.execute(post)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config"}, method = RequestMethod.POST, produces = "application/json") public String createConfiguration(@RequestBody ConfigurationEntity cE, @PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion, @PathVariable("profile-name") String prName) @@ -182,8 +393,8 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpPost post = new HttpPost("https://localhost:32780/api/multicloud-k8s/v1/v1/definition/" + rbName + "/" - + rbVersion + "/profile/" + prName + "/config"); + HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion + + "/profile/" + prName + "/config"); ObjectMapper objectMapper = new ObjectMapper(); String requestBody = objectMapper.writeValueAsString(cE); StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON); @@ -197,8 +408,8 @@ public class CnfAdapterRest { } @ResponseBody - @RequestMapping(value = { - "/api/multicloud-k8s/v1/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"}, + @RequestMapping( + value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"}, method = RequestMethod.GET, produces = "application/json") public String getConfiguration(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion, @PathVariable("profile-name") String prName, @PathVariable("cfg-name") String cfgName) throws Exception { @@ -207,17 +418,89 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/v1/definition/" + rbName + "/" - + rbVersion + "/profile/" + prName + "/config/" + cfgName); + HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion + "/profile/" + + prName + "/config/" + cfgName); + + try (CloseableHttpResponse response = httpClient.execute(req)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + } + + @ResponseBody + @RequestMapping( + value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"}, + method = RequestMethod.DELETE, produces = "application/json") + public String deleteConfiguration(@PathVariable("rb-name") String rbName, + @PathVariable("rb-version") String rbVersion, @PathVariable("profile-name") String prName, + @PathVariable("cfg-name") String cfgName) throws Exception { + + logger.info("delete Configuration called."); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpDelete req = new HttpDelete("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion + + "/profile/" + prName + "/config/" + cfgName); try (CloseableHttpResponse response = httpClient.execute(req)) { logger.info("response:" + response.getEntity()); return EntityUtils.toString(response.getEntity()); } + + } + + @ResponseBody + @RequestMapping( + value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"}, + method = RequestMethod.PUT, produces = "application/json") + public String updateConfiguration(@RequestBody ConfigurationEntity cE, @PathVariable("rb-name") String rbName, + @PathVariable("rb-version") String rbVersion, @PathVariable("profile-name") String prName, + @PathVariable("cfg-name") String cfgName) throws Exception { + + logger.info("update Configuration called."); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpPut post = new HttpPut("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion + "/profile/" + + prName + "/config/" + cfgName); + ObjectMapper objectMapper = new ObjectMapper(); + String requestBody = objectMapper.writeValueAsString(cE); + StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON); + post.setEntity(requestEntity); + + try (CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = httpClient.execute(post)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/tagit"}, + method = RequestMethod.POST, produces = "application/json") + public String tagConfigurationValue(@RequestBody Tag tag, @PathVariable("rb-name") String rbName, + @PathVariable("rb-version") String rbVersion, @PathVariable("pr-name") String prName) throws Exception { + logger.info("Tag Configuration called."); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion + + "/profile/" + prName + "/config/tagit"); + + ObjectMapper objectMapper = new ObjectMapper(); + String requestBody = objectMapper.writeValueAsString(tag); + StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON); + post.setEntity(requestEntity); + + try (CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = httpClient.execute(post)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/connectivity-info"}, method = RequestMethod.POST, + @RequestMapping(value = {"/api/cnf-adapter/v1/connectivity-info"}, method = RequestMethod.POST, produces = "application/json") public String createConnectivityInfo(@RequestBody ConnectivityInfo cIE) throws Exception { @@ -225,7 +508,7 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpPost post = new HttpPost("https://localhost:32780/api/multicloud-k8s/v1/v1/connectivity-info"); + HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/connectivity-info"); ObjectMapper objectMapper = new ObjectMapper(); String requestBody = objectMapper.writeValueAsString(cIE); StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON); @@ -239,7 +522,7 @@ public class CnfAdapterRest { } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/connectivity-info/{connname}"}, method = RequestMethod.GET, + @RequestMapping(value = {"/api/cnf-adapter/v1/connectivity-info/{connname}"}, method = RequestMethod.GET, produces = "application/json") public String getConnectivityInfo(@PathVariable("connname") String connName) throws Exception { @@ -247,16 +530,34 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/v1/connectivity-info/" + connName); + HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/connectivity-info/" + connName); + + try (CloseableHttpResponse response = httpClient.execute(req)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/connectivity-info/{connname}"}, method = RequestMethod.DELETE, + produces = "application/json") + public String deleteConnectivityInfo(@PathVariable("connname") String connName) throws Exception { + + logger.info("delete Connectivity Info called."); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpDelete req = new HttpDelete("http://multicloud-k8s:9015/v1/connectivity-info/" + connName); try (CloseableHttpResponse response = httpClient.execute(req)) { logger.info("response:" + response.getEntity()); return EntityUtils.toString(response.getEntity()); } + } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}/config-template"}, + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/config-template"}, method = RequestMethod.POST, produces = "application/json") public String createConfigTemplate(@RequestBody ConfigTemplateEntity tE, @PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion) throws Exception { @@ -265,8 +566,8 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpPost post = new HttpPost("http://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/" - + rbVersion + "/config-template"); + HttpPost post = new HttpPost( + "http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/config-template"); ObjectMapper objectMapper = new ObjectMapper(); String requestBody = objectMapper.writeValueAsString(tE); StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON); @@ -280,7 +581,7 @@ public class CnfAdapterRest { } @ResponseBody - @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}"}, + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}"}, method = RequestMethod.GET, produces = "application/json") public String getConfigTemplate(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion, @PathVariable("tname") String tName) throws Exception { @@ -289,8 +590,8 @@ public class CnfAdapterRest { // TODO // Below URL should be changed as appropriate multicloud URL. - HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/" - + rbVersion + "/config-template/" + tName); + HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + + "/config-template/" + tName); try (CloseableHttpResponse response = httpClient.execute(req)) { logger.info("response:" + response.getEntity()); @@ -298,4 +599,83 @@ public class CnfAdapterRest { } } + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}"}, + method = RequestMethod.DELETE, produces = "application/json") + public String deleteTemplate(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion, + @PathVariable("tname") String tName) throws Exception { + + logger.info("deleteTemplate called."); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpDelete req = new HttpDelete("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + + "/config-template/" + tName); + + try (CloseableHttpResponse response = httpClient.execute(req)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + + } + + @ResponseBody + @RequestMapping( + value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}/content"}, + method = RequestMethod.POST, produces = "multipart/form-data") + public String uploadTarFileForTemplate(@RequestParam("file") MultipartFile file, + @PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion, + @PathVariable("tname") String tName) throws Exception { + + logger.info("uploadTarFileForTemplate called."); + + File convFile = new File(file.getOriginalFilename()); + file.transferTo(convFile); + FileBody fileBody = new FileBody(convFile, ContentType.DEFAULT_BINARY); + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addPart("file", fileBody); + HttpEntity entity = builder.build(); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + + "/config-template/" + tName + "/content"); + post.setHeader("Content-Type", "multipart/form-data"); + + logger.info(String.valueOf(post)); + post.setEntity(entity); + + try (CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = httpClient.execute(post)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + } + + @ResponseBody + @RequestMapping(value = {"/api/cnf-adapter/v1/definition/{rbName}/{rbVersion}/profile/{prName}/config/rollback"}, + method = RequestMethod.DELETE, produces = "application/json") + public String rollbackConfiguration(@RequestBody ConfigurationRollbackEntity rE, + @PathVariable("rbName") String rbName, @PathVariable("rbVersion") String rbVersion, + @PathVariable("prName") String prName) throws Exception { + logger.info("rollbackConfiguration called."); + + // TODO + // Below URL should be changed as appropriate multicloud URL. + HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion + + "/profile/" + prName + "/config/rollback"); + + ObjectMapper objectMapper = new ObjectMapper(); + String requestBody = objectMapper.writeValueAsString(rE); + StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON); + post.setEntity(requestEntity); + + try (CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = httpClient.execute(post)) { + logger.info("response:" + response.getEntity()); + return EntityUtils.toString(response.getEntity()); + } + } + } diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java new file mode 100644 index 0000000000..06c09e3431 --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java @@ -0,0 +1,269 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.service; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.persistence.EntityNotFoundException; +import javax.ws.rs.core.UriBuilder; +import org.apache.http.HttpStatus; +import org.onap.so.adapters.cnf.model.BpmnInstanceRequest; +import org.onap.so.adapters.cnf.model.InstanceMiniResponse; +import org.onap.so.adapters.cnf.model.InstanceMiniResponseList; +import org.onap.so.adapters.cnf.model.InstanceResponse; +import org.onap.so.adapters.cnf.model.InstanceStatusResponse; +import org.onap.so.adapters.cnf.model.MulticloudInstanceRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpStatusCodeException; +import org.springframework.web.client.RestTemplate; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; + +@Service +public class CnfAdapterService { + private static final Logger logger = LoggerFactory.getLogger(CnfAdapterService.class); + @Autowired + private RestTemplate restTemplate; + private static final String INSTANCE_CREATE_PATH = "/v1/instance"; + private static final String HEALTH_CHECK = "/v1/healthcheck"; + + public ResponseEntity<String> healthCheck() { + + logger.info("CnfAdapterService createInstance called"); + ResponseEntity<String> result = null; + try { + + logger.info("CnfAdapterService createInstance called"); + + // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO: + // This needs to be added as well + // for configuration + String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri? + String endpoint = UriBuilder.fromUri(uri).path(HEALTH_CHECK).build().toString(); + HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders()); + result = restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, String.class); + return result; + } catch (HttpClientErrorException e) { + logger.error("Error Calling Multicloud, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } catch (HttpStatusCodeException e) { + logger.error("Error in Multicloud, e"); + String responseString = e.getResponseBodyAsString(); + return ResponseEntity.status(e.getStatusCode()).body(responseString); + } + } + + public ResponseEntity<InstanceResponse> createInstance(BpmnInstanceRequest bpmnInstanceRequest) + throws JsonParseException, JsonMappingException, IOException { + try { + logger.info("CnfAdapterService createInstance called"); + MulticloudInstanceRequest multicloudInstanceRequest = new MulticloudInstanceRequest(); + ResponseEntity<InstanceResponse> instanceResponse = null; + if (bpmnInstanceRequest.getK8sRBProfileName() != null) { + multicloudInstanceRequest.setCloudRegion(bpmnInstanceRequest.getCloudRegionId()); + multicloudInstanceRequest.setLabels(bpmnInstanceRequest.getLabels()); + multicloudInstanceRequest.setOverrideValues(bpmnInstanceRequest.getOverrideValues()); + multicloudInstanceRequest.setProfileName(bpmnInstanceRequest.getK8sRBProfileName()); + multicloudInstanceRequest.setRbName(bpmnInstanceRequest.getModelInvariantId()); + multicloudInstanceRequest.setRbVersion(bpmnInstanceRequest.getModelVersionId()); + multicloudInstanceRequest.setVfModuleUuid(bpmnInstanceRequest.getVfModuleUUID()); + } else { + logger.error("k8sProfileName should not be null"); + return instanceResponse; + } + // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO: + // This needs to be added as well + // for configuration + String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri? + String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString(); + HttpEntity<?> entity = getHttpEntity(multicloudInstanceRequest); + instanceResponse = restTemplate.exchange(endpoint, HttpMethod.POST, entity, InstanceResponse.class); + return instanceResponse; + } catch (HttpClientErrorException e) { + logger.error("Error Calling Multicloud, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } catch (HttpStatusCodeException e) { + logger.error("Error in Multicloud, e"); + String responseString = e.getResponseBodyAsString(); + InstanceResponse result = new InstanceResponse(responseString.trim()); + return ResponseEntity.status(e.getStatusCode()).body(result); + } + } + + public ResponseEntity<InstanceResponse> getInstanceByInstanceId(String instanceId) + throws JsonParseException, JsonMappingException, IOException { + + logger.info("CnfAdapterService createInstance called"); + ResponseEntity<InstanceResponse> instanceResponse = null; + try { + + // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO: + // This needs to be added as well + // for configuration + String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri? + String path = "/v1/instance/" + instanceId; + String endpoint = UriBuilder.fromUri(uri).path(path).build().toString(); + HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders()); + instanceResponse = restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, InstanceResponse.class); + return instanceResponse; + } catch (HttpClientErrorException e) { + logger.error("Error Calling Multicloud, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } catch (HttpStatusCodeException e) { + logger.error("Error in Multicloud, e"); + String responseString = e.getResponseBodyAsString(); + InstanceResponse result = new InstanceResponse(responseString.trim()); + return ResponseEntity.status(e.getStatusCode()).body(result); + } + } + + public ResponseEntity<InstanceStatusResponse> getInstanceStatusByInstanceId(String instanceId) + throws JsonParseException, JsonMappingException, IOException { + + logger.info("CnfAdapterService createInstance called"); + ResponseEntity<InstanceStatusResponse> instanceResponse = null; + try { + + // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO: + // This needs to be added as well + // for configuration + String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri? + String path = "/v1/instance/" + instanceId + "/status"; + String endpoint = UriBuilder.fromUri(uri).path(path).build().toString(); + HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders()); + instanceResponse = + restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, InstanceStatusResponse.class); + return instanceResponse; + } catch (HttpClientErrorException e) { + logger.error("Error Calling Multicloud, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } catch (HttpStatusCodeException e) { + logger.error("Error in Multicloud, e"); + String responseString = e.getResponseBodyAsString(); + InstanceStatusResponse result = new InstanceStatusResponse(responseString.trim()); + return ResponseEntity.status(e.getStatusCode()).body(result); + } + + } + + public ResponseEntity<InstanceMiniResponseList> getInstanceByRBNameOrRBVersionOrProfileName(String rbName, + String rbVersion, String profileName) throws JsonParseException, JsonMappingException, IOException { + + logger.info("CnfAdapterService createInstance called"); + ResponseEntity<InstanceMiniResponseList> instanceMiniResponseList = null; + try { + + // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO: + // This needs to be added as well + // for configuration + String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri? + String path = + "/v1/instance" + "?rb-name=" + rbName + "&rb-version=" + rbVersion + "&profile-name=" + profileName; + String endPoint = uri + path; + HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders()); + instanceMiniResponseList = + restTemplate.exchange(endPoint, HttpMethod.GET, requestEntity, InstanceMiniResponseList.class); + return instanceMiniResponseList; + } catch (HttpClientErrorException e) { + logger.error("Error Calling Multicloud, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } catch (HttpStatusCodeException e) { + logger.error("Error in Multicloud, e"); + String responseString = e.getResponseBodyAsString(); + InstanceMiniResponseList result = new InstanceMiniResponseList(responseString.trim()); + return ResponseEntity.status(e.getStatusCode()).body(result); + } + } + + public ResponseEntity<String> deleteInstanceByInstanceId(String instanceId) + throws JsonParseException, JsonMappingException, IOException { + + logger.info("CnfAdapterService createInstance called"); + ResponseEntity<String> result = null; + try { + + // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO: + // This needs to be added as well + // for configuration + String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri? + String path = "/v1/instance/" + instanceId; + String endpoint = UriBuilder.fromUri(uri).path(path).build().toString(); + HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders()); + result = restTemplate.exchange(endpoint, HttpMethod.DELETE, requestEntity, String.class); + return result; + } catch (HttpClientErrorException e) { + logger.error("Error Calling Multicloud, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } catch (HttpStatusCodeException e) { + logger.error("Error in Multicloud, e"); + String responseString = e.getResponseBodyAsString(); + return ResponseEntity.status(e.getStatusCode()).body(responseString); + } + } + + protected HttpHeaders getHttpHeaders() { + HttpHeaders headers = new HttpHeaders(); + List<MediaType> acceptableMediaTypes = new ArrayList<>(); + acceptableMediaTypes.add(MediaType.APPLICATION_JSON); + headers.setAccept(acceptableMediaTypes); + headers.setContentType(MediaType.APPLICATION_JSON); + /* + * try { String userCredentials = CryptoUtils.decrypt(env.getRequiredProperty("mso.cnf.adapter.auth"), + * env.getRequiredProperty("mso.msoKey")); if (userCredentials != null) { headers.add(HttpHeaders.AUTHORIZATION, + * "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes())); } } catch + * (GeneralSecurityException e) { logger.error("Security exception", e); } + */ + return headers; + } + + protected HttpEntity<?> getHttpEntity(MulticloudInstanceRequest request) { + HttpHeaders headers = getHttpHeaders(); + return new HttpEntity<>(request, headers); + } +} diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/util/CNfAdapterUtil.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/util/CNfAdapterUtil.java new file mode 100644 index 0000000000..25e506c55e --- /dev/null +++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/util/CNfAdapterUtil.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf.util; + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import org.onap.so.adapters.cnf.exceptions.ApplicationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.onap.logging.filter.base.ErrorCode; +import static org.onap.so.logger.LoggingAnchor.THREE; +import static org.onap.so.logger.MessageEnum.RA_NS_EXC; + +public class CNfAdapterUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(CNfAdapterUtil.class); + + public static final int BAD_REQUEST = 400; + + private static final String UNMARSHAL_FAIL_MSG = "Failed to unmarshal json"; + + private static final String MARSHAL_FAIL_MSG = "Failed to marshal object"; + + private static final ObjectMapper MAPPER = new ObjectMapper(); + + public static class StatusDesc { + + public static final String ALLOCATE_NSS_SUCCESS = "Allocating nss is " + "successful"; + + public static final String CREATE_NSS_SUCCESS = "Creating nss is " + "successful"; + + public static final String DEALLOCATE_NSS_SUCCESS = "Deallocate nss " + "is successful"; + + public static final String ACTIVATE_NSS_SUCCESS = "Activate nss " + "is successful"; + + public static final String DEACTIVATE_NSS_SUCCESS = "Deactivate nss " + "is successful"; + + public static final String QUERY_JOB_STATUS_FAILED = "Query job " + "status failed"; + + public static final String QUERY_JOB_STATUS_SUCCESS = "Query job " + "status is successful"; + + private StatusDesc() { + + } + } + + private CNfAdapterUtil() { + + } + + public static void assertObjectNotNull(Object object) throws ApplicationException { + if (null == object) { + LOGGER.error("Object is null."); + throw new ApplicationException(BAD_REQUEST, "An object is null."); + } + } + + public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException { + try { + return MAPPER.readValue(jsonstr, type); + } catch (IOException e) { + LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), UNMARSHAL_FAIL_MSG, e); + throw new ApplicationException(BAD_REQUEST, UNMARSHAL_FAIL_MSG); + } + } + + public static String marshal(Object srcObj) throws ApplicationException { + try { + return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(srcObj); + } catch (IOException e) { + LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), MARSHAL_FAIL_MSG, e); + throw new ApplicationException(BAD_REQUEST, MARSHAL_FAIL_MSG); + } + } + +} diff --git a/adapters/mso-cnf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/adapters/mso-cnf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties index f93ec63f37..bccd43aea7 100644 --- a/adapters/mso-cnf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties +++ b/adapters/mso-cnf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties @@ -1 +1 @@ -org.onap.so.adapters.nssmf.extclients.aai.AaiClientPropertiesImpl
\ No newline at end of file +org.onap.so.adapters.cnf.extclients.aai.AaiClientPropertiesImpl
\ No newline at end of file diff --git a/adapters/mso-cnf-adapter/src/main/resources/application.yaml b/adapters/mso-cnf-adapter/src/main/resources/application.yaml index 30b1b626a5..5a9adbfd04 100644 --- a/adapters/mso-cnf-adapter/src/main/resources/application.yaml +++ b/adapters/mso-cnf-adapter/src/main/resources/application.yaml @@ -38,14 +38,14 @@ # naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy # enable-lazy-load-no-trans: true server: - port: 9013 + port: 9012 tomcat: max-threads: 50 #mso: # key: 07a7159d3bf51a0e53be7a8f89699be7 # site-name: localSite -# logPath: ./logs/nssmf +# logPath: ./logs/cnf # msb-ip: msb-iag.{{ include "common.namespace" . }} # msb-port: 80 # adapters: diff --git a/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/CnfAdapterRestTest.java b/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/CnfAdapterRestTest.java new file mode 100644 index 0000000000..ee7a771034 --- /dev/null +++ b/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/CnfAdapterRestTest.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.cnf; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.onap.so.adapters.cnf.model.BpmnInstanceRequest; +import org.onap.so.adapters.cnf.rest.CnfAdapterRest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +public class CnfAdapterRestTest { + + @InjectMocks + CnfAdapterRest cnfAdapterRest; + + @Test + public void createInstanceTest() throws Exception { + + Map<String, String> labels = new HashMap<String, String>(); + labels.put("custom-label-1", "label1"); + Map<String, String> overrideValues = new HashMap<String, String>(); + labels.put("image.tag", "latest"); + labels.put("dcae_collector_ip", "1.2.3.4"); + BpmnInstanceRequest bpmnInstanceRequest = new BpmnInstanceRequest(); + bpmnInstanceRequest.setCloudRegionId("v1"); + bpmnInstanceRequest.setLabels(labels); + bpmnInstanceRequest.setModelInvariantId("krd"); + bpmnInstanceRequest.setModelVersionId("p1"); + bpmnInstanceRequest.setOverrideValues(overrideValues); + bpmnInstanceRequest.setVfModuleUUID("20200824"); + + String mockedResponse = "K8sRBProfileName is required"; + String actualResponse = cnfAdapterRest.createInstance(bpmnInstanceRequest); + assertNotNull(actualResponse); + assertEquals(mockedResponse, actualResponse); + } + +} +*/ diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml index db791826c3..45fe77eecc 100644 --- a/adapters/mso-nssmf-adapter/pom.xml +++ b/adapters/mso-nssmf-adapter/pom.xml @@ -162,7 +162,6 @@ <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> - <version>1.18.2</version> </dependency> </dependencies> </project> diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java index cd011e6437..83a09dc343 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java @@ -20,6 +20,7 @@ package org.onap.so.adapters.nssmf; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/annotation/ServiceLogger.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/annotation/ServiceLogger.java new file mode 100644 index 0000000000..1de29bcc2b --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/annotation/ServiceLogger.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.annotation; + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface ServiceLogger { + + String value() default ""; + + boolean ignore() default false; +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java new file mode 100644 index 0000000000..6a592448a6 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.config; + +import lombok.Getter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Configuration +@Getter +public class NssmfAdapterConfig { + + @Value("${mso.infra.endpoint}") + private String infraEndpoint; + + @Value("${mso.infra.auth}") + private String infraAuth; +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/RequestDbConfig.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/RequestDbConfig.java index 484f7624aa..dcb5d6198c 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/RequestDbConfig.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/RequestDbConfig.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.nssmf; +package org.onap.so.adapters.nssmf.config; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/WebSecurityConfig.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/WebSecurityConfig.java index 1522ca9c6d..dfb2b61978 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/WebSecurityConfig.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/WebSecurityConfig.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.nssmf; +package org.onap.so.adapters.nssmf.config; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java new file mode 100644 index 0000000000..28789f2a98 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java @@ -0,0 +1,187 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.consts; + +import org.onap.so.adapters.nssmf.entity.NssmfUrlInfo; +import org.onap.so.adapters.nssmf.enums.ActionType; +import org.onap.so.adapters.nssmf.enums.ExecutorType; +import org.onap.so.adapters.nssmf.enums.HttpMethod; +import org.onap.so.beans.nsmf.NetworkType; +import java.util.HashMap; +import java.util.Map; + +public class NssmfAdapterConsts { + + public final static String ONAP_INTERNAL_TAG = "ONAP_internal"; + + public final static String CURRENT_INTERNAL_NSSMF_API_VERSION = "v1"; + + private static Map<String, NssmfUrlInfo> urlInfoMap = new HashMap<>(); + + private final static String EXTERNAL_CN_ALLOCATE_URL = "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles"; + + private final static String EXTERNAL_TN_ALLOCATE_URL = "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles"; + + private final static String EXTERNAL_AN_ALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles"; + + private final static String INTERNAL_ALLOCATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/allocate"; + + private final static String EXTERNAL_CN_DEALLOCATE_URL = + "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles/{sliceProfileId}"; + + private final static String EXTERNAL_TN_DEALLOCATE_URL = + "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles/{sliceProfileId}"; + + private final static String EXTERNAL_AN_DEALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles/{sliceProfileId}"; + + private final static String INTERNAL_DEALLOCATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/deAllocate"; + + private final static String EXTERNAL_CN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/NSS/{snssai}/activation"; + + private final static String EXTERNAL_TN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/tn/NSS/{snssai}/activation"; + + private final static String EXTERNAL_AN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/an/NSS/{snssai}/activations"; + + private final static String INTERNAL_ACTIVATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/activate"; + + private final static String EXTERNAL_CN_DEACTIVATE_URL = "/api/rest/provMns/{apiVersion}/NSS/{snssai}/deactivation"; + + private final static String EXTERNAL_TN_DEACTIVATE_URL = + "/api/rest/provMns/{apiVersion}/tn/NSS/{snssai}/deactivation"; + + private final static String EXTERNAL_AN_DEACTIVATE_URL = + "/api/rest/provMns/{apiVersion}/an/NSS/{snssai}/deactivation"; + + private final static String INTERNAL_DEACTIVATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/deActivate"; + + // + private final static String EXTERNAL_CN_TERMINATE_URL = + "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles/{SliceProfileId}"; + + private final static String EXTERNAL_TN_TERMINATE_URL = + "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles/{SliceProfileId}"; + + private final static String EXTERNAL_AN_TERMINATE_URL = + "/api/rest/provMns/{apiVersion}/an/NSS/SliceProfiles/{SliceProfileId}"; + + private final static String INTERNAL_TERMINATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/terminate"; + + // + private final static String EXTERNAL_AN_MODIFY_URL = + "/api/rest/provMns/{apiVersion}/an/NSS/SliceProfiles/{SliceProfileId}"; + + private final static String INTERNAL_MODIFY_URL = "/onap/so/infra/3gppservices/{apiVersion}/modify"; + + // + private final static String EXTERNAL_QUERY_JOB_STATUS = + "/api/rest/provMns/{apiVersion}/NSS/jobs/{jobId}?responseId={responseId}"; + + private final static String INTERNAL_QUERY_SUB_NET_CAPABILITY = + "/onap/so/infra/3gppservices/{apiVersion}/subnetCapabilityQuery"; + + static { + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.ALLOCATE), + new NssmfUrlInfo(EXTERNAL_AN_ALLOCATE_URL, HttpMethod.POST)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.ALLOCATE), + new NssmfUrlInfo(EXTERNAL_TN_ALLOCATE_URL, HttpMethod.POST)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.ALLOCATE), + new NssmfUrlInfo(EXTERNAL_CN_ALLOCATE_URL, HttpMethod.POST)); + urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.ALLOCATE), + new NssmfUrlInfo(INTERNAL_ALLOCATE_URL, HttpMethod.POST)); + + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.DEALLOCATE), + new NssmfUrlInfo(EXTERNAL_AN_DEALLOCATE_URL, HttpMethod.DELETE)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.DEALLOCATE), + new NssmfUrlInfo(EXTERNAL_TN_DEALLOCATE_URL, HttpMethod.DELETE)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.DEALLOCATE), + new NssmfUrlInfo(EXTERNAL_CN_DEALLOCATE_URL, HttpMethod.DELETE)); + urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.DEALLOCATE), + new NssmfUrlInfo(INTERNAL_DEALLOCATE_URL, HttpMethod.DELETE)); + + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.ACTIVATE), + new NssmfUrlInfo(EXTERNAL_AN_ACTIVATE_URL, HttpMethod.PUT)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.ACTIVATE), + new NssmfUrlInfo(EXTERNAL_TN_ACTIVATE_URL, HttpMethod.PUT)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.ACTIVATE), + new NssmfUrlInfo(EXTERNAL_CN_ACTIVATE_URL, HttpMethod.PUT)); + urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.ACTIVATE), + new NssmfUrlInfo(INTERNAL_ACTIVATE_URL, HttpMethod.PUT)); + + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.DEACTIVATE), + new NssmfUrlInfo(EXTERNAL_AN_DEACTIVATE_URL, HttpMethod.PUT)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.DEACTIVATE), + new NssmfUrlInfo(EXTERNAL_TN_DEACTIVATE_URL, HttpMethod.PUT)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.DEACTIVATE), + new NssmfUrlInfo(EXTERNAL_CN_DEACTIVATE_URL, HttpMethod.PUT)); + urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.DEACTIVATE), + new NssmfUrlInfo(INTERNAL_DEACTIVATE_URL, HttpMethod.PUT)); + + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.TERMINATE), + new NssmfUrlInfo(EXTERNAL_AN_TERMINATE_URL, HttpMethod.DELETE)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.TERMINATE), + new NssmfUrlInfo(EXTERNAL_TN_TERMINATE_URL, HttpMethod.DELETE)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.TERMINATE), + new NssmfUrlInfo(EXTERNAL_CN_TERMINATE_URL, HttpMethod.DELETE)); + urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.TERMINATE), + new NssmfUrlInfo(INTERNAL_TERMINATE_URL, HttpMethod.DELETE)); + + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.MODIFY), + new NssmfUrlInfo(EXTERNAL_AN_MODIFY_URL, HttpMethod.PUT)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.MODIFY), + new NssmfUrlInfo(EXTERNAL_CN_ALLOCATE_URL, HttpMethod.PUT)); + urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.MODIFY), + new NssmfUrlInfo(INTERNAL_MODIFY_URL, HttpMethod.PUT)); + + + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.QUERY_JOB_STATUS), + new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.QUERY_JOB_STATUS), + new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET)); + urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.QUERY_JOB_STATUS), + new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET)); + + urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.QUERY_SUB_NET_CAPABILITY), + new NssmfUrlInfo(INTERNAL_QUERY_SUB_NET_CAPABILITY, HttpMethod.POST)); + } + + /** + * get nssmf url info from consts + * + * @param executorType {@link ExecutorType} + * @param networkType {@link NetworkType} + * @param actionType {@link ActionType} + * @return {@link NssmfUrlInfo} + */ + public static NssmfUrlInfo getNssmfUrlInfo(ExecutorType executorType, NetworkType networkType, + ActionType actionType) { + + return urlInfoMap.get(generateKey(executorType, networkType, actionType)); + } + + private static String generateKey(ExecutorType executorType, NetworkType networkType, ActionType actionType) { + if (ExecutorType.EXTERNAL.equals(executorType)) { + return executorType.name() + "_" + networkType.name() + "_" + actionType.name(); + } + return executorType.name() + "_" + actionType.name(); + } + + +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java new file mode 100644 index 0000000000..02d7468a0c --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java @@ -0,0 +1,57 @@ +package org.onap.so.adapters.nssmf.controller; + +import org.onap.so.adapters.nssmf.service.NssmfManagerService; +import org.onap.so.beans.nsmf.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + +@RestController +@RequestMapping(value = "/api/rest/provMns/v1", produces = {APPLICATION_JSON}, consumes = {APPLICATION_JSON}) +public class NssmfAdapterController { + + @Autowired + private NssmfManagerService nssmfManagerService; + + @PostMapping(value = "/NSS/SliceProfiles") + public ResponseEntity allocateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest) { + return nssmfManagerService.allocateNssi(nbiRequest); + } + + @PostMapping(value = "/NSS/SliceProfiles/{sliceProfileId}") + public ResponseEntity deAllocateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest, + @PathVariable("sliceProfileId") final String sliceProfileId) { + return nssmfManagerService.deAllocateNssi(nbiRequest, sliceProfileId); + } + + + @PostMapping(value = "/NSS/{snssai}/activation") + public ResponseEntity activateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest, + @PathVariable("snssai") String snssai) { + return nssmfManagerService.activateNssi(nbiRequest, snssai); + } + + @PostMapping(value = "/NSS/{snssai}/deactivation") + public ResponseEntity deactivateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest, + @PathVariable("snssai") String snssai) { + return nssmfManagerService.deActivateNssi(nbiRequest, snssai); + } + + @PostMapping(value = "/NSS/jobs/{jobId}") + public ResponseEntity queryJobStatus(@RequestBody NssmfAdapterNBIRequest nbiRequest, + @PathVariable("jobId") String jobId) { + return nssmfManagerService.queryJobStatus(nbiRequest, jobId); + } + + @PostMapping(value = "/NSS/NSSISelectionCapability") + public ResponseEntity queryNSSISelectionCapability(@RequestBody NssmfAdapterNBIRequest nbiRequest) { + return nssmfManagerService.queryNSSISelectionCapability(nbiRequest); + } + + @PostMapping(value = "/NSS/subnetCapabilityQuery") + public ResponseEntity querySubnetCapability(@RequestBody NssmfAdapterNBIRequest nbiRequest) { + return nssmfManagerService.querySubnetCapability(nbiRequest); + } + +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java new file mode 100644 index 0000000000..a8653f8d73 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.nssmf.entity; + +public class ErrorResponse { + + private int status; + + private String error; + + private String message; + + public ErrorResponse(int status, String message) { + this.status = status; + this.message = message; + this.error = "Bad Request"; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getError() { + if (status == 500) { + this.error = "Internal Server Error"; + } + return error; + } + + public void setError(String error) { + this.error = error; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java new file mode 100644 index 0000000000..af26264074 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.nssmf.entity; + +import lombok.Data; + +@Data +public class NssmfInfo { + + private String url; + + private String ipAddress; + + private String port; + + private String insecure; + + private String cacert; + + private String userName; + + private String password; +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java new file mode 100644 index 0000000000..f55ff10f1c --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java @@ -0,0 +1,17 @@ +package org.onap.so.adapters.nssmf.entity; + +import lombok.Data; +import org.onap.so.adapters.nssmf.enums.HttpMethod; + +@Data +public class NssmfUrlInfo { + + private String url; + + private HttpMethod httpMethod; + + public NssmfUrlInfo(String url, HttpMethod httpMethod) { + this.url = url; + this.httpMethod = httpMethod; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/RestResponse.java index cc047e45c7..218867c1ab 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/RestResponse.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.nssmf.rest; +package org.onap.so.adapters.nssmf.entity; import java.util.Map; diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientConnector.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenRequest.java index 652df6ff0d..bfcb875290 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientConnector.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenRequest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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. @@ -18,11 +18,16 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.base.client; +package org.onap.so.adapters.nssmf.entity; -@FunctionalInterface -public interface CloudifyClientConnector { +import lombok.Data; - public <T> CloudifyResponse request(CloudifyRequest<T> request); +@Data +public class TokenRequest { + private String grantType; + + private String userName; + + private String value; } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenResponse.java index 8007075e04..552612a6fb 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenResponse.java @@ -18,27 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.nssmf.model; +package org.onap.so.adapters.nssmf.entity; + +import lombok.Data; + +@Data public class TokenResponse { private String accessToken; private int expires; - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - public int getExpires() { - return expires; - } - - public void setExpires(int expires) { - this.expires = expires; - } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java new file mode 100644 index 0000000000..ed327fd981 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.enums; + +public enum ActionType { + ALLOCATE, + + DEALLOCATE, + + CREATE, + + TERMINATE, + + ACTIVATE, + + DEACTIVATE, + + QUERY_JOB_STATUS, + + MODIFY_BY_ID, + + MODIFY, + + QUERY_NSSI_SELECTION_CAPABILITY, + + QUERY_SUB_NET_CAPABILITY +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java new file mode 100644 index 0000000000..a76a54c348 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.enums; + +public enum ExecutorType { + INTERNAL, EXTERNAL +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/HttpMethod.java index f6abd98794..9271bb50b3 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/HttpMethod.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.nssmf.rest; +package org.onap.so.adapters.nssmf.enums; public enum HttpMethod { GET, POST, PUT, DELETE, PATCH; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/JobStatus.java index f2e651fd6e..d5cc1df377 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/JobStatus.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.nssmf.rest; +package org.onap.so.adapters.nssmf.enums; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java new file mode 100644 index 0000000000..420dfdce49 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.enums; + +public enum SelectionType { + NSSMF, + + NSMF +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java index f63ba356a1..2461f5ca78 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java @@ -20,7 +20,7 @@ package org.onap.so.adapters.nssmf.exceptions; -import org.onap.so.adapters.nssmf.model.ErrorResponse; +import org.onap.so.adapters.nssmf.entity.ErrorResponse; import org.springframework.http.ResponseEntity; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java index c737ba6440..665b111e03 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java @@ -22,6 +22,7 @@ package org.onap.so.adapters.nssmf.extclients.aai; import org.onap.aai.domain.yang.EsrSystemInfoList; import org.onap.aai.domain.yang.EsrThirdpartySdncList; +import org.onap.aai.domain.yang.ServiceInstance; public interface AaiServiceProvider { @@ -29,4 +30,7 @@ public interface AaiServiceProvider { EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId); + void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, + String serviceInstanceId); + } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java index 8cb47ebf38..3f2e5b23f2 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java @@ -23,7 +23,9 @@ package org.onap.so.adapters.nssmf.extclients.aai; import org.onap.aai.domain.yang.EsrSystemInfoList; import org.onap.aai.domain.yang.EsrThirdpartySdncList; +import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,4 +65,12 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { }); } + + @Override + public void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, + String serviceInstanceId) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, + serviceType, serviceInstanceId); + aaiClientProvider.getAaiClient().create(uri, nssiInstance); + } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java new file mode 100644 index 0000000000..ea6a1250d9 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.interceptor; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.onap.so.adapters.nssmf.annotation.ServiceLogger; +import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import java.lang.reflect.Method; + +/** + * support to print logger of service method + */ +@Aspect +@Order(100) +@Component +public class LoggerInterceptor { + + private static final Logger logger = LoggerFactory.getLogger(LoggerInterceptor.class); + + @Pointcut("execution(* org.onap.so.adapters.nssmf.service..*(..))") + public void serviceLogger() { + + } + + @Around("serviceLogger()") + public Object around(ProceedingJoinPoint joinPoint) { + try { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + + Class<?> targetClass = method.getDeclaringClass(); + + StringBuilder classAndMethod = new StringBuilder(); + ServiceLogger classAnnotation = targetClass.getAnnotation(ServiceLogger.class); + ServiceLogger methodAnnotation = method.getAnnotation(ServiceLogger.class); + + if (classAnnotation == null && methodAnnotation == null) { + return joinPoint.proceed(); + } + + if (classAnnotation != null) { + if (classAnnotation.ignore()) { + return joinPoint.proceed(); + } + classAndMethod.append(classAnnotation.value()).append("-"); + } + + String target = targetClass.getName() + "#" + method.getName(); + + String params = NssmfAdapterUtil.marshal(joinPoint.getArgs()); + + logger.info("{} Start: Method = {} \nParams = {}", classAndMethod.toString(), target, params); + + long start = System.currentTimeMillis(); + Object result = joinPoint.proceed(); + long timeConsuming = System.currentTimeMillis() - start; + + logger.info("\n{} End: Method = {}, Spend time = {}ms \nResult = {}", classAndMethod.toString(), target, + timeConsuming, NssmfAdapterUtil.marshal(result)); + return result; + + } catch (Throwable e) { + logger.error(e.getMessage(), e); + } + return null; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java new file mode 100644 index 0000000000..54ef1e09dd --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager; + +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.entity.RestResponse; +import org.onap.so.beans.nsmf.*; + +public interface NssmfManager { + + RestResponse allocateNssi(NssmfAdapterNBIRequest nssmfRequest) throws ApplicationException; + + RestResponse deAllocateNssi(NssmfAdapterNBIRequest nssmfRequest, String sliceId) throws ApplicationException; + + RestResponse activateNssi(NssmfAdapterNBIRequest nssmfRequest, String snssai) throws ApplicationException; + + RestResponse deActivateNssi(NssmfAdapterNBIRequest nssmfRequest, String snssai) throws ApplicationException; + + RestResponse queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) throws ApplicationException; + + RestResponse queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; + + RestResponse querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; + + RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException; +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java new file mode 100644 index 0000000000..0b332af607 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager; + +import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig; +import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts; +import org.onap.so.adapters.nssmf.enums.ActionType; +import org.onap.so.adapters.nssmf.enums.ExecutorType; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.manager.impl.external.ExternalAnNssmfManager; +import org.onap.so.adapters.nssmf.manager.impl.external.ExternalCnNssmfManager; +import org.onap.so.adapters.nssmf.manager.impl.internal.InternalAnNssmfManager; +import org.onap.so.adapters.nssmf.manager.impl.internal.InternalCnNssmfManager; +import org.onap.so.adapters.nssmf.manager.impl.internal.InternalTnNssmfManager; +import org.onap.so.adapters.nssmf.manager.impl.*; +import org.onap.so.adapters.nssmf.util.RestUtil; +import org.onap.so.beans.nsmf.EsrInfo; +import org.onap.so.beans.nsmf.NetworkType; +import org.onap.so.beans.nsmf.ServiceInfo; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; + +public class NssmfManagerBuilder { + + private BaseNssmfManager nssmfManger; + + private RestUtil restUtil; + + private ActionType actionType; + + private ResourceOperationStatusRepository repository; + + private ServiceInfo serviceInfo; + + private NssmfAdapterConfig adapterConfig; + + public NssmfManagerBuilder(EsrInfo esrInfo) throws ApplicationException { + + ExecutorType executorType = getExecutorType(esrInfo); + NetworkType networkType = esrInfo.getNetworkType(); + + if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.CORE.equals(networkType)) { + this.nssmfManger = new InternalCnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType); + return; + } + + if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.TRANSPORT.equals(networkType)) { + this.nssmfManger = new InternalTnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType); + return; + } + + if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) { + this.nssmfManger = new InternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType); + return; + } + + if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.CORE.equals(networkType)) { + this.nssmfManger = new ExternalCnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType) + .setInitStatus("deactivated"); + return; + } + + if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) { + this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType) + .setInitStatus("activated"); + return; + } + + throw new ApplicationException(404, "invalid domain and simulator"); + } + + private ExecutorType getExecutorType(EsrInfo esrInfo) { + if (NssmfAdapterConsts.ONAP_INTERNAL_TAG.equals(esrInfo.getVendor())) { + return ExecutorType.INTERNAL; + } + return ExecutorType.EXTERNAL; + } + + public NssmfManagerBuilder setRestUtil(RestUtil restUtil) { + this.restUtil = restUtil; + return this; + } + + public NssmfManagerBuilder setActionType(ActionType actionType) { + this.actionType = actionType; + return this; + } + + public NssmfManagerBuilder setRepository(ResourceOperationStatusRepository repository) { + this.repository = repository; + return this; + } + + public NssmfManagerBuilder setServiceInfo(ServiceInfo serviceInfo) { + this.serviceInfo = serviceInfo; + return this; + } + + public NssmfManagerBuilder setAdapterConfig(NssmfAdapterConfig adapterConfig) { + this.adapterConfig = adapterConfig; + return this; + } + + public NssmfManager build() { + return this.nssmfManger.setRestUtil(restUtil).setAdapterConfig(adapterConfig).setRepository(repository) + .setActionType(actionType).setServiceInfo(serviceInfo); + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java new file mode 100644 index 0000000000..97a4c5e889 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java @@ -0,0 +1,267 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager.impl; + +import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig; +import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts; +import org.onap.so.adapters.nssmf.entity.NssmfUrlInfo; +import org.onap.so.adapters.nssmf.enums.*; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.entity.RestResponse; +import org.onap.so.adapters.nssmf.manager.NssmfManager; +import org.onap.so.adapters.nssmf.util.RestUtil; +import org.onap.so.beans.nsmf.*; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.springframework.data.domain.Example; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; + +public abstract class BaseNssmfManager implements NssmfManager { + + protected RestUtil restUtil; + + protected ResourceOperationStatusRepository repository; + + protected NssmfAdapterConfig adapterConfig; + + protected ActionType actionType; + + protected EsrInfo esrInfo; + + protected String nssmfUrl; + + protected HttpMethod httpMethod; + + protected String initStatus; + + protected ServiceInfo serviceInfo; + + protected RestResponse restResponse; + + private ExecutorType executorType = ExecutorType.INTERNAL; + + private Map<String, String> params = new HashMap<>(); // request params + + @Override + public RestResponse allocateNssi(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + + this.params.clear(); + this.urlHandler(); + String requestBody = wrapAllocateReqBody(nbiRequest); + + this.restResponse = sendRequest(requestBody); + + this.afterRequest(); + + return restResponse; + } + + protected abstract String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; + + @Override + public RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException { + this.params.clear(); + this.urlHandler(); + String requestBody = wrapModifyReqBody(modifyRequest); + + this.restResponse = sendRequest(requestBody); + + this.afterRequest(); + + return restResponse; + } + + protected abstract String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; + + @Override + public RestResponse deAllocateNssi(NssmfAdapterNBIRequest nbiRequest, String sliceId) throws ApplicationException { + this.params.clear(); + this.params.put("sliceProfileId", sliceId); + + this.urlHandler(); + + String reqBody = wrapDeAllocateReqBody(nbiRequest.getDeAllocateNssi()); + + this.restResponse = sendRequest(reqBody); + + this.afterRequest(); + + return restResponse; + } + + protected abstract String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException; + + protected abstract String wrapReqBody(Object object) throws ApplicationException; + + @Override + public RestResponse activateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException { + this.params.clear(); + this.params.put("snssai", snssai); + + this.urlHandler(); + + String reqBody = wrapActDeActReqBody(nbiRequest.getActDeActNssi()); + + this.restResponse = sendRequest(reqBody); + + this.afterRequest(); + + return restResponse; + } + + @Override + public RestResponse deActivateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException { + return activateNssi(nbiRequest, snssai); + } + + protected abstract String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException; + + @Override + public RestResponse queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) throws ApplicationException { + this.params.clear(); + this.params.put("jobId", jobId); + this.params.put("responseId", jobReq.getResponseId()); + this.urlHandler(); + + /** + * find by jobId and nsiId jobId -> OperationId nsiId -> ServiceId serviceUuid -> resourceTemplateUUID + */ + ResourceOperationStatus status = + getOperationStatus(serviceInfo.getNsiId(), jobId, serviceInfo.getServiceUuid()); + + this.restResponse = doQueryJobStatus(status); + + afterQueryJobStatus(status); + return restResponse; + } + + protected abstract RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException; + + + protected abstract void afterQueryJobStatus(ResourceOperationStatus status); + + private ResourceOperationStatus getOperationStatus(String nsiId, String jobId, String serviceUuid) { + + ResourceOperationStatus status = new ResourceOperationStatus(nsiId, jobId, serviceUuid); + + Optional<ResourceOperationStatus> optional = repository.findOne(Example.of(status)); + + return optional.orElse(null); + } + + @Override + public RestResponse queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + SelectionType res = doQueryNSSISelectionCapability(); + HashMap<String, String> hashMap = new HashMap<>(); + hashMap.put("selection", res.name()); + RestResponse restResponse = new RestResponse(); + restResponse.setStatus(200); + restResponse.setResponseContent(marshal(hashMap)); + return restResponse; + } + + protected abstract SelectionType doQueryNSSISelectionCapability(); + + @Override + public RestResponse querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + this.params.clear(); + this.urlHandler(); + + return doQuerySubnetCapability(nbiRequest.getSubnetCapabilityQuery()); + } + + protected abstract RestResponse doQuerySubnetCapability(String req) throws ApplicationException; + + /** + * send request to nssmf + * + * @param content request body + * @return response + * @throws ApplicationException + */ + protected abstract RestResponse sendRequest(String content) throws ApplicationException; + + /** + * handle the url before request to nssmf, include get the nssmf request url, replace the path variable + */ + private void urlHandler() { + NssmfUrlInfo nssmfUrlInfo = + NssmfAdapterConsts.getNssmfUrlInfo(this.executorType, this.esrInfo.getNetworkType(), actionType); + this.nssmfUrl = nssmfUrlInfo.getUrl(); + this.httpMethod = nssmfUrlInfo.getHttpMethod(); + this.nssmfUrl = nssmfUrl.replaceAll("\\{apiVersion}", getApiVersion()); + this.params.forEach((k, v) -> this.nssmfUrl = this.nssmfUrl.replaceAll("\\{" + k + "}", v)); + } + + /** + * after request + */ + protected abstract void afterRequest() throws ApplicationException; + + protected abstract String getApiVersion(); + + public RestUtil getRestUtil() { + return restUtil; + } + + public BaseNssmfManager setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + return this; + } + + public BaseNssmfManager setExecutorType(ExecutorType executorType) { + this.executorType = executorType; + return this; + } + + public BaseNssmfManager setRestUtil(RestUtil restUtil) { + this.restUtil = restUtil; + return this; + } + + public BaseNssmfManager setActionType(ActionType actionType) { + this.actionType = actionType; + return this; + } + + public BaseNssmfManager setRepository(ResourceOperationStatusRepository repository) { + this.repository = repository; + return this; + } + + public BaseNssmfManager setServiceInfo(ServiceInfo serviceInfo) { + this.serviceInfo = serviceInfo; + return this; + } + + public BaseNssmfManager setInitStatus(String initStatus) { + this.initStatus = initStatus; + return this; + } + + public BaseNssmfManager setAdapterConfig(NssmfAdapterConfig adapterConfig) { + this.adapterConfig = adapterConfig; + return this; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java new file mode 100644 index 0000000000..16a5b2ada0 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager.impl; + +import org.apache.http.Header; +import org.apache.http.message.BasicHeader; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.so.adapters.nssmf.entity.NssmfInfo; +import org.onap.so.adapters.nssmf.entity.RestResponse; +import org.onap.so.adapters.nssmf.enums.JobStatus; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; +import org.onap.so.beans.nsmf.*; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import static java.lang.String.valueOf; +import static org.onap.so.adapters.nssmf.enums.JobStatus.*; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.*; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; + +public abstract class ExternalNssmfManager extends BaseNssmfManager { + + @Override + protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + return doWrapExtAllocateReqBody(nbiRequest); + } + + protected abstract String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; + + @Override + protected String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + return doWrapModifyReqBody(nbiRequest); + } + + protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; + + @Override + protected String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException { + return doWrapDeAllocateReqBody(deAllocateNssi); + } + + protected abstract String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException; + + @Override + protected void afterQueryJobStatus(ResourceOperationStatus status) { + if (Integer.parseInt(status.getProgress()) == 100) { + + ServiceInstance nssiInstance = new ServiceInstance(); + nssiInstance.setServiceInstanceId(serviceInfo.getNssiId()); + nssiInstance.setServiceInstanceName(serviceInfo.getNssiName()); + nssiInstance.setServiceType(serviceInfo.getSST()); + + nssiInstance.setOrchestrationStatus(initStatus); + nssiInstance.setModelInvariantId(serviceInfo.getServiceInvariantUuid()); + nssiInstance.setModelVersionId(serviceInfo.getServiceUuid()); + nssiInstance.setServiceInstanceLocationId(serviceInfo.getPLMNIdList()); + nssiInstance.setEnvironmentContext(esrInfo.getNetworkType().getNetworkType()); + nssiInstance.setServiceRole("nssi"); + + restUtil.createServiceInstance(nssiInstance, serviceInfo); + } + } + + + + @Override + protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException { + return marshal(actDeActNssi); + } + + protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException { + return doResponseStatus(status); + } + + private RestResponse doResponseStatus(ResourceOperationStatus status) throws ApplicationException { + RestResponse restResponse = sendRequest(null); + ResponseDescriptor rspDesc = + unMarshal(restResponse.getResponseContent(), JobStatusResponse.class).getResponseDescriptor(); + updateRequestDbJobStatus(rspDesc, status, restResponse); + return restResponse; + } + + @Override + protected String wrapReqBody(Object object) throws ApplicationException { + return marshal(object); + } + + @Override + protected RestResponse sendRequest(String content) throws ApplicationException { + return sendExternalRequest(content); + } + + @Override + protected String getApiVersion() { + return "v1"; + } + + + // external + protected RestResponse sendExternalRequest(String content) throws ApplicationException { + NssmfInfo nssmfInfo = restUtil.getNssmfHost(esrInfo); + Header header = new BasicHeader("X-Auth-Token", restUtil.getToken(nssmfInfo)); + String nssmfUrl = nssmfInfo.getUrl() + this.nssmfUrl; + return restUtil.send(nssmfUrl, this.httpMethod, content, header); + } + + private void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status, RestResponse rsp) + throws ApplicationException { + + switch (fromString(rspDesc.getStatus())) { + case STARTED: + updateDbStatus(status, rsp.getStatus(), STARTED, QUERY_JOB_STATUS_SUCCESS); + break; + case PROCESSING: + updateDbStatus(status, rsp.getStatus(), PROCESSING, QUERY_JOB_STATUS_SUCCESS); + break; + case FINISHED: + if (rspDesc.getProgress() == 100) { + updateDbStatus(status, rsp.getStatus(), FINISHED, QUERY_JOB_STATUS_SUCCESS); + } + break; + case ERROR: + updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED); + throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED); + } + } + + protected void updateDbStatus(ResourceOperationStatus status, int rspStatus, JobStatus jobStatus, + String description) { + status.setErrorCode(valueOf(rspStatus)); + status.setStatus(jobStatus.toString()); + status.setStatusDescription(description); + repository.save(status); + } + + @Override + protected RestResponse doQuerySubnetCapability(String req) throws ApplicationException { + RestResponse response = new RestResponse(); + response.setStatus(200); + response.setResponseContent(null); + return response; + } + + /** + * after request, if response code is 2XX, continue handle, else return + */ + @Override + protected void afterRequest() throws ApplicationException { + if (valueOf(restResponse.getStatus()).startsWith("2")) { + doAfterRequest(); + } + } + + + protected void doAfterRequest() throws ApplicationException { + // + NssiResponse response = unMarshal(restResponse.getResponseContent(), NssiResponse.class); + ResourceOperationStatus status = + new ResourceOperationStatus(serviceInfo.getNsiId(), response.getJobId(), serviceInfo.getServiceUuid()); + status.setResourceInstanceID(response.getNssiId()); + + updateDbStatus(status, restResponse.getStatus(), STARTED, NssmfAdapterUtil.getStatusDesc(actionType)); + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java new file mode 100644 index 0000000000..f439b400d9 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager.impl; + +import org.apache.http.Header; +import org.apache.http.message.BasicHeader; +import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts; +import org.onap.so.adapters.nssmf.entity.RestResponse; +import org.onap.so.adapters.nssmf.enums.SelectionType; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.beans.nsmf.*; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import static org.onap.so.adapters.nssmf.enums.JobStatus.PROCESSING; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; + +public abstract class InternalNssmfManager extends BaseNssmfManager { + + @Override + protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + return doWrapAllocateReqBody(nbiRequest); + } + + protected abstract String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; + + @Override + protected String wrapReqBody(Object object) throws ApplicationException { + NssmfRequest nssmfRequest = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), object); + return marshal(nssmfRequest); + } + + + @Override + protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException { + + return wrapReqBody(actDeActNssi); + } + + + @Override + protected String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException { + return wrapReqBody(deAllocateNssi); + } + + + @Override + protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException { + return responseDBStatus(status); + } + + private RestResponse responseDBStatus(ResourceOperationStatus status) throws ApplicationException { + ResponseDescriptor descriptor = new ResponseDescriptor(); + if (status == null) { + descriptor.setProgress(0); + descriptor.setStatus(PROCESSING.name()); + descriptor.setStatusDescription("Initiating Nssi Instance"); + return restUtil.createResponse(200, marshal(descriptor)); + } + descriptor.setStatus(status.getStatus()); + descriptor.setStatusDescription(status.getStatusDescription()); + descriptor.setProgress(Integer.parseInt(status.getProgress())); + // descriptor.setResponseId(status.getOperationId()); + return restUtil.createResponse(200, marshal(descriptor)); + } + + @Override + protected RestResponse sendRequest(String content) { + return sendInternalRequest(content); + } + + @Override + protected void afterRequest() { + // + } + + @Override + protected void afterQueryJobStatus(ResourceOperationStatus status) { + // internal + } + + // internal + private RestResponse sendInternalRequest(String content) { + Header header = new BasicHeader("X-Auth-Token", adapterConfig.getInfraAuth()); + this.nssmfUrl = adapterConfig.getInfraEndpoint() + this.nssmfUrl; + return restUtil.send(this.nssmfUrl, this.httpMethod, content, header); + } + + @Override + protected String getApiVersion() { + return NssmfAdapterConsts.CURRENT_INTERNAL_NSSMF_API_VERSION; + } + + + @Override + protected SelectionType doQueryNSSISelectionCapability() { + return SelectionType.NSSMF; + } + + @Override + protected String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + return doWrapModifyReqBody(nbiRequest); + } + + protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; + + @Override + protected RestResponse doQuerySubnetCapability(String req) throws ApplicationException { + // handler + return sendRequest(req); + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java new file mode 100644 index 0000000000..bc7a3d0bb7 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager.impl.external; + +import org.onap.so.adapters.nssmf.entity.RestResponse; +import org.onap.so.adapters.nssmf.enums.ActionType; +import org.onap.so.adapters.nssmf.enums.JobStatus; +import org.onap.so.adapters.nssmf.enums.SelectionType; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager; +import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; +import org.onap.so.beans.nsmf.DeAllocateNssi; +import org.onap.so.beans.nsmf.NssiResponse; +import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; + + +public class ExternalAnNssmfManager extends ExternalNssmfManager { + + private Map<String, String> bodyParams = new HashMap<>(); // request body params + + @Override + protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + Map<String, Object> request = new HashMap<>(); + request.put("attributeListIn", nbiRequest.getAllocateAnNssi().getSliceProfile()); + return marshal(request); + } + + @Override + protected void doAfterRequest() throws ApplicationException { + if (ActionType.ALLOCATE.equals(actionType) || ActionType.DEALLOCATE.equals(actionType)) { + String nssiId; + if (ActionType.ALLOCATE.equals(actionType)) { + @SuppressWarnings("unchecked") + Map<String, String> response = unMarshal(restResponse.getResponseContent(), Map.class); + nssiId = response.get("href"); + } else { + nssiId = this.bodyParams.get("nssiId"); + } + + NssiResponse resp = new NssiResponse(); + resp.setJobId(UUID.randomUUID().toString()); + resp.setNssiId(nssiId); + + RestResponse returnRsp = new RestResponse(); + + returnRsp.setStatus(202); + returnRsp.setResponseContent(marshal(resp)); + restResponse = returnRsp; + + ResourceOperationStatus status = + new ResourceOperationStatus(serviceInfo.getNsiId(), nssiId, serviceInfo.getServiceUuid()); + status.setResourceInstanceID(nssiId); + + updateDbStatus(status, restResponse.getStatus(), JobStatus.FINISHED, + NssmfAdapterUtil.getStatusDesc(actionType)); + } + // todo + } + + @Override + protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + // TODO + return null; + } + + @Override + protected String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException { + this.bodyParams.clear(); + this.bodyParams.put("nssiId", deAllocateNssi.getNssiId()); + + Map<String, String> request = new HashMap<>(); + request.put("nSSId", deAllocateNssi.getNssiId()); + return marshal(request); + } + + + @Override + public RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException { + // TODO + return null; + } + + @Override + public RestResponse activateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException { + // TODO + return null; + } + + @Override + protected SelectionType doQueryNSSISelectionCapability() { + return SelectionType.NSSMF; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java new file mode 100644 index 0000000000..fb76adcce6 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager.impl.external; + +import org.onap.so.adapters.nssmf.enums.SelectionType; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager; +import org.onap.so.beans.nsmf.DeAllocateNssi; +import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; + +public class ExternalCnNssmfManager extends ExternalNssmfManager { + + @Override + protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + return marshal(nbiRequest.getAllocateCnNssi()); + } + + @Override + protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + return marshal(nbiRequest.getAllocateCnNssi()); + } + + @Override + protected String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException { + return marshal(deAllocateNssi); + } + + @Override + protected SelectionType doQueryNSSISelectionCapability() { + + return SelectionType.NSMF; + } + +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java new file mode 100644 index 0000000000..dc6528381b --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager.impl.internal; + +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager; +import org.onap.so.beans.nsmf.*; +import java.util.HashMap; +import java.util.Map; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; + + +public class InternalAnNssmfManager extends InternalNssmfManager { + + @Override + protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + NssmfRequest request = + new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), nbiRequest.getAllocateAnNssi()); + request.setName(nbiRequest.getAllocateAnNssi().getNssiName()); + return marshal(request); + } + + @Override + protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + AllocateAnNssi allocateAnNssi = nbiRequest.getAllocateAnNssi(); + AnSliceProfile sliceProfile = allocateAnNssi.getSliceProfile(); + Map<String, Object> additional = new HashMap<>(); + additional.put("modifyAction", "allocate"); + additional.put("snssaiList", sliceProfile.getSNSSAIList()); + additional.put("sliceProfileId", sliceProfile.getSliceProfileId()); + additional.put("nsiInfo", allocateAnNssi.getNsiInfo()); + additional.put("scriptName", allocateAnNssi.getScriptName()); + NssmfRequest request = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), additional); + return marshal(request); + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java new file mode 100644 index 0000000000..4a93b3007c --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager.impl.internal; + +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager; +import org.onap.so.beans.nsmf.*; +import java.util.HashMap; +import java.util.Map; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; + +public class InternalCnNssmfManager extends InternalNssmfManager { + + @Override + protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + + NssmfRequest request = + new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), nbiRequest.getAllocateCnNssi()); + request.setName(nbiRequest.getAllocateCnNssi().getNssiName()); + return marshal(request); + } + + @Override + protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + AllocateCnNssi allocateCnNssi = nbiRequest.getAllocateCnNssi(); + CnSliceProfile cnSliceProfile = allocateCnNssi.getSliceProfile(); + Map<String, Object> additional = new HashMap<>(); + additional.put("modifyAction", "allocate"); + additional.put("nsiInfo", allocateCnNssi.getNsiInfo()); + additional.put("scriptName", allocateCnNssi.getScriptName()); + additional.put("snssaiList", cnSliceProfile.getSnssaiList()); + additional.put("sliceProfileId", cnSliceProfile.getSliceProfileId()); + + NssmfRequest request = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), additional); + return marshal(request); + } + +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java new file mode 100644 index 0000000000..8bfbd55387 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.manager.impl.internal; + +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager; +import org.onap.so.beans.nsmf.*; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; + +public class InternalTnNssmfManager extends InternalNssmfManager { + + @Override + protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + + return marshal(new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), + nbiRequest.getAllocateTnNssi())); + } + + @Override + protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { + // TODO + return null; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java index d8e1e36058..4fdcbf110f 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java @@ -20,6 +20,7 @@ package org.onap.so.adapters.nssmf.rest; +import org.onap.so.adapters.nssmf.entity.RestResponse; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.onap.so.beans.nsmf.JobStatusRequest; import org.onap.so.beans.nsmf.NssiActDeActRequest; @@ -43,6 +44,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.assertObjectNotNull; +@Deprecated @Controller @RequestMapping(value = "/api/rest/provMns/v1", produces = {APPLICATION_JSON}, consumes = {APPLICATION_JSON}) public class NssmfAdapterRest { @@ -52,17 +54,6 @@ public class NssmfAdapterRest { @Autowired private NssmfManager nssmfMgr; - @PostMapping(value = "/NSS/SliceProfiles") - public ResponseEntity allocateNssi(@RequestBody NssiAllocateRequest allocate) { - try { - logger.info("Nssmi allocate request is invoked"); - assertObjectNotNull(allocate); - RestResponse rsp = getNssmfMgr().allocateNssi(allocate); - return buildResponse(rsp); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } @PostMapping(value = "/NSS/nssi") public ResponseEntity createNssi(@RequestBody NssiCreateRequest create) { @@ -76,19 +67,6 @@ public class NssmfAdapterRest { } } - @PostMapping(value = "/NSS/SliceProfiles/{sliceProfileId}") - public ResponseEntity deAllocateNssi(@RequestBody NssiDeAllocateRequest deAllocate, - @PathVariable("sliceProfileId") final String sliceId) { - try { - logger.info("Nssmf deallocate request is invoked"); - assertObjectNotNull(deAllocate); - RestResponse rsp = getNssmfMgr().deAllocateNssi(deAllocate, sliceId); - return buildResponse(rsp); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - @PostMapping(value = "/NSS/nssi/{nssiId}") public ResponseEntity terminateNssi(@RequestBody NssiTerminateRequest terminate, @PathVariable("nssiId") String nssiId) { @@ -128,44 +106,6 @@ public class NssmfAdapterRest { } } - @PostMapping(value = "/NSS/{snssai}/activation") - public ResponseEntity activateNssi(@RequestBody NssiActDeActRequest activate, - @PathVariable("snssai") String snssai) { - try { - logger.info("Nssmf activate request is invoked"); - assertObjectNotNull(activate); - RestResponse rsp = getNssmfMgr().activateNssi(activate, snssai); - return buildResponse(rsp); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - - @PostMapping(value = "/NSS/{snssai}/deactivation") - public ResponseEntity deactivateNssi(@RequestBody NssiActDeActRequest deActivate, - @PathVariable("snssai") String snssai) { - try { - logger.info("Nssmf activate request is invoked"); - assertObjectNotNull(deActivate); - RestResponse rsp = getNssmfMgr().deActivateNssi(deActivate, snssai); - return buildResponse(rsp); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - - @PostMapping(value = "/NSS/jobs/{jobId}") - public ResponseEntity queryJobStatus(@RequestBody JobStatusRequest jobStatusReq, - @PathVariable("jobId") String jobId) { - try { - logger.info("Nssmf query job status request is invoked"); - assertObjectNotNull(jobStatusReq); - RestResponse rsp = getNssmfMgr().queryJobStatus(jobStatusReq, jobId); - return buildResponse(rsp); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } @GetMapping(value = "/vendor/{vendorName}/type/{networkType}/NSS" + "/SliceProfiles/{sliceProfileId}") public ResponseEntity queryNssi(@PathVariable("vendorName") String vendorName, diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java deleted file mode 100644 index 6306643a97..0000000000 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.adapters.nssmf.rest; - -public class NssmfInfo { - - private String url; - - private String ipAddress; - - private String port; - - private String insecure; - - private String cacert; - - private String userName; - - private String password; - - public String getInsecure() { - return insecure; - } - - public void setInsecure(String insecure) { - this.insecure = insecure; - } - - public String getCacert() { - return cacert; - } - - public void setCacert(String cacert) { - this.cacert = cacert; - } - - public String getIpAddress() { - return ipAddress; - } - - public void setIpAddress(String ipAddress) { - this.ipAddress = ipAddress; - } - - public String getPort() { - return port; - } - - public void setPort(String port) { - this.port = port; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java index 0e25729610..2d0980f60e 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java @@ -20,7 +20,10 @@ package org.onap.so.adapters.nssmf.rest; +import org.onap.so.adapters.nssmf.entity.RestResponse; +import org.onap.so.adapters.nssmf.enums.JobStatus; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.util.RestUtil; import org.onap.so.beans.nsmf.ActDeActNssi; import org.onap.so.beans.nsmf.AllocateAnNssi; import org.onap.so.beans.nsmf.AllocateCnNssi; @@ -52,15 +55,15 @@ import org.springframework.context.annotation.Primary; import org.springframework.data.domain.Example; import org.springframework.stereotype.Component; import static java.lang.String.valueOf; -import static org.onap.so.adapters.nssmf.rest.HttpMethod.DELETE; -import static org.onap.so.adapters.nssmf.rest.HttpMethod.GET; -import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST; -import static org.onap.so.adapters.nssmf.rest.HttpMethod.PUT; -import static org.onap.so.adapters.nssmf.rest.JobStatus.ERROR; -import static org.onap.so.adapters.nssmf.rest.JobStatus.FINISHED; -import static org.onap.so.adapters.nssmf.rest.JobStatus.PROCESSING; -import static org.onap.so.adapters.nssmf.rest.JobStatus.STARTED; -import static org.onap.so.adapters.nssmf.rest.JobStatus.fromString; +import static org.onap.so.adapters.nssmf.enums.HttpMethod.DELETE; +import static org.onap.so.adapters.nssmf.enums.HttpMethod.GET; +import static org.onap.so.adapters.nssmf.enums.HttpMethod.POST; +import static org.onap.so.adapters.nssmf.enums.HttpMethod.PUT; +import static org.onap.so.adapters.nssmf.enums.JobStatus.ERROR; +import static org.onap.so.adapters.nssmf.enums.JobStatus.FINISHED; +import static org.onap.so.adapters.nssmf.enums.JobStatus.PROCESSING; +import static org.onap.so.adapters.nssmf.enums.JobStatus.STARTED; +import static org.onap.so.adapters.nssmf.enums.JobStatus.fromString; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.ACTIVATE_NSS_SUCCESS; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.ALLOCATE_NSS_SUCCESS; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.CREATE_NSS_SUCCESS; @@ -76,6 +79,7 @@ import static org.onap.so.beans.nsmf.ActDeActNssi.DE_ACT_URL; @Component @Primary +@Deprecated public class NssmfManager { private static final Logger logger = LoggerFactory.getLogger(NssmfManager.class); @@ -129,14 +133,15 @@ public class NssmfManager { case TRANSPORT: AllocateTnNssi tn = nssmiAllocate.getAllocateTnNssi(); assertObjectNotNull(tn); - assertObjectNotNull(tn.getNsiInfo()); - assertObjectNotNull(tn.getNsiInfo().getNsiId()); - nsiId = tn.getNsiInfo().getNsiId(); + // assertObjectNotNull(tn.getNsiInfo()); + // assertObjectNotNull(tn.getNsiInfo().getNsiId()); + // nsiId = tn.getNsiInfo().getNsiId(); allocateReq = marshal(tn); - allocateUrl = AllocateTnNssi.URL; + // allocateUrl = AllocateTnNssi.URL; break; } + RestResponse rsp = restUtil.sendRequest(allocateUrl, POST, allocateReq, nssmiAllocate.getEsrInfo()); assertObjectNotNull(rsp); @@ -152,6 +157,8 @@ public class NssmfManager { return rsp; } + + public RestResponse createNssi(NssiCreateRequest nssiCreate) throws ApplicationException { assertObjectNotNull(nssiCreate.getEsrInfo()); @@ -192,6 +199,7 @@ public class NssmfManager { return rsp; } + @Deprecated public RestResponse deAllocateNssi(NssiDeAllocateRequest nssiDeallocate, String sliceId) throws ApplicationException { diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java index 254186bda8..fc0f3ddde5 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java @@ -23,6 +23,7 @@ package org.onap.so.adapters.nssmf.rest; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; +@Deprecated public class TrustAllHostNameVerifier implements HostnameVerifier { public boolean verify(String hostname, SSLSession session) { diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java new file mode 100644 index 0000000000..92fe5576dd --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.service; + +import org.onap.so.adapters.nssmf.annotation.ServiceLogger; +import org.onap.so.beans.nsmf.*; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +@Service +@ServiceLogger +public interface NssmfManagerService { + ResponseEntity allocateNssi(NssmfAdapterNBIRequest allocateRequest); + + ResponseEntity deAllocateNssi(NssmfAdapterNBIRequest allocateRequest, String sliceProfileId); + + ResponseEntity activateNssi(NssmfAdapterNBIRequest deActRequest, String snssai); + + ResponseEntity deActivateNssi(NssmfAdapterNBIRequest nssiDeActivate, String snssai); + + ResponseEntity queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId); + + ResponseEntity queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest); + + ResponseEntity querySubnetCapability(NssmfAdapterNBIRequest nbiRequest); + +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java new file mode 100644 index 0000000000..5b53856f2f --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java @@ -0,0 +1,143 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.service.impl; + +import org.apache.commons.lang3.StringUtils; +import org.onap.so.adapters.nssmf.annotation.ServiceLogger; +import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig; +import org.onap.so.adapters.nssmf.enums.ActionType; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.manager.NssmfManagerBuilder; +import org.onap.so.adapters.nssmf.entity.RestResponse; +import org.onap.so.adapters.nssmf.manager.NssmfManager; +import org.onap.so.adapters.nssmf.service.NssmfManagerService; +import org.onap.so.adapters.nssmf.util.RestUtil; +import org.onap.so.beans.nsmf.*; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + + +@Service +@ServiceLogger +public class NssmfManagerServiceImpl implements NssmfManagerService { + + @Autowired + private RestUtil restUtil; + + @Autowired + private ResourceOperationStatusRepository repository; + + @Autowired + private NssmfAdapterConfig nssmfAdapterConfig; + + @Override + public ResponseEntity allocateNssi(NssmfAdapterNBIRequest request) { + try { + + if (StringUtils.isNotBlank(request.getServiceInfo().getNssiId())) { + return buildResponse(buildNssmfManager(request, ActionType.MODIFY).modifyNssi(request)); + } + + return buildResponse(buildNssmfManager(request, ActionType.ALLOCATE).allocateNssi(request)); + + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @Override + public ResponseEntity deAllocateNssi(NssmfAdapterNBIRequest request, String sliceProfileId) { + try { + return buildResponse( + buildNssmfManager(request, ActionType.DEALLOCATE).deAllocateNssi(request, sliceProfileId)); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @Override + public ResponseEntity activateNssi(NssmfAdapterNBIRequest request, String snssai) { + try { + return buildResponse(buildNssmfManager(request, ActionType.ACTIVATE).activateNssi(request, snssai)); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @Override + public ResponseEntity deActivateNssi(NssmfAdapterNBIRequest request, String snssai) { + try { + return buildResponse(buildNssmfManager(request, ActionType.DEACTIVATE).deActivateNssi(request, snssai)); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @Override + public ResponseEntity queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) { + try { + return buildResponse(buildNssmfManager(jobReq, ActionType.QUERY_JOB_STATUS).queryJobStatus(jobReq, jobId)); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @Override + public ResponseEntity queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) { + EsrInfo esrInfo = nbiRequest.getEsrInfo(); + try { + return buildResponse(buildNssmfManager(esrInfo, ActionType.QUERY_NSSI_SELECTION_CAPABILITY, null) + .queryNSSISelectionCapability(nbiRequest)); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @Override + public ResponseEntity querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) { + EsrInfo esrInfo = nbiRequest.getEsrInfo(); + try { + return buildResponse(buildNssmfManager(esrInfo, ActionType.QUERY_SUB_NET_CAPABILITY, null) + .querySubnetCapability(nbiRequest)); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + private ResponseEntity buildResponse(RestResponse rsp) { + return ResponseEntity.status(rsp.getStatus()).body(rsp.getResponseContent()); + } + + + private NssmfManager buildNssmfManager(NssmfAdapterNBIRequest request, ActionType actionType) + throws ApplicationException { + return buildNssmfManager(request.getEsrInfo(), actionType, request.getServiceInfo()); + } + + private NssmfManager buildNssmfManager(EsrInfo esrInfo, ActionType actionType, ServiceInfo serviceInfo) + throws ApplicationException { + + return new NssmfManagerBuilder(esrInfo).setActionType(actionType).setRepository(repository) + .setRestUtil(restUtil).setAdapterConfig(nssmfAdapterConfig).setServiceInfo(serviceInfo).build(); + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java index 3a7c2f19df..090417ddc2 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java @@ -22,10 +22,12 @@ package org.onap.so.adapters.nssmf.util; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; +import org.onap.so.adapters.nssmf.enums.ActionType; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.onap.logging.filter.base.ErrorCode; +import org.springframework.stereotype.Component; import static org.onap.so.logger.LoggingAnchor.THREE; import static org.onap.so.logger.MessageEnum.RA_NS_EXC; @@ -45,6 +47,8 @@ public class NssmfAdapterUtil { public static final String ALLOCATE_NSS_SUCCESS = "Allocating nss is " + "successful"; + public static final String MODIFY_NSS_SUCCESS = "Modify nss is " + "successful"; + public static final String CREATE_NSS_SUCCESS = "Creating nss is " + "successful"; public static final String DEALLOCATE_NSS_SUCCESS = "Deallocate nss " + "is successful"; @@ -91,4 +95,29 @@ public class NssmfAdapterUtil { } } + + public static String getStatusDesc(ActionType actionType) { + String desc = ""; + switch (actionType) { + case ALLOCATE: + desc = StatusDesc.ALLOCATE_NSS_SUCCESS; + break; + case DEALLOCATE: + desc = StatusDesc.DEALLOCATE_NSS_SUCCESS; + break; + case ACTIVATE: + desc = StatusDesc.ACTIVATE_NSS_SUCCESS; + break; + case DEACTIVATE: + desc = StatusDesc.DEACTIVATE_NSS_SUCCESS; + break; + case MODIFY: + desc = StatusDesc.MODIFY_NSS_SUCCESS; + break; + default: + break; + } + + return desc; + } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java index dcc6f5ba72..0c5999b20e 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java @@ -18,11 +18,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.nssmf.rest; +package org.onap.so.adapters.nssmf.util; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; +import javax.net.ssl.*; import javax.ws.rs.core.UriBuilder; import java.net.SocketTimeoutException; import java.net.URI; @@ -30,32 +28,29 @@ import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.client.methods.*; import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicHeader; import org.apache.http.util.EntityUtils; -import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.EsrThirdpartySdnc; -import org.onap.aai.domain.yang.EsrThirdpartySdncList; +import org.onap.aai.domain.yang.*; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.onap.so.adapters.nssmf.extclients.aai.AaiServiceProvider; -import org.onap.so.adapters.nssmf.model.TokenRequest; -import org.onap.so.adapters.nssmf.model.TokenResponse; +import org.onap.so.adapters.nssmf.entity.TokenRequest; +import org.onap.so.adapters.nssmf.entity.TokenResponse; +import org.onap.so.adapters.nssmf.enums.HttpMethod; +import org.onap.so.adapters.nssmf.entity.NssmfInfo; +import org.onap.so.adapters.nssmf.entity.RestResponse; import org.onap.so.beans.nsmf.EsrInfo; +import org.onap.so.beans.nsmf.ServiceInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import static org.apache.http.entity.ContentType.APPLICATION_JSON; -import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST; +import static org.onap.so.adapters.nssmf.enums.HttpMethod.POST; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.BAD_REQUEST; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; @@ -77,6 +72,10 @@ public class RestUtil { @Autowired private AaiServiceProvider aaiSvcProv; + public void createServiceInstance(ServiceInstance serviceInstance, ServiceInfo serviceInfo) { + aaiSvcProv.invokeCreateServiceInstance(serviceInstance, serviceInfo.getGlobalSubscriberId(), + serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); + } public NssmfInfo getNssmfHost(EsrInfo esrInfo) throws ApplicationException { EsrThirdpartySdncList sdncList = aaiSvcProv.invokeGetThirdPartySdncList(); @@ -112,10 +111,9 @@ public class RestUtil { throw new ApplicationException(BAD_REQUEST, "ESR information is improper"); } - public RestResponse sendRequest(String url, HttpMethod methodType, String content, EsrInfo esrInfo) - throws ApplicationException { - NssmfInfo nssmfInfo = getNssmfHost(esrInfo); + public String getToken(NssmfInfo nssmfInfo) throws ApplicationException { + TokenRequest req = new TokenRequest(); req.setGrantType("password"); @@ -128,13 +126,12 @@ public class RestUtil { RestResponse tokenRes = send(nssmfInfo.getUrl() + TOKEN_URL, POST, tokenReq, null); TokenResponse res = unMarshal(tokenRes.getResponseContent(), TokenResponse.class); - String token = res.getAccessToken(); - Header header = new BasicHeader("X-Auth-Token", token); - String nssmfUrl = nssmfInfo.getUrl() + url; - return send(nssmfUrl, methodType, content, header); + + return res.getAccessToken(); } - private RestResponse send(String url, HttpMethod methodType, String content, Header header) { + + public RestResponse send(String url, HttpMethod methodType, String content, Header header) { HttpRequestBase req = null; HttpResponse res = null; @@ -168,8 +165,6 @@ public class RestUtil { } if (null != req) { req.reset(); - } else { - logger.debug("method is NULL:"); } req = null; @@ -201,7 +196,7 @@ public class RestUtil { } } - private RestResponse createResponse(int statusCode, String errMsg) { + public RestResponse createResponse(int statusCode, String errMsg) { RestResponse restResponse = new RestResponse(); restResponse.setStatus(statusCode); restResponse.setResponseContent(errMsg); @@ -210,7 +205,7 @@ public class RestUtil { private HttpRequestBase getHttpReq(String url, HttpMethod method, Header header, RequestConfig config, String content) throws ApplicationException { - HttpRequestBase base = null; + HttpRequestBase base; switch (method) { case POST: HttpPost post = new HttpPost(url); @@ -229,6 +224,7 @@ public class RestUtil { break; case PATCH: + base = new HttpPatch(url); break; case DELETE: @@ -238,6 +234,8 @@ public class RestUtil { } base = delete; break; + default: + throw new ApplicationException(404, "invalid method: " + method); } base.setConfig(config); @@ -247,6 +245,14 @@ public class RestUtil { return base; } + public RestResponse sendRequest(String allocateUrl, HttpMethod post, String allocateReq, EsrInfo esrInfo) + throws ApplicationException { + NssmfInfo nssmfInfo = getNssmfHost(esrInfo); + Header header = new BasicHeader("X-Auth-Token", getToken(nssmfInfo)); + String nssmfUrl = nssmfInfo.getUrl() + allocateUrl; + return send(nssmfUrl, post, allocateReq, header); + } + class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { public static final String METHOD_NAME = "DELETE"; @@ -289,7 +295,7 @@ public class RestUtil { // HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); SSLConnectionSocketFactory sslsf = - new SSLConnectionSocketFactory(sc, new String[] {"TLSv1"}, null, new TrustAllHostNameVerifier()); + new SSLConnectionSocketFactory(sc, new String[] {"TLSv1"}, null, (s, sslSession) -> true); return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } catch (Exception e) { throw new IllegalArgumentException(e); diff --git a/adapters/mso-nssmf-adapter/src/main/resources/application-test.yaml b/adapters/mso-nssmf-adapter/src/main/resources/application-test.yaml new file mode 100644 index 0000000000..8e10dfb72b --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/resources/application-test.yaml @@ -0,0 +1,60 @@ + +aai: + auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 + endpoint: https://aai.onap:30233 +logging: + path: logs + +spring: + datasource: + jdbcUrl: jdbc:mariadb://49.232.146.162:8989/requestdb + username: root + password: 123456 + driver-class-name: org.mariadb.jdbc.Driver + initialization-mode: always + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: none + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + security: + usercredentials: + - username: bpel + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: BPEL-Client + - username: mso_admin + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: ACTUATOR +server: + port: 8080 + tomcat: + max-threads: 50 + +mso: + key: 07a7159d3bf51a0e53be7a8f89699be7 + site-name: localSite + logPath: ./logs/nssmf + adapters: + requestDb: + endpoint: https://so-request-db-adapter.onap:8083 + auth: Basic YnBlbDpwYXNzd29yZDEk + infra: + endpoint: https://so.onap:8080 + auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== + +#Actuator +management: + endpoints: + web: + base-path: /manage + exposure: + include: "*" + metrics: + se-global-registry: false + export: + prometheus: + enabled: true # Whether exporting of metrics to Prometheus is enabled. + step: 1m # Step size (i.e. reporting frequency) to use.
\ No newline at end of file diff --git a/adapters/mso-nssmf-adapter/src/main/resources/application.yaml b/adapters/mso-nssmf-adapter/src/main/resources/application.yaml index 303d63d4a2..8da911d4e0 100644 --- a/adapters/mso-nssmf-adapter/src/main/resources/application.yaml +++ b/adapters/mso-nssmf-adapter/src/main/resources/application.yaml @@ -58,6 +58,9 @@ mso: requestDb: endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083 auth: Basic YnBlbDpwYXNzd29yZDEk + infra: + endpoint: https://so.{{ include "common.namespace" . }}:8080 + auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== #Actuator management: diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java index 5bfd39096c..67cd913b3e 100644 --- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java @@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.LinkedList; import java.util.List; +import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.StatusLine; @@ -35,12 +36,12 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.onap.so.adapters.nssmf.model.TokenResponse; -import org.onap.so.adapters.nssmf.rest.HttpMethod; +import org.onap.so.adapters.nssmf.entity.TokenResponse; +import org.onap.so.adapters.nssmf.enums.HttpMethod; import org.onap.so.adapters.nssmf.rest.NssmfAdapterRest; -import org.onap.so.adapters.nssmf.rest.NssmfInfo; +import org.onap.so.adapters.nssmf.entity.NssmfInfo; import org.onap.so.adapters.nssmf.rest.NssmfManager; -import org.onap.so.adapters.nssmf.rest.RestUtil; +import org.onap.so.adapters.nssmf.util.RestUtil; import org.onap.so.beans.nsmf.ActDeActNssi; import org.onap.so.beans.nsmf.AllocateCnNssi; import org.onap.so.beans.nsmf.CnSliceProfile; @@ -53,7 +54,7 @@ import org.onap.so.beans.nsmf.NssiAllocateRequest; import org.onap.so.beans.nsmf.NssiDeAllocateRequest; import org.onap.so.beans.nsmf.NssiResponse; import org.onap.so.beans.nsmf.PerfReq; -import org.onap.so.beans.nsmf.PerfReqEmbbList; +import org.onap.so.beans.nsmf.PerfReqEmbb; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; @@ -127,13 +128,16 @@ public class NssmfAdapterRestTest { } private void createCommonMock(int statusCode, NssmfInfo nssmf) throws Exception { + when(this.restUtil.send(any(String.class), any(HttpMethod.class), any(String.class), any(Header.class))) + .thenCallRealMethod(); + when(this.restUtil.createResponse(any(Integer.class), any(String.class))).thenCallRealMethod(); when(nssmfRest.getNssmfMgr()).thenReturn(nssmfMgr); - when(nssmfRest.allocateNssi(any(NssiAllocateRequest.class))).thenCallRealMethod(); - when(nssmfRest.deAllocateNssi(any(NssiDeAllocateRequest.class), any(String.class))).thenCallRealMethod(); - when(nssmfRest.activateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod(); - when(nssmfRest.deactivateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod(); - - when(nssmfRest.queryJobStatus(any(JobStatusRequest.class), any(String.class))).thenCallRealMethod(); + // when(nssmfRest.createAllocateNssi(any(NssiAllocateRequest.class))).thenCallRealMethod(); + // when(nssmfRest.deAllocateNssi(any(NssiDeAllocateRequest.class), any(String.class))).thenCallRealMethod(); + // when(nssmfRest.activateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod(); + // when(nssmfRest.deactivateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod(); + // + // when(nssmfRest.queryJobStatus(any(JobStatusRequest.class), any(String.class))).thenCallRealMethod(); when(restUtil.sendRequest(any(String.class), any(HttpMethod.class), any(String.class), any(EsrInfo.class))) .thenCallRealMethod(); when(restUtil.getHttpsClient()).thenReturn(httpClient); @@ -168,113 +172,113 @@ public class NssmfAdapterRestTest { doAnswer(answer).when(httpClient).execute(any(HttpRequestBase.class)); } - @Test - public void testNssiAllocate() throws Exception { - NssmfInfo nssmf = new NssmfInfo(); - nssmf.setUserName("nssmf-user"); - nssmf.setPassword("nssmf-pass"); - nssmf.setPort("8080"); - nssmf.setIpAddress("127.0.0.1"); - - NssiResponse nssiRes = new NssiResponse(); - nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); - nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - - TokenResponse token = new TokenResponse(); - token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); - token.setExpires(1800); - - postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); - tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); - - createCommonMock(200, nssmf); - // assertEquals(prettyPrint(allocateNssi()), ALLOCATE); - ResponseEntity res = nssmfRest.allocateNssi(allocateNssi()); - assertNotNull(res); - assertNotNull(res.getBody()); - NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); - assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); - assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - } - - @Test - public void testNssiDeAllocate() throws Exception { - NssmfInfo nssmf = new NssmfInfo(); - nssmf.setUserName("nssmf-user"); - nssmf.setPassword("nssmf-pass"); - nssmf.setPort("8080"); - nssmf.setIpAddress("127.0.0.1"); - - NssiResponse nssiRes = new NssiResponse(); - nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); - - TokenResponse token = new TokenResponse(); - token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); - token.setExpires(1800); - - postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); - tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); - - createCommonMock(200, nssmf); - ResponseEntity res = nssmfRest.deAllocateNssi(deAllocateNssi(), "ab9af40f13f721b5f13539d87484098"); - assertNotNull(res); - assertNotNull(res.getBody()); - NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); - assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); - } - - @Test - public void testNssiActivate() throws Exception { - NssmfInfo nssmf = new NssmfInfo(); - nssmf.setUserName("nssmf-user"); - nssmf.setPassword("nssmf-pass"); - nssmf.setPort("8080"); - nssmf.setIpAddress("127.0.0.1"); - - NssiResponse nssiRes = new NssiResponse(); - nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); - - TokenResponse token = new TokenResponse(); - token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); - token.setExpires(1800); - - postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); - tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); - - createCommonMock(200, nssmf); - ResponseEntity res = nssmfRest.activateNssi(activateNssi(), "001-100001"); - assertNotNull(res); - assertNotNull(res.getBody()); - NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); - assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); - } - - @Test - public void testNssiDeActivate() throws Exception { - NssmfInfo nssmf = new NssmfInfo(); - nssmf.setUserName("nssmf-user"); - nssmf.setPassword("nssmf-pass"); - nssmf.setPort("8080"); - nssmf.setIpAddress("127.0.0.1"); - - NssiResponse nssiRes = new NssiResponse(); - nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); - - TokenResponse token = new TokenResponse(); - token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); - token.setExpires(1800); - - postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); - tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); - - createCommonMock(200, nssmf); - ResponseEntity res = nssmfRest.deactivateNssi(deActivateNssi(), "001-100001"); - assertNotNull(res); - assertNotNull(res.getBody()); - NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); - assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); - } - + // @Test + // public void testNssiAllocate() throws Exception { + // NssmfInfo nssmf = new NssmfInfo(); + // nssmf.setUserName("nssmf-user"); + // nssmf.setPassword("nssmf-pass"); + // nssmf.setPort("8080"); + // nssmf.setIpAddress("127.0.0.1"); + // + // NssiResponse nssiRes = new NssiResponse(); + // nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + // nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + // + // TokenResponse token = new TokenResponse(); + // token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + // token.setExpires(1800); + // + // postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + // tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + // + // createCommonMock(200, nssmf); + // // assertEquals(prettyPrint(createAllocateNssi()), ALLOCATE); + // ResponseEntity res = nssmfRest.createAllocateNssi(createAllocateNssi()); + // assertNotNull(res); + // assertNotNull(res.getBody()); + // NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + // assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + // assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + // } + // + // @Test + // public void testNssiDeAllocate() throws Exception { + // NssmfInfo nssmf = new NssmfInfo(); + // nssmf.setUserName("nssmf-user"); + // nssmf.setPassword("nssmf-pass"); + // nssmf.setPort("8080"); + // nssmf.setIpAddress("127.0.0.1"); + // + // NssiResponse nssiRes = new NssiResponse(); + // nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + // + // TokenResponse token = new TokenResponse(); + // token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + // token.setExpires(1800); + // + // postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + // tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + // + // createCommonMock(200, nssmf); + // ResponseEntity res = nssmfRest.deAllocateNssi(deAllocateNssi(), "ab9af40f13f721b5f13539d87484098"); + // assertNotNull(res); + // assertNotNull(res.getBody()); + // NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + // assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + // } + // + // @Test + // public void testNssiActivate() throws Exception { + // NssmfInfo nssmf = new NssmfInfo(); + // nssmf.setUserName("nssmf-user"); + // nssmf.setPassword("nssmf-pass"); + // nssmf.setPort("8080"); + // nssmf.setIpAddress("127.0.0.1"); + // + // NssiResponse nssiRes = new NssiResponse(); + // nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + // + // TokenResponse token = new TokenResponse(); + // token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + // token.setExpires(1800); + // + // postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + // tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + // + // createCommonMock(200, nssmf); + // ResponseEntity res = nssmfRest.activateNssi(activateNssi(), "001-100001"); + // assertNotNull(res); + // assertNotNull(res.getBody()); + // NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + // assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + // } + // + // @Test + // public void testNssiDeActivate() throws Exception { + // NssmfInfo nssmf = new NssmfInfo(); + // nssmf.setUserName("nssmf-user"); + // nssmf.setPassword("nssmf-pass"); + // nssmf.setPort("8080"); + // nssmf.setIpAddress("127.0.0.1"); + // + // NssiResponse nssiRes = new NssiResponse(); + // nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + // + // TokenResponse token = new TokenResponse(); + // token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + // token.setExpires(1800); + // + // postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + // tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + // + // createCommonMock(200, nssmf); + // ResponseEntity res = nssmfRest.deactivateNssi(deActivateNssi(), "001-100001"); + // assertNotNull(res); + // assertNotNull(res.getBody()); + // NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + // assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + // } + // @Test public void testAllocateJsonSerDeSer() throws Exception { assertEquals(marshal(allocateNssi()), ALLOCATE); @@ -285,7 +289,7 @@ public class NssmfAdapterRestTest { assertEquals(all.getAllocateCnNssi().getSliceProfile().getResourceSharingLevel(), NON_SHARED); assertNotNull(all.getAllocateCnNssi().getSliceProfile().getPerfReq()); assertNotNull(all.getAllocateCnNssi().getSliceProfile().getPerfReq().getPerfReqEmbbList()); - PerfReqEmbbList embb = + PerfReqEmbb embb = all.getAllocateCnNssi().getSliceProfile().getPerfReq().getPerfReqEmbbList().iterator().next(); assertNotNull(embb); assertEquals(embb.getActivityFactor(), 50); @@ -298,9 +302,9 @@ public class NssmfAdapterRestTest { List<String> plmn = new LinkedList<>(); plmn.add("460-00"); plmn.add("460-01"); - PerfReqEmbbList embb = new PerfReqEmbbList(); + PerfReqEmbb embb = new PerfReqEmbb(); embb.setActivityFactor(50); - List<PerfReqEmbbList> embbList = new LinkedList<>(); + List<PerfReqEmbb> embbList = new LinkedList<>(); embbList.add(embb); PerfReq perfReq = new PerfReq(); perfReq.setPerfReqEmbbList(embbList); @@ -334,50 +338,51 @@ public class NssmfAdapterRestTest { return allocate; } - public NssiDeAllocateRequest deAllocateNssi() throws Exception { - DeAllocateNssi deAllocateNssi = new DeAllocateNssi(); - deAllocateNssi.setTerminateNssiOption(0); - List<String> snssai = new LinkedList<>(); - snssai.add("001-100001"); - deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - deAllocateNssi.setScriptName("CN1"); - deAllocateNssi.setSnssaiList(snssai); - EsrInfo esrInfo = new EsrInfo(); - esrInfo.setVendor("huawei"); - esrInfo.setNetworkType(CORE); - NssiDeAllocateRequest deAllocate = new NssiDeAllocateRequest(); - deAllocate.setDeAllocateNssi(deAllocateNssi); - deAllocate.setEsrInfo(esrInfo); - return deAllocate; - } - - public NssiActDeActRequest activateNssi() throws Exception { - EsrInfo esrInfo = new EsrInfo(); - esrInfo.setVendor("huawei"); - esrInfo.setNetworkType(CORE); - ActDeActNssi act = new ActDeActNssi(); - act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - NssiActDeActRequest actReq = new NssiActDeActRequest(); - actReq.setActDeActNssi(act); - actReq.setEsrInfo(esrInfo); - return actReq; - } - - public NssiActDeActRequest deActivateNssi() throws Exception { - EsrInfo esrInfo = new EsrInfo(); - esrInfo.setVendor("huawei"); - esrInfo.setNetworkType(CORE); - ActDeActNssi deAct = new ActDeActNssi(); - deAct.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - deAct.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - NssiActDeActRequest deActReq = new NssiActDeActRequest(); - deActReq.setActDeActNssi(deAct); - deActReq.setEsrInfo(esrInfo); - return deActReq; - } - + // + // public NssiDeAllocateRequest deAllocateNssi() throws Exception { + // DeAllocateNssi deAllocateNssi = new DeAllocateNssi(); + // deAllocateNssi.setTerminateNssiOption(0); + // List<String> snssai = new LinkedList<>(); + // snssai.add("001-100001"); + // deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + // deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + // deAllocateNssi.setScriptName("CN1"); + // deAllocateNssi.setSnssaiList(snssai); + // EsrInfo esrInfo = new EsrInfo(); + // esrInfo.setVendor("huawei"); + // esrInfo.setNetworkType(CORE); + // NssiDeAllocateRequest deAllocate = new NssiDeAllocateRequest(); + // deAllocate.setDeAllocateNssi(deAllocateNssi); + // deAllocate.setEsrInfo(esrInfo); + // return deAllocate; + // } + // + // public NssiActDeActRequest activateNssi() throws Exception { + // EsrInfo esrInfo = new EsrInfo(); + // esrInfo.setVendor("huawei"); + // esrInfo.setNetworkType(CORE); + // ActDeActNssi act = new ActDeActNssi(); + // act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + // act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + // NssiActDeActRequest actReq = new NssiActDeActRequest(); + // actReq.setActDeActNssi(act); + // actReq.setEsrInfo(esrInfo); + // return actReq; + // } + // + // public NssiActDeActRequest deActivateNssi() throws Exception { + // EsrInfo esrInfo = new EsrInfo(); + // esrInfo.setVendor("huawei"); + // esrInfo.setNetworkType(CORE); + // ActDeActNssi deAct = new ActDeActNssi(); + // deAct.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + // deAct.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + // NssiActDeActRequest deActReq = new NssiActDeActRequest(); + // deActReq.setActDeActNssi(deAct); + // deActReq.setEsrInfo(esrInfo); + // return deActReq; + // } + // public String queryJobStatusNssi() throws Exception { EsrInfo esrInfo = new EsrInfo(); esrInfo.setVendor("huawei"); diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java new file mode 100644 index 0000000000..4a659e1ca3 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java @@ -0,0 +1,438 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.adapters.nssmf.service.impl; + + +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.StatusLine; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpRequestBase; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.stubbing.Answer; +import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts; +import org.onap.so.adapters.nssmf.entity.NssmfInfo; +import org.onap.so.adapters.nssmf.entity.TokenResponse; +import org.onap.so.adapters.nssmf.enums.HttpMethod; +import org.onap.so.adapters.nssmf.util.RestUtil; +import org.onap.so.beans.nsmf.*; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.util.*; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; +import static org.onap.so.beans.nsmf.NetworkType.CORE; +import static org.onap.so.beans.nsmf.ResourceSharingLevel.NON_SHARED; + +@RunWith(SpringRunner.class) +public class NssmfManagerServiceImplTest { + + @Mock + private RestUtil restUtil; + + + private NssmfManagerServiceImpl nssiManagerService; + + @Mock + private HttpResponse tokenResponse; + + @Mock + private HttpEntity tokenEntity; + + @Mock + private HttpResponse commonResponse; + + @Mock + private HttpEntity commonEntity; + + @Mock + private StatusLine statusLine; + + @Mock + private HttpClient httpClient; + + private InputStream postStream; + + private InputStream tokenStream; + + @Mock + private ResourceOperationStatusRepository repository; + + @Before + public void setUp() throws Exception { + initMocks(this); + + nssiManagerService = new NssmfManagerServiceImpl(); + + Field restUtil = nssiManagerService.getClass().getDeclaredField("restUtil"); + restUtil.setAccessible(true); + restUtil.set(nssiManagerService, this.restUtil); + + Field repository = nssiManagerService.getClass().getDeclaredField("repository"); + repository.setAccessible(true); + repository.set(nssiManagerService, this.repository); + // nssiManagerService.setRestUtil(this.restUtil); + + when(this.restUtil.send(any(String.class), any(HttpMethod.class), any(), any(Header.class))) + .thenCallRealMethod(); + when(this.restUtil.createResponse(any(Integer.class), any(String.class))).thenCallRealMethod(); + } + + private void createCommonMock(int statusCode, NssmfInfo nssmf) throws Exception { + when(restUtil.getToken(any(NssmfInfo.class))).thenReturn("7512eb3feb5249eca5ddd742fedddd39"); + when(restUtil.getHttpsClient()).thenReturn(httpClient); + + when(statusLine.getStatusCode()).thenReturn(statusCode); + when(restUtil.getNssmfHost(any(EsrInfo.class))).thenReturn(nssmf); + + when(tokenResponse.getEntity()).thenReturn(tokenEntity); + when(tokenResponse.getStatusLine()).thenReturn(statusLine); + when(tokenEntity.getContent()).thenReturn(tokenStream); + + when(commonResponse.getEntity()).thenReturn(commonEntity); + when(commonResponse.getStatusLine()).thenReturn(statusLine); + when(commonEntity.getContent()).thenReturn(postStream); + + Answer<HttpResponse> answer = invocation -> { + Object[] arguments = invocation.getArguments(); + if (arguments != null && arguments.length == 1 && arguments[0] != null) { + + HttpRequestBase base = (HttpRequestBase) arguments[0]; + if (base.getURI().toString().endsWith("/oauth/token")) { + return tokenResponse; + } else { + return commonResponse; + } + } + return commonResponse; + }; + + doAnswer(answer).when(httpClient).execute(any(HttpRequestBase.class)); + + } + + @Test + public void allocateNssi() throws Exception { + + NssmfInfo nssmf = new NssmfInfo(); + nssmf.setUserName("nssmf-user"); + nssmf.setPassword("nssmf-pass"); + nssmf.setPort("8080"); + nssmf.setIpAddress("127.0.0.1"); + nssmf.setUrl("http://127.0.0.1:8080"); + + NssiResponse nssiRes = new NssiResponse(); + nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + + TokenResponse token = new TokenResponse(); + token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + token.setExpires(1800); + + postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + + createCommonMock(200, nssmf); + + + NssmfAdapterNBIRequest nbiRequest = createAllocateNssi(); + assertNotNull(nbiRequest); + System.out.println(marshal(nbiRequest)); + ResponseEntity res = nssiManagerService.allocateNssi(nbiRequest); + assertNotNull(res); + assertNotNull(res.getBody()); + NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + + System.out.println(res); + } + + + + private NssmfAdapterNBIRequest createAllocateNssi() { + CnSliceProfile sP = new CnSliceProfile(); + List<String> sns = new LinkedList<>(); + sns.add("001-100001"); + List<String> plmn = new LinkedList<>(); + plmn.add("460-00"); + plmn.add("460-01"); + PerfReqEmbb embb = new PerfReqEmbb(); + embb.setActivityFactor(50); + List<PerfReqEmbb> embbList = new LinkedList<>(); + embbList.add(embb); + PerfReq perfReq = new PerfReq(); + perfReq.setPerfReqEmbbList(embbList); + List<String> taList = new LinkedList<>(); + taList.add("1"); + taList.add("2"); + taList.add("3"); + sP.setSnssaiList(sns); + sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098"); + sP.setPlmnIdList(plmn); + sP.setPerfReq(perfReq); + sP.setMaxNumberofUEs(200); + sP.setCoverageAreaTAList(taList); + sP.setLatency(6); + sP.setResourceSharingLevel(NON_SHARED); + NsiInfo nsiInfo = new NsiInfo(); + nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + nsiInfo.setNsiName("eMBB-001"); + AllocateCnNssi cnNssi = new AllocateCnNssi(); + cnNssi.setNssiId("NSST-C-001-HDBNJ-NSSMF-01-A-ZX"); + cnNssi.setNssiName("eMBB-001"); + cnNssi.setScriptName("CN1"); + cnNssi.setSliceProfile(sP); + cnNssi.setNsiInfo(nsiInfo); + + NssmfAdapterNBIRequest nbiRequest = createNbiRequest(); + nbiRequest.setAllocateCnNssi(cnNssi); + return nbiRequest; + } + + @Test + public void deAllocateNssi() throws Exception { + DeAllocateNssi deAllocateNssi = new DeAllocateNssi(); + deAllocateNssi.setTerminateNssiOption(0); + List<String> snssai = new LinkedList<>(); + snssai.add("001-100001"); + deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + deAllocateNssi.setScriptName("CN1"); + deAllocateNssi.setSnssaiList(snssai); + + NssmfAdapterNBIRequest nbiRequest = createNbiRequest(); + nbiRequest.setDeAllocateNssi(deAllocateNssi); + + NssmfInfo nssmf = new NssmfInfo(); + nssmf.setUserName("nssmf-user"); + nssmf.setPassword("nssmf-pass"); + nssmf.setPort("8080"); + nssmf.setIpAddress("127.0.0.1"); + + NssiResponse nssiRes = new NssiResponse(); + nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + + TokenResponse token = new TokenResponse(); + token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + token.setExpires(1800); + + postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + + createCommonMock(202, nssmf); + ResponseEntity res = nssiManagerService.deAllocateNssi(nbiRequest, "ab9af40f13f721b5f13539d87484098"); + assertNotNull(res); + assertNotNull(res.getBody()); + NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + assertNotNull(res); + assertNotNull(res.getBody()); + } + + @Test + public void activateNssi() throws Exception { + NssmfInfo nssmf = new NssmfInfo(); + nssmf.setUserName("nssmf-user"); + nssmf.setPassword("nssmf-pass"); + nssmf.setPort("8080"); + nssmf.setIpAddress("127.0.0.1"); + + NssiResponse nssiRes = new NssiResponse(); + nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + + TokenResponse token = new TokenResponse(); + token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + token.setExpires(1800); + + postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + + ActDeActNssi act = new ActDeActNssi(); + act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + + NssmfAdapterNBIRequest nbiRequest = createNbiRequest(); + nbiRequest.setActDeActNssi(act); + + createCommonMock(200, nssmf); + ResponseEntity res = nssiManagerService.activateNssi(nbiRequest, "001-100001"); + assertNotNull(res); + assertNotNull(res.getBody()); + NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + } + + @Test + public void deActivateNssi() throws Exception { + NssmfInfo nssmf = new NssmfInfo(); + nssmf.setUserName("nssmf-user"); + nssmf.setPassword("nssmf-pass"); + nssmf.setPort("8080"); + nssmf.setIpAddress("127.0.0.1"); + + NssiResponse nssiRes = new NssiResponse(); + nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + + TokenResponse token = new TokenResponse(); + token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + token.setExpires(1800); + + postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + + ActDeActNssi act = new ActDeActNssi(); + act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + + NssmfAdapterNBIRequest nbiRequest = createNbiRequest(); + nbiRequest.setActDeActNssi(act); + + createCommonMock(200, nssmf); + ResponseEntity res = nssiManagerService.deActivateNssi(nbiRequest, "001-100001"); + assertNotNull(res); + assertNotNull(res.getBody()); + NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + } + + @Test + public void queryJobStatus() throws Exception { + NssmfInfo nssmf = new NssmfInfo(); + nssmf.setUserName("nssmf-user"); + nssmf.setPassword("nssmf-pass"); + nssmf.setPort("8080"); + nssmf.setIpAddress("127.0.0.1"); + + JobStatusResponse jobStatusResponse = new JobStatusResponse(); + ResponseDescriptor descriptor = new ResponseDescriptor(); + descriptor.setResponseId("7512eb3feb5249eca5ddd742fedddd39"); + descriptor.setProgress(20); + descriptor.setStatusDescription("Initiating VNF Instance"); + descriptor.setStatus("processing"); + jobStatusResponse.setResponseDescriptor(descriptor); + + TokenResponse token = new TokenResponse(); + token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + token.setExpires(1800); + + postStream = new ByteArrayInputStream(marshal(jobStatusResponse).getBytes(UTF_8)); + tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + + ResourceOperationStatus operationStatus = new ResourceOperationStatus(); + operationStatus.setOperationId("4b45d919816ccaa2b762df5120f72067"); + operationStatus.setResourceTemplateUUID("8ee5926d-720b-4bb2-86f9-d20e921c143b"); + operationStatus.setServiceId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + + NssmfAdapterNBIRequest nbiRequest = createNbiRequest(); + nbiRequest.setResponseId("7512eb3feb5249eca5ddd742fedddd39"); + Optional<ResourceOperationStatus> optional = Optional.of(operationStatus); + + doAnswer(invocation -> optional).when(repository).findOne(any()); + + createCommonMock(200, nssmf); + + ResponseEntity res = nssiManagerService.queryJobStatus(nbiRequest, "4b45d919816ccaa2b762df5120f72067"); + assertNotNull(res); + assertNotNull(res.getBody()); + JobStatusResponse allRes = unMarshal(res.getBody().toString(), JobStatusResponse.class); + assertEquals(allRes.getResponseDescriptor().getProgress(), 20); + assertEquals(allRes.getResponseDescriptor().getStatus(), "processing"); + assertEquals(allRes.getResponseDescriptor().getResponseId(), "7512eb3feb5249eca5ddd742fedddd39"); + + System.out.println(res); + + } + + @Test + public void queryNSSISelectionCapability() throws Exception { + + NssmfAdapterNBIRequest nbiRequest = createNbiRequest(); + ResponseEntity res = nssiManagerService.queryNSSISelectionCapability(nbiRequest); + assertNotNull(res); + assertNotNull(res.getBody()); + Map allRes = unMarshal(res.getBody().toString(), Map.class); + assertEquals(allRes.get("selection"), "NSMF"); + + System.out.println(res); + + nbiRequest.getEsrInfo().setVendor(NssmfAdapterConsts.ONAP_INTERNAL_TAG); + res = nssiManagerService.queryNSSISelectionCapability(nbiRequest); + assertNotNull(res); + assertNotNull(res.getBody()); + allRes = unMarshal(res.getBody().toString(), Map.class); + assertEquals(allRes.get("selection"), "NSSMF"); + + System.out.println(res); + + nbiRequest.getEsrInfo().setNetworkType(NetworkType.ACCESS); + res = nssiManagerService.queryNSSISelectionCapability(nbiRequest); + assertNotNull(res); + assertNotNull(res.getBody()); + allRes = unMarshal(res.getBody().toString(), Map.class); + assertEquals(allRes.get("selection"), "NSSMF"); + + System.out.println(res); + } + + private NssmfAdapterNBIRequest createNbiRequest() { + NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest(); + EsrInfo esrInfo = new EsrInfo(); + esrInfo.setVendor("huawei"); + esrInfo.setNetworkType(CORE); + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.setServiceUuid("8ee5926d-720b-4bb2-86f9-d20e921c143b"); + serviceInfo.setServiceInvariantUuid("e75698d9-925a-4cdd-a6c0-edacbe6a0b51"); + serviceInfo.setGlobalSubscriberId("5GCustomer"); + serviceInfo.setServiceType("5G"); + serviceInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + nbiRequest.setEsrInfo(esrInfo); + nbiRequest.setServiceInfo(serviceInfo); + return nbiRequest; + } + + @Test + public void querySubnetCapability() { + NssmfAdapterNBIRequest nbiRequest = createNbiRequest(); + + String subnetCapabilityQuery = "\"subnetTypes\": [\"TN-FH\",\"TN-MH\",\"TN-BH\"]"; + nbiRequest.setSubnetCapabilityQuery(subnetCapabilityQuery); + ResponseEntity res = nssiManagerService.queryNSSISelectionCapability(nbiRequest); + assertNotNull(res); + assertNotNull(res.getBody()); + } +} diff --git a/adapters/mso-nssmf-adapter/src/test/resources/application-test.yaml b/adapters/mso-nssmf-adapter/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..fa323e887b --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/test/resources/application-test.yaml @@ -0,0 +1,60 @@ + +aai: + auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 + endpoint: https://aai.onap:30233 +logging: + path: logs + +spring: + datasource: + username: root + password: 123456 + driver-class-name: org.mariadb.jdbc.Driver + initialization-mode: always + url: jdbc:mariadb://49.232.146.162:8989/requestdb + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: none + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + security: + usercredentials: + - username: bpel + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: BPEL-Client + - username: mso_admin + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: ACTUATOR +server: + port: 8080 + tomcat: + max-threads: 50 + +mso: + key: 07a7159d3bf51a0e53be7a8f89699be7 + site-name: localSite + logPath: ./logs/nssmf + adapters: + requestDb: + endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083 + auth: Basic YnBlbDpwYXNzd29yZDEk + infra: + endpoint: https://so.{{ include "common.namespace" . }}:8080 + auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== + +#Actuator +management: + endpoints: + web: + base-path: /manage + exposure: + include: "*" + metrics: + se-global-registry: false + export: + prometheus: + enabled: true # Whether exporting of metrics to Prometheus is enabled. + step: 1m # Step size (i.e. reporting frequency) to use.
\ No newline at end of file diff --git a/adapters/mso-oof-adapter/.gitignore b/adapters/mso-oof-adapter/.gitignore new file mode 100644 index 0000000000..549e00a2a9 --- /dev/null +++ b/adapters/mso-oof-adapter/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/adapters/mso-oof-adapter/pom.xml b/adapters/mso-oof-adapter/pom.xml new file mode 100644 index 0000000000..98150d39e0 --- /dev/null +++ b/adapters/mso-oof-adapter/pom.xml @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>adapters</artifactId> + <version>1.7.1-SNAPSHOT</version> + </parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-oof-adapter</artifactId> + <name>mso-oof-adapter</name> + <description>mso oof adapter</description> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${springboot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-webflux</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-service-description-swagger</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <mainClass>org.onap.so.adapters.oof.MsoOofAdapterApplication</mainClass> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + </plugin> + </plugins> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <excludes> + <exclude>**/*.p12</exclude> + <exclude>**/*.jks</exclude> + </excludes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <includes> + <include>**/*.p12</include> + <include>**/*.jks</include> + </includes> + </resource> + </resources> + </build> +</project> diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/MsoOofAdapterApplication.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/MsoOofAdapterApplication.java new file mode 100644 index 0000000000..78fbe6e271 --- /dev/null +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/MsoOofAdapterApplication.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.adapters.oof; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MsoOofAdapterApplication { + + public static void main(String[] args) { + SpringApplication.run(MsoOofAdapterApplication.class, args); + } +} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/OofAdapterClientConfig.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/OofAdapterClientConfig.java new file mode 100644 index 0000000000..5e13c592b7 --- /dev/null +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/OofAdapterClientConfig.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.adapters.oof; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import org.apache.http.client.HttpClient; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.HttpClients; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class OofAdapterClientConfig { + + @Bean + public RestTemplate getRestTemplate() { + HttpComponentsClientHttpRequestFactory requestFactory = + new HttpComponentsClientHttpRequestFactory(getHttpsClient()); + requestFactory.setConnectTimeout(60000); + requestFactory.setReadTimeout(60000); + return new RestTemplate(requestFactory); + } + + private HttpClient getHttpsClient() { + TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {} + + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {} + }}; + + // Install the all-trusting trust manager + try { + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + HostnameVerifier hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sc, + new String[] {"TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"}, null, hostnameVerifier); + return HttpClients.custom().setSSLSocketFactory(sslsf).build(); + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyManagerNotFound.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/WebSecurityConfig.java index bc6fd6204c..9a07b0119f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyManagerNotFound.java +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/WebSecurityConfig.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. 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. @@ -18,16 +18,20 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.exceptions; +package org.onap.so.adapters.oof; -public class MsoCloudifyManagerNotFound extends MsoCloudifyException { +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - private static final long serialVersionUID = 1L; +@EnableWebSecurity +@Configuration +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - // Constructor to create a new MsoCloudifyException instance - public MsoCloudifyManagerNotFound(String cloudSiteId) { - // Set the detailed error as the Exception 'message' - super(0, "Cloudify Manager Not Found", "No Cloudify Manager configured for cloud site " + cloudSiteId); + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable(); } } diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseStatus.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/constants/Constants.java index ccdd7a4168..5d91bf38f8 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseStatus.java +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/constants/Constants.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. 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. @@ -17,21 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +package org.onap.so.adapters.oof.constants; -package org.onap.so.cloudify.base.client; +public class Constants { -public class CloudifyResponseStatus { - - public static final int OK = 200; - - public static final int ACCEPTED = 201; - - public static final int BAD_REQUEST = 400; - - public static final int NOT_AUTHORIZED = 401; - - public static final int NOT_FOUND = 404; - - public static final int CONFLICT = 409; + public static final String OOF_ENDPOINT = "mso.oof.endpoint"; + public static final String OOF_AUTH = "mso.oof.auth"; + public static final String MSO_KEY = "mso.msoKey"; + public static final String CAMUNDA_URL = "mso.camundaURL"; + public static final String CAMUNDA_AUTH = "mso.camundaAuth"; + public static final String WORKFLOW_MESSAGE_ENPOINT = "mso.workflow.message.endpoint"; } diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifySimpleTokenProvider.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/exceptions/OofAdapterException.java index 0c1e42d0e8..ff16d7442c 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifySimpleTokenProvider.java +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/exceptions/OofAdapterException.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. 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. @@ -18,22 +18,22 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.base.client; +package org.onap.so.adapters.oof.exceptions; -public class CloudifySimpleTokenProvider implements CloudifyTokenProvider { +public class OofAdapterException extends Exception { - String token; + private static final long serialVersionUID = 1L; - public CloudifySimpleTokenProvider(String token) { - this.token = token; + public OofAdapterException(String message) { + super(message); } - @Override - public String getToken() { - return this.token; + public OofAdapterException(Throwable e) { + super(e); } - @Override - public void expireToken() {} + public OofAdapterException(String message, Throwable e) { + super(message, e); + } } diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CancelExecutionParams.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/model/OofRequest.java index 7f96b8f7c6..1eb694fd96 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CancelExecutionParams.java +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/model/OofRequest.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. 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. @@ -17,34 +17,36 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +package org.onap.so.adapters.oof.model; -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CancelExecutionParams implements Serializable { +/** + * POJO representing generic request payload from BPMN processes + */ +public class OofRequest { - private static final long serialVersionUID = 1L; + private String apiPath; - @JsonProperty("action") - private String action; + private Object requestDetails; - public static final String CANCEL_ACTION = "cancel"; - public static final String FORCE_CANCEL_ACTION = "force-cancel"; + public String getApiPath() { + return apiPath; + } - public String getAction() { - return action; + public void setApiPath(String apiPath) { + this.apiPath = apiPath; } - public void setAction(String action) { - this.action = action; + public Object getRequestDetails() { + return requestDetails; } + public void setRequestDetails(Object requestDetails) { + this.requestDetails = requestDetails; + } @Override public String toString() { - return "CancelExecutionParams{" + "action='" + action + '\'' + '}'; + return "{\"apiPath:\"\"" + apiPath + "\"\", requestDetails:\"\"" + requestDetails + "}"; } } diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofCallbackHandler.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofCallbackHandler.java new file mode 100644 index 0000000000..f8da6c6d2e --- /dev/null +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofCallbackHandler.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.adapters.oof.rest; + +import org.onap.so.adapters.oof.exceptions.OofAdapterException; +import org.onap.so.adapters.oof.utils.OofUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +/** + * A generic call back handler to receive async response from OOF + */ +@RestController +@RequestMapping("/so/adapters/oof/callback/") +public class OofCallbackHandler { + + @Autowired + OofUtils utils; + + @Autowired + RestTemplate restTemplate; + + private static final Logger logger = LoggerFactory.getLogger(OofCallbackHandler.class); + + @PostMapping("/{version:[vV][1]}/{messageEventName}/{correlator}") + public ResponseEntity<String> processCallback(@PathVariable("messageEventName") String messageEventName, + @PathVariable("correlator") String correlator, @RequestBody String oofCallbackRequest) + throws OofAdapterException { + logger.debug("Oof Async response received for event : {} , callback request body : {} ", messageEventName, + oofCallbackRequest); + String camundaMsgUrl = utils.getCamundaMsgUrl(messageEventName, correlator); + HttpEntity<String> request = new HttpEntity<String>(oofCallbackRequest, utils.getCamundaHeaders()); + try { + ResponseEntity<String> response = restTemplate.postForEntity(camundaMsgUrl, request, String.class); + logger.debug("Response from BPMN : {} ", response); + return response; + } catch (Exception e) { + logger.warn("Error injecting message event into BPMN {} {} ", e.getCause(), e.getMessage()); + throw new OofAdapterException(e); + } + + } + +} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofClient.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofClient.java new file mode 100644 index 0000000000..3a91ec495e --- /dev/null +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofClient.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.adapters.oof.rest; + +import org.onap.so.adapters.oof.exceptions.OofAdapterException; +import org.onap.so.adapters.oof.model.OofRequest; +import org.onap.so.adapters.oof.utils.OofUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +/** + * A generic client class to call OOF with request from BPMN + */ +@RestController +@RequestMapping("/so/adapters/oof/") +public class OofClient { + + @Autowired + RestTemplate restTemplate; + + @Autowired + OofUtils utils; + + private static final Logger logger = LoggerFactory.getLogger(OofClient.class); + + @PostMapping("/{version:[vV][1]}") + public ResponseEntity<String> callOof(@RequestBody OofRequest oofRequest) throws OofAdapterException { + try { + logger.debug("Received Request from BPEL {} ", oofRequest); + String oofUrl = utils.getOofurl(oofRequest.getApiPath()); + HttpEntity<?> request = new HttpEntity<>(oofRequest.getRequestDetails(), utils.getOofHttpHeaders()); + ResponseEntity<String> response = restTemplate.postForEntity(oofUrl, request, String.class); + logger.debug("Response from OOF : {} ", response); + return response; + } catch (Exception e) { + logger.warn("Error while calling OOF {} {} ", e.getCause(), e.getMessage()); + throw new OofAdapterException(e); + } + } + +} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/utils/OofUtils.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/utils/OofUtils.java new file mode 100644 index 0000000000..f45baa30fe --- /dev/null +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/utils/OofUtils.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.adapters.oof.utils; + +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.DatatypeConverter; +import org.onap.so.adapters.oof.constants.Constants; +import org.onap.so.utils.CryptoUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; + +@Component +public class OofUtils { + private static Logger logger = LoggerFactory.getLogger(OofUtils.class); + + @Autowired + private Environment env; + + /** + * @param messageEventName + * @param correlator + * @return + */ + public String getCamundaMsgUrl(String messageEventName, String correlator) { + System.out.println(env); + String camundaMsgUrl = new StringBuilder(env.getRequiredProperty(Constants.WORKFLOW_MESSAGE_ENPOINT)) + .append("/").append(messageEventName).append("/").append(correlator).toString(); + return camundaMsgUrl; + } + + /** + * @return + */ + public HttpHeaders getCamundaHeaders() { + HttpHeaders headers = new HttpHeaders(); + List<MediaType> acceptableMediaTypes = new ArrayList<>(); + acceptableMediaTypes.add(MediaType.ALL); + headers.setAccept(acceptableMediaTypes); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.add(HttpHeaders.AUTHORIZATION, addAuthorizationHeader(env.getRequiredProperty(Constants.CAMUNDA_AUTH), + env.getRequiredProperty(Constants.MSO_KEY))); + return headers; + } + + /** + * @param auth + * @param msoKey + * @return + */ + protected String addAuthorizationHeader(String auth, String msoKey) { + String basicAuth = null; + try { + String userCredentials = CryptoUtils.decrypt(auth, msoKey); + if (userCredentials != null) { + basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + } + } catch (GeneralSecurityException e) { + logger.error("Security exception", e); + } + return basicAuth; + } + + /** + * @return + * @throws Exception + */ + public HttpHeaders getOofHttpHeaders() throws Exception { + HttpHeaders headers = new HttpHeaders(); + List<MediaType> acceptableMediaTypes = new ArrayList<>(); + acceptableMediaTypes.add(MediaType.APPLICATION_JSON); + headers.setAccept(acceptableMediaTypes); + headers.setContentType(MediaType.APPLICATION_JSON); + return headers; + } + + /** + * @param apiPath + * @return + */ + public String getOofurl(String apiPath) { + return new StringBuilder(env.getRequiredProperty(Constants.OOF_ENDPOINT)).append(apiPath).toString(); + } + + +} diff --git a/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofCallbackHandlerTest.java b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofCallbackHandlerTest.java new file mode 100644 index 0000000000..3a2f7f5e11 --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofCallbackHandlerTest.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.adapters.oof.rest; + +import static org.mockito.Mockito.when; +import java.io.File; +import java.io.IOException; +import org.junit.Before; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.so.adapters.oof.utils.OofUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; +import com.fasterxml.jackson.databind.ObjectMapper; + + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +class OofCallbackHandlerTest { + + @Autowired + TestRestTemplate restTemplate; + + @MockBean + OofUtils oofutils; + + @MockBean + RestTemplate mockrestTemplate; + + @Before + void prepareMocks() throws Exception { + ResponseEntity<Object> responseEntity = new ResponseEntity<>(HttpStatus.OK); + when(oofutils.getCamundaHeaders()).thenReturn(new HttpHeaders()); + when(oofutils.getCamundaMsgUrl(Mockito.anyString(), Mockito.anyString())).thenReturn("oofurl"); + when(mockrestTemplate.postForEntity(Mockito.anyString(), Mockito.any(), Mockito.any())) + .thenReturn(responseEntity); + } + + @Test + void processCallbackTest() throws Exception { + Object request = prepareOofResponse(); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity<Object> entity = new HttpEntity<Object>(request, headers); + ResponseEntity<String> response = restTemplate.postForEntity( + "/so/adapters/oof/callback/v1/NSISelectionResponse/d88da85c-d9e8-4f73-b837-3a72a431622a", entity, + String.class); + Assertions.assertEquals(HttpStatus.OK, response.getStatusCode()); + } + + private Object prepareOofResponse() throws IOException { + File file = new ClassPathResource("testInputs/NsiSelectionResponse.json").getFile(); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(file, Object.class); + } + +} diff --git a/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofClientTest.java b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofClientTest.java new file mode 100644 index 0000000000..ff38a9af63 --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofClientTest.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.adapters.oof.rest; + +import static org.mockito.Mockito.when; +import java.io.File; +import java.io.IOException; +import org.junit.Before; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.so.adapters.oof.model.OofRequest; +import org.onap.so.adapters.oof.utils.OofUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; +import com.fasterxml.jackson.databind.ObjectMapper; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +class OofClientTest { + + @Autowired + TestRestTemplate restTemplate; + + @MockBean + OofUtils oofutils; + + @MockBean + RestTemplate mockrestTemplate; + + @Before + void prepareMocks() throws Exception { + ResponseEntity<Object> responseEntity = new ResponseEntity<>(HttpStatus.OK); + when(oofutils.getOofHttpHeaders()).thenReturn(new HttpHeaders()); + when(oofutils.getOofurl(Mockito.anyString())).thenReturn("oofurl"); + when(mockrestTemplate.postForEntity(Mockito.anyString(), Mockito.any(), Mockito.any())) + .thenReturn(responseEntity); + } + + @Test + void callOofTest() throws Exception { + OofRequest request = prepareOofRequest(); + System.out.println(request); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity<OofRequest> entity = new HttpEntity<OofRequest>(request, headers); + ResponseEntity<String> response = restTemplate.postForEntity("/so/adapters/oof/v1", entity, String.class); + Assertions.assertEquals(HttpStatus.OK, response.getStatusCode()); + } + + private OofRequest prepareOofRequest() throws IOException { + File file = new ClassPathResource("testInputs/NsiSelectionOofRequest.json").getFile(); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(file, OofRequest.class); + } + + +} diff --git a/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/utils/OofUtilsTest.java b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/utils/OofUtilsTest.java new file mode 100644 index 0000000000..e68fa10c3e --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/utils/OofUtilsTest.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.adapters.oof.utils; + +import static org.mockito.Mockito.when; +import java.security.GeneralSecurityException; +import javax.xml.bind.DatatypeConverter; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.so.utils.CryptoUtils; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class OofUtilsTest { + + @InjectMocks + OofUtils oofUtils; + + @Mock + Environment env; + + @Test + void testGetCamundaMsgUrl() { + when(env.getRequiredProperty(Mockito.anyString())).thenReturn("dummyString"); + String camundamsgUrl = oofUtils.getCamundaMsgUrl("samplemessage", "sampleCorrelator"); + Assertions.assertNotNull(camundamsgUrl); + } + + + void testGetCamundaHeaders() throws GeneralSecurityException { + when(env.getRequiredProperty(Mockito.anyString())).thenReturn("dummyString"); + when(CryptoUtils.decrypt(Mockito.anyString(), Mockito.anyString())).thenReturn("decryptedString"); + HttpHeaders headers = oofUtils.getCamundaHeaders(); + Assertions.assertNotNull(headers); + } + + + @Test + void testGetOofHttpHeaders() throws Exception { + when(env.getRequiredProperty(Mockito.anyString())).thenReturn("dummyString"); + HttpHeaders headers = oofUtils.getOofHttpHeaders(); + Assertions.assertNotNull(headers); + } + + @Test + void testGetOofurl() { + when(env.getRequiredProperty(Mockito.anyString())).thenReturn("dummyString"); + String oofurl = oofUtils.getOofurl("/api/v1/"); + Assertions.assertNotNull(oofurl); + } + +} diff --git a/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionOofRequest.json b/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionOofRequest.json new file mode 100644 index 0000000000..569aae9f38 --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionOofRequest.json @@ -0,0 +1,84 @@ +{ + "apiPath":"/api/oof/selection/nsi/v1", + "requestDetails":{ + "serviceProfile":{ + "blob":"content" + }, + "requestInfo":{ + "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl":"myDomain.com/myCallback", + "callbackHeader":{ + "blob":"content" + }, + "sourceId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "timeout":5, + "numSolutions":1 + }, + "NSTInfo":{ + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa1", + "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-nst" + }, + "NSSTInfo":[ + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa2", + "invariantUUID":"2fa85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-an-nf" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa3", + "invariantUUID":"4fa85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-cn" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa4", + "invariantUUID":"5ta85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-fh" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa5", + "invariantUUID":"6ya85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-mh" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa7", + "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-bh" + } + ], + "preferReuse":false, + "subnetCapabilities":[ + { + "domainType":"AN-NF", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"CN", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"TN-FH", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"TN-MH", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"TN-BH", + "capabilityDetails":{ + "blob":"content" + } + } + ] +} +}
\ No newline at end of file diff --git a/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionResponse.json b/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionResponse.json new file mode 100644 index 0000000000..4ddca3eaf9 --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionResponse.json @@ -0,0 +1,20 @@ +{ + "transactionId": "s4r0f1ee-6c54-4b01-90e6-d701748f0851", + "requestId": "r500f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "completed", + "solutions": [ + { + "existingNSI": false, + "newNSISolution": { + "sliceProfiles": [ + { + "domainType":"CN" + } + ], + "matchLevel": { + "blob": "content" + } + } + } + ] +} diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index ad41b0f050..eb6cba5510 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -298,7 +298,7 @@ <dependency> <groupId>commons-validator</groupId> <artifactId>commons-validator</artifactId> - <version>1.4.0</version> + <version>1.4.1</version> </dependency> <!-- added for unit testing --> diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index ef2577d6fe..7e25ed600f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -49,6 +49,7 @@ import org.apache.commons.validator.routines.InetAddressValidator; import org.onap.aai.domain.yang.Flavor; import org.onap.aai.domain.yang.Image; import org.onap.aai.domain.yang.L3InterfaceIpv4AddressList; +import org.onap.aai.domain.yang.L3InterfaceIpv6AddressList; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; @@ -303,6 +304,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); List<String> portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE); + if (portIds == null) + return; for (String portId : portIds) { Port port = osClient.getPortById(portId); Network network = osClient.getNetworkById(port.getNetworkId()); @@ -320,7 +323,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { lIf.setInterfaceRole(port.getvNicType()); } boolean isL2Multicast = false; - if (port.getProfile().get("trusted") != null) { + if (port.getProfile() != null && port.getProfile().get("trusted") != null) { String trusted = port.getProfile().get("trusted").toString(); if (Boolean.parseBoolean(trusted)) { isL2Multicast = true; @@ -505,13 +508,14 @@ public class HeatBridgeImpl implements HeatBridgeApi { } } - private void updateLInterfaceIps(final Port port, final LInterface lIf) { + protected void updateLInterfaceIps(final Port port, final LInterface lIf) { for (IP ip : port.getFixedIps()) { String ipAddress = ip.getIpAddress(); if (InetAddressValidator.getInstance().isValidInet4Address(ipAddress)) { Subnet subnet = osClient.getSubnetById(ip.getSubnetId()); IPAddressString cidr = new IPAddressString(subnet.getCidr()); L3InterfaceIpv4AddressList lInterfaceIp = new L3InterfaceIpv4AddressList(); + lInterfaceIp.setIsFloating(false); lInterfaceIp.setL3InterfaceIpv4Address(ipAddress); lInterfaceIp.setNeutronNetworkId(port.getNetworkId()); lInterfaceIp.setNeutronSubnetId(ip.getSubnetId()); @@ -522,6 +526,21 @@ public class HeatBridgeImpl implements HeatBridgeApi { .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) .lInterface(lIf.getInterfaceName()).l3InterfaceIpv4AddressList(ipAddress)), Optional.of(lInterfaceIp)); + } else if (InetAddressValidator.getInstance().isValidInet6Address(ipAddress)) { + Subnet subnet = osClient.getSubnetById(ip.getSubnetId()); + IPAddressString cidr = new IPAddressString(subnet.getCidr()); + L3InterfaceIpv6AddressList ipv6 = new L3InterfaceIpv6AddressList(); + ipv6.setIsFloating(false); + ipv6.setL3InterfaceIpv6Address(ipAddress); + ipv6.setNeutronNetworkId(port.getNetworkId()); + ipv6.setNeutronSubnetId(ip.getSubnetId()); + ipv6.setL3InterfaceIpv6PrefixLength(Long.parseLong(cidr.getNetworkPrefixLength().toString())); + + transaction.createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).l3InterfaceIpv6AddressList(ipAddress)), + Optional.of(ipv6)); } } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index 8c21e3f7f7..18348f19d7 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -32,9 +32,12 @@ */ package org.onap.so.heatbridge; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -65,6 +68,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.L3InterfaceIpv6AddressList; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.SriovPf; @@ -73,6 +77,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.heatbridge.constants.HeatBridgeConstants; @@ -93,8 +99,11 @@ import org.openstack4j.model.network.Subnet; import org.openstack4j.openstack.heat.domain.HeatResource; import org.openstack4j.openstack.heat.domain.HeatResource.Resources; import org.springframework.core.env.Environment; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; +import inet.ipaddr.IPAddressString; @RunWith(MockitoJUnitRunner.class) @@ -423,6 +432,18 @@ public class HeatBridgeImplTest { when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); + IP ip = mock(IP.class); + + Set<IP> ipSet = new HashSet<>(); + ipSet.add(ip); + when(ip.getIpAddress()).thenReturn("2606:ae00:2e60:100::226"); + when(ip.getSubnetId()).thenReturn("testSubnetId"); + when(port.getFixedIps()).thenAnswer(x -> ipSet); + + Subnet subnet = mock(Subnet.class); + when(subnet.getCidr()).thenReturn("169.254.100.0/24"); + when(osClient.getSubnetById("testSubnetId")).thenReturn(subnet); + Network network = mock(Network.class); when(network.getId()).thenReturn("test-network-id"); when(network.getNetworkType()).thenReturn(NetworkType.VLAN); @@ -446,8 +467,9 @@ public class HeatBridgeImplTest { heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); // Assert - verify(transaction, times(15)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + verify(transaction, times(20)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); verify(osClient, times(5)).getPortById(anyString()); + verify(osClient, times(5)).getSubnetById("testSubnetId"); verify(osClient, times(10)).getNetworkById(anyString()); } @@ -516,6 +538,54 @@ public class HeatBridgeImplTest { } @Test + public void testUpdateLInterfaceIps() + throws HeatBridgeException, JsonParseException, JsonMappingException, IOException { + + Port port = mock(Port.class); + when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); + when(port.getDeviceId()).thenReturn("test-device-id"); + + IP ip = mock(IP.class); + + Set<IP> ipSet = new HashSet<>(); + ipSet.add(ip); + when(ip.getIpAddress()).thenReturn("2606:ae00:2e60:100::226"); + when(ip.getSubnetId()).thenReturn("testSubnetId"); + when(port.getFixedIps()).thenAnswer(x -> ipSet); + + Subnet subnet = mock(Subnet.class); + when(subnet.getCidr()).thenReturn("169.254.100.0/24"); + when(osClient.getSubnetById("testSubnetId")).thenReturn(subnet); + + LInterface lIf = new LInterface(); + lIf.setInterfaceName("test-port-name"); + + // Act + heatbridge.updateLInterfaceIps(port, lIf); + + L3InterfaceIpv6AddressList ipv6 = new L3InterfaceIpv6AddressList(); + ipv6.setIsFloating(false); + ipv6.setL3InterfaceIpv6Address("2606:ae00:2e60:100::226"); + ipv6.setNeutronNetworkId(port.getNetworkId()); + ipv6.setNeutronSubnetId(ip.getSubnetId()); + ipv6.setL3InterfaceIpv6PrefixLength(Long.parseLong("24")); + + ArgumentCaptor<Optional> argument = ArgumentCaptor.forClass(Optional.class); + + // Assert + verify(transaction).createIfNotExists( + eq(AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion("CloudOwner", "RegionOne") + .tenant("7320ec4a5b9d4589ba7c4412ccfd290f").vserver("test-device-id") + .lInterface("test-port-name").l3InterfaceIpv6AddressList("2606:ae00:2e60:100::226"))), + argument.capture()); + + assertTrue(argument.getValue().isPresent()); + + assertThat((L3InterfaceIpv6AddressList) argument.getValue().get(), sameBeanAs(ipv6)); + } + + @Test public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException { // Arrange List<Resource> stackResources = (List<Resource>) extractTestStackResources(); diff --git a/adapters/pom.xml b/adapters/pom.xml index 3c71b3c031..49f25b8102 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -24,6 +24,7 @@ <module>mso-openstack-adapters</module> <module>etsi-sol003-adapter</module> <module>mso-nssmf-adapter</module> + <module>mso-oof-adapter</module> <module>so-appc-orchestrator</module> </modules> 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 ad96e1be4b..44ea2a25a2 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 @@ -754,6 +754,12 @@ public class ASDCController { } // process NsstResource this.processNsstNotification(iNotif, toscaResourceStructure); + + if (iNotif.getResources().isEmpty()) { + logger.error("Service Model contains no resources."); + return; + } + for (IResourceInstance resource : iNotif.getResources()) { String resourceType = resource.getResourceType(); @@ -965,8 +971,10 @@ public class ASDCController { private void processNsstNotification(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) { Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata(); try { - if (serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY).equalsIgnoreCase("NSST")) { - + String category = serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY); + boolean isNeedInital = (category.contains("NSST") || category.equalsIgnoreCase("TN Network Requirement")) + && iNotif.getResources().isEmpty(); + if (isNeedInital) { String artifactContent = null; List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts(); Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream() @@ -980,14 +988,18 @@ public class ASDCController { artifactContent = zipParserInstance.parseJsonForZip(filePath); logger.debug( "serviceArtifact parsing success! serviceArtifactUUID: " + artifactInfo.getArtifactUUID()); + + ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance()); + resourceStructure.setResourceType(ResourceType.OTHER); + toscaInstaller.installNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure, + artifactContent); } else { logger.debug("serviceArtifact is null"); + toscaInstaller.installNsstService(toscaResourceStructure, null, null); } - ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance()); - resourceStructure.setResourceType(ResourceType.OTHER); - toscaInstaller.installTheNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure, - artifactContent); + } + } catch (IOException e) { logger.error("serviceArtifact parse failure for service uuid: " + serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index d023df3b79..49fef1d3f0 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -2870,7 +2870,15 @@ public class ToscaResourceInstaller { List<Input> serviceInputs = sdcCsarHelper.getServiceInputs(); if (!serviceInputs.isEmpty()) { serviceInputList = new ArrayList<>(); - serviceInputs.forEach(input -> { + List<Input> filterList; + filterList = serviceInputs.stream() + .filter(input -> !SKIP_POST_INST_CONF.equals(input.getName()) + && !CDS_MODEL_NAME.equalsIgnoreCase(input.getName()) + && !CDS_MODEL_VERSION.equalsIgnoreCase(input.getName()) + && !CONTROLLER_ACTOR.equalsIgnoreCase(input.getName())) + .collect(Collectors.toList()); + + filterList.forEach(input -> { Map<String, Object> serviceInputMap = new HashMap<>(); serviceInputMap.put("name", input.getName()); serviceInputMap.put("type", input.getType()); @@ -2894,7 +2902,7 @@ public class ToscaResourceInstaller { } @Transactional(rollbackFor = {ArtifactInstallerException.class}) - public void installTheNsstService(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct, + public void installNsstService(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct, String artifactContent) { createToscaCsar(toscaResourceStruct); createService(toscaResourceStruct, vfResourceStruct); @@ -2925,6 +2933,10 @@ public class ToscaResourceInstaller { } private void createServiceInfo(ToscaResourceStructure toscaResourceStruct, Service service) { + if (!service.getServiceInfos().isEmpty()) { + return; + } + List<ServiceInfo> serviceInfos = new ArrayList<>(); ServiceInfo serviceInfo = new ServiceInfo(); @@ -2945,42 +2957,67 @@ public class ToscaResourceInstaller { ISdcCsarHelper helper = toscaResourceStruct.getSdcCsarHelper(); String typeName = helper.getServiceSubstitutionMappingsTypeName(); Optional<NodeTemplate> nodeTemplate = helper.getServiceNodeTemplates().stream().findAny(); - List<Object> serviceProperties = new ArrayList<>(); - Map<String, Object> servicePropertiesMap; + if (nodeTemplate.isPresent()) { + String serviceUUID = nodeTemplate.get().getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID); LinkedHashMap<String, Object> customDef = nodeTemplate.get().getCustomDef(); - Optional<String> machKey = - customDef.keySet().stream().filter(key -> key.equalsIgnoreCase(typeName)).findFirst(); - if (machKey.isPresent()) { - Object obj = customDef.get(machKey.get()); - try { - if (obj instanceof Map) { - Object properties = ((HashMap) obj).get("properties"); - if (null != properties) { - for (Object propertyName : ((Map) properties).keySet()) { - servicePropertiesMap = new HashMap<>(); - servicePropertiesMap.put("name", propertyName); - Object object = ((Map) properties).get(propertyName); - for (Object entry : ((Map) object).entrySet()) { - servicePropertiesMap.put((String) ((Map.Entry) entry).getKey(), - ((Map.Entry) entry).getValue()); - } - servicePropertiesMap.remove("description"); - serviceProperties.add(servicePropertiesMap); + List<Object> serviceProperties = getPropertiesFromCustomDef(customDef, typeName); + + try { + propertiesJson = objectMapper.writeValueAsString(serviceProperties); + propertiesJson = propertiesJson.replace("\"", "\\\""); + } catch (JsonProcessingException e) { + logger.error("serviceProperties could not be deserialized for service uuid: " + serviceUUID); + } catch (Exception ex) { + logger.error("service properties parsing failed. service uuid:" + serviceUUID); + } + + } else { + logger.debug("ServiceNodeTemplates is null"); + } + return propertiesJson; + } + + private static List<Object> getPropertiesFromCustomDef(LinkedHashMap<String, Object> customDef, + final String typeName) { + Optional<String> machKey = + customDef.keySet().stream().filter(key -> key.equalsIgnoreCase(typeName)).findFirst(); + Map<String, Object> servicePropertiesMap; + List<Object> serviceProperties = new ArrayList<>(); + + if (machKey.isPresent()) { + Object obj = customDef.get(machKey.get()); + if (obj instanceof Map) { + Object properties = ((HashMap) obj).get("properties"); + if (null != properties) { + for (Object propertyName : ((Map) properties).keySet()) { + if (propertyName.toString().split("_").length >= 2) { + continue; + } + + servicePropertiesMap = new HashMap<>(); + servicePropertiesMap.put("name", propertyName); + Object object = ((Map) properties).get(propertyName); + for (Object entry : ((Map) object).entrySet()) { + servicePropertiesMap.put((String) ((Map.Entry) entry).getKey(), + ((Map.Entry) entry).getValue()); + } + + String type = servicePropertiesMap.get("type").toString(); + if (type.split("\\.").length >= 2) { + List<Object> subProperties = getPropertiesFromCustomDef(customDef, type); + if (subProperties.size() > 0) { + serviceProperties.addAll(subProperties); } - propertiesJson = objectMapper.writeValueAsString(serviceProperties); - propertiesJson = propertiesJson.replace("\"", "\\\""); + continue; } + servicePropertiesMap.remove("description"); + serviceProperties.add(servicePropertiesMap); } - } catch (JsonProcessingException e) { - logger.error("serviceProperties could not be deserialized for service uuid: " - + nodeTemplate.get().getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); } } - } else { - logger.debug("ServiceNodeTemplates is null"); } - return propertiesJson; + return serviceProperties; } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy new file mode 100644 index 0000000000..644cf5e387 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.common.scripts + +import javax.ws.rs.core.Response + +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.oof.adapter.beans.payload.OofRequest +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import com.fasterxml.jackson.databind.ObjectMapper + + +import static org.onap.so.bpmn.common.scripts.GenericUtils.* + + +class DoHandleOofRequest extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger(DoHandleOofRequest.class) + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug("In Preprocess Oof Request Handler") + String apiPath = execution.getVariable("apiPath") + if (isBlank(apiPath)) { + String msg = "Cannot process OOF adapter call : API PATH is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + //msoRequestId is used for correlation + String requestId = execution.getVariable("correlator") + if (isBlank(requestId)) { + String msg = "Cannot process OOF adapter call : correlator is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String messageType = execution.getVariable("messageType") + if (isBlank(messageType)) { + String msg = "Cannot process OOF adapter call : messageType is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String timeout = execution.getVariable("timeout") + if (isBlank(timeout)) { + timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + if (isBlank(timeout)) { + logger.debug("Setting OOF timeout to default : PT30M") + timeout = "PT30M" + } + } + + Object requestDetails = execution.getVariable("oofRequest") + OofRequest oofRequestPayload = new OofRequest() + oofRequestPayload.setApiPath(apiPath) + oofRequestPayload.setRequestDetails(requestDetails) + ObjectMapper objectMapper = new ObjectMapper() + String requestJson = objectMapper.writeValueAsString(oofRequestPayload) + execution.setVariable("oofRequestPayload", requestJson) + } + + public void callOofAdapter(DelegateExecution execution) { + logger.debug("Start callOofAdapter") + String requestId = execution.getVariable("msoRequestId") + String oofAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.oof.endpoint", execution) + String basicAuthCred = execution.getVariable("BasicAuthHeaderValue") + URL requestUrl = new URL(oofAdapterEndpoint) + String oofRequest = execution.getVariable("oofRequestPayload") + logger.debug("oofRequest : " + oofRequest) + HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.EXTERNAL) + Response httpResponse = httpClient.post(oofRequest) + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + if(responseCode != 200){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 69dfacd9bc..040fc26f23 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -22,42 +22,29 @@ package org.onap.so.bpmn.common.scripts -import com.fasterxml.jackson.databind.ObjectMapper +import static org.onap.so.bpmn.common.scripts.GenericUtils.* + +import javax.ws.rs.core.UriBuilder + import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.util.OofInfraUtils import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.AllottedResource import org.onap.so.bpmn.core.domain.HomingSolution import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.Resource -import org.onap.so.bpmn.core.domain.AllottedResource import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceInstance import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient -import org.onap.so.client.HttpClientFactory import org.onap.so.db.catalog.beans.CloudSite import org.onap.so.db.catalog.beans.HomingInstance -import org.onap.logging.filter.base.ONAPComponents; -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.web.util.UriComponentsBuilder import org.slf4j.Logger import org.slf4j.LoggerFactory +import com.google.gson.JsonObject -import javax.ws.rs.core.MediaType -import javax.ws.rs.core.Response -import javax.ws.rs.core.UriBuilder - -import static org.onap.so.bpmn.common.scripts.GenericUtils.* +import com.fasterxml.jackson.databind.ObjectMapper class OofUtils { private static final Logger logger = LoggerFactory.getLogger( OofUtils.class); @@ -530,10 +517,11 @@ class OofUtils { return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString() } - public String buildSelectNSTRequest(String requestId, Map<String, Object> profileInfo) { + public String buildSelectNSTRequest(String requestId,String messageType, Map<String, Object> profileInfo) { def transactionId = requestId logger.debug( "transactionId is: " + transactionId) - String callbackUrl = "http://0.0.0.0:9000/callback/" + String correlator = requestId + String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator ObjectMapper objectMapper = new ObjectMapper() String json = objectMapper.writeValueAsString(profileInfo) StringBuilder response = new StringBuilder() @@ -554,11 +542,12 @@ class OofUtils { return response.toString() } - public String buildSelectNSIRequest(String requestId, String nstInfo, Map<String, Object> profileInfo){ + public String buildSelectNSIRequest(String requestId, String nstInfo,String messageType, Map<String, Object> profileInfo){ def transactionId = requestId logger.debug( "transactionId is: " + transactionId) - String callbackUrl = "http://0.0.0.0:9000/callback/" + String correlator = requestId + String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator ObjectMapper objectMapper = new ObjectMapper(); String json = objectMapper.writeValueAsString(profileInfo); StringBuilder response = new StringBuilder(); @@ -583,5 +572,82 @@ class OofUtils { response.append("\n }\n") return response.toString() } - +/** +* Method to create select NSSI request +* @param requestId - mso-request-id +* @param messageType - Message type for callback correlation +* @param UUID - UUID of NSST +* @param invariantUUID - Invariant UUID of NSST +* @param name - name of the NSST model +* @param profileInfo - A JSON object containing slice profile parameters +* @return +*/ +public String buildSelectNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID, +String name, Map<String, Object> profileInfo){ + +def transactionId = requestId +logger.debug( "transactionId is: " + transactionId) +String correlator = requestId +String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator +ObjectMapper objectMapper = new ObjectMapper(); +String profileJson = objectMapper.writeValueAsString(profileInfo); + +//Prepare requestInfo object +JsonObject requestInfo = new JsonObject() +requestInfo.addProperty("transactionId", transactionId) +requestInfo.addProperty("requestId", requestId) +requestInfo.addProperty("callbackUrl", callbackUrl) +requestInfo.addProperty("sourceId","SO" ) +requestInfo.addProperty("timeout", 600) +requestInfo.addProperty("numSolutions", 1) + +//Prepare serviceInfo object +JsonObject nsstInfo = new JsonObject() +nsstInfo.addProperty("UUID", UUID) +nsstInfo.addProperty("invariantUUID", invariantUUID) +nsstInfo.addProperty("name", name) + +JsonObject json = new JsonObject() +json.add("requestInfo", requestInfo) +json.add("NSSTInfo", nsstInfo) +json.addProperty("sliceProfile", profileJson) +return json.toString() +} +/** +* Method to create NSI/NSSI termination request +* (OOF response will be synchronous in G-Release) +* @param requestId - mso-request-id +* @param nxlId - NSI/NSSI Id to be terminated +* @param messageType - Message type for callback correlation +* @param serviceInstanceId - NSI/NSSI Id related to nxlId +* @return +*/ +public String buildTerminateNxiRequest(String requestId,String nxlId, String nxlType, String messageType, String serviceInstanceId) { +def transactionId = requestId +logger.debug( "transactionId is: " + transactionId) +String correlator = requestId +String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator +//Prepare Terminate Nxl Json +JsonObject json = new JsonObject() +json.addProperty("type", nxlType) +json.addProperty("NxIId", nxlId) + +//Prepare requestInfo object +JsonObject requestInfo = new JsonObject() +requestInfo.addProperty("transactionId", transactionId) +requestInfo.addProperty("requestId", requestId) +requestInfo.addProperty("callbackUrl", callbackUrl) +requestInfo.addProperty("sourceId","SO" ) +requestInfo.addProperty("timeout", 600) + +//Prepare addtnlArgs object +JsonObject addtnlArgs = new JsonObject() +addtnlArgs.addProperty("serviceInstanceId", serviceInstanceId) + +requestInfo.add("addtnlArgs", addtnlArgs) +json.add("requestInfo", requestInfo) + +return json.toString() + +} } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy index b35042e3c0..23dfdce753 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils @@ -116,4 +117,100 @@ class RequestDBUtil { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } } + + /** + * init resource operation status in requestDB + * @param execution + * @param resourceoperationStatus + */ + void prepareInitResourceOperationStatus(DelegateExecution execution, final ResourceOperationStatus resourceoperationStatus){ + logger.debug("start prepareinitResourceOperationStatus") + try{ + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution) + execution.setVariable("dbAdapterEndpoint", dbAdapterEndpoint) + logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String serviceId = resourceoperationStatus.getServiceId() + serviceId = UriUtils.encode(serviceId,"UTF-8") + String operationId = resourceoperationStatus.getOperationId() + String resourceTemplateUUID = resourceoperationStatus.getResourceTemplateUUID() + String operType = resourceoperationStatus.getOperType() + + String payload = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:initResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> + <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> + <operationType>${MsoUtils.xmlEscape(operType)}</operationType> + <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs> + </ns:initResourceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + execution.setVariable("initResourceOperationStatus", payload) + + }catch(any){ + String exceptionMessage = "Prepare init ResourceOperationStatus failed. cause - " + any.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + logger.trace("finished init ResourceOperationStatus") + } + + /** + * update resource operation status in requestDB + * @param execution + * @param resourceoperationStatus + */ + void prepareUpdateResourceOperationStatus(DelegateExecution execution, final ResourceOperationStatus resourceoperationStatus){ + logger.debug("start prepareUpdateResourceOperationStatus") + try{ + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution) + execution.setVariable("dbAdapterEndpoint", dbAdapterEndpoint) + logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String serviceId = resourceoperationStatus.getServiceId() + serviceId = UriUtils.encode(serviceId,"UTF-8") + String operationId = resourceoperationStatus.getOperationId() + String resourceTemplateUUID = resourceoperationStatus.getResourceTemplateUUID() + String operType = resourceoperationStatus.getOperType() + String resourceInstanceID = resourceoperationStatus.getResourceInstanceID() + String jobId = resourceoperationStatus.getJobId() + String status = resourceoperationStatus.getStatus() + String progress = resourceoperationStatus.getProgress() + String errorCode = resourceoperationStatus.getErrorCode()?: "" + String statusDescription = resourceoperationStatus.getStatusDescription()?: "" + + String payload = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:updateResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> + <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> + <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs> + <operationType>${MsoUtils.xmlEscape(operType)}</operationType> + <jobId>${MsoUtils.xmlEscape(jobId)}</jobId> + <status>${MsoUtils.xmlEscape(status)}</status> + <progress>${MsoUtils.xmlEscape(progress)}</progress> + <errorCode>${MsoUtils.xmlEscape(errorCode)}</errorCode> + <statusDescription>${MsoUtils.xmlEscape(statusDescription)}</statusDescription> + </ns:updateResourceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + execution.setVariable("updateResourceOperationStatus", payload) + + }catch(any){ + String exceptionMessage = "Prepare update ResourceOperationStatus failed. cause - " + any.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + logger.trace("finished update ResourceOperationStatus") + } + } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy index 08c032fba3..146889351a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy @@ -64,208 +64,211 @@ import org.slf4j.LoggerFactory class SniroHomingV1 extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger( SniroHomingV1.class); - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - SniroUtils sniroUtils = new SniroUtils(this) - - /** - * This method validates the incoming variables. - * The method then prepares the sniro request - * and posts it to sniro's rest api. - * - * @param execution - * - * @author cb645j - */ - public void callSniro(DelegateExecution execution){ - execution.setVariable("prefix","HOME_") - logger.trace("Started Sniro Homing Call Sniro ") - try{ - execution.setVariable("rollbackData", null) - execution.setVariable("rolledBack", false) - - String requestId = execution.getVariable("msoRequestId") - logger.debug("Incoming Request Id is: " + requestId) - String serviceInstanceId = execution.getVariable("serviceInstanceId") - logger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - logger.debug("Incoming Service Decomposition is: " + serviceDecomposition) - String subscriberInfo = execution.getVariable("subscriberInfo") - logger.debug("Incoming Subscriber Information is: " + subscriberInfo) - - if(isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)){ - exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null") - }else{ - String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId") - String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName") - String subCommonSiteId = "" - if(jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")){ - subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId") - } - Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId) - - String cloudConfiguration = execution.getVariable("cloudConfiguration") // TODO Currently not being used - String homingParameters = execution.getVariable("homingParameters") // (aka. request parameters) Should be json format. TODO confirm its json format - - //Authentication - String authHeader = UrnPropertiesReader.getVariable("sniro.manager.headers.auth", execution) - execution.setVariable("BasicAuthHeaderValue", authHeader) - - //Prepare Callback - String timeout = execution.getVariable("timeout") - if(isBlank(timeout)){ - timeout = UrnPropertiesReader.getVariable("sniro.manager.timeout", execution) - if(isBlank(timeout)) { - timeout = "PT30M"; - } - } - logger.debug("Async Callback Timeout will be: " + timeout) - - execution.setVariable("timeout", timeout); - execution.setVariable("correlator", requestId); - execution.setVariable("messageType", "SNIROResponse"); - - //Build Request & Call Sniro - String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters) - execution.setVariable("sniroRequest", sniroRequest) - logger.debug("SNIRO Request is: " + sniroRequest) - - String endpoint = UrnPropertiesReader.getVariable("sniro.manager.uri.v1", execution) - String host = UrnPropertiesReader.getVariable("sniro.manager.host", execution) - String urlString = host + endpoint - logger.debug("Sniro Url is: " + urlString) - - URL url = new URL(urlString); - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SNIRO) - httpClient.addAdditionalHeader("Authorization", authHeader) - Response httpResponse = httpClient.post(sniroRequest) - - int responseCode = httpResponse.getStatus() - - logger.debug("Sniro sync response code is: " + responseCode) - if(httpResponse.hasEntity()){ - logger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class)) - } - - if(responseCode != 202){ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.") - } - - logger.trace("Completed Sniro Homing Call Sniro") - } - }catch(BpmnError b){ - throw b - }catch(Exception e){ - logger.debug("Error encountered within Homing CallSniro method: " + e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage()) - } - } - - /** - * This method processes the callback response - * and the contained homing solution. It sets - * homing solution assignment and license - * information to the corresponding resources - * - * @param execution - * - * @author cb645j - */ - public void processHomingSolution(DelegateExecution execution){ - logger.trace("Started Sniro Homing Process Homing Solution") - try{ - String response = execution.getVariable("asyncCallbackResponse") - logger.debug("Sniro Async Callback Response is: " + response) - - sniroUtils.validateCallbackResponse(execution, response) - - ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition") - List<Resource> resourceList = decomposition.getServiceResources() - - if(JsonUtils.jsonElementExist(response, "solutionInfo.placementInfo")){ - String placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo") - JSONArray arr = new JSONArray(placements) - for(int i = 0; i < arr.length(); i++){ - JSONObject placement = arr.getJSONObject(i) - String jsonServiceResourceId = placement.getString("serviceResourceId") - for(Resource resource:resourceList){ - String serviceResourceId = resource.getResourceId() - if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){ - //match - String inventoryType = placement.getString("inventoryType") - resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType)) - resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId")) - resource.getHomingSolution().setRehome(placement.getBoolean("isRehome")) - JSONArray assignmentArr = placement.getJSONArray("assignmentInfo") - Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue") - resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner")) - resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli")) - resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion")) - if(inventoryType.equalsIgnoreCase("service")){ - VnfResource vnf = new VnfResource() - vnf.setVnfHostname(assignmentMap.get("vnfHostName")) - resource.getHomingSolution().setVnf(vnf) - resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId")) - } - } - } - } - } - - if(JsonUtils.jsonElementExist(response, "solutionInfo.licenseInfo")){ - String licenseInfo = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo") - JSONArray licenseArr = new JSONArray(licenseInfo) - for(int l = 0; l < licenseArr.length(); l++){ - JSONObject license = licenseArr.getJSONObject(l) - String jsonServiceResourceId = license.getString("serviceResourceId") - for(Resource resource:resourceList){ - String serviceResourceId = resource.getResourceId() - if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){ - //match - String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList") - List<String> entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList) - resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList) - - String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList") - List<String> licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList) - resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList) - } - } - } - } - execution.setVariable("serviceDecomposition", decomposition) - - logger.trace("Completed Sniro Homing Process Homing Solution") - }catch(BpmnError b){ - throw b - }catch(Exception e){ - logger.debug("Error encountered within Homing ProcessHomingSolution method: " + e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Sniro Homing Process Solution") - } - } - - /** - * This method logs the start of DHVCreateService - * to make debugging easier. - * - * @param - execution - * @author cb645j - */ - public String logStart(DelegateExecution execution){ - String requestId = execution.getVariable("testReqId") - if(isBlank(requestId)){ - requestId = execution.getVariable("msoRequestId") - } - execution.setVariable("DHVCS_requestId", requestId) - logger.trace("STARTED Homing Subflow for request: " + requestId + " ") - logger.debug("****** Homing Subflow Global Debug Enabled: " + execution.getVariable("isDebugLogEnabled") + " *****") - logger.trace("STARTED Homing Subflow for request: " + requestId + " ") - } - - - /** - * Auto-generated method stub - */ - public void preProcessRequest(DelegateExecution execution){} + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + SniroUtils sniroUtils = new SniroUtils(this) + + /** + * This method validates the incoming variables. + * The method then prepares the sniro request + * and posts it to sniro's rest api. + * + * @param execution + * + * @author cb645j + */ + public void callSniro(DelegateExecution execution){ + execution.setVariable("prefix","HOME_") + logger.trace("Started Sniro Homing Call Sniro ") + try{ + execution.setVariable("rollbackData", null) + execution.setVariable("rolledBack", false) + + String requestId = execution.getVariable("msoRequestId") + logger.debug("Incoming Request Id is: " + requestId) + String serviceInstanceId = execution.getVariable("serviceInstanceId") + logger.debug("Incoming Service Instance Id is: " + serviceInstanceId) + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + logger.debug("Incoming Service Decomposition is: " + serviceDecomposition) + String subscriberInfo = execution.getVariable("subscriberInfo") + logger.debug("Incoming Subscriber Information is: " + subscriberInfo) + + if(isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)){ + exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null") + }else{ + String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId") + String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName") + String subCommonSiteId = "" + if(jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")){ + subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId") + } + Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId) + + String cloudConfiguration = execution.getVariable("cloudConfiguration") // TODO Currently not being used + String homingParameters = execution.getVariable("homingParameters") // (aka. request parameters) Should be json format. TODO confirm its json format + + //Authentication + String authHeader = UrnPropertiesReader.getVariable("sniro.manager.headers.auth", execution) + execution.setVariable("BasicAuthHeaderValue", authHeader) + + //Prepare Callback + String timeout = execution.getVariable("timeout") + if(isBlank(timeout)){ + timeout = UrnPropertiesReader.getVariable("sniro.manager.timeout", execution) + if(isBlank(timeout)) { + timeout = "PT30M"; + } + } + logger.debug("Async Callback Timeout will be: " + timeout) + + execution.setVariable("timeout", timeout); + execution.setVariable("correlator", requestId); + execution.setVariable("messageType", "SNIROResponse"); + + //Build Request & Call Sniro + String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters) + execution.setVariable("sniroRequest", sniroRequest) + logger.debug("SNIRO Request is: " + sniroRequest) + + String endpoint = UrnPropertiesReader.getVariable("sniro.manager.uri.v1", execution) + String host = UrnPropertiesReader.getVariable("sniro.manager.host", execution) + String urlString = host + endpoint + logger.debug("Sniro Url is: " + urlString) + + URL url = new URL(urlString); + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SNIRO) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(sniroRequest) + + int responseCode = httpResponse.getStatus() + + logger.debug("Sniro sync response code is: " + responseCode) + if(httpResponse.hasEntity()){ + logger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class)) + } + + if(responseCode != 202){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.") + } + + logger.trace("Completed Sniro Homing Call Sniro") + } + }catch(BpmnError b){ + throw b + }catch(Exception e){ + logger.debug("Error encountered within Homing CallSniro method: " + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage()) + } + } + + /** + * This method processes the callback response + * and the contained homing solution. It sets + * homing solution assignment and license + * information to the corresponding resources + * + * @param execution + * + * @author cb645j + */ + public void processHomingSolution(DelegateExecution execution){ + logger.trace("Started Sniro Homing Process Homing Solution") + try{ + String response = execution.getVariable("asyncCallbackResponse") + logger.debug("Sniro Async Callback Response is: " + response) + + sniroUtils.validateCallbackResponse(execution, response) + + ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition") + List<Resource> resourceList = decomposition.getServiceResources() + + if(JsonUtils.jsonElementExist(response, "solutionInfo.placementInfo")){ + String placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo") + JSONArray arr = new JSONArray(placements) + for(int i = 0; i < arr.length(); i++){ + JSONObject placement = arr.getJSONObject(i) + String jsonServiceResourceId = placement.getString("serviceResourceId") + for(Resource resource:resourceList){ + String serviceResourceId = resource.getResourceId() + if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){ + //match + String inventoryType = placement.getString("inventoryType") + resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType)) + resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId")) + resource.getHomingSolution().setRehome(placement.getBoolean("isRehome")) + JSONArray assignmentArr = placement.getJSONArray("assignmentInfo") + Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue") + resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner")) + resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli")) + resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion")) + if(inventoryType.equalsIgnoreCase("service")){ + VnfResource vnf = new VnfResource() + vnf.setVnfHostname(assignmentMap.get("vnfHostName")) + resource.getHomingSolution().setVnf(vnf) + resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId")) + } + if(placement.getBoolean("isRehome")) { + resource.getHomingSolution().setAllottedResourceId(assignmentMap.get("serviceResourceId")) + } + } + } + } + } + + if(JsonUtils.jsonElementExist(response, "solutionInfo.licenseInfo")){ + String licenseInfo = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo") + JSONArray licenseArr = new JSONArray(licenseInfo) + for(int l = 0; l < licenseArr.length(); l++){ + JSONObject license = licenseArr.getJSONObject(l) + String jsonServiceResourceId = license.getString("serviceResourceId") + for(Resource resource:resourceList){ + String serviceResourceId = resource.getResourceId() + if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){ + //match + String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList") + List<String> entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList) + resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList) + + String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList") + List<String> licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList) + resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList) + } + } + } + } + execution.setVariable("serviceDecomposition", decomposition) + + logger.trace("Completed Sniro Homing Process Homing Solution") + }catch(BpmnError b){ + throw b + }catch(Exception e){ + logger.debug("Error encountered within Homing ProcessHomingSolution method: " + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Sniro Homing Process Solution") + } + } + + /** + * This method logs the start of DHVCreateService + * to make debugging easier. + * + * @param - execution + * @author cb645j + */ + public String logStart(DelegateExecution execution){ + String requestId = execution.getVariable("testReqId") + if(isBlank(requestId)){ + requestId = execution.getVariable("msoRequestId") + } + execution.setVariable("DHVCS_requestId", requestId) + logger.trace("STARTED Homing Subflow for request: " + requestId + " ") + logger.debug("****** Homing Subflow Global Debug Enabled: " + execution.getVariable("isDebugLogEnabled") + " *****") + logger.trace("STARTED Homing Subflow for request: " + requestId + " ") + } + + + /** + * Auto-generated method stub + */ + public void preProcessRequest(DelegateExecution execution){} } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java index 0193469d93..12abec0b77 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java @@ -57,6 +57,16 @@ public class RequestContext implements Serializable { private List<Map<String, String>> configurationParameters = new ArrayList<>(); @JsonProperty("application-id") private String applicationId; + @JsonProperty("is-helm") + private Boolean isHelm; + + public Boolean getIsHelm() { + return isHelm; + } + + public void setIsHelm(Boolean isHelm) { + this.isHelm = isHelm; + } public String getServiceURI() { return serviceURI; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 009686d0fc..5a8244266b 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -193,6 +193,12 @@ public class BBInputSetup implements JavaDelegate { execution.setVariable(GBB_INPUT_VAR_NAME, outputBB); execution.setVariable(LOOKUP_KEY_MAP_VAR_NAME, lookupKeyMap); + if (outputBB.getRequestContext().getIsHelm()) { + execution.setVariable("isHelm", true); + } else { + execution.setVariable("isHelm", false); + } + BuildingBlockExecution gBuildingBlockExecution = new DelegateExecutionImpl(execution); execution.setVariable("gBuildingBlockExecution", gBuildingBlockExecution); execution.setVariable("RetryCount", 1); @@ -431,7 +437,8 @@ public class BBInputSetup implements JavaDelegate { protected void mapCatalogInstanceGroup(InstanceGroup instanceGroup, ModelInfo modelInfo, Service service) { // @TODO: this will populate the instanceGroup model info. - // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter to support VNF Groups + // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter + // to support VNF Groups } protected void populateConfiguration(BBInputSetupParameter parameter) { @@ -613,6 +620,10 @@ public class BBInputSetup implements JavaDelegate { parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID); } } + if (vfModule.getModelInfoVfModule() != null && vfModule.getModelInfoVfModule().getModelName() != null + && vfModule.getModelInfoVfModule().getModelName().contains("helm")) { + parameter.setIsHelm(true); + } } else { logger.debug("Related VNF instance Id not found: {}", parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID)); @@ -1018,7 +1029,6 @@ public class BBInputSetup implements JavaDelegate { if (requestDetails.getOwningEntity() != null) owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity()); - Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); if (service == null) { @@ -1094,6 +1104,7 @@ public class BBInputSetup implements JavaDelegate { RequestContext requestContext = mapperLayer.mapRequestContext(parameter.getRequestDetails()); requestContext.setAction(parameter.getRequestAction()); requestContext.setMsoRequestId(parameter.getExecuteBB().getRequestId()); + requestContext.setIsHelm(parameter.getIsHelm()); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(parameter.getRequestDetails().getCloudConfiguration()); CloudRegion cloudRegion = @@ -1852,8 +1863,9 @@ public class BBInputSetup implements JavaDelegate { } private void mapRelationship(ServiceInstance serviceInstance, Relationships relationships) { - this.mapProject(relationships.getByType(AAIObjectType.PROJECT), serviceInstance); - this.mapOwningEntity(relationships.getByType(AAIObjectType.OWNING_ENTITY), serviceInstance); + this.mapProject(relationships.getByType(AAIObjectType.PROJECT, uri -> uri.nodesOnly(true)), serviceInstance); + this.mapOwningEntity(relationships.getByType(AAIObjectType.OWNING_ENTITY, uri -> uri.nodesOnly(true)), + serviceInstance); this.mapL3Networks(relationships.getRelatedAAIUris(AAIObjectType.L3_NETWORK), serviceInstance.getNetworks()); this.mapGenericVnfs(relationships.getRelatedAAIUris(AAIObjectType.GENERIC_VNF), serviceInstance.getVnfs()); this.mapPnfs(relationships.getRelatedAAIUris(AAIObjectType.PNF), serviceInstance.getPnfs()); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupParameter.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupParameter.java index 36ac0969ee..1290f2aeef 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupParameter.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupParameter.java @@ -45,6 +45,7 @@ public class BBInputSetupParameter { private String applicationId; private boolean isReplace; private ServiceModel serviceModel; + private boolean isHelm; private BBInputSetupParameter(Builder builder) { this.cloudConfiguration = builder.cloudConfiguration; @@ -74,6 +75,7 @@ public class BBInputSetupParameter { this.applicationId = builder.applicationId; this.isReplace = builder.isReplace; this.serviceModel = builder.serviceModel; + this.isHelm = builder.isHelm; } @@ -331,6 +333,15 @@ public class BBInputSetupParameter { this.serviceModel = serviceModel; } + protected boolean getIsHelm() { + return isHelm; + } + + + protected void setIsHelm(boolean isHelm) { + this.isHelm = isHelm; + } + public static class Builder { private CloudConfiguration cloudConfiguration; private ConfigurationResourceKeys configurationResourceKeys; @@ -359,6 +370,7 @@ public class BBInputSetupParameter { private String applicationId; private boolean isReplace; private ServiceModel serviceModel; + private boolean isHelm; public Builder setCloudConfiguration(CloudConfiguration cloudConfiguration) { this.cloudConfiguration = cloudConfiguration; @@ -495,6 +507,15 @@ public class BBInputSetupParameter { return this; } + protected boolean getIsHelm() { + return isHelm; + } + + + protected void setIsHelm(boolean isHelm) { + this.isHelm = isHelm; + } + public BBInputSetupParameter build() { return new BBInputSetupParameter(this); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java new file mode 100644 index 0000000000..0f35b38f72 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.client.dmaapproperties; + +import java.io.IOException; +import java.util.Optional; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.dmaap.DmaapPublisher; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +@Component +@Scope("prototype") +public class SdnrDmaapPublisher extends DmaapPublisher { + + + public SdnrDmaapPublisher() throws IOException { + super(); + } + + @Override + public String getAuth() { + + return UrnPropertiesReader.getVariable("mso.global.dmaap.auth"); + } + + @Override + public String getKey() { + + return UrnPropertiesReader.getVariable("mso.msoKey"); + } + + @Override + public String getTopic() { + return UrnPropertiesReader.getVariable("sdnc.dmaap.publisher.topic"); + } + + @Override + public Optional<String> getHost() { + return Optional.ofNullable(UrnPropertiesReader.getVariable("sdnc.dmaap.host")); + } +} + + diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/oof/adapter/beans/payload/OofRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/oof/adapter/beans/payload/OofRequest.java new file mode 100644 index 0000000000..9d81332ed7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/oof/adapter/beans/payload/OofRequest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.client.oof.adapter.beans.payload; + +public class OofRequest { + + private String apiPath; + + private Object requestDetails; + + public String getApiPath() { + return apiPath; + } + + public void setApiPath(String apiPath) { + this.apiPath = apiPath; + } + + public Object getRequestDetails() { + return requestDetails; + } + + public void setRequestDetails(Object requestDetails) { + this.requestDetails = requestDetails; + } + + @Override + public String toString() { + return "OofRequest [apiPath=" + apiPath + ", requestDetails=" + requestDetails + "]"; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java new file mode 100644 index 0000000000..d9656f7ea2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.client.sdnc.common; + +import static org.onap.so.bpmn.common.scripts.GenericUtils.isBlank; +import javax.inject.Provider; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.dmaapproperties.SdnrDmaapPublisher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component("SendRequestToSdnr") +public class SendRequestToSdnr implements JavaDelegate { + private static final Logger logger = LoggerFactory.getLogger(SendRequestToSdnr.class); + ExceptionUtil exceptionUtil = new ExceptionUtil(); + + @Autowired + private Provider<SdnrDmaapPublisher> sdnrDmaapPublisher; + + @Override + public void execute(DelegateExecution execution) throws Exception { + + logger.debug("SendRequestToSdnr_start"); + + String requestId = (String) execution.getVariable("correlator"); + if (isBlank(requestId)) { + String msg = "Cannot process SDNR Request : correlator is null"; + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg); + } + + String messageType = (String) execution.getVariable("messageType"); + if (isBlank(messageType)) { + String msg = "Cannot process SDNR Request : messageType is null"; + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg); + } + + String timeout = (String) execution.getVariable("timeout"); + if (isBlank(timeout)) { + timeout = UrnPropertiesReader.getVariable("sdnc.dmaap.callback.timeout", execution); + if (isBlank(timeout)) { + logger.debug("Setting SDNR timeout to default : PT30M"); + timeout = "PT30M"; + } + } + logger.debug("Async Callback Timeout will be: " + timeout); + String msg = (String) execution.getVariable("sdnrRequest"); + logger.debug("msg to be sent on dmaap " + msg); + sdnrDmaapPublisher.get().send(msg); + + } +} + + diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json index fe33308d78..7662b995e4 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json @@ -8,7 +8,8 @@ "userParams": [], "aLaCarte": true }, - "configurationParameters": [] + "configurationParameters": [], + "is-helm": false }, "orchContext": { "is-rollback-enabled": false diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json index b18cad0620..2f26913ffc 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json @@ -33,7 +33,8 @@ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" } - ] + ], + "is-helm": false }, "orchContext": { "is-rollback-enabled": false diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json index f07f060b06..0137d42009 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json @@ -43,7 +43,8 @@ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" } - ] + ], + "is-helm": false }, "orchContext": { "is-rollback-enabled": false diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json index f55717fc91..d8294c0a17 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json @@ -14,7 +14,8 @@ "requestParameters": { }, - "configurationParameters": [] + "configurationParameters": [], + "is-helm": false }, "orchContext": { "is-rollback-enabled": true diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json index ca2b76e4bf..e7fa4debeb 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json @@ -33,7 +33,8 @@ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" } - ] + ], + "is-helm": false }, "orchContext": { "is-rollback-enabled": false diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json index 9b32a4c446..8e4e3632e9 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json @@ -72,7 +72,7 @@ "aggregateRoutes": { "aggregateRoute": [ { - "routeId": "routeId", + "aggRouteId": "routeId", "networkStartAddress": "10.80.12.0", "cidrMask": "23", "ipVersion": "4" diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java index 309b053589..ddfb29e97e 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java @@ -37,6 +37,7 @@ public class HomingSolution extends JsonWrapper implements Serializable { private InventoryType inventoryType; private boolean isRehome; private String serviceInstanceId; // TODO should start using si object instead + private String allottedResourceId; private String cloudOwner; private String cloudRegionId; private String aicClli; @@ -74,6 +75,14 @@ public class HomingSolution extends JsonWrapper implements Serializable { this.serviceInstanceId = serviceInstanceId; } + public String getAllottedResourceId() { + return allottedResourceId; + } + + public void setAllottedResourceId(String allottedResourceId) { + this.allottedResourceId = allottedResourceId; + } + public String getCloudOwner() { return cloudOwner; } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java deleted file mode 100644 index 58d0c6d374..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.onap.so.bpmn.common.workflow.service; - -import java.util.ArrayList; -import java.util.List; -import org.camunda.bpm.engine.ProcessEngine; -import org.camunda.bpm.engine.RepositoryService; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.migration.MigrationInstruction; -import org.camunda.bpm.engine.migration.MigrationPlan; -import org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder; -import org.camunda.bpm.engine.repository.ProcessDefinition; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.event.EventListener; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -@Service -public class AutoProcessInstanceMigrationService { - - private static Logger logger = LoggerFactory.getLogger(AutoProcessInstanceMigrationService.class); - - @Autowired - private Environment env; - @Autowired - protected ProcessEngine processEngine; - - @Value("${migration.autoMigrationEnabled:false}") - private boolean autoMigrationEnabled; - - private RuntimeService runtimeService; - private RepositoryService repositoryService; - private List<String> processDefinitionKeys; - - @EventListener(ApplicationReadyEvent.class) - protected void executeAutoProcessInstanceMigrations() { - if (autoMigrationEnabled) { - runtimeService = processEngine.getRuntimeService(); - repositoryService = processEngine.getRepositoryService(); - for (ProcessDefinition definition : getProcessDefinitions()) { - for (ProcessDefinition procDefOld : getOldProcessDefinitions(definition.getKey(), - definition.getVersion())) { - migrate(procDefOld.getId(), definition.getId()); - } - } - } - } - - protected List<ProcessDefinition> getProcessDefinitions() { - - List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>(); - processDefinitionKeys = env.getProperty("migration.processDefinitionKeys", List.class, new ArrayList<String>()); - for (String key : processDefinitionKeys) { - processDefinitions.add(repositoryService.createProcessDefinitionQuery().processDefinitionKey(key) - .latestVersion().singleResult()); - } - return processDefinitions; - } - - private void migrate(String sourceProcessDefinitionId, String targetProcessDefinitionId) { - MigrationPlan migrationPlan = - runtimeService.createMigrationPlan(sourceProcessDefinitionId, targetProcessDefinitionId) - .mapEqualActivities().updateEventTriggers().build(); - List<String> activityIds = new ArrayList<>(); - - for (MigrationInstruction instruction : migrationPlan.getInstructions()) { - activityIds.add(instruction.getSourceActivityId()); - } - for (String activityId : activityIds) { - ProcessInstanceQuery activeProcessInstancesQuery = runtimeService.createProcessInstanceQuery() - .processDefinitionId(sourceProcessDefinitionId).activityIdIn(activityId).active(); - if (!activeProcessInstancesQuery.list().isEmpty()) { - logger.info("Migrating {} process instance(s) from {} to {}", - Long.valueOf(activeProcessInstancesQuery.count()), sourceProcessDefinitionId, - targetProcessDefinitionId); - MigrationPlanExecutionBuilder migration = - runtimeService.newMigration(migrationPlan).processInstanceQuery(activeProcessInstancesQuery); - migration.executeAsync(); - } - } - suspendEmptyProcessDefinition(sourceProcessDefinitionId); - } - - private void suspendEmptyProcessDefinition(String sourceProcessDefinitionId) { - List<ProcessInstance> activeProcessInstances = runtimeService.createProcessInstanceQuery() - .processDefinitionId(sourceProcessDefinitionId).active().list(); - if (activeProcessInstances.isEmpty()) { - repositoryService.suspendProcessDefinitionById(sourceProcessDefinitionId); - } else { - logger.info("Unable to migrate {} process instance(s) from {}", - Integer.valueOf(activeProcessInstances.size()), sourceProcessDefinitionId); - } - } - - protected List<ProcessDefinition> getOldProcessDefinitions(String key, int version) { - List<ProcessDefinition> processDefinitions = - repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).list(); - List<ProcessDefinition> oldProcessDefinitions = new ArrayList<>(); - for (ProcessDefinition processDef : processDefinitions) { - if (!processDef.isSuspended() && (processDef.getVersion() != version)) { - oldProcessDefinitions.add(processDef); - } - } - return oldProcessDefinitions; - } -} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java deleted file mode 100644 index 36e828448d..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 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.common.workflow.service; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doReturn; -import java.util.ArrayList; -import java.util.List; -import org.camunda.bpm.engine.ProcessEngine; -import org.camunda.bpm.engine.RepositoryService; -import org.camunda.bpm.engine.repository.ProcessDefinition; -import org.camunda.bpm.engine.repository.ProcessDefinitionQuery; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.core.env.Environment; - -@RunWith(MockitoJUnitRunner.class) -public class AutoProcessInstanceMigrationServiceTest { - - @Mock - private ProcessEngine processEngine; - - @Mock - private ProcessDefinition outdated; - - @Mock - private ProcessDefinition newDef; - - @Mock - private ProcessDefinition key; - - @Mock - private ProcessDefinition testKey; - - @Mock - private ProcessDefinition suspendedDef; - - @Mock - private RepositoryService repositoryService; - - @Mock - private ProcessDefinitionQuery query; - - @Mock - private ProcessDefinitionQuery keyQuery; - - @Mock - private Environment env; - - @Spy - @InjectMocks - private AutoProcessInstanceMigrationService migrationService; - - - @Test - public void getOldProcessDefinitionsTest() { - List<ProcessDefinition> expectedList = new ArrayList<>(); - expectedList.add(outdated); - - List<ProcessDefinition> defList = new ArrayList<>(); - defList.add(outdated); - defList.add(newDef); - defList.add(suspendedDef); - - - doReturn(query).when(repositoryService).createProcessDefinitionQuery(); - doReturn(query).when(query).processDefinitionKey("test"); - doReturn(defList).when(query).list(); - doReturn(3).when(outdated).getVersion(); - doReturn(4).when(newDef).getVersion(); - doReturn(true).when(suspendedDef).isSuspended(); - List<ProcessDefinition> outdatedList = migrationService.getOldProcessDefinitions("test", 4); - - assertEquals(expectedList, outdatedList); - } - - @Test - public void getProcessDefinitionsTest() { - List<ProcessDefinition> expected = new ArrayList<ProcessDefinition>(); - expected.add(testKey); - expected.add(key); - - List<String> processDefinitionKeys = new ArrayList<String>(); - processDefinitionKeys.add("testKey"); - processDefinitionKeys.add("key"); - - doReturn(processDefinitionKeys).when(env).getProperty("migration.processDefinitionKeys", List.class, - new ArrayList<String>()); - - doReturn(query).when(repositoryService).createProcessDefinitionQuery(); - doReturn(query).when(query).processDefinitionKey("testKey"); - doReturn(query).when(query).latestVersion(); - doReturn(testKey).when(query).singleResult(); - - doReturn(keyQuery).when(query).processDefinitionKey("key"); - doReturn(keyQuery).when(keyQuery).latestVersion(); - doReturn(key).when(keyQuery).singleResult(); - - List<ProcessDefinition> actualProcessDefinitions = migrationService.getProcessDefinitions(); - - assertEquals(expected, actualProcessDefinitions); - } -} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfAdapterBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfAdapterBB.bpmn new file mode 100644 index 0000000000..6cd2c20ab9 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfAdapterBB.bpmn @@ -0,0 +1,80 @@ +<?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.10.0"> + <bpmn:process id="Process_1" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>SequenceFlow_0xb4elc</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1ee5kqt"> + <bpmn:incoming>SequenceFlow_0lc785k</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0xb4elc" sourceRef="StartEvent_1" targetRef="Task_0amo55n" /> + <bpmn:sequenceFlow id="SequenceFlow_0lc785k" sourceRef="Task_0amo55n" targetRef="EndEvent_1ee5kqt" /> + <bpmn:serviceTask id="Task_0amo55n" name="Call CnfAdapter" camunda:expression="${CnfAdapter.callCnfAdapter(execution)}"> + <bpmn:incoming>SequenceFlow_0xb4elc</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0lc785k</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:subProcess id="SubProcess_12ghmoa" name="Java Exception Handling Sub Process" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_1pwqeib" name="error"> + <bpmn:outgoing>SequenceFlow_0hqxgyk</bpmn:outgoing> + <bpmn:errorEventDefinition errorRef="Error_0oqb77k" camunda:errorCodeVariable="BPMN_javaExpCode" camunda:errorMessageVariable="BPMN_javaExpMsg" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1ysk6aa"> + <bpmn:incoming>SequenceFlow_0hqxgyk</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0hqxgyk" sourceRef="StartEvent_1pwqeib" targetRef="EndEvent_1ysk6aa" /> + </bpmn:subProcess> + </bpmn:process> + <bpmn:error id="Error_0oqb77k" name="java.lang.Exception" errorCode="java.lang.Exception" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="173" y="102" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1ee5kqt_di" bpmnElement="EndEvent_1ee5kqt"> + <dc:Bounds x="636" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="654" y="142" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0xb4elc_di" bpmnElement="SequenceFlow_0xb4elc"> + <di:waypoint xsi:type="dc:Point" x="209" y="120" /> + <di:waypoint xsi:type="dc:Point" x="377" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="293" y="99" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0lc785k_di" bpmnElement="SequenceFlow_0lc785k"> + <di:waypoint xsi:type="dc:Point" x="477" y="120" /> + <di:waypoint xsi:type="dc:Point" x="636" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="556.5" y="99" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1vbkgmd_di" bpmnElement="Task_0amo55n"> + <dc:Bounds x="377" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_12ghmoa_di" bpmnElement="SubProcess_12ghmoa" isExpanded="true"> + <dc:Bounds x="225" y="284" width="404" height="165" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_1pwqeib_di" bpmnElement="StartEvent_1pwqeib"> + <dc:Bounds x="340" y="350" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="346" y="393" width="26" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1ysk6aa_di" bpmnElement="EndEvent_1ysk6aa"> + <dc:Bounds x="472" y="350" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-235" y="114" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0hqxgyk_di" bpmnElement="SequenceFlow_0hqxgyk"> + <di:waypoint xsi:type="dc:Point" x="376" y="368" /> + <di:waypoint xsi:type="dc:Point" x="472" y="368" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="424" y="347" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn index 61c870b956..7638f34a59 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn @@ -1,29 +1,26 @@ <?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="3.1.2"> +<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.10.0"> <bpmn:process id="CreateVfModuleBB" name="CreateVfModuleBB" isExecutable="true"> <bpmn:startEvent id="CreateVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_1xr6chl</bpmn:outgoing> </bpmn:startEvent> <bpmn:serviceTask id="QueryVfModule" name=" SDNC Get (vf module) " camunda:expression="${SDNCQueryTasks.queryVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_1s4rpyp</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_15hn8si</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1ig2ix4</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1xr6chl" sourceRef="CreateVfModuleBB_Start" targetRef="QueryVnf" /> <bpmn:endEvent id="CreateVfModuleBB_End"> <bpmn:incoming>SequenceFlow_1vbwdaw</bpmn:incoming> </bpmn:endEvent> <bpmn:serviceTask id="CreateVfModule" name="Prepare Request" camunda:expression="${VnfAdapterCreateTasks.createVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_15hn8si</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_16g4dz0</bpmn:outgoing> + <bpmn:incoming>NoHelm</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0dehck5</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_15hn8si" sourceRef="QueryVfModule" targetRef="CreateVfModule" /> <bpmn:sequenceFlow id="SequenceFlow_1s4rpyp" sourceRef="QueryVnf" targetRef="QueryVfModule" /> <bpmn:serviceTask id="QueryVnf" name=" SDNC Get (vnf) " camunda:expression="${SDNCQueryTasks.queryVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_1xr6chl</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1s4rpyp</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_16g4dz0" sourceRef="CreateVfModule" targetRef="VnfAdapter" /> - <bpmn:sequenceFlow id="SequenceFlow_0ecr393" sourceRef="VnfAdapter" targetRef="ServiceTask_01zrt6x" /> <bpmn:callActivity id="VnfAdapter" name="Vnf Adapter" calledElement="VnfAdapter"> <bpmn:extensionElements> <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> @@ -35,8 +32,8 @@ <camunda:out source="oamManagementV6Address" target="oamManagementV6Address" /> <camunda:out source="contrailNetworkPolicyFqdnList" target="contrailNetworkPolicyFqdnList" /> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_16g4dz0</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0ecr393</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_0dehck5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0uetprw</bpmn:outgoing> </bpmn:callActivity> <bpmn:serviceTask id="UpdateVfModuleStatus" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusCreatedVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_0rds4rj</bpmn:incoming> @@ -80,7 +77,8 @@ </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_15do1tu" sourceRef="UpdateVfModuleContrailServiceInstanceFqdn" targetRef="UpdateVfModuleHeatStackId" /> <bpmn:serviceTask id="ServiceTask_01zrt6x" name=" Create Cloud Variable " camunda:expression="${CreateVFModule.createInventoryVariable(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0ecr393</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1mg8eym</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0uetprw</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1io8r33</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1io8r33" sourceRef="ServiceTask_01zrt6x" targetRef="ServiceTask_00d84m7" /> @@ -89,6 +87,23 @@ <bpmn:outgoing>SequenceFlow_1yn8o6d</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1yn8o6d" sourceRef="ServiceTask_00d84m7" targetRef="CreateNetworkPolicies" /> + <bpmn:exclusiveGateway id="CheckIfIsHelm" name="Check If Is Helm"> + <bpmn:incoming>SequenceFlow_1ig2ix4</bpmn:incoming> + <bpmn:outgoing>YesHelm</bpmn:outgoing> + <bpmn:outgoing>NoHelm</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:serviceTask id="CnfAdapter" name="Cnf Adapter" camunda:expression="${CnfAdapterCreateTasks.createInstance(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>YesHelm</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1mg8eym</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="YesHelm" name="Yes Helm" sourceRef="CheckIfIsHelm" targetRef="CnfAdapter"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isHelm")}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1mg8eym" sourceRef="CnfAdapter" targetRef="ServiceTask_01zrt6x" /> + <bpmn:sequenceFlow id="SequenceFlow_1ig2ix4" sourceRef="QueryVfModule" targetRef="CheckIfIsHelm" /> + <bpmn:sequenceFlow id="NoHelm" name="No Helm" sourceRef="CheckIfIsHelm" targetRef="CreateVfModule" /> + <bpmn:sequenceFlow id="SequenceFlow_0dehck5" sourceRef="CreateVfModule" targetRef="VnfAdapter" /> + <bpmn:sequenceFlow id="SequenceFlow_0uetprw" sourceRef="VnfAdapter" targetRef="ServiceTask_01zrt6x" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateVfModuleBB"> @@ -102,31 +117,24 @@ <dc:Bounds x="513" y="66" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1xr6chl_di" bpmnElement="SequenceFlow_1xr6chl"> - <di:waypoint x="192" y="106" /> - <di:waypoint x="313" y="106" /> + <di:waypoint xsi:type="dc:Point" x="192" y="106" /> + <di:waypoint xsi:type="dc:Point" x="313" y="106" /> <bpmndi:BPMNLabel> <dc:Bounds x="156" y="91" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_0qdq7wj_di" bpmnElement="CreateVfModuleBB_End"> - <dc:Bounds x="1215" y="293" width="36" height="36" /> + <dc:Bounds x="1300" y="450" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1136" y="333" width="0" height="0" /> + <dc:Bounds x="1176" y="446" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1dgenhy_di" bpmnElement="CreateVfModule"> - <dc:Bounds x="709" y="66" width="100" height="80" /> + <dc:Bounds x="794" y="66" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_15hn8si_di" bpmnElement="SequenceFlow_15hn8si"> - <di:waypoint x="613" y="106" /> - <di:waypoint x="709" y="106" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="519" y="91" width="90" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1s4rpyp_di" bpmnElement="SequenceFlow_1s4rpyp"> - <di:waypoint x="413" y="106" /> - <di:waypoint x="513" y="106" /> + <di:waypoint xsi:type="dc:Point" x="413" y="106" /> + <di:waypoint xsi:type="dc:Point" x="513" y="106" /> <bpmndi:BPMNLabel> <dc:Bounds x="321" y="91" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -134,124 +142,166 @@ <bpmndi:BPMNShape id="ServiceTask_1frb5h2_di" bpmnElement="QueryVnf"> <dc:Bounds x="313" y="66" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_16g4dz0_di" bpmnElement="SequenceFlow_16g4dz0"> - <di:waypoint x="809" y="106" /> - <di:waypoint x="887" y="106" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="751" y="91" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0ecr393_di" bpmnElement="SequenceFlow_0ecr393"> - <di:waypoint x="987" y="107" /> - <di:waypoint x="1091" y="107" /> - <di:waypoint x="1091" y="209" /> - <di:waypoint x="680" y="209" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="534" y="194" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1i1pfzb_di" bpmnElement="VnfAdapter"> - <dc:Bounds x="887" y="66" width="100" height="80" /> + <dc:Bounds x="959" y="66" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0fpfn71_di" bpmnElement="UpdateVfModuleStatus"> - <dc:Bounds x="1039" y="271" width="100" height="80" /> + <dc:Bounds x="1124" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_04k1b85_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="874" y="271" width="100" height="80" /> + <dc:Bounds x="959" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_1getwnf_di" bpmnElement="SubProcess_1getwnf" isExpanded="true"> - <dc:Bounds x="233" y="439" width="231" height="135" /> + <dc:Bounds x="202" y="556" width="231" height="135" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_1c8o652_di" bpmnElement="StartEvent_1c8o652"> - <dc:Bounds x="272" y="497" width="36" height="36" /> + <dc:Bounds x="241" y="614" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="148" y="533" width="0" height="0" /> + <dc:Bounds x="72" y="606" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1emam1w_di" bpmnElement="EndEvent_1emam1w"> - <dc:Bounds x="409" y="497" width="36" height="36" /> + <dc:Bounds x="378" y="614" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="285" y="533" width="0" height="0" /> + <dc:Bounds x="209" y="606" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0gcots6_di" bpmnElement="SequenceFlow_0gcots6"> - <di:waypoint x="308" y="515" /> - <di:waypoint x="409" y="515" /> + <di:waypoint xsi:type="dc:Point" x="277" y="632" /> + <di:waypoint xsi:type="dc:Point" x="378" y="632" /> <bpmndi:BPMNLabel> - <dc:Bounds x="262" y="494" width="0" height="0" /> + <dc:Bounds x="186" y="567" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0rds4rj_di" bpmnElement="SequenceFlow_0rds4rj"> - <di:waypoint x="974" y="311" /> - <di:waypoint x="1039" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1059" y="468" /> + <di:waypoint xsi:type="dc:Point" x="1124" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="910" y="296" width="0" height="0" /> + <dc:Bounds x="950" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1vbwdaw_di" bpmnElement="SequenceFlow_1vbwdaw"> - <di:waypoint x="1139" y="311" /> - <di:waypoint x="1180" y="311" /> - <di:waypoint x="1180" y="311" /> - <di:waypoint x="1215" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1224" y="468" /> + <di:waypoint xsi:type="dc:Point" x="1265" y="468" /> + <di:waypoint xsi:type="dc:Point" x="1265" y="468" /> + <di:waypoint xsi:type="dc:Point" x="1300" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1098" y="311" width="0" height="0" /> + <dc:Bounds x="1138" y="424" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1v8zx4s_di" bpmnElement="CreateNetworkPolicies"> - <dc:Bounds x="239" y="271" width="100" height="80" /> + <dc:Bounds x="324" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0xqhep5_di" bpmnElement="SequenceFlow_0xqhep5"> - <di:waypoint x="339" y="311" /> - <di:waypoint x="392" y="311" /> + <di:waypoint xsi:type="dc:Point" x="424" y="468" /> + <di:waypoint xsi:type="dc:Point" x="477" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="269" y="296" width="0" height="0" /> + <dc:Bounds x="309" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_015ayw5_di" bpmnElement="UpdateVnfIpv4OamAddress"> - <dc:Bounds x="392" y="271" width="100" height="80" /> + <dc:Bounds x="477" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1yo6mvv_di" bpmnElement="SequenceFlow_1yo6mvv"> - <di:waypoint x="492" y="311" /> - <di:waypoint x="561" y="311" /> + <di:waypoint xsi:type="dc:Point" x="577" y="468" /> + <di:waypoint xsi:type="dc:Point" x="646" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="430" y="296" width="0" height="0" /> + <dc:Bounds x="470" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0mlfsc9_di" bpmnElement="UpdateVnfManagementV6Address"> - <dc:Bounds x="561" y="271" width="100" height="80" /> + <dc:Bounds x="646" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1i03uy2_di" bpmnElement="SequenceFlow_1i03uy2"> - <di:waypoint x="661" y="311" /> - <di:waypoint x="709" y="311" /> + <di:waypoint xsi:type="dc:Point" x="746" y="468" /> + <di:waypoint xsi:type="dc:Point" x="794" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="588" y="296" width="0" height="0" /> + <dc:Bounds x="628" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0wctnhw_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> - <dc:Bounds x="709" y="271" width="100" height="80" /> + <dc:Bounds x="794" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_15do1tu_di" bpmnElement="SequenceFlow_15do1tu"> - <di:waypoint x="809" y="311" /> - <di:waypoint x="874" y="311" /> + <di:waypoint xsi:type="dc:Point" x="894" y="468" /> + <di:waypoint xsi:type="dc:Point" x="959" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="745" y="286" width="0" height="0" /> + <dc:Bounds x="785" y="399" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_01zrt6x_di" bpmnElement="ServiceTask_01zrt6x"> - <dc:Bounds x="580" y="169" width="100" height="80" /> + <dc:Bounds x="665" y="326" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1io8r33_di" bpmnElement="SequenceFlow_1io8r33"> - <di:waypoint x="580" y="209" /> - <di:waypoint x="478" y="209" /> + <di:waypoint xsi:type="dc:Point" x="665" y="366" /> + <di:waypoint xsi:type="dc:Point" x="563" y="366" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="569" y="297" width="90" height="20" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_00d84m7_di" bpmnElement="ServiceTask_00d84m7"> - <dc:Bounds x="378" y="169" width="100" height="80" /> + <dc:Bounds x="463" y="326" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1yn8o6d_di" bpmnElement="SequenceFlow_1yn8o6d"> - <di:waypoint x="378" y="209" /> - <di:waypoint x="170" y="209" /> - <di:waypoint x="170" y="306" /> - <di:waypoint x="239" y="306" /> + <di:waypoint xsi:type="dc:Point" x="463" y="366" /> + <di:waypoint xsi:type="dc:Point" x="255" y="366" /> + <di:waypoint xsi:type="dc:Point" x="255" y="463" /> + <di:waypoint xsi:type="dc:Point" x="324" y="463" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="225" y="361" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1g3vemz_di" bpmnElement="CheckIfIsHelm" isMarkerVisible="true"> + <dc:Bounds x="690.2114427860697" y="81.35572139303483" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="673" y="48" width="84" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0tag50w_di" bpmnElement="CnfAdapter"> + <dc:Bounds x="665" y="166" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0q1janp_di" bpmnElement="YesHelm"> + <di:waypoint xsi:type="dc:Point" x="715" y="131" /> + <di:waypoint xsi:type="dc:Point" x="715" y="166" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="730" y="136" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1mg8eym_di" bpmnElement="SequenceFlow_1mg8eym"> + <di:waypoint xsi:type="dc:Point" x="715" y="246" /> + <di:waypoint xsi:type="dc:Point" x="715" y="326" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="846" y="291.5" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ig2ix4_di" bpmnElement="SequenceFlow_1ig2ix4"> + <di:waypoint xsi:type="dc:Point" x="613" y="106" /> + <di:waypoint xsi:type="dc:Point" x="691" y="106" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="652" y="85" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1g7zahc_di" bpmnElement="NoHelm"> + <di:waypoint xsi:type="dc:Point" x="740" y="106" /> + <di:waypoint xsi:type="dc:Point" x="794" y="106" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="767" y="85" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0dehck5_di" bpmnElement="SequenceFlow_0dehck5"> + <di:waypoint xsi:type="dc:Point" x="894" y="106" /> + <di:waypoint xsi:type="dc:Point" x="959" y="106" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="926.5" y="85" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0uetprw_di" bpmnElement="SequenceFlow_0uetprw"> + <di:waypoint xsi:type="dc:Point" x="1009" y="146" /> + <di:waypoint xsi:type="dc:Point" x="1009" y="366" /> + <di:waypoint xsi:type="dc:Point" x="765" y="366" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1024" y="228" width="0" height="12" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy new file mode 100644 index 0000000000..c7fe7e36a6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy @@ -0,0 +1,181 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank + +class ActivateSliceSubnet extends AbstractServiceTaskProcessor { + String Prefix="ActSS" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI ID + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + //operationType = deactivateInstance/activateInstance + String operationType = execution.getVariable("requestAction") + if (isBlank(operationType)) { + msg = "Input operationType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("operationType", operationType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType(operationType) + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse) + sendWorkflowResponse(execution, 202, activateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy new file mode 100644 index 0000000000..5a7722d679 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy @@ -0,0 +1,190 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank + +class AllocateSliceSubnet extends AbstractServiceTaskProcessor { + + String Prefix="ASS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //modelInfo + String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid") + if (isBlank(modelInvariantUuid)) { + msg = "Input modelInvariantUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + } + + logger.debug("modelInvariantUuid: " + modelInvariantUuid) + + String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid") + if (isBlank(modelUuid)) { + msg = "Input modelUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelUuid", modelUuid) + } + + logger.debug("modelUuid: " + modelUuid) + + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + String dummyServiceId = new UUID(0,0).toString(); + execution.setVariable("dummyServiceId", dummyServiceId) + logger.debug("dummyServiceId: " + dummyServiceId) + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("dummyServiceId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Allocate") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "").trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse) + sendWorkflowResponse(execution, 202, allocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy new file mode 100644 index 0000000000..d59f865b01 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy @@ -0,0 +1,448 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # 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.scripts + +import com.google.gson.JsonArray +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import java.sql.Timestamp +import java.util.List +import static org.apache.commons.lang3.StringUtils.isBlank +import com.google.gson.JsonObject +import com.fasterxml.jackson.databind.ObjectMapper +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import javax.ws.rs.NotFoundException +import org.onap.so.beans.nsmf.AllocateTnNssi +import org.onap.so.beans.nsmf.DeAllocateNssi +import org.onap.so.beans.nsmf.EsrInfo +import org.onap.so.beans.nsmf.ServiceInfo +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.SliceProfile +import org.onap.aai.domain.yang.SliceProfiles +import org.onap.aai.domain.yang.Relationship + +class AnNssmfUtils { + + private static final Logger logger = LoggerFactory.getLogger(AnNssmfUtils.class) + ObjectMapper objectMapper = new ObjectMapper(); + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + public String buildSelectRANNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID, + String name, Map<String, Object> profileInfo, List<String> nsstInfoList, JsonArray capabilitiesList, Boolean preferReuse){ + + def transactionId = requestId + logger.debug( "transactionId is: " + transactionId) + String correlator = requestId + String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator + ObjectMapper objectMapper = new ObjectMapper(); + String profileJson = objectMapper.writeValueAsString(profileInfo); + String nsstInfoListString = objectMapper.writeValueAsString(nsstInfoList); + //Prepare requestInfo object + JsonObject requestInfo = new JsonObject() + requestInfo.addProperty("transactionId", transactionId) + requestInfo.addProperty("requestId", requestId) + requestInfo.addProperty("callbackUrl", callbackUrl) + requestInfo.addProperty("sourceId","SO" ) + requestInfo.addProperty("timeout", 600) + requestInfo.addProperty("numSolutions", 1) + + //Prepare serviceInfo object + JsonObject ranNsstInfo = new JsonObject() + ranNsstInfo.addProperty("UUID", UUID) + ranNsstInfo.addProperty("invariantUUID", invariantUUID) + ranNsstInfo.addProperty("name", name) + + JsonObject json = new JsonObject() + json.add("requestInfo", requestInfo) + json.add("NSTInfo", ranNsstInfo) + json.addProperty("serviceProfile", profileJson) + json.addProperty("NSSTInfo", nsstInfoListString) + json.add("subnetCapabilities", capabilitiesList) + json.addProperty("preferReuse", preferReuse) + + return json.toString() +} + +public String buildCreateTNNSSMFSubnetCapabilityRequest() { + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType("TN") + esrInfo.setVendor("ONAP") + + JsonArray subnetTypes = new JsonArray() + subnetTypes.add("TN_FH") + subnetTypes.add("TN_MH") + JsonObject response = new JsonObject() + response.add("subnetCapabilityQuery", subnetTypes) + response.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + return response.toString() +} + +public String buildCreateANNFNSSMFSubnetCapabilityRequest() { + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType("AN") + esrInfo.setVendor("ONAP") + + JsonArray subnetTypes = new JsonArray() + subnetTypes.add("AN_NF") + JsonObject response = new JsonObject() + response.add("subnetCapabilityQuery", subnetTypes) + response.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + return response.toString() +} +public void createDomainWiseSliceProfiles(List<String> ranConstituentSliceProfiles, DelegateExecution execution) { + + for(String profile : ranConstituentSliceProfiles) { + String domainType = jsonUtil.getJsonValue(profile, "domainType") + switch(domainType) { + case "AN_NF": + execution.setVariable("ranNfSliceProfile", profile) + break + case "TN_FH": + execution.setVariable("tnFhSliceProfile", profile) + break + case "TN_MH": + execution.setVariable("tnMhSliceProfile", profile) + break + default: + logger.debug("No expected match found for current domainType") + logger.error("No expected match found for current domainType "+ domainType) + exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ domainType) + } + + } +} + +public void createSliceProfilesInAai(DelegateExecution execution) { + + org.onap.aai.domain.yang.ServiceInstance ANNF_sliceProfileInstance = new ServiceInstance(); + org.onap.aai.domain.yang.ServiceInstance TNFH_sliceProfileInstance = new ServiceInstance(); + org.onap.aai.domain.yang.ServiceInstance TNMH_sliceProfileInstance = new ServiceInstance(); + //generate slice profile ids and slice profile instance ids + String ANNF_sliceProfileInstanceId = UUID.randomUUID().toString() + String ANNF_sliceProfileId = UUID.randomUUID().toString() + String TNFH_sliceProfileInstanceId = UUID.randomUUID().toString() + String TNFH_sliceProfileId = UUID.randomUUID().toString() + String TNMH_sliceProfileInstanceId = UUID.randomUUID().toString() + String TNMH_sliceProfileId = UUID.randomUUID().toString() + execution.setVariable("ANNF_sliceProfileInstanceId",ANNF_sliceProfileInstanceId) + execution.setVariable("ANNF_sliceProfileId",ANNF_sliceProfileId) + execution.setVariable("TNFH_sliceProfileInstanceId",TNFH_sliceProfileInstanceId) + execution.setVariable("TNFH_sliceProfileId",TNFH_sliceProfileId) + execution.setVariable("TNMH_sliceProfileInstanceId",TNMH_sliceProfileInstanceId) + execution.setVariable("TNMH_sliceProfileId",TNMH_sliceProfileId) + //slice profiles assignment + org.onap.aai.domain.yang.SliceProfiles ANNF_SliceProfiles = new SliceProfiles() + org.onap.aai.domain.yang.SliceProfiles TNFH_SliceProfiles = new SliceProfiles() + org.onap.aai.domain.yang.SliceProfiles TNMH_SliceProfiles = new SliceProfiles() + org.onap.aai.domain.yang.SliceProfile ANNF_SliceProfile = new SliceProfile() + org.onap.aai.domain.yang.SliceProfile TNFH_SliceProfile = new SliceProfile() + org.onap.aai.domain.yang.SliceProfile TNMH_SliceProfile = new SliceProfile() + ANNF_SliceProfile = createSliceProfile("AN-NF", execution) + TNFH_SliceProfile = createSliceProfile("TN-FH",execution) + TNMH_SliceProfile = createSliceProfile("TN-MH",execution) + + ANNF_SliceProfiles.getSliceProfile().add(ANNF_SliceProfile) + TNFH_SliceProfiles.getSliceProfile().add(TNFH_SliceProfile) + TNMH_SliceProfiles.getSliceProfile().add(TNMH_SliceProfile) + + logger.debug("sliceProfiles : 1. "+ANNF_SliceProfiles.toString()+"\n 2. "+TNFH_SliceProfiles.toString()+"\n 3. "+TNMH_SliceProfiles.toString()) + //ANNF slice profile instance creation + ANNF_sliceProfileInstance.setServiceInstanceId(ANNF_sliceProfileInstanceId) + String sliceInstanceName = "sliceprofile_"+ANNF_sliceProfileId + ANNF_sliceProfileInstance.setServiceInstanceName(sliceInstanceName) + String serviceType = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "sST") + ANNF_sliceProfileInstance.setServiceType(serviceType) + String serviceStatus = "deactivated" + ANNF_sliceProfileInstance.setOrchestrationStatus(serviceStatus) + String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList") + ANNF_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + String serviceRole = "slice-profile-instance" + ANNF_sliceProfileInstance.setServiceRole(serviceRole) + List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + String snssai = snssaiList.get(0) + ANNF_sliceProfileInstance.setEnvironmentContext(snssai) + ANNF_sliceProfileInstance.setWorkloadContext("AN-NF") + ANNF_sliceProfileInstance.setSliceProfiles(ANNF_SliceProfiles) + logger.debug("completed ANNF sliceprofileinstance build "+ ANNF_sliceProfileInstance.toString()) + //TNFH slice profile instance creation + TNFH_sliceProfileInstance.setServiceInstanceId(TNFH_sliceProfileInstanceId) + sliceInstanceName = "sliceprofile_"+TNFH_sliceProfileId + TNFH_sliceProfileInstance.setServiceInstanceName(sliceInstanceName) + serviceType = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "sST") + TNFH_sliceProfileInstance.setServiceType(serviceType) + TNFH_sliceProfileInstance.setOrchestrationStatus(serviceStatus) + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "plmnIdList") + TNFH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + TNFH_sliceProfileInstance.setServiceRole(serviceRole) + TNFH_sliceProfileInstance.setEnvironmentContext(snssai) + TNFH_sliceProfileInstance.setWorkloadContext("TN-FH") + TNFH_sliceProfileInstance.setSliceProfiles(TNFH_SliceProfiles) + logger.debug("completed TNFH sliceprofileinstance build "+TNFH_sliceProfileInstance) + //TNMH slice profile instance creation + TNMH_sliceProfileInstance.setServiceInstanceId(TNMH_sliceProfileInstanceId) + sliceInstanceName = "sliceprofile_"+TNMH_sliceProfileId + TNMH_sliceProfileInstance.setServiceInstanceName(sliceInstanceName) + serviceType = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "sST") + TNMH_sliceProfileInstance.setServiceType(serviceType) + TNMH_sliceProfileInstance.setOrchestrationStatus(serviceStatus) + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "plmnIdList") + TNMH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + TNMH_sliceProfileInstance.setServiceRole(serviceRole) + TNMH_sliceProfileInstance.setEnvironmentContext(snssai) + TNMH_sliceProfileInstance.setWorkloadContext("TN-MH") + TNMH_sliceProfileInstance.setSliceProfiles(TNMH_SliceProfiles) + logger.debug("completed TNMH sliceprofileinstance build "+TNMH_sliceProfileInstance) + String msg = "" + try { + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), ANNF_sliceProfileInstanceId) + client.create(sliceProfileUri, ANNF_sliceProfileInstance) + + AAIResourceUri sliceProfileUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), TNFH_sliceProfileInstanceId) + client.create(sliceProfileUri1, TNFH_sliceProfileInstance) + + AAIResourceUri sliceProfileUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), TNMH_sliceProfileInstanceId) + client.create(sliceProfileUri2, TNMH_sliceProfileInstance) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + +} +private SliceProfile createSliceProfile(String domainType, DelegateExecution execution) { + + SliceProfile result = new SliceProfile() + Map<String,Object> profile + switch(domainType) { + case "AN-NF": + profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, pLMNIdList, cSReliabilityMeanTime, + //msgSizeByte, maxNumberofPDUSessions,overallUserDensity,transferIntervalTarget + result.setJitter(profile.get("jitter")) + result.setLatency(profile.get("latency")) + result.setResourceSharingLevel(profile.get("resourceSharingLevel")) + result.setSNssai(profile.get("sNSSAI")) + result.setUeMobilityLevel(profile.get("uEMobilityLevel")) + result.setMaxNumberOfUEs(profile.get("maxNumberofUEs")) + result.setActivityFactor(profile.get("activityFactor")) + result.setCoverageAreaTAList(profile.get("coverageAreaTAList")) + result.setCsAvailability(profile.get("cSAvailabilityTarget")) + result.setExpDataRateDL(profile.get("expDataRateDL")) + result.setExpDataRateUL(profile.get("expDataRateUL")) + result.setSurvivalTime(profile.get("survivalTime")) + result.setAreaTrafficCapDL(profile.get("areaTrafficCapDL")) + result.setAreaTrafficCapUL(profile.get("areaTrafficCapUL")) + result.setExpDataRate(profile.get("expDataRate")) + result.setProfileId(execution.getVariable("ANNF_sliceProfileId")) + break + case "TN-FH": + profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) //pending fields - maxBandwidth, sST, pLMNIdList + result.setJitter(profile.get("jitter")) + result.setLatency(profile.get("latency")) + result.setResourceSharingLevel(profile.get("resourceSharingLevel")) + result.setSNssai(profile.get("sNSSAI")) + result.setProfileId(execution.getVariable("TNFH_sliceProfileId")) + break + case "TN-MH": + profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, pLMNIdList + result.setJitter(profile.get("jitter")) + result.setLatency(profile.get("latency")) + result.setResourceSharingLevel(profile.get("resourceSharingLevel")) + result.setSNssai(profile.get("sNSSAI")) + result.setProfileId(execution.getVariable("TNMH_sliceProfileId")) + break + default: + logger.debug("No expected match found for current domainType") + logger.error("No expected match found for current domainType "+ domainType) + exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ domainType) + } + return result +} + + /** + * create relationship in AAI + */ + public createRelationShipInAAI = { DelegateExecution execution, final Relationship relationship, String instanceId -> + logger.debug("createRelationShipInAAI Start") + String msg + AAIResourcesClient client = new AAIResourcesClient() + try { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + instanceId).relationshipAPI() + client.create(uri, relationship) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in CreateCommunicationService.createRelationShipInAAI. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("createRelationShipInAAI Exit") + + } + + public void processRanNfModifyRsp(DelegateExecution execution) { + String status = execution.getVariable("ranNfStatus") + if(status.equals("success")) { + logger.debug("completed Ran NF NSSI modification ... proceeding with the flow") + } + else { + logger.error("failed to modify ran Nf nssi") + exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "modify ran nf nssi not successfull") + } + } + + public String buildCreateNSSMFRequest(DelegateExecution execution, String domainType, String action) { + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType("TN") + esrInfo.setVendor("ONAP") + String esrInfoString = objectMapper.writeValueAsString(esrInfo) + JsonObject response = new JsonObject() + JsonObject allocateTnNssi = new JsonObject() + JsonObject serviceInfo = new JsonObject() + JsonArray transportSliceNetworksList = new JsonArray() + JsonArray connectionLinksList = new JsonArray() + JsonObject connectionLinks = new JsonObject() + if(action.equals("allocate")){ + Map<String, String> endpoints + if(domainType.equals("TN_FH")) { + serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid")) + serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid")) + allocateTnNssi.addProperty("nsstId", execution.getVariable("TNFH_modelUuid")) + allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_modelName")) + Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) + sliceProfile.put("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId")) + String sliceProfileString = objectMapper.writeValueAsString(sliceProfile) + allocateTnNssi.addProperty("sliceProfile", sliceProfileString) + endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_RU")) + endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN")) + String endpointsString = objectMapper.writeValueAsString(endpoints) + connectionLinksList.add(endpointsString) + }else if(domainType.equals("TN_MH")) { + serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid")) + serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid")) + allocateTnNssi.addProperty("nsstId", execution.getVariable("TNMH_modelUuid")) + allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_modelName")) + Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class) + sliceProfile.put("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) + String sliceProfileString = objectMapper.writeValueAsString(sliceProfile) + allocateTnNssi.addProperty("sliceProfile", sliceProfileString) + endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG")) + endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN")) + String endpointsString = objectMapper.writeValueAsString(endpoints) + connectionLinksList.add(endpointsString) + } + + //Connection links + connectionLinks.add("connectionLinks", connectionLinksList) + transportSliceNetworksList.add(connectionLinks) + allocateTnNssi.add("transportSliceNetworks", transportSliceNetworksList) + allocateTnNssi.addProperty("nssiId", null) + serviceInfo.addProperty("nssiId", null) + }else if(action.equals("modify-allocate")) { + if(domainType.equals("TN_FH")) { + serviceInfo.addProperty("serviceInvariantUuid", null) + serviceInfo.addProperty("serviceUuid", null) + allocateTnNssi.addProperty("nsstId", null) + allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_nssiName")) + allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId")) + allocateTnNssi.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) + serviceInfo.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) + }else if(domainType.equals("TN_MH")) { + serviceInfo.addProperty("serviceInvariantUuid", null) + serviceInfo.addProperty("serviceUuid", null) + allocateTnNssi.addProperty("nsstId", null) + allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_nssiName")) + allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) + allocateTnNssi.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) + serviceInfo.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) + } + } + String nsiInfo = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "nsiInfo") + allocateTnNssi.addProperty("nsiInfo", nsiInfo) + allocateTnNssi.addProperty("scriptName", "TN1") + serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) + serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) + serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + response.addProperty("esrInfo", esrInfoString) + response.add("serviceInfo", serviceInfo) + response.add("allocateTnNssi", allocateTnNssi) + return response.toString() + } + + public String buildDeallocateNssiRequest(DelegateExecution execution,String domainType) { + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + JsonObject deAllocateNssi = new JsonObject() + deAllocateNssi.addProperty("snssaiList", execution.getVariable("snssaiList")) + deAllocateNssi.addProperty("nsiId", execution.getVariable("nsiId")) + deAllocateNssi.addProperty("modifyAction", true) + deAllocateNssi.addProperty("terminateNssiOption", 0) + deAllocateNssi.addProperty("scriptName", "TN1") + + if(domainType.equals("TN_FH")) { + deAllocateNssi.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) + deAllocateNssi.addProperty("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId")) + }else if(domainType.equals("TN_MH")) { + deAllocateNssi.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) + deAllocateNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) + } + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setVendor("ONAP") + esrInfo.setNetworkType("TN") + + JsonObject serviceInfo = new JsonObject() + serviceInfo.addProperty("serviceInvariantUuid", null) + serviceInfo.addProperty("serviceUuid", null) + serviceInfo.addProperty("globalSubscriberId", globalSubscriberId) + serviceInfo.addProperty("subscriptionServiceType", subscriptionServiceType) + + JsonObject json = new JsonObject() + json.add("deAllocateNssi", deAllocateNssi) + json.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + json.add("serviceInfo", serviceInfo) + return json.toString() + + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index 12cd0dde0b..f8eafe7e98 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -184,7 +184,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { logger.debug(Prefix + "prepareInitOperationStatus Start") String serviceId = execution.getVariable("serviceInstanceId") - // 生成 operationId + //operationId is generated String operationId = execution.getVariable("operationId") logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId) @@ -370,20 +370,23 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { for (String e2eInput in e2eInputs) { - if (jsonUtil.getJsonValue(e2eInput, "type") == "integer") { + key = jsonUtil.getJsonValue(e2eInput, "name") + String type = jsonUtil.getJsonValue(e2eInput, "type") + if (type == "integer") { def temp - key = jsonUtil.getJsonValue(e2eInput, "name") value = csInputMap.containsKey(key) ? csInputMap.getOrDefault(key, 0) : (isBlank(temp = jsonUtil.getJsonValue(e2eInput, "default")) ? 0 : temp) e2eInputMap.put(key, value as Integer) - } else { - e2eInputMap.put(key = jsonUtil.getJsonValue(e2eInput, "name"), csInputMap.containsKey(key) + } else if(type == "string") { + e2eInputMap.put(key, csInputMap.containsKey(key) ? csInputMap.getOrDefault(key, null) : (jsonUtil.getJsonValue(e2eInput, "default"))) + } } + //TODO e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id")) - e2eInputMap.put("sST", execution.getVariable("csServiceType")) + e2eInputMap.put("sST", execution.getVariable("csServiceType")) execution.setVariable("e2eInputMap", e2eInputMap) execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType()) execution.setVariable("e2eModelInvariantUuid", e2eServiceDecomposition.getModelInfo().getModelInvariantUuid()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index 15a0f34482..dcbaf746ea 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -178,60 +178,36 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { logger.debug("Finish preProcessRequest") } - public void getNSTSelection(DelegateExecution execution) { - logger.debug("Start getNSTSelection") + public void prepareSelectNSTRequest(DelegateExecution execution) { + logger.debug("Start prepareSelectNSTRequest") String requestId = execution.getVariable("msoRequestId") + String messageType = "NSTSelectionResponse" Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") - String oofUrl = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) - - def authHeader = "" - String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) - String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) - - String basicAuthValue = utils.encrypt(basicAuth, msokey) - if (basicAuthValue != null) { - logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) - try { - authHeader = utils.getBasicAuth(basicAuthValue, msokey) - execution.setVariable("BasicAuthHeaderValue", authHeader) - } catch (Exception ex) { - logger.debug( "Unable to encode username and password string: " + ex) - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + - "encode username and password string") - } - } else { - logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + - "value null") - } - - URL requestUrl = new URL(oofUrl + "/api/oof/v1/selection/nst") - String oofRequest = oofUtils.buildSelectNSTRequest(requestId, serviceProfile) - HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.OOF) - httpClient.addAdditionalHeader("Authorization", authHeader) - Response httpResponse = httpClient.post(oofRequest) - - int responseCode = httpResponse.getStatus() - logger.debug("OOF sync response code is: " + responseCode) - - if(responseCode != 200){ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") - } - - Map<String, Object> nstSolution - try { - Map<String, Object> resMap = httpResponse.readEntity(Map.class) - List<Map<String, Object>> nstSolutions = (List<Map<String, Object>>) resMap.get("solutions") - nstSolution = nstSolutions.get(0) - execution.setVariable("nstSolution", nstSolution) - } catch (Exception ex) { - logger.debug( "Failed to get NST solution suggested by OOF.") - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get NST solution suggested by OOF.") - } - - logger.debug("Finish getNSTSelection") + execution.setVariable("nstSelectionUrl", "/api/oof/v1/selection/nst") + execution.setVariable("nstSelection_messageType",messageType) + execution.setVariable("nstSelection_correlator",requestId) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + execution.setVariable("nstSelection_timeout",timeout) + String oofRequest = oofUtils.buildSelectNSTRequest(requestId,messageType, serviceProfile) + execution.setVariable("nstSelection_oofRequest",oofRequest) + logger.debug("Finish prepareSelectNSTRequest") } + + public void processNSTSolutions(DelegateExecution execution) { + Map<String, Object> nstSolution + try { + logger.debug("Start processing NSTSolutions") + Map<String, Object> resMap = objectMapper.readValue(execution.getVariable("nstSelection_oofResponse"),Map.class) + List<Map<String, Object>> nstSolutions = (List<Map<String, Object>>) resMap.get("solutions") + nstSolution = nstSolutions.get(0) + execution.setVariable("nstSolution", nstSolution) + } catch (Exception ex) { + logger.debug( "Failed to get NST solution suggested by OOF.") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get NST solution suggested by OOF.") + } + + } public void prepareDecomposeService(DelegateExecution execution) { logger.debug("Start prepareDecomposeService") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy new file mode 100644 index 0000000000..964baa7a9d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy @@ -0,0 +1,170 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank + +class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { + String Prefix="DeASS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI ID + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in DeAllocateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Deallocate") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse) + sendWorkflowResponse(execution, 202, deAllocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy new file mode 100644 index 0000000000..4d86fb4cd9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy @@ -0,0 +1,589 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.scripts + +import static org.apache.commons.lang3.StringUtils.isBlank + +import javax.ws.rs.NotFoundException + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.beans.nsmf.ActDeActNssi +import org.onap.so.beans.nsmf.EsrInfo +import org.onap.so.beans.nsmf.ServiceInfo +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import com.fasterxml.jackson.databind.ObjectMapper +import com.google.gson.JsonObject + +/** + * Internal AN NSSMF to handle NSSI Activation/Deactivation + * + */ +class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { + + String Prefix="DoActivateAccessNSSI" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + ObjectMapper objectMapper = new ObjectMapper() + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + private static final Logger logger = LoggerFactory.getLogger(DoActivateAccessNSSI.class) + private static final String ROLE_SLICE_PROFILE = "slice-profile-instance" + private static final String ROLE_NSSI = "nssi" + + private static final String KEY_SLICE_PROFILE = "SliceProfile" + private static final String KEY_NSSI = "NSSI" + + private static final String AN_NF = "AN-NF" + private static final String TN_FH = "TN-FH" + private static final String TN_MH = "TN-MH" + + private static final String ACTIVATE = "activateInstance" + private static final String DEACTIVATE = "deactivateInstance" + + private static final String VENDOR_ONAP = "ONAP" + + Map<String,String> orchStatusMap = new HashMap<>() + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug("${Prefix} - Start preProcessRequest") + + String sliceParams = execution.getVariable("sliceParams") + String sNssaiList = jsonUtil.getJsonValue(sliceParams, "snssaiList") + String anSliceProfileId = jsonUtil.getJsonValue(sliceParams, "sliceProfileId") + String nsiId = execution.getVariable("nsiId") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String anNssiId = execution.getVariable("serviceInstanceID") + String operationType = execution.getVariable("operationType") + + if(isBlank(sNssaiList) || isBlank(anSliceProfileId) || isBlank(nsiId)) { + String msg = "Input fields cannot be null : Mandatory attributes : [snssaiList, sliceProfileId, nsiId]" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if( isBlank(anNssiId) || isBlank(globalSubscriberId) || isBlank(subscriptionServiceType) || isBlank(operationType)) { + String msg = "Missing Input fields from main process : [serviceInstanceID, globalSubscriberId, subscriptionServiceType, operationType]" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + execution.setVariable("sNssaiList", sNssaiList) + execution.setVariable("anSliceProfileId", anSliceProfileId) + execution.setVariable("nsiId", nsiId) + execution.setVariable("anNssiId", anNssiId) + + orchStatusMap.put(ACTIVATE, "activated") + orchStatusMap.put(DEACTIVATE, "deactivated") + + logger.debug("${Prefix} - Preprocessing completed with sliceProfileId : ${anSliceProfileId} , nsiId : ${nsiId} , nssiId : ${anNssiId}") + + } + + /** + * Method to fetch AN NSSI Constituents and Slice Profile constituents + * @param execution + */ + void getRelatedInstances(DelegateExecution execution) { + logger.debug("${Prefix} - Get Related Instances") + String anSliceProfileId = execution.getVariable("anSliceProfileId") + String anNssiId = execution.getVariable("anNssiId") + + Map<String,ServiceInstance> relatedSPs = new HashMap<>() + execution.setVariable("relatedSPs", getRelatedInstancesByRole(execution, ROLE_SLICE_PROFILE,KEY_SLICE_PROFILE, anSliceProfileId)) + + Map<String,ServiceInstance> relatedNssis = new HashMap<>() + execution.setVariable("relatedNssis", getRelatedInstancesByRole(execution, ROLE_NSSI,KEY_NSSI, anNssiId)) + logger.trace("${Prefix} - Exit Get Related instances") + } + + /** + * Method to check Slice profile orchestration status + * @param execution + */ + void getSPOrchStatus(DelegateExecution execution) { + logger.debug("${Prefix} - Start getSPOrchStatus") + ServiceInstance sliceProfileInstance = execution.getVariable(KEY_SLICE_PROFILE) + String orchStatus = sliceProfileInstance.getOrchestrationStatus() + String operationType = execution.getVariable("operationType") + if(orchStatusMap.get(operationType).equalsIgnoreCase(orchStatus)) { + execution.setVariable("shouldChangeSPStatus", true) + }else { + execution.setVariable("shouldChangeSPStatus", false) + } + logger.debug("${Prefix} - SPOrchStatus : ${orchStatus}") + } + + /** + * Method to check AN NF's Slice profile instance orchestration status + * @param execution + */ + void getAnNfSPOrchStatus(DelegateExecution execution) { + logger.debug("${Prefix} - getAnNfSPOrchStatus ") + ServiceInstance sliceProfileInstance = getInstanceByWorkloadContext(execution.getVariable("relatedSPs"), AN_NF) + String anNfNssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), AN_NF) + execution.setVariable("anNfNssiId", anNfNssiId) + String anNfSPId = sliceProfileInstance.getServiceInstanceId() + execution.setVariable("anNfSPId", anNfSPId) + + String orchStatus = sliceProfileInstance.getOrchestrationStatus() + String operationType = execution.getVariable("operationType") + if(orchStatusMap.get(operationType).equalsIgnoreCase(orchStatus)) { + execution.setVariable("shouldChangeAN_NF_SPStatus", true) + }else { + execution.setVariable("shouldChangeAN_NF_SPStatus", false) + } + logger.debug("${Prefix} - getAnNfSPOrchStatus AN_NF SP ID:${anNfSPId} : ${orchStatus}") + } + + void prepareSdnrActivationRequest(DelegateExecution execution) { + logger.debug("${Prefix} - start prepareSdnrActivationRequest") + String operationType = execution.getVariable("operationType") + String action = operationType.equalsIgnoreCase(ACTIVATE) ? "activate":"deactivate" + + String anNfNssiId = execution.getVariable("anNfNssiId") + String sNssai = execution.getVariable("sNssaiList") + String reqId = execution.getVariable("msoRequestId") + String messageType = "SDNRActivateResponse" + StringBuilder callbackURL = new StringBuilder(UrnPropertiesReader.getVariable("mso.workflow.message.endpoint", execution)) + callbackURL.append("/").append(messageType).append("/").append(reqId) + + JsonObject input = new JsonObject() + input.addProperty("RANNFNSSIId", anNfNssiId) + input.addProperty("callbackURL", callbackURL.toString()) + input.addProperty("s-NSSAI", sNssai) + + JsonObject Payload = new JsonObject() + Payload.addProperty("version", "1.0") + Payload.addProperty("rpc-name", "activateRANSlice") + Payload.addProperty("correlation-id", reqId) + Payload.addProperty("type", "request") + + JsonObject wrapinput = new JsonObject() + wrapinput.addProperty("Action", action) + + JsonObject CommonHeader = new JsonObject() + CommonHeader.addProperty("TimeStamp", new Date(System.currentTimeMillis()).format("yyyy-MM-ddTHH:mm:ss.sss", TimeZone.getDefault())) + CommonHeader.addProperty("APIver", "1.0") + CommonHeader.addProperty("RequestID", reqId) + CommonHeader.addProperty("SubRequestID", "1") + + JsonObject body = new JsonObject() + body.add("input", wrapinput) + + JsonObject sdnrRequest = new JsonObject() + Payload.add("input", input) + wrapinput.add("Payload", Payload) + wrapinput.add("CommonHeader", CommonHeader) + body.add("input", wrapinput) + sdnrRequest.add("body", body) + + String json = sdnrRequest.toString() + execution.setVariable("sdnrRequest", sdnrRequest) + execution.setVariable("SDNR_messageType", messageType) + execution.setVariable("SDNR_timeout", "PT10M") + + logger.debug("${Prefix} - prepareSdnrActivationRequest : SDNR Request : ${json}") + } + + void processSdnrResponse(DelegateExecution execution) { + logger.debug("${Prefix} processing SdnrResponse") + Map<String, Object> resMap = objectMapper.readValue(execution.getVariable("SDNR_Response"),Map.class) + String status = resMap.get("status") + String reason = resMap.get("reason") + if("success".equalsIgnoreCase(status)) { + execution.setVariable("isANactivationSuccess", true) + }else { + execution.setVariable("isANactivationSuccess", false) + logger.debug("AN NF Activation/Deactivation failed with reason ${reason}") + } + logger.debug("${Prefix} processed SdnrResponse") + } + + /** + * Update AN NF - NSSI and SP Instance status + * @param execution + */ + void updateAnNfStatus(DelegateExecution execution) { + logger.debug("${Prefix}Start updateAnNfStatus") + String anNfNssiId = execution.getVariable("anNfNssiId") + String anNfSPId = execution.getVariable("anNfSPId") + + updateOrchStatus(execution, anNfSPId) + updateOrchStatus(execution, anNfNssiId) + logger.debug("${Prefix}Exit updateAnNfStatus") + } + + /** + * Method to check AN NF's Slice profile instance orchestration status + * @param execution + */ + void getTnFhSPOrchStatus(DelegateExecution execution) { + logger.debug("${Prefix} start getTnFhSPOrchStatus ") + ServiceInstance sliceProfileInstance = getInstanceByWorkloadContext(execution.getVariable("relatedSPs"), TN_FH) + String tnFhNssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), TN_FH) + execution.setVariable("tnFhNssiId", tnFhNssiId) + String tnFhSPId = sliceProfileInstance.getServiceInstanceId() + execution.setVariable("tnFhSPId", tnFhSPId) + + String orchStatus = sliceProfileInstance.getOrchestrationStatus() + String operationType = execution.getVariable("operationType") + if(orchStatusMap.get(operationType).equalsIgnoreCase(orchStatus)) { + execution.setVariable("shouldChangeTN_FH_SPStatus", true) + }else { + execution.setVariable("shouldChangeTN_FH_SPStatus", false) + } + + logger.debug("${Prefix} Exit getTnFhSPOrchStatus TN_FH SP ID:${tnFhSPId} : ${orchStatus}") + } + + void doTnFhNssiActivation(DelegateExecution execution){ + logger.debug("Start doTnFhNssiActivation in ${Prefix}") + String nssmfRequest = buildTNActivateNssiRequest(execution, TN_FH) + String operationType = execution.getVariable("operationType") + String urlOpType = operationType.equalsIgnoreCase(ACTIVATE) ? "activation":"deactivation" + + List<String> sNssaiList = execution.getVariable("sNssaiList") + String snssai = sNssaiList != null ? sNssaiList.get(0) : "" + + String urlString = "/api/rest/provMns/v1/NSS/" + snssai + urlOpType + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + if (nssmfResponse != null) { + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TN_FH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + logger.debug("Exit doTnFhNssiActivation in ${Prefix}") + } + + void getTnMhSPOrchStatus(DelegateExecution execution) { + logger.debug("${Prefix} Start getTnMhSPOrchStatus ") + ServiceInstance sliceProfileInstance = getInstanceByWorkloadContext(execution.getVariable("relatedSPs"), TN_MH) + String tnFhNssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), TN_MH) + execution.setVariable("tnMhNssiId", tnFhNssiId) + String tnFhSPId = sliceProfileInstance.getServiceInstanceId() + execution.setVariable("tnMhSPId", tnFhSPId) + + String orchStatus = sliceProfileInstance.getOrchestrationStatus() + String operationType = execution.getVariable("operationType") + if(orchStatusMap.get(operationType).equalsIgnoreCase(orchStatus)) { + execution.setVariable("shouldChangeTN_MH_SPStatus", true) + }else { + execution.setVariable("shouldChangeTN_MH_SPStatus", false) + } + logger.debug("${Prefix} Exit getTnMhSPOrchStatus TN_MH SP ID:${tnFhSPId} : ${orchStatus}") + } + + void doTnMhNssiActivation(DelegateExecution execution){ + logger.debug("Start doTnMhNssiActivation in ${Prefix}") + String nssmfRequest = buildTNActivateNssiRequest(execution, TN_MH) + String operationType = execution.getVariable("operationType") + String urlOpType = operationType.equalsIgnoreCase(ACTIVATE) ? "activation":"deactivation" + + List<String> sNssaiList = execution.getVariable("sNssaiList") + String snssai = sNssaiList != null ? sNssaiList.get(0) : "" + + String urlString = "/api/rest/provMns/v1/NSS/" + snssai + urlOpType + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + if (nssmfResponse != null) { + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TN_MH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + logger.debug("Exit doTnMhNssiActivation in ${Prefix}") + + } + + /** + * Update TN FH - NSSI and SP Instance status + * @param execution + */ + void updateTNFHStatus(DelegateExecution execution) { + logger.debug("${Prefix} Start updateTNFHStatus") + + String tnFhNssiId = execution.getVariable("tnFhNssiId") + String tnFhSPId = execution.getVariable("tnFhSPId") + updateOrchStatus(execution, tnFhSPId) + updateOrchStatus(execution, tnFhNssiId) + + logger.debug("${Prefix} Exit updateTNFHStatus") + + } + + /** + * Update TN MH - NSSI and SP Instance status + * @param execution + */ + void updateTNMHStatus(DelegateExecution execution) { + logger.debug("${Prefix} Start updateTNMHStatus") + + String tnMhNssiId = execution.getVariable("tnMhNssiId") + String tnMhSPId = execution.getVariable("tnMhSPId") + updateOrchStatus(execution, tnMhSPId) + updateOrchStatus(execution, tnMhNssiId) + + logger.debug("${Prefix} Exit updateTNMHStatus") + } + + /** + * Update AN - NSSI and SP Instance status + * @param execution + */ + void updateANStatus(DelegateExecution execution) { + logger.debug("${Prefix} Start updateANStatus") + String anNssiId = execution.getVariable("anNssiId") + String anSliceProfileId = execution.getVariable("anSliceProfileId") + updateOrchStatus(execution, anNssiId) + updateOrchStatus(execution, anSliceProfileId) + logger.debug("${Prefix} Start updateANStatus") + } + + void prepareQueryJobStatus(DelegateExecution execution,String jobId,String networkType,String instanceId) { + logger.debug("${Prefix} Start prepareQueryJobStatus : ${jobId}") + String responseId = "1" + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType(networkType) + esrInfo.setVendor(VENDOR_ONAP) + + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.setNssiId(instanceId) + serviceInfo.setNsiId(execution.getVariable("nsiId")) + serviceInfo.setGlobalSubscriberId(globalSubscriberId) + serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + + execution.setVariable("${networkType}_esrInfo", esrInfo) + execution.setVariable("${networkType}_responseId", responseId) + execution.setVariable("${networkType}_serviceInfo", serviceInfo) + + } + + void validateJobStatus(DelegateExecution execution,String responseDescriptor) { + logger.debug("validateJobStatus ${responseDescriptor}") + String status = jsonUtil.getJsonValue(responseDescriptor, "responseDescriptor.status") + String statusDescription = jsonUtil.getJsonValue(responseDescriptor, "responseDescriptor.statusDescription") + if("finished".equalsIgnoreCase(status)) { + execution.setVariable("isSuccess", true) + }else { + execution.setVariable("isSuccess", false) + } + } + + + private void updateOrchStatus(DelegateExecution execution,String serviceId) { + logger.debug("${Prefix} Start updateOrchStatus : ${serviceId}") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String operationType = execution.getVariable("operationType") + + try { + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, serviceId) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") + } + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + if (si.isPresent()) { + String orchStatus = si.get().getOrchestrationStatus() + logger.debug("Orchestration status of instance ${serviceId} is ${orchStatus}") + if (ACTIVATE.equalsIgnoreCase(operationType) && "deactivated".equalsIgnoreCase(orchStatus)) { + si.get().setOrchestrationStatus("activated") + client.update(uri, si.get()) + } else if(DEACTIVATE.equalsIgnoreCase(operationType) && "activated".equalsIgnoreCase(orchStatus)){ + si.get().setOrchestrationStatus("deactivated") + client.update(uri, si.get()) + } + } + } catch (Exception e) { + logger.info("Service is already in active state") + String msg = "Service is already in active state, " + e.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("${Prefix} Exit updateOrchStatus : ${serviceId}") + } + + void prepareUpdateJobStatus(DelegateExecution execution,String status,String progress,String statusDescription) { + logger.debug("${Prefix} Start prepareUpdateJobStatus : ${statusDescription}") + String serviceId = execution.getVariable("anNssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setServiceId(serviceId) + roStatus.setOperationId(jobId) + roStatus.setResourceTemplateUUID(nsiId) + roStatus.setOperType(operationType) + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + } + + + + /** + * Fetches a collection of service instances with the specific role and maps it based on workload context + * (AN-NF,TN-FH,TN-MH) + * @param execution + * @param role - nssi/slice profile instance + * @param key - NSSI/Sliceprofile corresponding to instanceId + * @param instanceId - id to which the related list to be found + * @return + */ + private Map<String,ServiceInstance> getRelatedInstancesByRole(DelegateExecution execution,String role,String key, String instanceId) { + logger.debug("${Prefix} - Fetching related ${role} from AAI") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + if( isBlank(role) || isBlank(instanceId)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Role and instanceId are mandatory") + } + + Map<String,ServiceInstance> relatedInstances = new HashMap<>() + + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, instanceId) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") + } + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + if(si.isPresent()) { + execution.setVariable(key, si.get()) + List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo.toLowerCase() == "service-instance") { + String relatioshipurl = relationship.getRelatedLink() + String serviceInstanceId = + relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) + uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, serviceInstanceId) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}") + } + AAIResultWrapper wrapper01 = client.get(uri, NotFoundException.class) + Optional<ServiceInstance> serviceInstance = wrapper01.asBean(ServiceInstance.class) + if (serviceInstance.isPresent()) { + ServiceInstance instance = serviceInstance.get() + if (role.equalsIgnoreCase(instance.getServiceRole())) { + relatedInstances.put(instance.getWorkloadContext(),instance) + } + } + } + } + } + logger.debug("Found ${relatedInstances.size()} ${role} related to ${instanceId} ") + return relatedInstances + } + + private ServiceInstance getInstanceByWorkloadContext(Map<String,ServiceInstance> instances,String workloadContext ) { + ServiceInstance instance = instances.get(workloadContext) + if(instance == null) { + throw new BpmnError( 2500, "${workloadContext} Instance ID is not found.") + } + return instance + } + + private String getInstanceIdByWorkloadContext(Map<String,ServiceInstance> instances,String workloadContext ) { + String instanceId = instances.get(workloadContext).getServiceInstanceId() + if(instanceId == null) { + throw new BpmnError( 2500, "${workloadContext} instance ID is not found.") + } + return instanceId + } + + + /** + * Method to handle deallocation of RAN NSSI constituents(TN_FH/TN_MH) + * @param execution + * @param serviceFunction - TN_FH/TN_MH + * @return + */ + private String buildTNActivateNssiRequest(DelegateExecution execution,String serviceFunction) { + logger.debug("${Prefix} Exit buildTNActivateNssiRequest : ${serviceFunction}") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + Map<String, ServiceInstance> relatedNssis = execution.getVariable("relatedNssis") + + String anNssiId = execution.getVariable("anNssiId") + List<String> sNssaiList = execution.getVariable("sNssaiList") + + ServiceInstance tnNssi = relatedNssis.get(serviceFunction) + String nssiId = tnNssi.getServiceInstanceId() + + Map<String, ServiceInstance> relatedSPs = execution.getVariable("relatedSPs") + + ActDeActNssi actDeactNssi = new ActDeActNssi() + actDeactNssi.setNssiId(nssiId) + actDeactNssi.setNsiId(anNssiId) + actDeactNssi.setSliceProfileId(relatedSPs.get(serviceFunction).getServiceInstanceId()) + actDeactNssi.setSnssaiList(sNssaiList) + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setVendor(VENDOR_ONAP) + esrInfo.setNetworkType("TN") + + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.setServiceInvariantUuid(tnNssi.getModelInvariantId()) + serviceInfo.setServiceUuid(tnNssi.getModelVersionId()) + serviceInfo.setGlobalSubscriberId(globalSubscriberId) + serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + + JsonObject json = new JsonObject() + json.addProperty("actDeActNssi", objectMapper.writeValueAsString(actDeactNssi)) + json.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + json.addProperty("serviceInfo", objectMapper.writeValueAsString(serviceInfo)) + return json.toString() + + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy new file mode 100644 index 0000000000..306c53a73c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy @@ -0,0 +1,685 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONObject +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.serviceinstancebeans.CloudConfiguration +import org.onap.so.serviceinstancebeans.LineOfBusiness +import org.onap.so.serviceinstancebeans.ModelInfo +import org.onap.so.serviceinstancebeans.ModelType +import org.onap.so.serviceinstancebeans.OwningEntity +import org.onap.so.serviceinstancebeans.Platform +import org.onap.so.serviceinstancebeans.Project +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.rest.catalog.beans.Vnf +import org.onap.so.serviceinstancebeans.RequestDetails +import org.onap.so.serviceinstancebeans.RequestInfo +import org.onap.so.serviceinstancebeans.RequestParameters +import org.onap.so.serviceinstancebeans.SubscriberInfo +import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.RelatedToProperty +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipData +import org.onap.aai.domain.yang.RelationshipList +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.v19.SliceProfile +import org.onap.aai.domain.yang.v19.SliceProfiles +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import com.fasterxml.jackson.databind.ObjectMapper + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { + String Prefix="DACTCNSSI_" + private static final Logger logger = LoggerFactory.getLogger(DoActivateCoreNSSI.class); + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + private RequestDBUtil requestDBUtil = new RequestDBUtil() + ExceptionUtil exceptionUtil = new ExceptionUtil() + ObjectMapper mapper = new ObjectMapper(); + + JsonUtils jsonUtil = new JsonUtils() + + private final Long TIMEOUT = 60 * 60 * 1000 + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: preProcessRequest ****") + + String operationType = execution.getVariable("operationType") + String oStatus= "" + + if(operationType.equals("activateInstance")) { + oStatus ="activated" + } else { + oStatus ="deactivated" + } + + execution.setVariable("oStatus", oStatus) + String sNssaiListAsString = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "snssaiList") + + logger.debug("sNssaiListAsString "+sNssaiListAsString) + + List<String> sNssaiList = jsonUtil.StringArrayToList(sNssaiListAsString) + + logger.debug("sNssaiList "+sNssaiList) + + + String sNssai = sNssaiList.get(0) + execution.setVariable("sNssai", sNssai) + + logger.debug("sNssai: "+sNssai) + + String serviceType = execution.getVariable("subscriptionServiceType") + execution.setVariable("serviceType", serviceType) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: preProcessRequest ****") + } + + public void getNetworkInstanceWithSPInstanceAssociatedWithNssiId(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getNetworkInstanceWithSPInstanceAssociatedWithNssiId ****") + //NSSI Id as service Instance Id to get from Request + String serviceInstanceId = execution.getVariable("serviceInstanceID") + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional<ServiceInstance> nsi = wrapper.asBean(ServiceInstance.class) + String networkServiceInstanceName = "" + String networkServiceInstanceId ="" + if(nsi.isPresent()) { + List<Relationship> relationshipList = nsi.get().getRelationshipList()?.getRelationship() + List spiWithsNssaiAndOrchStatusList = new ArrayList<>() + + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "service-instance") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + execution.setVariable("networkServiceInstanceId", relationshipData.getRelationshipValue()) + } + } + for (RelatedToProperty relatedToProperty : relatedToPropertyList) { + if (relatedToProperty.getPropertyKey() == "service-instance.service-instance-name") { + execution.setVariable("networkServiceInstanceName", relatedToProperty.getPropertyValue()) + } + } + } + + //If related to is allotted-Resource + if (relatedTo == "allotted-resource") { + //get slice Profile Instance Id from allotted resource in list by nssi + List<String> sliceProfileInstanceIdList = new ArrayList<>() + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + sliceProfileInstanceIdList.add(relationshipData.getRelationshipValue()) + } + } + for (String sliceProfileServiceInstanceId : sliceProfileInstanceIdList) { + String errorSliceProfileMsg = "Slice Profile Service Instance was not found in aai" + + //Query Slice Profile Service Instance From AAI by sliceProfileServiceInstanceId + AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) + Optional<ServiceInstance> sliceProfileServiceInstance = sliceProfileInstanceWrapper.asBean(ServiceInstance.class) + if (sliceProfileServiceInstance.isPresent()) { + String orchestrationStatus= sliceProfileServiceInstance.get().getOrchestrationStatus() + String sNssai = sliceProfileServiceInstance.get().getSliceProfiles().getSliceProfile().get(0).getSNssai() + if(sNssai.equals(execution.getVariable("sNssai"))) { + orchestrationStatus = execution.getVariable("oStatus") + //Slice Profile Service Instance to be updated in AAI + execution.setVariable("sliceProfileServiceInstance", sliceProfileServiceInstance) + } + + Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() + spiWithsNssaiAndOrchStatus.put("snssai", sNssai) + spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus) + spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus) + } + } + } + } + execution.setVariable("snssaiAndOrchStatusList", spiWithsNssaiAndOrchStatusList) + } + logger.debug("NSSI Id: ${serviceInstanceId}, network Service Instance Id: ${networkServiceInstanceId}, serviceName: ${networkServiceInstanceName}") + //Get ServiceInstance Relationships + getServiceInstanceRelationships(execution) + //Get Vnf Relationships + getVnfRelationships(execution) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getNetworkInstanceWithSPInstanceAssociatedWithNssiId ****") + } + + + private String prepareVnfInstanceParamsJson(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareVnfInstanceParamsJson ****") + List instanceParamsvalues = execution.getVariable("snssaiAndOrchStatusList") + Map<String, Object> nSsai= new LinkedHashMap<>() + nSsai.put("sNssai", instanceParamsvalues) + String supportedsNssaiJson = mapper.writeValueAsString(nSsai) + //SupportedNssai + Map<String, Object> supportedNssai= new LinkedHashMap<>() + supportedNssai.put("supportedNssai", supportedsNssaiJson) + logger.debug("**** supportedsNssaiJson**** "+supportedNssai) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareVnfInstanceParamsJson ****") + return supportedNssai + } + + private void getServiceInstanceRelationships(DelegateExecution execution) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getServiceInstanceRelationships ****") + String serviceInstanceId = execution.getVariable("networkServiceInstanceId") + logger.debug("**** serviceInstanceId :: getServiceInstanceRelationships :: "+serviceInstanceId) + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + + String networkServiceModelInvariantUuid = si.get().getModelInvariantId() + execution.setVariable("networkServiceModelInvariantUuid", networkServiceModelInvariantUuid) + if(si.isPresent()) { + List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "owning-entity") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "owning-entity.owning-entity-id") { + execution.setVariable("owningEntityId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "generic-vnf") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() + + //Get VnfId + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "generic-vnf.vnf-id") { + execution.setVariable("vnfId", relationshipData.getRelationshipValue()) + String vnfId = relationshipData.getRelationshipValue() + logger.debug("vnfId :"+vnfId) + } + } + } else if (relatedTo == "project") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "project.project-name") { + execution.setVariable("projectName", relationshipData.getRelationshipValue()) + } + } + } + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getServiceInstanceRelationships ****") + } + } + + private void getVnfRelationships(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getVnfRelationships ****") + String msg = "query Generic Vnf from AAI failed" + try { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + if (!getAAIClient().exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + AAIResultWrapper wrapper = getAAIClient().get(uri, NotFoundException.class) + Optional<GenericVnf> vnf = wrapper.asBean(GenericVnf.class) + if(vnf.isPresent()) { + List<Relationship> relationshipList = vnf.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "tenant") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "tenant.tenant-id") { + execution.setVariable("tenantId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "cloud-region") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "cloud-region.cloud-owner") { + execution.setVariable("cloudOwner", relationshipData.getRelationshipValue()) + } else if (relationshipData.getRelationshipKey() == "cloud-region.cloud-region-id") { + execution.setVariable("lcpCloudRegionId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "platform") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "platform.platform-name") { + execution.setVariable("platformName", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "line-of-business") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "line-of-business.line-of-business-name") { + execution.setVariable("lineOfBusinessName", relationshipData.getRelationshipValue()) + } + } + } + } + } + } catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in getVnfRelationships " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getVnfRelationships ****") + } + + + /** + * query AAI + * @param execution + * @param aaiObjectType + * @param instanceId + * @return AAIResultWrapper + */ + private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) { + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: queryAAI ****") + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) + if (!getAAIClient().exists(resourceUri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) + } + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: queryAAI ****") + return wrapper + } + + public void getServiceVNFAndVFsFromCatalogDB(DelegateExecution execution) { + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getServiceVNFAndVFsFromCatalogDB ****") + + String modelInvariantUuid = execution.getVariable("networkServiceModelInvariantUuid") + + try{ + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, modelInvariantUuid) + logger.debug("***** JSON IS: "+json) + + String serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: "" + String serviceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.modelInfo") ?: "" + + + execution.setVariable("serviceVnfs",serviceVnfs) + execution.setVariable("serviceModelInfo", serviceModelInfo) + logger.debug(Prefix +" ***** serviceVnfs is: "+ serviceVnfs) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + String msg = "Exception in getServiceVNFAndVFsFromCatalogDB " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: getServiceVNFAndVFsFromCatalogDB ****") + } + + public void prepareSOMacroRequestPayLoad(DelegateExecution execution) { + logger.debug("**** Enter DoActivateCoreNSSI ::: prepareSOMacroRequestPayLoad ****") + String json = execution.getVariable("serviceVnfs") + logger.debug(">>>> json "+json) + List<Object> vnfList = mapper.readValue(json, List.class); + logger.debug("vnfList: "+vnfList) + Map<String,Object> serviceMap = mapper.readValue(execution.getVariable("serviceModelInfo"), Map.class); + ModelInfo serviceModelInfo = new ModelInfo() + serviceModelInfo.setModelType(ModelType.service) + serviceModelInfo.setModelInvariantId(serviceMap.get("modelInvariantUuid")) + serviceModelInfo.setModelVersionId(serviceMap.get("modelUuid")) + serviceModelInfo.setModelName(serviceMap.get("modelName")) + serviceModelInfo.setModelVersion(serviceMap.get("modelVersion")) + + logger.debug("serviceModelInfo: "+serviceModelInfo) + //List of Vnfs + List<Object> vnfModelInfoList = new ArrayList<>() + + Map vnfMap = vnfList.get(0) + ModelInfo vnfModelInfo = vnfMap.get("modelInfo") + logger.debug("vnfModelInfo "+vnfModelInfo) + + //List of VFModules + List<Map<String, Object>> vfModuleList = vnfMap.get("vfModules") + logger.debug("vfModuleList "+vfModuleList) + + //List of VfModules + List<ModelInfo> vfModelInfoList = new ArrayList<>() + + //Traverse VFModules List and add in vfModelInfoList + for (vfModule in vfModuleList) { + ModelInfo vfModelInfo = vfModule.get("modelInfo") + logger.debug("vfModelInfo "+vfModelInfo) + vfModelInfoList.add(vfModelInfo) + } + + //RequestInfo + RequestInfo requestInfo = new RequestInfo() + + //Dummy Product FamilyId + requestInfo.setProductFamilyId("test1234") + requestInfo.setSource("VID") + requestInfo.setInstanceName(execution.getVariable("networkServiceInstanceName")) + requestInfo.setSuppressRollback(false) + requestInfo.setRequestorId("NBI") + + //Service Level InstanceParams + List<Map<String, Object>> serviceParams = new ArrayList<>() + Map<String, Object> serviceParamsValues = new LinkedHashMap<>() + serviceParams.add(serviceParamsValues) + + //Cloud Configuration + CloudConfiguration cloudConfiguration = new CloudConfiguration() + cloudConfiguration.setLcpCloudRegionId(execution.getVariable("lcpCloudRegionId")) + cloudConfiguration.setTenantId(execution.getVariable("tenantId")) + cloudConfiguration.setCloudOwner(execution.getVariable("cloudOwner")) + + //VFModules List + List<Map<String, Object>> vfModules = new ArrayList<>() + for (ModelInfo vfModuleModelInfo : vfModelInfoList) { + //Individual VFModule List + Map<String, Object> vfModuleValues = new LinkedHashMap<>() + vfModuleValues.put("modelInfo", vfModuleModelInfo) + vfModuleValues.put("instanceName", vfModuleModelInfo.getModelInstanceName()) + + //VFModule InstanceParams should be empty or this field should not be there? + List<Map<String, Object>> vfModuleInstanceParams = new ArrayList<>() + vfModuleValues.put("instanceParams", vfModuleInstanceParams) + } + + //Vnf intsanceParams + ObjectMapper objectMapper = new ObjectMapper(); + Map<String, Object> sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class); + + List vnfInstanceParamsList = new ArrayList<>() + String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution) + vnfInstanceParamsList.add(supportedsNssaiJson) + + Platform platform = new Platform() + platform.setPlatformName(execution.getVariable("platform")) + + LineOfBusiness lineOfbusiness = new LineOfBusiness() + lineOfbusiness.setLineOfBusinessName(execution.getVariable("lineOfBusiness")) + + //Vnf Values + Map<String, Object> vnfValues = new LinkedHashMap<>() + vnfValues.put("lineOfBusiness", lineOfbusiness) + vnfValues.put("platform", platform) + vnfValues.put("productFamilyId", "test1234") + vnfValues.put("cloudConfiguration", cloudConfiguration) + vnfValues.put("vfModules", vfModules) + vnfValues.put("modelInfo", vnfModelInfo) + vnfValues.put("instanceName", execution.getVariable("vnfInstanceName")) + vnfValues.put("instanceParams",vnfInstanceParamsList) + + vnfModelInfoList.add(vnfValues) + //Service Level Resources + Map<String, Object> serviceResources = new LinkedHashMap<>() + serviceResources.put("vnfs", vnfModelInfoList) + + //Service Values + Map<String, Object> serviceValues = new LinkedHashMap<>() + serviceValues.put("modelInfo", serviceModelInfo) + serviceValues.put("instanceName", execution.getVariable("networkServiceInstanceName")) + serviceValues.put("resources", serviceResources) + serviceValues.put("instanceParams", serviceParams) + + //UserParams Values + Map<String, Object> userParamsValues = new LinkedHashMap<>() + + Map<String, Object> homingSolution = new LinkedHashMap<>() + homingSolution.put("Homing_Solution", "none") + + userParamsValues.put("service", serviceValues) + + //UserParams + List<Map<String, Object>> userParams = new ArrayList<>() + userParams.add(homingSolution) + userParams.add(userParamsValues) + + //Request Parameters + RequestParameters requestParameters = new RequestParameters() + requestParameters.setaLaCarte(false) + requestParameters.setSubscriptionServiceType(execution.getVariable("serviceType")) + requestParameters.setUserParams(userParams) + + //SubscriberInfo + SubscriberInfo subscriberInfo = new SubscriberInfo() + subscriberInfo.setGlobalSubscriberId(execution.getVariable("globalSubscriberId")) + + //Owning Entity + OwningEntity owningEntity = new OwningEntity() + owningEntity.setOwningEntityId(execution.getVariable("owningEntityId")) + + //Project + Project project = new Project() + project.setProjectName(execution.getVariable("projectName")) + + RequestDetails requestDetails = new RequestDetails() + requestDetails.setModelInfo(serviceModelInfo) + requestDetails.setSubscriberInfo(subscriberInfo) + requestDetails.setRequestInfo(requestInfo) + requestDetails.setRequestParameters(requestParameters) + requestDetails.setCloudConfiguration(cloudConfiguration) + requestDetails.setOwningEntity(owningEntity) + requestDetails.setProject(project) + + Map<String, Object> requestDetailsMap = new LinkedHashMap<>() + requestDetailsMap.put("requestDetails", requestDetails) + String requestPayload = objectMapper.writeValueAsString(requestDetailsMap) + + logger.debug("requestDetails "+requestPayload) + execution.setVariable("requestPayload", requestPayload) + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareSOMacroRequestPayLoad ****") + } + + public void sendPutRequestToSOMacro(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: sendPutRequestToSOMacro ****") + try { + String msoEndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) + String url = msoEndpoint+"/serviceInstantiation/v7/serviceInstances/"+execution.getVariable("networkServiceInstanceId")+"/vnfs/"+execution.getVariable("vnfId") + String requestBody = execution.getVariable("requestPayload") + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuthValue = utils.encrypt(basicAuth, msoKey) + String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) + + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) + httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Accept", "application/json") + Response httpResponse = httpClient.put(requestBody) + handleSOResponse(httpResponse, execution) + + } catch (BpmnError e) { + throw e + } catch (any) { + String msg = "Exception in DoActivateCoreNSSSI " + any.getCause() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: sendPostRequestToSOMacro ****") + } + + /** + * Handle SO Response for PUT and prepare update operation status + * @param execution + */ + private void handleSOResponse(Response httpResponse, DelegateExecution execution){ + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: handleSOResponse ****") + + int soResponseCode = httpResponse.getStatus() + logger.debug("soResponseCode : "+soResponseCode) + + if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { + String soResponse = httpResponse.readEntity(String.class) + String operationId = execution.getVariable("operationId") + def macroOperationId = jsonUtil.getJsonValue(soResponse, "operationId") + execution.setVariable("macroOperationId", macroOperationId) + execution.setVariable("isSOTimeOut", "no") + execution.setVariable("isSOResponseSucceed","yes") + } + else + { + String serviceName = execution.getVariable("serviceInstanceName") + execution.setVariable("isSOResponseSucceed","no") + prepareFailedOperationStatusUpdate(execution) + } + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: handleSOResponse ****") + } + + /** + * prepare to call sub process CheckProcessStatus + * @param execution + */ + void prepareCallCheckProcessStatus(DelegateExecution execution){ + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareCallCheckProcessStatus ****") + def successConditions = new ArrayList<>() + successConditions.add("finished") + execution.setVariable("successConditions", successConditions) + def errorConditions = new ArrayList<>() + errorConditions.add("error") + execution.setVariable("errorConditions", errorConditions) + execution.setVariable("processServiceType", "Network service") + execution.setVariable("subOperationType", "PUT") + execution.setVariable("initProgress", 20) + execution.setVariable("endProgress",90) + execution.setVariable("timeOut", TIMEOUT) + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareCallCheckProcessStatus ****") + } + + void prepareUpdateResourceOperationStatus(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareUpdateResourceOperationStatus ****") + + String nssiOperationId = execution.getVariable("nssiOperationId") + execution.setVariable("operationId", nssiOperationId) + //Prepare Update Status for PUT failure and success + if(execution.getVariable("isTimeOut").equals("YES")) { + logger.debug("TIMEOUT - SO PUT Failure") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") + } + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareUpdateResourceOperationStatus ****") + } + + void updateSliceProfileOrchestrationStatus(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: updateSliceProfileOrchestrationStatus ****") + + String globalCustId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String oStatus = execution.getVariable("oStatus") + + ServiceInstance si = execution.getVariable("sliceProfileServiceInstance") + String sliceProfileInstanceId = si.getServiceInstanceId() + si.setOrchestrationStatus(oStatus) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustId, serviceType, sliceProfileInstanceId) + try { + + Response response = getAAIClient().update(uri, si) + + if(response.getStatus()!=200 || response.getStatus()!=201 || response.getStatus()!=202) { + exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI failed to update sliceProlie service Instance orchestration status") + } else { + setResourceOperationStatus(execution) + } + } catch (Exception e) { + logger.info("Update OrchestrationStatus in AAI failed") + String msg = "Update OrchestrationStatus in AAI failed, " + e.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: updateSliceProfileOrchestrationStatus ****") + } + + /** + * prepare ResourceOperation status + * @param execution + * @param operationType + */ + private void setResourceOperationStatus(DelegateExecution execution) { + + logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: setResourceOperationStatus ****") + + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setStatus("finished") + resourceOperationStatus.setProgress("100") + resourceOperationStatus.setStatusDescription("Core Activation Successful") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + + logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: setResourceOperationStatus ****") + } + + void prepareFailedOperationStatusUpdate(DelegateExecution execution){ + logger.debug(Prefix + " **** Enter DoActivateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setProgress(0) + resourceOperationStatus.setStatus("failed") + resourceOperationStatus.setStatusDescription("Core NSSI Activation Failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + + logger.debug(Prefix + " **** Exit DoActivateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + } + +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy new file mode 100644 index 0000000000..04fe161295 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import groovy.json.JsonSlurper +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +public class DoActivateTnNssi extends AbstractServiceTaskProcessor { + String Prefix = "TNACT_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() + JsonSlurper jsonSlurper = new JsonSlurper() + ObjectMapper objectMapper = new ObjectMapper() + private static final Logger logger = LoggerFactory.getLogger(DoActivateTnNssi.class) + + + public void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + + execution.setVariable("startTime", System.currentTimeMillis()) + String msg = tnNssmfUtils.getExecutionInputParams(execution) + logger.debug("Activate TN NSSI input parameters: " + msg) + + execution.setVariable("prefix", Prefix) + + tnNssmfUtils.setSdncCallbackUrl(execution, true) + logger.debug("SDNC Callback URL: " + execution.getVariable("sdncCallbackUrl")) + + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + //here modelVersion is not set, we use modelUuid to decompose the service. + def isDebugLogEnabled = true + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + + String sliceServiceInstanceId = execution.getVariable("serviceInstanceID") + execution.setVariable("sliceServiceInstanceId", sliceServiceInstanceId) + + String sliceServiceInstanceName = execution.getVariable("servicename") + execution.setVariable("sliceServiceInstanceName", sliceServiceInstanceName) + + String operationType = execution.getVariable("operationType") + String actionType = operationType.equals("activateInstance") ? "activate" : "deactivate" + execution.setVariable("actionType", actionType) + + + logger.debug("Finish preProcessRequest") + } + + void preprocessSdncActOrDeactTnNssiRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preprocessSdncActivateTnNssiRequest(' + + 'execution=' + execution.getId() + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + + try { + String serviceInstanceId = execution.getVariable("sliceServiceInstanceId") + String actionType = execution.getVariable("actionType") + + String sdncRequest = tnNssmfUtils.buildSDNCRequest(execution, serviceInstanceId, actionType) + + execution.setVariable("TNNSSMF_SDNCRequest", sdncRequest) + logger.debug("Outgoing SDNCRequest is: \n" + sdncRequest) + + } catch (Exception e) { + logger.debug("Exception Occured Processing preprocessSdncDeallocateTnNssiRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preprocessSdncActivateTnNssiRequest Process") + } + + + void validateSDNCResponse(DelegateExecution execution, String response) { + tnNssmfUtils.validateSDNCResponse(execution, response, method) + } + + + void updateAAIOrchStatus(DelegateExecution execution) { + logger.debug("Start updateAAIOrchStatus") + String tnNssiId = execution.getVariable("tnNssiId") + String orchStatus = execution.getVariable("orchestrationStatus") + + try { + ServiceInstance si = new ServiceInstance() + si.setOrchestrationStatus(orchStatus) + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, tnNssiId) + client.update(uri, si) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Finish updateAAIOrchStatus") + } + + void prepareUpdateJobStatus(DelegateExecution execution, + String status, + String progress, + String statusDescription) { + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operType = execution.getVariable("actionType") + + + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setServiceId(serviceId) + roStatus.setOperationId(jobId) + roStatus.setResourceTemplateUUID(nsiId) + roStatus.setOperType(operType) + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + } + +} + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy new file mode 100644 index 0000000000..3df0d3d6f0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy @@ -0,0 +1,1041 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import java.sql.Timestamp +import java.util.List +import static org.apache.commons.lang3.StringUtils.isBlank +import com.google.gson.JsonObject +import com.fasterxml.jackson.databind.ObjectMapper +import com.google.gson.JsonArray +import org.onap.aai.domain.yang.Relationship +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.so.beans.nsmf.AllocateTnNssi +import org.onap.so.beans.nsmf.EsrInfo +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInstance +import org.onap.so.bpmn.core.domain.ServiceProxy +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.AAINamespaceConstants +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.NetworkRoute + +class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { + + String Prefix="AASS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + OofUtils oofUtils = new OofUtils() + AnNssmfUtils anNssmfUtils = new AnNssmfUtils() + ObjectMapper objectMapper = new ObjectMapper(); + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + private static final Logger logger = LoggerFactory.getLogger(DoAllocateAccessNSSI.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + + logger.debug("input variables : msoRequestId - "+execution.getVariable("msoRequestId") + +" modelInvariantUuid - "+execution.getVariable("modelInvariantUuid")+ + " modelUuid - "+execution.getVariable("modelUuid")+ + " globalSubscriberId - "+execution.getVariable("globalSubscriberId")+ + " dummyServiceId - "+ execution.getVariable("dummyServiceId")+ + " nsiId - "+execution.getVariable("nsiId")+ + " networkType - "+execution.getVariable("networkType")+ + " subscriptionServiceType - "+execution.getVariable("subscriptionServiceType")+ + " jobId - "+execution.getVariable("jobId")+ + " sliceParams - "+execution.getVariable("sliceParams")+ + " servicename - "+ execution.getVariable("servicename")) + + //validate slice subnet inputs + + String sliceParams = execution.getVariable("sliceParams") + String sliceProfile = jsonUtil.getJsonValue(sliceParams, "sliceProfile") + if (isBlank(sliceProfile)) { + msg = "Input sliceProfile is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("sliceProfile", sliceProfile) + } + String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId") + def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList")) + def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "plmnIdList")) + def coverageAreaTAList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList")) + + if (isBlank(sliceProfileId) || (snssaiList.empty) || (plmnIdList.empty) + || (coverageAreaTAList.empty)) { + + msg = "Mandatory slice profile fields are empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("sliceProfileId", sliceProfileId) + execution.setVariable("snssaiList", snssaiList) + execution.setVariable("plmnIdList", plmnIdList) + execution.setVariable("coverageAreaTAList", coverageAreaTAList) + } + String nsiName = jsonUtil.getJsonValue(sliceParams, "nsiInfo.nsiName") + String scriptName = jsonUtil.getJsonValue(sliceParams, "scriptName") + execution.setVariable("nsiName", nsiName) + execution.setVariable("scriptName", scriptName) + //generate RAN,RAN NF NSSIs - will be re assigned if oof returns existing NSSI + String RANServiceInstanceId = UUID.randomUUID().toString() + String RANNFServiceInstanceId = UUID.randomUUID().toString() + logger.debug("RAN serviceInstance Id "+RANServiceInstanceId) + logger.debug("RAN NF serviceInstance Id "+RANNFServiceInstanceId) + execution.setVariable("RANServiceInstanceId", RANServiceInstanceId) + execution.setVariable("RANNFServiceInstanceId", RANNFServiceInstanceId) + execution.setVariable("ranNssiPreferReuse", true) + execution.setVariable("ranNfNssiPreferReuse", true) + execution.setVariable("job_timeout", 10) + + //set BH end point + List<String> BH_endPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints")) + logger.debug("BH end points list : "+BH_endPoints) + if(BH_endPoints.empty) { + msg = "End point info is empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + }else { + execution.setVariable("bh_endpoint", BH_endPoints.get(0)) + } + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in DoAllocateAccessNSSI.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + /* + * Prepare request params for decomposing RAN NSST + */ + + def prepareDecomposeService = { DelegateExecution execution -> + logger.debug(Prefix+"prepareDecomposeService method start") + String RANServiceInstanceId = execution.getVariable("RANServiceInstanceId") + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + execution.setVariable("serviceInstanceId", RANServiceInstanceId) + logger.debug("serviceModelInfo : "+serviceModelInfo) + logger.debug("Finish RAN NSST prepareDecomposeService") + } + + /* process the decompose service(RAN NSST) response + * + */ + def processDecomposition = { DelegateExecution execution -> + logger.debug(Prefix+"processDecomposition method start") + ServiceDecomposition ranNsstServiceDecomposition = execution.getVariable("ranNsstServiceDecomposition") + logger.debug("ranNsstServiceDecomposition : "+ranNsstServiceDecomposition.toString()) + //RAN NSST decomposition + String ranModelVersion = ranNsstServiceDecomposition.getModelInfo().getModelVersion() + String ranModelName = ranNsstServiceDecomposition.getModelInfo().getModelName() + List<ServiceProxy> serviceProxyList = ranNsstServiceDecomposition.getServiceProxy() + List<String> nsstInfoList = new ArrayList<>() + for(ServiceProxy serviceProxy : serviceProxyList) + { + String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid() + String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid() + String name = serviceProxy.getModelInfo().getModelName() + String nsstServiceModelInfo = """{ + "UUID":"${nsstModelUuid}", + "invariantUUID":"${nsstModelInvariantUuid}", + "name":"${name}" + }""" + nsstInfoList.add(nsstServiceModelInfo) + } + int currentIndex=0 + int maxIndex=nsstInfoList.size() + if(maxIndex < 1) + { + String msg = "Exception in RAN NSST processDecomposition. There is no NSST associated with RAN NSST " + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + execution.setVariable("ranNsstInfoList",nsstInfoList) + execution.setVariable("ranModelVersion", ranModelVersion) + execution.setVariable("ranModelName", ranModelName) + execution.setVariable("currentIndex",currentIndex) + execution.setVariable("maxIndex",maxIndex) + logger.debug(Prefix+"processDecomposition maxIndex value - "+maxIndex) + } + + /* + * Function to subnet capabilities from nssmf adapter + */ + def getSubnetCapabilities = { DelegateExecution execution -> + logger.debug(Prefix+"getSubnetCapabilities method start") + + String tnNssmfRequest = anNssmfUtils.buildCreateTNNSSMFSubnetCapabilityRequest() + + String urlString = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery" + + String tnNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, tnNssmfRequest) + + if (tnNssmfResponse != null) { + String FHCapabilities= jsonUtil.getJsonValue(tnNssmfResponse, "TN_FH") + String MHCapabilities = jsonUtil.getJsonValue(tnNssmfResponse, "TN_MH") + execution.setVariable("FHCapabilities",FHCapabilities) + execution.setVariable("MHCapabilities",MHCapabilities) + + } else { + logger.error("received error message from NSSMF : "+ tnNssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + String anNssmfRequest = anNssmfUtils.buildCreateANNFNSSMFSubnetCapabilityRequest() + + String anNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, anNssmfRequest) + + if (anNssmfResponse != null) { + String ANNFCapabilities = jsonUtil.getJsonValue(anNssmfResponse, "AN_NF") + execution.setVariable("ANNFCapabilities",ANNFCapabilities) + + } else { + logger.error("received error message from NSSMF : "+ anNssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + } + + /* + * prepare OOF request for RAN NSSI selection + */ + def prepareOofRequestForRanNSS = { DelegateExecution execution -> + logger.debug(Prefix+"prepareOofRequestForRanNSS method start") + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSSI option OOF Url: " + urlString) + + //build oof request body + boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse"); + String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) + String modelUuid = execution.getVariable("modelUuid") + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelName = execution.getVariable("ranModelName") + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("nsstInfoList"), List.class) + JsonArray capabilitiesList = new JsonArray() + String FHCapabilities = execution.getVariable("FHCapabilities") + String MHCapabilities = execution.getVariable("MHCapabilities") + String ANNFCapabilities = execution.getVariable("ANNFCapabilities") + JsonObject FH = new JsonObject() + JsonObject MH = new JsonObject() + JsonObject ANNF = new JsonObject() + FH.addProperty("domainType", "TN_FH") + FH.addProperty("capabilityDetails", FHCapabilities) + MH.addProperty("domainType", "TN_MH") + MH.addProperty("capabilityDetails", MHCapabilities) + ANNF.addProperty("domainType", "AN_NF") + ANNF.addProperty("capabilityDetails", FHCapabilities) + capabilitiesList.add(FH) + capabilitiesList.add(MH) + capabilitiesList.add(ANNF) + + execution.setVariable("nssiSelection_Url", "/api/oof/selection/nsi/v1") + execution.setVariable("nssiSelection_messageType",messageType) + execution.setVariable("nssiSelection_correlator",requestId) + execution.setVariable("nssiSelection_timeout",timeout) + + String oofRequest = anNssmfUtils.buildSelectRANNSSIRequest(requestId, messageType, modelUuid,modelInvariantUuid, + modelName, profileInfo, nsstInfoList, capabilitiesList, ranNssiPreferReuse) + + execution.setVariable("nssiSelection_oofRequest",oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) + } + /* + * process OOF response for RAN NSSI selection + */ + def processOofResponseForRanNSS = { DelegateExecution execution -> + logger.debug(Prefix+"processOofResponseForRanNSS method start") + String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse") + String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") + if(requestStatus.equals("completed")) { + List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions")) + boolean existingNSI = jsonUtil.getJsonValue(solution.get(0), "existingNSI") + if(existingNSI) { + def sharedNSISolution = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution") + execution.setVariable("sharedRanNSSISolution", sharedNSISolution) + logger.debug("sharedRanNSSISolution from OOF "+sharedNSISolution) + String RANServiceInstanceId = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution.NSIId") + execution.setVariable("RANServiceInstanceId", RANServiceInstanceId) + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setInstanceId(RANServiceInstanceId); + ServiceDecomposition serviceDecomposition = execution.getVariable("ranNsstServiceDecomposition") + serviceDecomposition.setServiceInstance(serviceInstance); + execution.setVariable("ranNsstServiceDecomposition", serviceDecomposition) + execution.setVariable("isRspRanNssi", true) + }else { + def sliceProfiles = jsonUtil.getJsonValue(solution.get(0), "newNSISolution.sliceProfiles") + execution.setVariable("RanConstituentSliceProfiles", sliceProfiles) + logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles) + } + }else { + String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage") + logger.error("received failed status from oof "+ statusMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage) + } + + } + + def prepareModifyAccessNssiInputs = { DelegateExecution execution -> + logger.debug(Prefix+"prepareModifyAccessNssiInputs method start") + String jobId = UUID.randomUUID().toString() + execution.setVariable("modifyRanNssiJobId", jobId) + String snssaiList = execution.getVariable("snssaiList") + String sliceParams = execution.getVariable("sliceParams") + String sliceProfileId = execution.getVariable("sliceProfileId") + String nsiInfo = jsonUtil.getJsonValue(sliceParams, "nsiInfo") + String scriptName = execution.getVariable("scriptName") + + JsonObject modifySliceParams = new JsonObject() + modifySliceParams.addProperty("modifyAction", "allocate") + modifySliceParams.addProperty("snssaiList", snssaiList) + modifySliceParams.addProperty("sliceProfileId", sliceProfileId) + modifySliceParams.addProperty("nsiInfo", nsiInfo) + modifySliceParams.addProperty("scriptName", scriptName) + + execution.setVariable("modifySliceParams", modifySliceParams.toString()) + //create operation status in request db + String serviceId = execution.getVariable("RANServiceInstanceId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Modify") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + } + + def createModifyNssiQueryJobStatus = { DelegateExecution execution -> + logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType("AN") + esrInfo.setVendor("ONAP") + String esrInfoString = objectMapper.writeValueAsString(esrInfo) + execution.setVariable("esrInfo", esrInfoString) + JsonObject serviceInfo = new JsonObject() + serviceInfo.addProperty("nssiId", execution.getVariable("RANServiceInstanceId")) + serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) + serviceInfo.addProperty("nssiName", execution.getVariable("servicename")) + String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") + serviceInfo.addProperty("sST", sST) + serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList"))) + serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) + serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid")) + serviceInfo.addProperty("serviceUuid", execution.getVariable("modelUuid")) + execution.setVariable("serviceInfo", serviceInfo.toString()) + execution.setVariable("responseId", "") + } + def prepareNsstDecomposeService = { DelegateExecution execution -> + logger.debug(Prefix+"prepareNsstDecomposeService method start") + List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class) + int currentIndex = execution.getVariable("currentIndex") + int maxIndex = execution.getVariable("maxIndex") + logger.debug(Prefix+"prepareNsstDecomposeService : currentIndex value - "+currentIndex+" maxIndex : "+maxIndex) + if(currentIndex<maxIndex) { + String nsstInfo = nsstInfoList.get(currentIndex) + String modelInvariantUuid = jsonUtil.getJsonValue(nsstInfo, "invariantUUID") + String modelUuid = jsonUtil.getJsonValue(nsstInfo, "UUID") + + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + execution.setVariable("serviceInstanceId", "") + logger.debug("serviceModelInfo : "+serviceModelInfo) + currentIndex++ + execution.setVariable("currentIndex", currentIndex) + }else { + logger.error("nsstList decomposition error ") + exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "nsstList decomposition error ") + } + + } + def processNsstDecomposition = { DelegateExecution execution -> + logger.debug(Prefix+"processNsstDecomposition method start") + ServiceDecomposition decomposedNsst = execution.getVariable("nsstServiceDecomposition") + logger.debug("decomposedNsst : "+decomposedNsst.toString()) + + String nsstType = decomposedNsst.getServiceRole() //domainType + String modelVersion = decomposedNsst.getModelInfo().getModelVersion() + String modelName = decomposedNsst.getModelInfo().getModelName() + String modelUuid = decomposedNsst.getModelInfo().getModelUuid() + String modelInvariantUuid = decomposedNsst.getModelInfo().getModelInvariantUuid() + + switch(nsstType) { + case "AN_NF": + execution.setVariable("ANNF_modelInvariantUuid", modelInvariantUuid) + execution.setVariable("ANNF_modelUuid", modelUuid) + execution.setVariable("ANNF_modelVersion", modelVersion) + execution.setVariable("ANNF_modelName", modelName) + execution.setVariable("ANNF_ServiceDecomposition", decomposedNsst) + break + case "TN_FH": + execution.setVariable("TNFH_modelInvariantUuid", modelInvariantUuid) + execution.setVariable("TNFH_modelUuid", modelUuid) + execution.setVariable("TNFH_modelVersion", modelVersion) + execution.setVariable("TNFH_modelName", modelName) + execution.setVariable("TNFH_ServiceDecomposition", decomposedNsst) + break + case "TN_MH": + execution.setVariable("TNMH_modelInvariantUuid", modelInvariantUuid) + execution.setVariable("TNMH_modelUuid", modelUuid) + execution.setVariable("TNMH_modelVersion", modelVersion) + execution.setVariable("TNMH_modelName", modelName) + execution.setVariable("TNMH_ServiceDecomposition", decomposedNsst) + break + default: + logger.debug("No expected match found for current nsstType") + logger.error("No expected match found for current nsstType "+ nsstType) + exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current nsstType "+ nsstType) + } + boolean isAllNsstsDecomposed = false + int currentIndex = execution.getVariable("currentIndex") + int maxIndex = execution.getVariable("maxIndex") + if(currentIndex == maxIndex) { + isAllNsstsDecomposed = true + } + execution.setVariable("isAllNsstsDecomposed", isAllNsstsDecomposed) + } + /* + * prepare OOF request for NF RAN NSSI selection + */ + def prepareOofRequestForRanNfNSS = { DelegateExecution execution -> + logger.debug(Prefix+"prepareOofRequestForRanNfNSS method start") + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSSI option OOF Url: " + urlString) + + //build oof request body + boolean ranNfNssiPreferReuse = execution.getVariable("ranNfNssiPreferReuse"); + String requestId = execution.getVariable("msoRequestId") + String messageType = "NSSISelectionResponse" + List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(execution.getVariable("RanConstituentSliceProfiles")) + anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution) + Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class) + String modelUuid = execution.getVariable("ANNF_modelUuid") + String modelInvariantUuid = execution.getVariable("ANNF_modelInvariantUuid") + String modelName = execution.getVariable("ANNF_modelName") + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + + execution.setVariable("nssiSelection_Url", "/api/oof/selection/nssi/v1") + execution.setVariable("nssiSelection_messageType",messageType) + execution.setVariable("nssiSelection_correlator",requestId) + execution.setVariable("nssiSelection_timeout",timeout) + + String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, modelUuid, modelInvariantUuid, modelName, profileInfo) + + execution.setVariable("nssiSelection_oofRequest",oofRequest) + } + /* + * process OOF response for RAN NF NSSI selection + */ + def processOofResponseForRanNfNSS = { DelegateExecution execution -> + logger.debug(Prefix+"processOofResponseForRanNfNSS method start") + String oofResponse = execution.getVariable("nfNssiSelection_asyncCallbackResponse") + String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") + if(requestStatus.equals("completed")) { + List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions")) + if(solution.size()>=1) { + String ranNfNssiId = jsonUtil.getJsonValue(solution.get(0), "NSSIId") + String invariantUuid = jsonUtil.getJsonValue(solution.get(0), "invariantUUID") + String uuid = jsonUtil.getJsonValue(solution.get(0), "UUID") + String nssiName = jsonUtil.getJsonValue(solution.get(0), "NSSIName") + execution.setVariable("RANNFServiceInstanceId", ranNfNssiId) + execution.setVariable("RANNFInvariantUUID", invariantUuid) + execution.setVariable("RANNFUUID", uuid) + execution.setVariable("RANNFNssiName", nssiName) + logger.debug("RANNFServiceInstanceId from OOF "+ranNfNssiId) + + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setInstanceId(ranNfNssiId); + ServiceDecomposition serviceDecomposition = execution.getVariable("ANNF_ServiceDecomposition") + serviceDecomposition.setServiceInstance(serviceInstance); + execution.setVariable("ANNF_ServiceDecomposition", serviceDecomposition) + execution.setVariable("isRspRanNfNssi", true) + }else { + logger.debug("No solutions returned from OOF .. Create new RAN NF NSSI") + } + }else { + String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage") + logger.error("received failed status from oof "+ statusMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage) + } + } + + def createSliceProfilesInAai = { DelegateExecution execution -> + logger.debug(Prefix+"createSliceProfilesInAai method start") + anNssmfUtils.createSliceProfilesInAai(execution) + } + + def processRanNfModifyRsp = { DelegateExecution execution -> + logger.debug(Prefix+"processRanNfModifyRsp method start") + anNssmfUtils.processRanNfModifyRsp(execution) + //create RAN NSSI + org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance(); + //AN instance creation + ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId")) + String sliceInstanceName = execution.getVariable("servicename") + ANServiceInstance.setServiceInstanceName(sliceInstanceName) + String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") + ANServiceInstance.setServiceType(serviceType) + String serviceStatus = "deactivated" + ANServiceInstance.setOrchestrationStatus(serviceStatus) + String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList") + ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + String serviceRole = "nssi" + ANServiceInstance.setServiceRole(serviceRole) + List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + String snssai = snssaiList.get(0) + ANServiceInstance.setEnvironmentContext(snssai) + ANServiceInstance.setWorkloadContext("AN") + + logger.debug("completed AN service instance build "+ ANServiceInstance.toString()) + String msg = "" + try { + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("RANServiceInstanceId")) + client.create(nssiServiceUri, ANServiceInstance) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + //end point update + createEndPointsInAai(execution) + } + + def createSdnrRequest = { DelegateExecution execution -> + logger.debug(Prefix+"createSdnrRequest method start") + String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId") + String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "InstantiateRANSlice", callbackUrl) + execution.setVariable("createNSSI_sdnrRequest", sdnrRequest) + execution.setVariable("createNSSI_timeout", "PT10M") + execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId")) + execution.setVariable("createNSSI_messageType", "AsyncSdnrResponse"); + } + + def processSdnrResponse = { DelegateExecution execution -> + logger.debug(Prefix+"processSdnrResponse method start") + String SDNRResponse = execution.getVariable("SDNR_asyncCallbackResponse") + String status = jsonUtil.getJsonValue(SDNRResponse, "status") + if(status.equalsIgnoreCase("success")) { + String nfIds = jsonUtil.getJsonValue(SDNRResponse, "nfIds") + execution.setVariable("ranNfIdsJson", nfIds) + }else { + String reason = jsonUtil.getJsonValue(SDNRResponse, "reason") + logger.error("received failed status from SDNR "+ reason) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from SDNR "+ reason) + } + logger.debug("response from SDNR "+SDNRResponse) + } + + def updateAaiWithRANInstances = { DelegateExecution execution -> + logger.debug(Prefix+"updateAaiWithRANInstances method start") + //create RAN NSSI + org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance(); + org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new ServiceInstance(); + //AN instance creation + ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId")) + String sliceInstanceName = execution.getVariable("servicename") + ANServiceInstance.setServiceInstanceName(sliceInstanceName) + String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") + ANServiceInstance.setServiceType(serviceType) + String serviceStatus = "deactivated" + ANServiceInstance.setOrchestrationStatus(serviceStatus) + String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList") + ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + String serviceRole = "nssi" + ANServiceInstance.setServiceRole(serviceRole) + List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + String snssai = snssaiList.get(0) + ANServiceInstance.setEnvironmentContext(snssai) + ANServiceInstance.setWorkloadContext("AN") + + logger.debug("completed AN service instance build "+ ANServiceInstance.toString()) + //create RAN NF NSSI + ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId")) + sliceInstanceName = execution.getVariable("ANNF_modelName") + ANNFServiceInstance.setServiceInstanceName(sliceInstanceName) + ANNFServiceInstance.setServiceType(serviceType) + ANNFServiceInstance.setOrchestrationStatus(serviceStatus) + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList") + ANNFServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) + ANNFServiceInstance.setServiceRole(serviceRole) + snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + snssai = snssaiList.get(0) + ANNFServiceInstance.setEnvironmentContext(snssai) + ANNFServiceInstance.setWorkloadContext("AN-NF") + logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString()) + + String msg = "" + try { + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("RANServiceInstanceId")) + client.create(nssiServiceUri, ANServiceInstance) + + AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("RANNFServiceInstanceId")) + client.create(nssiServiceUri1, ANNFServiceInstance) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + //end point update + createEndPointsInAai(execution) + } + def prepareTnFhRequest = { DelegateExecution execution -> + logger.debug(Prefix+"prepareTnFhRequest method start") + + String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "allocate") + String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles" + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + + if (nssmfResponse != null) { + execution.setVariable("nssmfResponse", nssmfResponse) + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TNFH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + logger.debug("Exit prepareTnFhRequest") + + } + def prepareTnMhRequest = { DelegateExecution execution -> + logger.debug(Prefix+"prepareTnMhRequest method start") + + String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "allocate") + String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles" + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + + if (nssmfResponse != null) { + execution.setVariable("nssmfResponse", nssmfResponse) + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TNMH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + logger.debug("Exit prepareTnMhRequest") + } + + def createFhAllocateNssiJobQuery = { DelegateExecution execution -> + logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + createTnAllocateNssiJobQuery(execution, "TN_FH") + } + + def createMhAllocateNssiJobQuery = { DelegateExecution execution -> + logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + createTnAllocateNssiJobQuery(execution, "TN_MH") + } + + private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) { + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType("TN") + esrInfo.setVendor("ONAP") + String esrInfoString = objectMapper.writeValueAsString(esrInfo) + execution.setVariable("esrInfo", esrInfoString) + JsonObject serviceInfo = new JsonObject() + serviceInfo.addProperty("nssiId", null) + serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) + String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") + serviceInfo.addProperty("sST", sST) + serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList"))) + serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) + serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + if(domainType.equals("TN_FH")) { + serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName")) + serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid")) + serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid")) + }else if(domainType.equals("TN_MH")) { + serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName")) + serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid")) + serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid")) + } + execution.setVariable("serviceInfo", serviceInfo.toString()) + execution.setVariable("responseId", "") + } + + def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution -> + logger.debug(Prefix+"processJobStatusRsp method start") + String jobResponse = execution.getVariable("TNFH_jobResponse") + logger.debug("Job status response "+jobResponse) + String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") + String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + if(status.equalsIgnoreCase("finished")) { + execution.setVariable("TNFH_NSSI", nssi) + logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) + } + else { + String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + } + } + + def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution -> + logger.debug(Prefix+"processJobStatusRsp method start") + String jobResponse = execution.getVariable("TNMH_jobResponse") + logger.debug("Job status response "+jobResponse) + String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") + String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + if(status.equalsIgnoreCase("finished")) { + execution.setVariable("TNMH_NSSI", nssi) + logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) + } + else { + String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + } + } + + def processModifyJobStatusRsp = { DelegateExecution execution -> + logger.debug(Prefix+"processJobStatusRsp method start") + String jobResponse = execution.getVariable("jobResponse") + logger.debug("Job status response "+jobResponse) + String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") + String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + if(status.equalsIgnoreCase("finished")) { + logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) + } + else { + String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + } + } + + def updateAairelationships = { DelegateExecution execution -> + logger.debug(Prefix + "updateAairelationships Start") + String msg = "" + try { + def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId") + def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI") + def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI") + def AN_profileInstanceId = execution.getVariable("sliceProfileId") + def AN_NSSI = execution.getVariable("RANServiceInstanceId") + def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId") + def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId") + def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + Relationship ANNF_relationship = new Relationship() + Relationship TNFH_relationship = new Relationship() + Relationship TNMH_relationship = new Relationship() + + String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}" + String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}" + String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}" + + String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}" + String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}" + String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}" + + ANNF_relationship.setRelatedLink(ANNF_relatedLink) + ANNF_relationship.setRelatedTo("service-instance") + ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + TNFH_relationship.setRelatedLink(TNFH_relatedLink) + TNFH_relationship.setRelatedTo("service-instance") + TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + TNMH_relationship.setRelatedLink(TNMH_relatedLink) + TNMH_relationship.setRelatedTo("service-instance") + TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + + // create SliceProfile and NSSI relationship in AAI + anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,TNMH_serviceInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_profileInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_profileInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_profileInstanceId) + + //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI + ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink) + TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink) + TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink) + anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_NSSI) + anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_NSSI) + anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_NSSI) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + + msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + /** + * update operation status in request db + * + */ + def prepareOperationStatusUpdate = { DelegateExecution execution -> + logger.debug(Prefix + "prepareOperationStatusUpdate Start") + + String serviceId = execution.getVariable("dummyServiceId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String nssiId = execution.getVariable("RANServiceInstanceId") + logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus updateStatus = new ResourceOperationStatus() + updateStatus.setServiceId(serviceId) + updateStatus.setOperationId(jobId) + updateStatus.setResourceTemplateUUID(nsiId) + updateStatus.setResourceInstanceID(nssiId) + updateStatus.setOperType("Allocate") + updateStatus.setProgress(100) + updateStatus.setStatus("finished") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) + + logger.debug(Prefix + "prepareOperationStatusUpdate Exit") + } + + def prepareFailedOperationStatusUpdate = { DelegateExecution execution -> + logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start") + + String serviceId = execution.getVariable("dummyServiceId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String nssiId = execution.getVariable("RANServiceInstanceId") + logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus updateStatus = new ResourceOperationStatus() + updateStatus.setServiceId(serviceId) + updateStatus.setOperationId(jobId) + updateStatus.setResourceTemplateUUID(nsiId) + updateStatus.setResourceInstanceID(nssiId) + updateStatus.setOperType("Allocate") + updateStatus.setProgress(0) + updateStatus.setStatus("failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) + } + + private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) { + + String requestId = execution.getVariable("msoRequestId") + Date date = new Date().getTime() + Timestamp time = new Timestamp(date) + Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class) + sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId")) + sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions")) + sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL")) + sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL")) + String sliceProfileString = objectMapper.writeValueAsString(sliceProfile) + JsonObject response = new JsonObject() + JsonObject body = new JsonObject() + JsonObject input = new JsonObject() + JsonObject commonHeader = new JsonObject() + JsonObject payload = new JsonObject() + JsonObject payloadInput = new JsonObject() + commonHeader.addProperty("TimeStamp", time.toString()) + commonHeader.addProperty("APIver", "1.0") + commonHeader.addProperty("RequestID", requestId) + commonHeader.addProperty("SubRequestID", "1") + commonHeader.add("RequestTrack", new JsonObject()) + commonHeader.add("Flags", new JsonObject()) + payloadInput.addProperty("sliceProfile", sliceProfileString) + payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId")) + payloadInput.addProperty("NSIID", execution.getVariable("nsiId")) + payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId")) + payloadInput.addProperty("callbackURL", callbackUrl) + payloadInput.add("additionalproperties", new JsonObject()) + payload.add("input", payloadInput) + input.add("CommonHeader", commonHeader) + input.addProperty("Action", action) + input.add("Payload", payload) + body.add("input", input) + response.add("body", body) + response.addProperty("version", "1.0") + response.addProperty("rpc-name", rpcName) + response.addProperty("correlation-id", requestId+"-1") + response.addProperty("type", "request") + return response.toString() + } + + private void createEndPointsInAai(DelegateExecution execution) { + String type = "endpoint" + String function = "transport_EP" + int prefixLength = 24 + String addressFamily = "ipv4" + //BH RAN end point update + String bh_endpoint = execution.getVariable("bh_endpoint") + String bh_routeId = UUID.randomUUID().toString() + execution.setVariable("tranportEp_ID_bh", bh_routeId) + String role = "CU" + String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress") + String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId") + String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo") + NetworkRoute bh_ep = new NetworkRoute() + bh_ep.setRouteId(bh_routeId) + bh_ep.setFunction(function) + bh_ep.setRole(role) + bh_ep.setType(type) + bh_ep.setIpAddress(CU_IpAddress) + bh_ep.setLogicalInterfaceId(LogicalLinkId) + bh_ep.setNextHop(nextHopInfo) + bh_ep.setPrefixLength(prefixLength) + bh_ep.setAddressFamily(addressFamily) + //FH RAN end points update + //RU + String RU_routeId = UUID.randomUUID().toString() + execution.setVariable("tranportEp_ID_RU", RU_routeId) + role = "RU" + NetworkRoute RU_ep = new NetworkRoute() + RU_ep.setRouteId(RU_routeId) + RU_ep.setFunction(function) + RU_ep.setRole(role) + RU_ep.setType(type) + RU_ep.setIpAddress("192.168.100.4") + RU_ep.setLogicalInterfaceId("1234") + RU_ep.setNextHop("Host1") + RU_ep.setPrefixLength(prefixLength) + RU_ep.setAddressFamily(addressFamily) + //DU Ingress + String DUIN_routeId = UUID.randomUUID().toString() + execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId) + role = "DU" + NetworkRoute DU_ep = new NetworkRoute() + DU_ep.setRouteId(DUIN_routeId) + DU_ep.setFunction(function) + DU_ep.setRole(role) + DU_ep.setType(type) + DU_ep.setIpAddress("192.168.100.5") + DU_ep.setLogicalInterfaceId("1234") + DU_ep.setNextHop("Host2") + DU_ep.setPrefixLength(prefixLength) + DU_ep.setAddressFamily(addressFamily) + //MH RAN end point update + //DUEG + String DUEG_routeId = UUID.randomUUID().toString() + execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId) + NetworkRoute DUEG_ep = new NetworkRoute() + DU_ep.setRouteId(DUEG_routeId) + DU_ep.setNextHop("Host3") + //CUIN + String CUIN_routeId = UUID.randomUUID().toString() + execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId) + NetworkRoute CUIN_ep = new NetworkRoute() + CUIN_ep.setRouteId(CUIN_routeId) + CUIN_ep.setFunction(function) + CUIN_ep.setRole(role) + CUIN_ep.setType(type) + CUIN_ep.setIpAddress("192.168.100.6") + CUIN_ep.setLogicalInterfaceId("1234") + CUIN_ep.setNextHop("Host4") + CUIN_ep.setPrefixLength(prefixLength) + CUIN_ep.setAddressFamily(addressFamily) + try { + AAIResourcesClient client = new AAIResourcesClient() + logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString()) + AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId) + client.create(networkRouteUri, bh_ep) + logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString()) + networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), RU_routeId) + client.create(networkRouteUri, RU_ep) + logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString()) + networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId) + client.create(networkRouteUri, DU_ep) + logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DU_ep.toString()) + networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId) + client.create(networkRouteUri, DU_ep) + logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString()) + networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId) + client.create(networkRouteUri, CUIN_ep) + //relationship b/w bh_ep and RAN NSSI + def AN_NSSI = execution.getVariable("RANServiceInstanceId") + Relationship relationship = new Relationship() + String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}" + relationship.setRelatedLink(relatedLink) + relationship.setRelatedTo("network-route") + relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI) + def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId") + relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}" + relationship.setRelatedLink(relatedLink) + anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId) + relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}" + relationship.setRelatedLink(relatedLink) + anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId) + relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}" + relationship.setRelatedLink(relatedLink) + anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId) + relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}" + relationship.setRelatedLink(relatedLink) + anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in createEndPointsInAai " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy new file mode 100644 index 0000000000..64c36e7026 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy @@ -0,0 +1,157 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * 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.scripts +import org.apache.commons.collections.map.HashedMap +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.beans.nsmf.SliceTaskParams +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.so.serviceinstancebeans.ModelInfo +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.*; +import com.fasterxml.jackson.databind.ObjectMapper +import groovy.json.JsonSlurper +import javax.ws.rs.core.Response +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.bpmn.common.scripts.RequestDBUtil + +class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { + String Prefix="DACNSSI_" + private static final Logger logger = LoggerFactory.getLogger( DoAllocateCoreNSSI.class); + ExceptionUtil exceptionUtil = new ExceptionUtil() + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + ObjectMapper mapper = new ObjectMapper() + OofUtils oofUtils = new OofUtils() + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: preProcessRequest ****") + execution.setVariable("prefix", Prefix) + String msg = "" + //Get SliceProfile from sliceParams JSON + String sliceProfile = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfile") + if (isBlank(sliceProfile)) { + msg = "Slice Profile is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("sliceProfile", sliceProfile) + } + String coreServiceInstanceId = UUID.randomUUID().toString() + execution.setVariable("coreServiceInstanceId", coreServiceInstanceId) + logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: preProcessRequest ****") + } + /** + * Query NSST name from CatalogDB + * @param execution + */ + void getNSSTName(DelegateExecution execution){ + logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: getNSSTName ****") + String nsstModelInvariantUuid = execution.getVariable("modelInvariantUuid") + try{ + String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, nsstModelInvariantUuid) + logger.debug("***** JSON Response is: "+json) + String nsstName = jsonUtil.getJsonValue(json, "serviceResources.modelInfo.modelName") ?: "" + String networkServiceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.serviceProxy.modelInfo") ?: "" + + execution.setVariable("networkServiceModelInfo", networkServiceModelInfo) + logger.debug("***** nsstName is: "+ nsstName) + execution.setVariable("nsstName",nsstName) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + String msg = "Exception in preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: getNSSTName ****") + } + void prepareOOFRequest(DelegateExecution execution){ + logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: prepareOOFRequest ****") + //API Path + String apiPath = "/api/oof/selection/nssi/v1" + logger.debug("API path for DoAllocateCoreNSSI: "+apiPath) + execution.setVariable("NSSI_apiPath", apiPath) + //Setting correlator as requestId + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("NSSI_correlator", requestId) + //Setting messageType for all Core slice as cn + String messageType = "cn" + execution.setVariable("NSSI_messageType", messageType) + //Is there any specific timeout we have to set or else we don't need to send + //if blank will be set default value in DoHandleOofRequest + String timeout = "PT30M" + execution.setVariable("NSSI_timeout", timeout) + Map<String, Object> profileInfo = mapper.readValue(execution.getVariable("sliceProfile"), Map.class) + String nsstModelUuid = execution.getVariable("modelUuid") + String nsstModelInvariantUuid = execution.getVariable("modelInvariantUuid") + String nsstName = execution.getVariable("nsstName") + String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, nsstModelUuid, nsstModelInvariantUuid, nsstName, profileInfo) + logger.debug("**** OOfRequest for Core Slice: "+oofRequest) + execution.setVariable("NSSI_oofRequest", oofRequest) + logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: prepareOOFRequest ****") + } + + void processOOFAsyncResponse(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNSSI ::: processOOFAsyncResponse ****") + String OOFResponse = execution.getVariable("NSSI_asyncCallbackResponse") + String requestStatus = jsonUtil.getJsonValue(OOFResponse, "requestStatus") + logger.debug("NSSI OOFResponse is: " + OOFResponse) + execution.setVariable("OOFResponse", OOFResponse) + String solutions ="" + if(requestStatus.equals("completed")) { + solutions = jsonUtil.getJsonValue(OOFResponse, "solutions") + } else { + String statusMessage = jsonUtil.getJsonValue(OOFResponse, "statusMessage") + logger.error("received failed status from oof "+ statusMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage) + } + execution.setVariable("solutions", solutions) + logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: processOOFAsyncResponse ****") + } + + void prepareFailedOperationStatusUpdate(DelegateExecution execution){ + logger.debug(Prefix + " **** Enter DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setProgress(0) + resourceOperationStatus.setStatus("failed") + resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix + " **** Exit DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy new file mode 100644 index 0000000000..2a31997cd5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy @@ -0,0 +1,432 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * 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.scripts + +import com.fasterxml.jackson.databind.ObjectMapper + +import groovy.json.JsonOutput + +import static org.hamcrest.CoreMatchers.instanceOf + +import javax.json.JsonArray +import javax.ws.rs.core.Response +import org.apache.commons.collections.map.HashedMap +import org.apache.commons.lang.StringEscapeUtils +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray +import org.json.JSONObject +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.aai.domain.yang.v19.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy +import org.onap.so.bpmn.core.json.JsonUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.http.HttpEntity + +import javax.ws.rs.NotFoundException + +class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { + String Prefix="DACNSNSSI_" + private static final Logger logger = LoggerFactory.getLogger( DoAllocateCoreNonSharedSlice.class); + private CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + private RequestDBUtil requestDBUtil = new RequestDBUtil() + private ExceptionUtil exceptionUtil = new ExceptionUtil() + private JsonUtils jsonUtil = new JsonUtils() + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix+ "**** Enter DoAllocateCoreNonSharedSlice::: preProcessRequest ****") + String nssiServiceInstanceId= execution.getVariable("serviceInstanceId") + execution.setVariable("nssiServiceInstanceId", nssiServiceInstanceId) + //Set orchestration-status as created + execution.setVariable("orchestrationStatus", "created") + //networkServiceName + String networkServiceName = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelName") ?: "" + execution.setVariable("networkServiceName", networkServiceName.replaceAll(" Service Proxy", "")) + //networkServiceModelUuid + String networkServiceModelUuid = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelUuid") ?: "" + execution.setVariable("networkServiceModelUuid", networkServiceModelUuid) + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice::: preProcessRequest ****") + } + + void createNSSIinAAI(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: Enter createNSSIinAAI ****") + String msg="" + String serviceInstanceId= execution.getVariable("nssiServiceInstanceId") + logger.debug("ServiceInstanceId: "+serviceInstanceId) + try { + String serviceType = execution.getVariable("subscriptionServiceType") + String oStatus = execution.getVariable("orchestrationStatus") + //Get workload context and environment context from DB + String environmentContext = "" + String workloadContext ="" + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + try{ + String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) + logger.debug("JSON Response from DB: "+json) + environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: "" + workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: "" + logger.debug("Env Context is: "+ environmentContext) + logger.debug("Workload Context is: "+ workloadContext) + } catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in createNSSIinAAI ::: DoAllocateCoreNonSharedSlice " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + String serviceInstanceName = "nssi_"+execution.getVariable("nsstName") + ServiceInstance si = new ServiceInstance() + si.setServiceInstanceId(execution.getVariable("nssiServiceInstanceId")) + si.setServiceInstanceName(serviceInstanceName) + si.setServiceType(serviceType) + si.setServiceRole("nssi") + si.setOrchestrationStatus(oStatus) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(execution.getVariable("modelUuid")) + si.setEnvironmentContext(environmentContext) + si.setWorkloadContext(workloadContext) + logger.debug("AAI service Instance Request Payload : "+si.toString()) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), serviceType, serviceInstanceId) + Response response = getAAIClient().create(uri, si) + if(response.getStatus()!=200) { + exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI instance creation failed") + } + execution.setVariable("nssiServiceInstance", si) + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in create AAI Instance" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+ " Exit DoAllocateCoreNonSharedSlice ::: Enter createNSSIinAAI ****") + } + + public void prepareServiceOrderRequest(DelegateExecution execution) { + logger.debug("**** Enter DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest ****") + String extAPIPath = UrnPropertiesReader.getVariable("extapi.endpoint", execution) + '/serviceOrder' + execution.setVariable("ExternalAPIURL", extAPIPath) + ObjectMapper objectMapper = new ObjectMapper(); + Map<String, Object> serviceOrder = new LinkedHashMap() + //ExternalId + serviceOrder.put("externalId", "ONAP001") + //Requested Start Date + String requestedStartDate = utils.generateCurrentTimeInUtc() + String requestedCompletionDate = utils.generateCurrentTimeInUtc() + serviceOrder.put("requestedStartDate", requestedStartDate) + serviceOrder.put("requestedCompletionDate", requestedCompletionDate) + //RelatedParty Fields + String relatedPartyId = execution.getVariable("globalSubscriberId") + String relatedPartyRole = "ONAPcustomer" + Map<String, String> relatedParty = new LinkedHashMap() + relatedParty.put("id", relatedPartyId) + relatedParty.put("role", relatedPartyRole) + List<Map<String, String>> relatedPartyList = new ArrayList() + relatedPartyList.add(relatedParty) + serviceOrder.put("relatedParty", relatedPartyList) + Map<String, Object> orderItem = new LinkedHashMap() + //orderItem id + String orderItemId = "1" + orderItem.put("id", orderItemId) + //order item action will always be add as we are triggering request for instantiation + String orderItemAction = "add" + orderItem.put("action", orderItemAction) + // service Details + Map<String, Object> service = new LinkedHashMap() + //ServiceName + String serviceName= "nsi_"+execution.getVariable("networkServiceName") + service.put("name", serviceName) + // Service Type + service.put("serviceType", execution.getVariable("serviceType")) + //Service State + service.put("serviceState", "active") + Map<String, String> serviceSpecification = new LinkedHashMap() + serviceSpecification.put("id", execution.getVariable("networkServiceModelUuid")) + service.put("serviceSpecification", serviceSpecification) + //serviceCharacteristic List + List serviceCharacteristicList = new ArrayList() + Map<String, Object> serviceCharacteristic = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class); + List serviceCharacteristicListMap = retrieveServiceCharacteristicsAsKeyValue(serviceCharacteristic) + logger.debug("serviceCharacteristicListMap "+serviceCharacteristicListMap) + serviceCharacteristicList.add(serviceCharacteristic) + //service.put("serviceCharacteristic", serviceCharacteristicList) + service.put("serviceCharacteristic", serviceCharacteristicListMap) + orderItem.put("service", service) + List<Map<String, String>> orderItemList = new ArrayList() + orderItemList.add(orderItem) + serviceOrder.put("orderItem", orderItemList) + String jsonServiceOrder = objectMapper.writeValueAsString(serviceOrder); + logger.debug("******* ServiceOrder :: "+jsonServiceOrder) + execution.setVariable("serviceOrderRequest", jsonServiceOrder) + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest****") + } + + private List retrieveServiceCharacteristicsAsKeyValue(Map serviceCharacteristics) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****") + List serviceCharacteristicsList = new ArrayList() + ObjectMapper mapperObj = new ObjectMapper(); + Map<String, Object> serviceCharacteristicsObject = new LinkedHashMap() + for (Map.Entry<String, Integer> entry : serviceCharacteristics.entrySet()) { + Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>() + System.out.println(entry.getKey() + ":" + entry.getValue()); + //For G Release we are sending single value from snssaiList + if(entry.getKey().equals("snssaiList")) { + List sNssaiValue = entry.getValue() + serviceCharacteristicsObject.put("name", "snssai") + ServiceCharacteristicValueObject.put("serviceCharacteristicValue", sNssaiValue.get(0)) + serviceCharacteristicsObject.put("value", ServiceCharacteristicValueObject) + } + } + serviceCharacteristicsList.add(serviceCharacteristicsObject) + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****") + return serviceCharacteristicsList + } + + public void postNBIServiceOrder(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****") + String msg="" + try { + String extAPIPath = execution.getVariable("ExternalAPIURL") + String payload = execution.getVariable("serviceOrderRequest") + logger.debug("externalAPIURL is: " + extAPIPath) + logger.debug("ServiceOrder payload is: " + payload) + ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create() + execution.setVariable("ServiceOrderId", "") + Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload) + int responseCode = response.getStatus() + execution.setVariable("PostServiceOrderResponseCode", responseCode) + logger.debug("Post ServiceOrder response code is: " + responseCode) + String extApiResponse = response.readEntity(String.class) + JSONObject responseObj = new JSONObject(extApiResponse) + execution.setVariable("PostServiceOrderResponse", extApiResponse) + logger.debug("ServiceOrder response body is: " + extApiResponse) + //Process Response + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) + //200 OK 201 CREATED 202 ACCEPTED + { + logger.debug("Post ServiceOrder Received a Good Response") + String serviceOrderId = responseObj.get("id") + execution.setVariable("ServiceOrderId", serviceOrderId) + logger.info("Post ServiceOrderid is: " + serviceOrderId) + } + else{ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Post ServiceOrder Received a bad response from extAPI serviceOrder API") + } + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in ServiceOrder ExtAPI" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("**** Exit DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****") + } + + public void getNBIServiceOrderProgress(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****") + String msg="" + try { + String extAPIPath = execution.getVariable("ExternalAPIURL") + extAPIPath += "/" + execution.getVariable("ServiceOrderId") + logger.debug("getNBIServiceOrderProgress externalAPIURL is: " + extAPIPath) + ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create() + Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath) + int responseCode = response.getStatus() + execution.setVariable("GetServiceOrderResponseCode", responseCode) + logger.debug("Get ServiceOrder response code is: " + responseCode) + String extApiResponse = response.readEntity(String.class) + JSONObject responseObj = new JSONObject(extApiResponse) + execution.setVariable("GetServiceOrderResponse", extApiResponse) + logger.debug("Create response body is: " + extApiResponse) + //Process Response //200 OK 201 CREATED 202 ACCEPTED + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) + { + logger.debug("Get Create ServiceOrder Received a Good Response") + String orderState = responseObj.get("state") + if("REJECTED".equalsIgnoreCase(orderState)) { + prepareFailedOperationStatusUpdate(execution) + return + } + JSONArray items = responseObj.getJSONArray("orderItem") + JSONObject item = items.get(0) + JSONObject service = item.get("service") + String networkServiceId = service.get("id") + if (networkServiceId == null || networkServiceId.equals("null")) { + prepareFailedOperationStatusUpdate(execution) + return + } + execution.setVariable("networkServiceId", networkServiceId) + String serviceOrderState = item.get("state") + execution.setVariable("ServiceOrderState", serviceOrderState) + // Get serviceOrder State and process progress + if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) { + execution.setVariable("status", "processing") + } + else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) { + execution.setVariable("status", "processing") + } + else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) { + execution.setVariable("status", "completed") + } + else if("FAILED".equalsIgnoreCase(serviceOrderState)) { + msg = "ServiceOrder failed" + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + else { + msg = "ServiceOrder failed" + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + else{ + msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode + prepareFailedOperationStatusUpdate(execution) + } + + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage()) + } + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****") + } + + /** + * delay 5 sec + */ + public void timeDelay(DelegateExecution execution) { + try { + logger.debug(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay going to sleep for 5 sec") + Thread.sleep(5000) + logger.debug("**** DoAllocateCoreNonSharedSlice ::: timeDelay wakeup after 5 sec") + } catch(InterruptedException e) { + logger.error(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay exception" + e) + } + } + + + void updateRelationship(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: updateRelationship ****") + + String networkServiceInstanceId = execution.getVariable("networkServiceId") + String nssiId = execution.getVariable("nssiServiceInstanceId") + String globalCustId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + try{ + //Update NSSI orchestration status nssiServiceInstance + ServiceInstance si = execution.getVariable("nssiServiceInstance") + si.setOrchestrationStatus("activated") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustId, serviceType, networkServiceInstanceId) + try { + getAAIClient().update(uri, si) + } catch (Exception e) { + logger.info("Update OrchestrationStatus in AAI failed") + String msg = "Update OrchestrationStatus in AAI failed, " + e.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + //URI for NSSI + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId); + + //URI for Network Service Instance + AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkServiceInstanceId) + + // Update Relationship in AAI + Response response = getAAIClient().connect(nssiUri, networkServiceInstanceUri, AAIEdgeLabel.COMPOSED_OF); + + if(response.getStatus()!=200 || response.getStatus()!=201 || response.getStatus()!=202) { + exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "Set association of NSSI and Network service instance has failed in AAI") + } else { + execution.setVariable("progress", 100) + execution.setVariable("status", "finished") + execution.setVariable("statusDescription", "DoAllocateCoreNonSharedNSSI success") + setResourceOperationStatus(execution) + } + }catch(Exception ex) { + String msg = "Exception while creating relationship " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: updateRelationship ****") + } + + /** + * prepare ResourceOperation status + * @param execution + * @param operationType + */ + private void setResourceOperationStatus(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setStatus(execution.getVariable("status")) + resourceOperationStatus.setProgress(execution.getVariable("progress")) + resourceOperationStatus.setStatusDescription(execution.getVariable("statusDescription")) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****") + } + + void prepareFailedOperationStatusUpdate(DelegateExecution execution){ + logger.debug(Prefix + " **** Enter DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setProgress(0) + resourceOperationStatus.setStatus("failed") + resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix + " **** Exit DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****") + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy new file mode 100644 index 0000000000..6367341228 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy @@ -0,0 +1,658 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONObject +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.serviceinstancebeans.CloudConfiguration +import org.onap.so.serviceinstancebeans.LineOfBusiness +import org.onap.so.serviceinstancebeans.ModelInfo +import org.onap.so.serviceinstancebeans.ModelType +import org.onap.so.serviceinstancebeans.OwningEntity +import org.onap.so.serviceinstancebeans.Platform +import org.onap.so.serviceinstancebeans.Project +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.rest.catalog.beans.Vnf +import org.onap.so.serviceinstancebeans.RequestDetails +import org.onap.so.serviceinstancebeans.RequestInfo +import org.onap.so.serviceinstancebeans.RequestParameters +import org.onap.so.serviceinstancebeans.SubscriberInfo +import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.RelatedToProperty +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipData +import org.onap.aai.domain.yang.RelationshipList +import org.onap.aai.domain.yang.ServiceInstance +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import com.fasterxml.jackson.databind.ObjectMapper + +import static org.apache.commons.lang3.StringUtils.isBlank + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { + + String Prefix="DACSNSSI_" + private static final Logger logger = LoggerFactory.getLogger(DoAllocateCoreSharedSlice.class); + private CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + private RequestDBUtil requestDBUtil = new RequestDBUtil() + private ExceptionUtil exceptionUtil = new ExceptionUtil() + private JsonUtils jsonUtil = new JsonUtils() + ObjectMapper mapper = new ObjectMapper(); + + private final Long TIMEOUT = 60 * 60 * 1000 + + @Override + public void preProcessRequest(DelegateExecution execution) { + + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: preProcessRequest ****") + //Get NSSI Solutions + String nssisolutions = execution.getVariable("solutions") + + //Get First Object + List<String> nssiSolutionList = jsonUtil.StringArrayToList(nssisolutions) + + logger.debug("nssiSolutionList : "+nssiSolutionList) + + String nssiId = jsonUtil.getJsonValue(nssiSolutionList.get(0), "NSSIId") + logger.debug("NSSIId : "+nssiId) + + if (isBlank(nssiId)) { + String msg = "solution nssiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("nssiId", nssiId) + } + + String sNssaiListAsString = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "snssaiList") + logger.debug("sNssaiListAsString "+sNssaiListAsString) + List<String> sNssaiList = jsonUtil.StringArrayToList(sNssaiListAsString) + logger.debug("sNssaiList "+sNssaiList) + String sNssai = sNssaiList.get(0) + execution.setVariable("sNssai", sNssai) + logger.debug("sNssai: "+sNssai) + + String serviceType = execution.getVariable("subscriptionServiceType") + execution.setVariable("serviceType", serviceType) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: preProcessRequest ****") + } + + public void getNetworkInstanceAssociatedWithNssiId(DelegateExecution execution) { + + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getNetworkInstanceAssociatedWithNssiId ****") + + //NSSI Id as service Instance Id to get from Request + String serviceInstanceId = execution.getVariable("serviceInstanceID") + + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional<ServiceInstance> nsi = wrapper.asBean(ServiceInstance.class) + + String networkServiceInstanceName = "" + String networkServiceInstanceId ="" + if(nsi.isPresent()) { + List<Relationship> relationshipList = nsi.get().getRelationshipList()?.getRelationship() + List spiWithsNssaiAndOrchStatusList = new ArrayList<>() + + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "service-instance") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + logger.debug("**** service-instance.service-instance-id 1 :: getServiceInstanceRelationships :: "+ relationshipData.getRelationshipValue()) + execution.setVariable("networkServiceInstanceId", relationshipData.getRelationshipValue()) + } + } + for (RelatedToProperty relatedToProperty : relatedToPropertyList) { + if (relatedToProperty.getPropertyKey() == "service-instance.service-instance-name") { + execution.setVariable("networkServiceInstanceName", relatedToProperty.getPropertyValue()) + } + } + } + //If related to is allotted-Resource + if (relatedTo == "allotted-resource") { + //get slice Profile Instance Id from allotted resource in list by nssi + List<String> sliceProfileInstanceIdList = new ArrayList<>() + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + sliceProfileInstanceIdList.add(relationshipData.getRelationshipValue()) + } + } + for (String sliceProfileServiceInstanceId : sliceProfileInstanceIdList) { + String errorSliceProfileMsg = "Slice Profile Service Instance was not found in aai" + + //Query Slice Profile Service Instance From AAI by sliceProfileServiceInstanceId + AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) + Optional<ServiceInstance> sliceProfileServiceInstance = sliceProfileInstanceWrapper.asBean(ServiceInstance.class) + if (sliceProfileServiceInstance.isPresent()) { + String orchestrationStatus= sliceProfileServiceInstance.get().getOrchestrationStatus() + String sNssai = sliceProfileServiceInstance.get().getSliceProfiles().getSliceProfile().get(0).getSNssai() + if(sNssai.equals(execution.getVariable("sNssai"))) { + orchestrationStatus = execution.getVariable("oStatus") + //Slice Profile Service Instance to be updated in AAI + execution.setVariable("sliceProfileServiceInstance", sliceProfileServiceInstance) + } + + Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() + spiWithsNssaiAndOrchStatus.put("snssai", sNssai) + spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus) + spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus) + logger.debug("service Profile's NSSAI And Orchestration Status: "+spiWithsNssaiAndOrchStatus) + } + } + } + } + execution.setVariable("snssaiAndOrchStatusList", spiWithsNssaiAndOrchStatusList) + } + + logger.debug("NSSI Id: ${serviceInstanceId}, network Service Instance Id: ${networkServiceInstanceId}, serviceName: ${networkServiceInstanceName}") + + //Get ServiceInstance Relationships + getServiceInstanceRelationships(execution) + + //Get Vnf Relationships + getVnfRelationships(execution) + + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getNetworkInstanceAssociatedWithNssiId ****") + } + + private void getServiceInstanceRelationships(DelegateExecution execution) { + + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****") + + String serviceInstanceId = execution.getVariable("networkServiceInstanceId") + + String errorMsg = "query Network Service Instance from AAI failed" + AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + + String networkServiceModelInvariantUuid = si.get().getModelInvariantId() + execution.setVariable("networkServiceModelInvariantUuid", networkServiceModelInvariantUuid) + if(si.isPresent()) { + List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "owning-entity") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "owning-entity.owning-entity-id") { + execution.setVariable("owningEntityId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "generic-vnf") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() + + //Get VnfId + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "generic-vnf.vnf-id") { + execution.setVariable("vnfId", relationshipData.getRelationshipValue()) + } + } + + //Get Vnf Name Check If necessary + for (RelatedToProperty relatedToProperty : relatedToPropertyList) { + if (relatedToProperty.getPropertyKey() == "generic-vnf.vnf-name") { + execution.setVariable("vnfName", relatedToProperty.getPropertyValue()) + } + } + } else if (relatedTo == "project") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "project.project-name") { + execution.setVariable("projectName", relationshipData.getRelationshipValue()) + } + } + } + } + + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****") + } + } + + private void getVnfRelationships(DelegateExecution execution) { + + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getVnfRelationships ****") + String msg = "query Generic Vnf from AAI failed" + try { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + if (!getAAIClient().exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + AAIResultWrapper wrapper = getAAIClient().get(uri, NotFoundException.class) + Optional<GenericVnf> vnf = wrapper.asBean(GenericVnf.class) + if(vnf.isPresent()) { + List<Relationship> relationshipList = vnf.get().getRelationshipList()?.getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo == "tenant") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "tenant.tenant-id") { + execution.setVariable("tenantId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "cloud-region") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "cloud-region.cloud-owner") { + execution.setVariable("cloudOwner", relationshipData.getRelationshipValue()) + } else if (relationshipData.getRelationshipKey() == "cloud-region.cloud-region-id") { + execution.setVariable("lcpCloudRegionId", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "platform") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "platform.platform-name") { + execution.setVariable("platformName", relationshipData.getRelationshipValue()) + } + } + } else if (relatedTo == "line-of-business") { + List<RelationshipData> relationshipDataList = relationship.getRelationshipData() + for (RelationshipData relationshipData : relationshipDataList) { + if (relationshipData.getRelationshipKey() == "line-of-business.line-of-business-name") { + execution.setVariable("lineOfBusinessName", relationshipData.getRelationshipValue()) + } + } + } + } + } + } catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in getVnfRelationships " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getVnfRelationships ****") + } + + + /** + * query AAI + * @param execution + * @param aaiObjectType + * @param instanceId + * @return AAIResultWrapper + */ + private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: queryAAI ****") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) + if (!getAAIClient().exists(resourceUri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) + } + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: queryAAI ****") + return wrapper + } + + public void getServiceVNFAndVFsFromCatalogDB(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getServiceVNFAndVFsFromCatalogDB ****") + String serviceVnfs=""; + String msg="" + String modelInvariantUuid = execution.getVariable("networkServiceModelInvariantUuid") + try{ + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, modelInvariantUuid) + logger.debug("***** JSON IS: "+json) + serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: "" + String serviceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.modelInfo") ?: "" + execution.setVariable("serviceModelInfo", serviceModelInfo) + execution.setVariable("serviceVnfs",serviceVnfs) + logger.debug("***** serviceVnfs is: "+ serviceVnfs) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getServiceVNFAndVFsFromCatalogDB ****") + } + + public void prepareSOMacroRequestPayload(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareSOMacroRequestPayLoad ****") + String json = execution.getVariable("serviceVnfs") + logger.debug(">>>> json "+json) + List<Object> vnfList = mapper.readValue(json, List.class); + logger.debug("vnfList: "+vnfList) + Map<String,Object> serviceMap = mapper.readValue(execution.getVariable("serviceModelInfo"), Map.class); + ModelInfo serviceModelInfo = new ModelInfo() + serviceModelInfo.setModelType(ModelType.service) + serviceModelInfo.setModelInvariantId(serviceMap.get("modelInvariantUuid")) + serviceModelInfo.setModelVersionId(serviceMap.get("modelUuid")) + serviceModelInfo.setModelName(serviceMap.get("modelName")) + serviceModelInfo.setModelVersion(serviceMap.get("modelVersion")) + logger.debug("serviceModelInfo: "+serviceModelInfo) + //List of Vnfs + List<Object> vnfModelInfoList = new ArrayList<>() + + Map vnfMap = vnfList.get(0) + ModelInfo vnfModelInfo = vnfMap.get("modelInfo") + logger.debug("vnfModelInfo "+vnfModelInfo) + + //List of VFModules + List<Map<String, Object>> vfModuleList = vnfMap.get("vfModules") + logger.debug("vfModuleList "+vfModuleList) + + //List of VfModules + List<ModelInfo> vfModelInfoList = new ArrayList<>() + + //Traverse VFModules List and add in vfModelInfoList + for (vfModule in vfModuleList) { + ModelInfo vfModelInfo = vfModule.get("modelInfo") + logger.debug("vfModelInfo "+vfModelInfo) + vfModelInfoList.add(vfModelInfo) + } + //RequestInfo + RequestInfo requestInfo = new RequestInfo() + + //Dummy Product FamilyId + requestInfo.setProductFamilyId("test1234") + requestInfo.setSource("VID") + requestInfo.setInstanceName(execution.getVariable("networkServiceInstanceName")) + requestInfo.setSuppressRollback(false) + requestInfo.setRequestorId("NBI") + + //Service Level InstanceParams + List<Map<String, Object>> serviceParams = new ArrayList<>() + Map<String, Object> serviceParamsValues = new LinkedHashMap<>() + serviceParams.add(serviceParamsValues) + + //Cloud Configuration + CloudConfiguration cloudConfiguration = new CloudConfiguration() + cloudConfiguration.setLcpCloudRegionId(execution.getVariable("lcpCloudRegionId")) + cloudConfiguration.setTenantId(execution.getVariable("tenantId")) + cloudConfiguration.setCloudOwner(execution.getVariable("cloudOwner")) + + //VFModules List + List<Map<String, Object>> vfModules = new ArrayList<>() + for (ModelInfo vfModuleModelInfo : vfModelInfoList) { + //Individual VFModule List + Map<String, Object> vfModuleValues = new LinkedHashMap<>() + vfModuleValues.put("modelInfo", vfModuleModelInfo) + vfModuleValues.put("instanceName", vfModuleModelInfo.getModelInstanceName()) + + //VFModule InstanceParams should be empty or this field should not be there? + List<Map<String, Object>> vfModuleInstanceParams = new ArrayList<>() + vfModuleValues.put("instanceParams", vfModuleInstanceParams) + } + + //Vnf intsanceParams + Map<String, Object> sliceProfile = mapper.readValue(execution.getVariable("sliceProfile"), Map.class); + + List vnfInstanceParamsList = new ArrayList<>() + String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution) + vnfInstanceParamsList.add(supportedsNssaiJson) + + Platform platform = new Platform() + platform.setPlatformName(execution.getVariable("platform")) + + LineOfBusiness lineOfbusiness = new LineOfBusiness() + lineOfbusiness.setLineOfBusinessName(execution.getVariable("lineOfBusiness")) + + //Vnf Values + Map<String, Object> vnfValues = new LinkedHashMap<>() + vnfValues.put("lineOfBusiness", lineOfbusiness) + vnfValues.put("platform", platform) + vnfValues.put("productFamilyId", "test1234") + vnfValues.put("cloudConfiguration", cloudConfiguration) + vnfValues.put("vfModules", vfModules) + vnfValues.put("modelInfo", vnfModelInfo) + vnfValues.put("instanceName", execution.getVariable("vnfInstanceName")) + vnfValues.put("instanceParams",vnfInstanceParamsList) + + vnfModelInfoList.add(vnfValues) + //Service Level Resources + Map<String, Object> serviceResources = new LinkedHashMap<>() + serviceResources.put("vnfs", vnfModelInfoList) + + //Service Values + Map<String, Object> serviceValues = new LinkedHashMap<>() + serviceValues.put("modelInfo", serviceModelInfo) + serviceValues.put("instanceName", execution.getVariable("networkServiceInstanceName")) + serviceValues.put("resources", serviceResources) + serviceValues.put("instanceParams", serviceParams) + + //UserParams Values + Map<String, Object> userParamsValues = new LinkedHashMap<>() + + Map<String, Object> homingSolution = new LinkedHashMap<>() + homingSolution.put("Homing_Solution", "none") + + userParamsValues.put("service", serviceValues) + + //UserParams + List<Map<String, Object>> userParams = new ArrayList<>() + userParams.add(homingSolution) + userParams.add(userParamsValues) + + //Request Parameters + RequestParameters requestParameters = new RequestParameters() + requestParameters.setaLaCarte(false) + requestParameters.setSubscriptionServiceType(execution.getVariable("serviceType")) + requestParameters.setUserParams(userParams) + + //SubscriberInfo + SubscriberInfo subscriberInfo = new SubscriberInfo() + subscriberInfo.setGlobalSubscriberId(execution.getVariable("globalSubscriberId")) + + //Owning Entity + OwningEntity owningEntity = new OwningEntity() + owningEntity.setOwningEntityId(execution.getVariable("owningEntityId")) + + //Project + Project project = new Project() + project.setProjectName(execution.getVariable("projectName")) + + RequestDetails requestDetails = new RequestDetails() + requestDetails.setModelInfo(serviceModelInfo) + requestDetails.setSubscriberInfo(subscriberInfo) + requestDetails.setRequestInfo(requestInfo) + requestDetails.setRequestParameters(requestParameters) + requestDetails.setCloudConfiguration(cloudConfiguration) + requestDetails.setOwningEntity(owningEntity) + requestDetails.setProject(project) + + Map<String, Object> requestDetailsMap = new LinkedHashMap<>() + requestDetailsMap.put("requestDetails", requestDetails) + String requestPayload = mapper.writeValueAsString(requestDetailsMap) + + logger.debug("requestDetails "+requestPayload) + execution.setVariable("requestPayload", requestPayload) + + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareSOMacroRequestPayLoad ****") + } + + private String prepareVnfInstanceParamsJson(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****") + List instanceParamsvalues = execution.getVariable("snssaiAndOrchStatusList") + Map<String, Object> nSsai= new LinkedHashMap<>() + nSsai.put("sNssai", instanceParamsvalues) + + String supportedsNssaiJson = mapper.writeValueAsString(nSsai) + //SupportedNssai + Map<String, Object> supportedNssai= new LinkedHashMap<>() + supportedNssai.put("supportedNssai", supportedsNssaiJson) + logger.debug("**** supportedsNssaiJson**** "+supportedNssai) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****") + return supportedNssai + } + + public void sendPutRequestToSOMacro(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: sendPutRequestToSOMacro ****") + try { + String msoEndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) + String url = msoEndpoint+"/serviceInstantiation/v7/serviceInstances/"+execution.getVariable("networkServiceInstanceId")+"/vnfs/"+execution.getVariable("vnfId") + + String requestBody = execution.getVariable("requestPayload") + + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuthValue = utils.encrypt(basicAuth, msoKey) + String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) + + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) + httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Accept", "application/json") + Response httpResponse = httpClient.put(requestBody) + handleSOResponse(httpResponse, execution) + } catch (BpmnError e) { + throw e + } catch (any) { + String msg = Prefix+" Exception in DoAllocateCoreSharedSlice " + any.getCause() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: sendPostRequestToSOMacro ****") + } + + /** + * Handle SO Response for PUT and prepare update operation status + * @param execution + */ + private void handleSOResponse(Response httpResponse, DelegateExecution execution){ + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: handleSOResponse ****") + + int soResponseCode = httpResponse.getStatus() + logger.debug("soResponseCode : "+soResponseCode) + + if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { + String soResponse = httpResponse.readEntity(String.class) + String operationId = execution.getVariable("operationId") + def macroOperationId = jsonUtil.getJsonValue(soResponse, "operationId") + execution.setVariable("macroOperationId", macroOperationId) + execution.setVariable("isSOTimeOut", "no") + execution.setVariable("isSOResponseSucceed","yes") + } + else { + String serviceName = execution.getVariable("serviceInstanceName") + execution.setVariable("isSOResponseSucceed","no") + prepareFailedOperationStatusUpdate(execution) + } + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: handleSOResponse ****") + } + + /** + * prepare to call sub process CheckProcessStatus + * @param execution + */ + void prepareCallCheckProcessStatus(DelegateExecution execution){ + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareCallCheckProcessStatus ****") + def successConditions = new ArrayList<>() + successConditions.add("finished") + execution.setVariable("successConditions", successConditions) + def errorConditions = new ArrayList<>() + errorConditions.add("error") + execution.setVariable("errorConditions", errorConditions) + execution.setVariable("processServiceType", "Network service") + execution.setVariable("subOperationType", "PUT") + execution.setVariable("initProgress", 20) + execution.setVariable("endProgress",90) + execution.setVariable("timeOut", TIMEOUT) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareCallCheckProcessStatus ****") + } + + void prepareUpdateResourceOperationStatus(DelegateExecution execution) { + + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareUpdateResourceOperationStatus ****") + //Prepare Update Status for PUT failure and success + if(execution.getVariable("isTimeOut").equals("YES")) { + logger.debug("TIMEOUT - SO PUT Failure") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") + } else { + execution.setVariable("progress", "100") + execution.setVariable("status", "finished") + execution.setVariable("operationContent", "AllocteCoreNSSI successful.") + logger.debug("prepareFailureStatus,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}") + } + setResourceOperationStatus(execution) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareUpdateResourceOperationStatus ****") + } + + /** + * prepare ResourceOperation status + * @param execution + * @param operationType + */ + private void setResourceOperationStatus(DelegateExecution execution) { + logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: setResourceOperationStatus ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setStatus("finished") + resourceOperationStatus.setProgress("100") + resourceOperationStatus.setStatusDescription("Core Allocate successful") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: setResourceOperationStatus ****") + } + + void prepareFailedOperationStatusUpdate(DelegateExecution execution){ + logger.debug(Prefix + " **** Enter DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****") + String serviceId = execution.getVariable("nssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() + resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setOperType(operationType) + resourceOperationStatus.setProgress(0) + resourceOperationStatus.setStatus("failed") + resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) + logger.debug(Prefix + " **** Exit DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****") + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy new file mode 100644 index 0000000000..924b42fe9f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy @@ -0,0 +1,613 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.scripts + +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.SliceProfile +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.beans.nsmf.* +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils +import org.onap.so.bpmn.core.json.JsonUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import javax.ws.rs.NotFoundException + +class DoAllocateNSIandNSSIV2 extends AbstractServiceTaskProcessor{ + + private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSIandNSSIV2.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + AAIResourcesClient client = getAAIClient() + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + + void preProcessRequest (DelegateExecution execution) { + String msg = "" + logger.trace("Enter preProcessRequest()") + Map<String, Object> nssiMap = new HashMap<>() + execution.setVariable("nssiMap", nssiMap) + boolean isMoreNSSTtoProcess = true + execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess) + List<String> nsstSequence = new ArrayList<>(Arrays.asList("cn")) + execution.setVariable("nsstSequence", nsstSequence) + logger.trace("Exit preProcessRequest") + } + + /** + * Process NSI options + * @param execution + */ + void retriveSliceOption(DelegateExecution execution) { + logger.trace("Enter retriveSliceOption() of DoAllocateNSIandNSSI") + + boolean isNSIOptionAvailable + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter +// try +// { +// Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map +// String modelUuid = nstSolution.get("UUID") +// String modelInvariantUuid = nstSolution.get("invariantUUID") +// String serviceModelInfo = """{ +// "modelInvariantUuid":"${modelInvariantUuid}", +// "modelUuid":"${modelUuid}", +// "modelVersion":"" +// }""" +// execution.setVariable("serviceModelInfo", serviceModelInfo) +// +// execution.setVariable("sliceParams", sliceParams) +// }catch (Exception ex) { +// logger.debug( "Unable to get the task information from request DB: " + ex) +// exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Unable to get task information from request DB.") +// } + + if(StringUtils.isBlank(sliceParams.getSuggestNsiId())) { + isNSIOptionAvailable = false + } + else { + isNSIOptionAvailable = true + execution.setVariable('nsiServiceInstanceId', sliceParams.getSuggestNsiId()) + execution.setVariable('nsiServiceInstanceName', sliceParams.getSuggestNsiName()) + } + execution.setVariable("isNSIOptionAvailable", isNSIOptionAvailable) + logger.trace("Exit retriveSliceOption() of DoAllocateNSIandNSSI") + } + + + /** + * create nsi instance in aai + * @param execution + */ + void createNSIinAAI(DelegateExecution execution) { + logger.debug("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()") + + String sliceInstanceId = UUID.randomUUID().toString() + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + + sliceParams.setServiceId(sliceInstanceId) + + ServiceInstance nsi = new ServiceInstance() + + + String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName") + String serviceType = execution.getVariable("serviceType") + String serviceStatus = "deactivated" + String modelInvariantUuid = sliceParams.getNSTInfo().invariantUUID + String modelUuid = sliceParams.getNSTInfo().UUID + + String uuiRequest = execution.getVariable("uuiRequest") + String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList") + String serviceRole = "nsi" + + execution.setVariable("sliceInstanceId", sliceInstanceId) + nsi.setServiceInstanceId(sliceInstanceId) + nsi.setServiceInstanceName(sliceInstanceName) + nsi.setServiceType(serviceType) + nsi.setOrchestrationStatus(serviceStatus) + nsi.setModelInvariantId(modelInvariantUuid) + nsi.setModelVersionId(modelUuid) + nsi.setServiceInstanceLocationId(serviceInstanceLocationid) + nsi.setServiceRole(serviceRole) + String msg + try { + + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + sliceInstanceId) + client.create(nsiServiceUri, nsi) + + execution.setVariable("nsiServiceUri", nsiServiceUri.build().toString()) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()") + } + + + /** + * create relationship between nsi and service profile instance + * @param execution + */ + void createRelationship(DelegateExecution execution) { + //relation ship + Relationship relationship = new Relationship() + String nsiServiceUri = execution.getVariable("nsiServiceUri") as String + logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri) + + relationship.setRelatedLink(nsiServiceUri) + + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri( + AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + execution.getVariable("sliceServiceInstanceId"), + execution.getVariable("allottedResourceId")) + .relationshipAPI() + client.create(allottedResourceUri, relationship) + } + + /** + * + * @param execution + */ + void updateRelationship(DelegateExecution execution) { + logger.debug("Enter update relationship in DoAllocateNSIandNSSI()") + String allottedResourceId = execution.getVariable("allottedResourceId") + //Need to check whether nsi exist : Begin + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + + String nsiServiceInstanceID = sliceParams.getSuggestNsiId() + sliceParams.setServiceId(nsiServiceInstanceID) + + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + nsiServiceInstanceID) + + try { + AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + //todo: if exists + if (!si.ifPresent()) { + String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + execution.getVariable("sliceServiceInstanceId"), + allottedResourceId) + + client.connect(allottedResourceUri, nsiServiceUri) + + execution.setVariable("sliceParams", sliceParams) + }catch(BpmnError e) { + throw e + }catch (Exception ex){ + String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Exit update relationship in DoAllocateNSIandNSSI()") + } + + /** + * create RAN Slice Profile Instance + * @param execution + */ + void createAnSliceProfileInstance(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String serviceInstanceId = UUID.randomUUID().toString() + execution.setVariable("ranSliceProfileInstanceId", serviceInstanceId) //todo: + + String serviceType = "" + String serviceRole = "slice-profile" + String oStatus = "deactivated" + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo + sliceTaskInfo.setServiceInstanceId(serviceInstanceId) + + // create slice profile + ServiceInstance rspi = new ServiceInstance() + rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) + rspi.setServiceType(serviceType) + rspi.setServiceRole(serviceRole) + rspi.setOrchestrationStatus(oStatus) + rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) + rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) + rspi.setInputParameters(uuiRequest) + rspi.setWorkloadContext(useInterval) + rspi.setEnvironmentContext(sNSSAI_id) + + //timestamp format YYYY-MM-DD hh:mm:ss + rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) + + execution.setVariable("communicationServiceInstance", rspi) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, + subscriptionServiceType, + serviceInstanceId) + client.create(uri, rspi) + + execution.setVariable("sliceParams", sliceParams) + } + + /** + * create An Slice Profile + * @param execution + */ + void createAnSliceProfile(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId") + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo + AnSliceProfile anSliceProfile = sliceTaskInfo.sliceProfile + + String profileId = UUID.randomUUID().toString() + anSliceProfile.setSliceProfileId(profileId) + + SliceProfile sliceProfile = new SliceProfile() + sliceProfile.setProfileId(profileId) + sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList as String) + //todo:... + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, + globalSubscriberId, + subscriptionServiceType, + sliceTaskInfo.serviceInstanceId, + profileId + ) + client.create(uri, sliceProfile) + execution.setVariable("sliceParams", sliceParams) + } + + /** + * prepare AllocateAnNssi + * @param execution + */ + void prepareAllocateAnNssi(DelegateExecution execution) { + + //todo: + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo + + NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() + + AllocateAnNssi allocateAnNssi = new AllocateAnNssi() + allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID + allocateAnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID + allocateAnNssi.nssiName = sliceTaskInfo.NSSTInfo.name + allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile + allocateAnNssi.nsiInfo.nsiId = sliceParams + + EsrInfo esrInfo = new EsrInfo() + //todo: vendor and network + esrInfo.setVendor(sliceTaskInfo.getVendor()) + esrInfo.setNetworkType(sliceTaskInfo.getNetworkType()) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + //todo: service info + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.globalSubscriberId = globalSubscriberId + serviceInfo.subscriptionServiceType = subscriptionServiceType + serviceInfo.nsiId = sliceParams.serviceId + serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID + serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID + + nbiRequest.setServiceInfo(serviceInfo) + nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setAllocateAnNssi(allocateAnNssi) + + execution.setVariable("AnAllocateNssiNbiRequest", nbiRequest) + execution.setVariable("anBHSliceTaskInfo", sliceTaskInfo) + } + + + /** + * create RAN Slice Profile Instance + * @param execution + */ + void createCnSliceProfileInstance(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String serviceInstanceId = UUID.randomUUID().toString() + execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo: + + String serviceType = "" + String serviceRole = "slice-profile" + String oStatus = "deactivated" + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo + sliceTaskInfo.setServiceInstanceId(serviceInstanceId) + + // create slice profile + ServiceInstance rspi = new ServiceInstance() + rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) + rspi.setServiceType(serviceType) + rspi.setServiceRole(serviceRole) + rspi.setOrchestrationStatus(oStatus) + rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) + rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) + rspi.setInputParameters(uuiRequest) + rspi.setWorkloadContext(useInterval) + rspi.setEnvironmentContext(sNSSAI_id) + + //timestamp format YYYY-MM-DD hh:mm:ss + rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) + + execution.setVariable("communicationServiceInstance", rspi) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, + subscriptionServiceType, + serviceInstanceId) + client.create(uri, rspi) + execution.setVariable("sliceParams", sliceParams) + } + + /** + * create An Slice Profile + * @param execution + */ + void createCnSliceProfile(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId") + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + + SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo + CnSliceProfile cnSliceProfile = sliceTaskInfo.sliceProfile + + String profileId = UUID.randomUUID().toString() + cnSliceProfile.setSliceProfileId(profileId) + + SliceProfile sliceProfile = new SliceProfile() + sliceProfile.setProfileId(profileId) + sliceProfile.setCoverageAreaTAList(cnSliceProfile.coverageAreaTAList as String) + //todo:... + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, + globalSubscriberId, + subscriptionServiceType, + sliceTaskInfo.serviceInstanceId, + profileId + ) + client.create(uri, sliceProfile) + execution.setVariable("sliceParams", sliceParams) + } + + /** + * prepare AllocateCnNssi + * @param execution + */ + void prepareAllocateCnNssi(DelegateExecution execution) { + + //todo: + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo + + NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() + + AllocateCnNssi allocateCnNssi = new AllocateCnNssi() + allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID + allocateCnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID + allocateCnNssi.nssiName = sliceTaskInfo.NSSTInfo.name + allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile + allocateCnNssi.nsiInfo.nsiId = sliceParams + + EsrInfo esrInfo = new EsrInfo() + //todo: vendor and network + esrInfo.setVendor(sliceTaskInfo.getVendor()) + esrInfo.setNetworkType(sliceTaskInfo.getNetworkType()) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + //todo: service info + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.globalSubscriberId = globalSubscriberId + serviceInfo.subscriptionServiceType = subscriptionServiceType + serviceInfo.nsiId = sliceParams.serviceId + serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID + serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID + + nbiRequest.setServiceInfo(serviceInfo) + nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setAllocateCnNssi(allocateCnNssi) + + execution.setVariable("CnAllocateNssiNbiRequest", nbiRequest) + execution.setVariable("cnSliceTaskInfo", sliceTaskInfo) + } + + + /** + * create TN Slice Profile Instance + * @param execution + */ + void createTnBHSliceProfileInstance(DelegateExecution execution) { + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + String serviceType = "" + String serviceRole = "slice-profile" + String oStatus = "deactivated" + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + + SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo + String serviceInstanceId = UUID.randomUUID().toString() + + sliceTaskInfo.setServiceInstanceId(serviceInstanceId) + //execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo: + + // create slice profile + ServiceInstance rspi = new ServiceInstance() + rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) + rspi.setServiceType(serviceType) + rspi.setServiceRole(serviceRole) + rspi.setOrchestrationStatus(oStatus) + rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) + rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) + rspi.setInputParameters(uuiRequest) + rspi.setWorkloadContext(useInterval) + rspi.setEnvironmentContext(sNSSAI_id) + + //timestamp format YYYY-MM-DD hh:mm:ss + rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) + + execution.setVariable("communicationServiceInstance", rspi) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, + subscriptionServiceType, + serviceInstanceId) + client.create(uri, rspi) + + execution.setVariable("sliceParams", sliceParams) + } + + /** + * create An Slice Profile + * @param execution + */ + void createTnBHSliceProfile(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId") + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + + SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo + + TnSliceProfile tnSliceProfile = sliceTaskInfo.sliceProfile + String profileId = UUID.randomUUID().toString() + tnSliceProfile.setSliceProfileId(profileId) + + SliceProfile sliceProfile = new SliceProfile() + sliceProfile.setProfileId(profileId) + //todo:... + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, + globalSubscriberId, + subscriptionServiceType, + serviceInstanceId, + profileId + ) + client.create(uri, sliceProfile) + + execution.setVariable("sliceParams", sliceParams) + } + + /** + * prepare AllocateCnNssi + * @param execution + */ + void prepareAllocateTnBHNssi(DelegateExecution execution) { + + //todo: + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo + + NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() + + AllocateTnNssi allocateTnNssi = new AllocateTnNssi() + //todo: AllocateTnNssi + //allocateTnNssi.networkSliceInfos + + EsrInfo esrInfo = new EsrInfo() + //todo: vendor and network + esrInfo.setVendor(sliceTaskInfo.getVendor()) + esrInfo.setNetworkType(sliceTaskInfo.getNetworkType()) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + //todo: service info + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.globalSubscriberId = globalSubscriberId + serviceInfo.subscriptionServiceType = subscriptionServiceType + serviceInfo.nsiId = sliceParams.serviceId + serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID + serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID + + nbiRequest.setServiceInfo(serviceInfo) + nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setAllocateTnNssi(allocateTnNssi) + + execution.setVariable("TnBHAllocateNssiNbiRequest", nbiRequest) + execution.setVariable("tnBHSliceTaskInfo", sliceTaskInfo) + } + +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index 081dddab99..88edd79d6d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -15,8 +15,8 @@ import org.onap.so.beans.nsmf.NetworkType import org.onap.so.beans.nsmf.NsiInfo import org.onap.so.beans.nsmf.NssiAllocateRequest import org.onap.so.beans.nsmf.PerfReq -import org.onap.so.beans.nsmf.PerfReqEmbbList -import org.onap.so.beans.nsmf.PerfReqUrllcList +import org.onap.so.beans.nsmf.PerfReqEmbb +import org.onap.so.beans.nsmf.PerfReqUrllc import org.onap.so.beans.nsmf.ResourceSharingLevel import org.onap.so.beans.nsmf.SliceTaskParams import org.onap.so.beans.nsmf.TnSliceProfile @@ -411,20 +411,20 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask execution.setVariable("esrInfo",esrInfo) - PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList() + PerfReqEmbb perfReqEmbb = new PerfReqEmbb() perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor")) perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL")) perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL")) perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL")) perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL")) - List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>() + List<PerfReqEmbb> listPerfReqEmbbList = new ArrayList<>() listPerfReqEmbbList.add(perfReqEmbb) PerfReq perfReq = new PerfReq() perfReq.setPerfReqEmbbList(listPerfReqEmbbList) - PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList() + PerfReqUrllc perfReqUrllc = new PerfReqUrllc() perfReqUrllc.setConnDensity(0) perfReqUrllc.setTrafficDensity(0) perfReqUrllc.setExpDataRate(0) @@ -436,7 +436,7 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask perfReqUrllc.setPayloadSize("0") perfReqUrllc.setServiceAreaDimension("") - List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>() + List<PerfReqUrllc> perfReqUrllcList = new ArrayList<>() perfReqUrllcList.add(perfReqUrllc) perfReq.setPerfReqUrllcList(perfReqUrllcList) @@ -558,20 +558,20 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask execution.setVariable("esrInfo",esrInfo) - PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList() + PerfReqEmbb perfReqEmbb = new PerfReqEmbb() perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor")) perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL")) perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL")) perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL")) perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL")) - List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>() + List<PerfReqEmbb> listPerfReqEmbbList = new ArrayList<>() listPerfReqEmbbList.add(perfReqEmbb) PerfReq perfReq = new PerfReq() perfReq.setPerfReqEmbbList(listPerfReqEmbbList) - PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList() + PerfReqUrllc perfReqUrllc = new PerfReqUrllc() perfReqUrllc.setConnDensity(0) perfReqUrllc.setTrafficDensity(0) perfReqUrllc.setExpDataRate(0) @@ -583,7 +583,7 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask perfReqUrllc.setPayloadSize("0") perfReqUrllc.setServiceAreaDimension("") - List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>() + List<PerfReqUrllc> perfReqUrllcList = new ArrayList<>() perfReqUrllcList.add(perfReqUrllc) perfReq.setPerfReqUrllcList(perfReqUrllcList) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy new file mode 100644 index 0000000000..05bb53a61e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy @@ -0,0 +1,117 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.beans.nsmf.SliceTaskInfo +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.JsonUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +class DoAllocateNSSIV2 extends AbstractServiceTaskProcessor { + + private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSSIV2.class); + private static final ObjectMapper MAPPER = new ObjectMapper(); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.trace("Enter preProcessRequest()") + +// String nssmfOperation +// +// String nsstInput = execution.getVariable("nsstInput") +// String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid") +// //modelUuid="2763777c-27bd-4df7-93b8-c690e23f4d3f" +// String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId") +// String serviceModelInfo = """{ +// "modelInvariantUuid":"", +// "modelUuid":"${modelUuid}", +// "modelVersion":"" +// }""" +// execution.setVariable("serviceModelInfo", serviceModelInfo) +// execution.setVariable("nssiInstanceId", nssiInstanceId) +// String nssiProfileID = UUID.randomUUID().toString() +// execution.setVariable("nssiProfileID", nssiProfileID) +// if(isBlank(nssiInstanceId)) +// { +// nssmfOperation="create" +// nssiInstanceId = UUID.randomUUID().toString() +// }else { +// nssmfOperation = "update" +// } +// execution.setVariable("nssmfOperation",nssmfOperation) +// execution.setVariable("nssiInstanceId",nssiInstanceId) +// +// def isNSSICreated = false +// execution.setVariable("isNSSICreated",isNSSICreated) +// +// int currentCycle = 0 +// execution.setVariable("currentCycle", currentCycle) + + + SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo + if (StringUtils.isBlank(sliceTaskInfo.suggestNssiId)) { + execution.setVariable("nssmfOperation", "create") + } else { + execution.setVariable("nssmfOperation", "update") + } + logger.trace("Exit preProcessRequest") + } + + /** + * prepare nssi request + * @param execution + */ + void prepareNSSIReq(DelegateExecution execution) { + + } + + void getNSSTInfo(DelegateExecution execution){ + logger.trace("Enter getNSSTInfo in DoAllocateNSSI()") + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + ModelInfo modelInfo = serviceDecomposition.getModelInfo() + String serviceRole = "nssi" + String nssiServiceInvariantUuid = serviceDecomposition.modelInfo.getModelInvariantUuid() + String nssiServiceUuid = serviceDecomposition.modelInfo.getModelUuid() + String nssiServiceType = serviceDecomposition.getServiceType() + String uuiRequest = execution.getVariable("uuiRequest") + String nssiServiceName = "nssi_"+jsonUtil.getJsonValue(uuiRequest, "service.name") + execution.setVariable("nssiServiceName",nssiServiceName) + execution.setVariable("nssiServiceType",nssiServiceType) + execution.setVariable("nssiServiceInvariantUuid",nssiServiceInvariantUuid) + execution.setVariable("nssiServiceUuid",nssiServiceUuid) + execution.setVariable("serviceRole",serviceRole) + + String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent() + String nsstID = jsonUtil.getJsonValue(content, "metadata.id") + String nsstVendor = jsonUtil.getJsonValue(content, "metadata.vendor") + String nsstDomain = jsonUtil.getJsonValue(content, "metadata.domainType") + String nsstType = jsonUtil.getJsonValue(content, "metadata.type") + + execution.setVariable("nsstID",nsstID) + execution.setVariable("nsstVendor",nsstVendor) + execution.setVariable("nsstDomain",nsstDomain) + execution.setVariable("nssiServiceUuid",nssiServiceUuid) + execution.setVariable("nsstType",nsstType) + + String nsstContentInfo = """{ + "NsstID":"${nsstID}", + "Vendor":"${nsstVendor}", + "type":"${nsstType}" + }""" + + logger.trace("Exit getNSSTInfo in DoAllocateNSSI()") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy index 26dcaa7ac4..7cdb084b7f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy @@ -158,11 +158,11 @@ class DoCreateCommunicationService extends AbstractServiceTaskProcessor{ String sNSSAI_id = generateNSSAI(serviceInstanceId) execution.setVariable("sNSSAI_id", sNSSAI_id) - // 创建service + // create communication service String serviceInstanceName = execution.getVariable("serviceInstanceName") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") String csServiceType = execution.getVariable("csServiceType") - String aaiServiceRole = "communication-service" //待确定 + String aaiServiceRole = "communication-service" String oStatus = "processing" String uuiRequest = execution.getVariable("uuiRequest") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index ec9596e7f3..9b78afba03 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -64,38 +64,16 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } - void getNSIOptionfromOOF(DelegateExecution execution) { + void prepareSelectNSIRequest(DelegateExecution execution) { String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) boolean isNSISuggested = true execution.setVariable("isNSISuggested",isNSISuggested) - - //Prepare auth for OOF - Begin - def authHeader = "" - String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) - String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) - - String basicAuthValue = utils.encrypt(basicAuth, msokey) - if (basicAuthValue != null) { - logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) - try { - authHeader = utils.getBasicAuth(basicAuthValue, msokey) - execution.setVariable("BasicAuthHeaderValue", authHeader) - } catch (Exception ex) { - logger.debug( "Unable to encode username and password string: " + ex) - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + - "encode username and password string") - } - } else { - logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + - "value null") - } - //Prepare auth for OOF - End - String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + Map<String, Object> profileInfo = execution.getVariable("serviceProfile") Map<String, Object> nstSolution = execution.getVariable("nstSolution") logger.debug("Get NST selection from OOF: " + nstSolution.toString()) @@ -104,36 +82,21 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ "modelVersionId":"${nstSolution.UUID}", "modelName":"${nstSolution.NSTName}" }""" - - String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, profileInfo) - logger.debug("Sending request to OOF: " + oofRequest) - - //send request to get NSI option - Begin - URL url = new URL(urlString+"/api/oof/selection/nsi/v1") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF) - httpClient.addAdditionalHeader("Authorization", authHeader) - Response httpResponse = httpClient.post(oofRequest) - - processOOFResponse(httpResponse, execution) - - //解析sliceProfile - logger.debug("start parseServiceProfile") - parseServiceProfile(execution) - logger.debug("end parseServiceProfile") + + execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1") + execution.setVariable("nsiSelection_messageType",messageType) + execution.setVariable("nsiSelection_correlator",requestId) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + execution.setVariable("nsiSelection_timeout",timeout) + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo,messageType, profileInfo) + execution.setVariable("nsiSelection_oofRequest",oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) } - private void processOOFResponse(Response httpResponse, DelegateExecution execution) { + void processOOFResponse(Response httpResponse, DelegateExecution execution) { int responseCode = httpResponse.getStatus() - logger.debug("OOF sync response code is: " + responseCode) - - if (responseCode != 200) { - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") - logger.debug("Info: No NSI suggested by OOF") - } - SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") - if (httpResponse.hasEntity()) { - String OOFResponse = httpResponse.readEntity(String.class) + String OOFResponse = execution.getVariable("nsiSelection_oofResponse") logger.debug("NSI OOFResponse is: " + OOFResponse) execution.setVariable("OOFResponse", OOFResponse) //This needs to be changed to derive a value when we add policy to decide the solution options. @@ -154,8 +117,11 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } execution.setVariable("sliceTaskParams", sliceTaskParams) logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) - } logger.debug("*** Completed options Call to OOF ***") + //解析sliceProfile + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") } private boolean hasSharedNSIsolutions( Map solutions){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy new file mode 100644 index 0000000000..ca262172d0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy @@ -0,0 +1,907 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.ObjectMapper +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.* +import org.onap.so.beans.nsmf.oof.SubnetCapability +import org.onap.so.beans.nsmf.oof.TemplateInfo +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +class DoCreateSliceServiceOptionV2 extends AbstractServiceTaskProcessor{ + + private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOptionV2.class) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + OofUtils oofUtils = new OofUtils() + + ObjectMapper objectMapper = new ObjectMapper() + + void preProcessRequest (DelegateExecution execution) { + } + + + /** + * prepare select nsi request + * @param execution + */ + void prepareSelectNSIRequest(DelegateExecution execution) { + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSI option OOF Url: " + urlString) + + boolean isNSISuggested = true + execution.setVariable("isNSISuggested",isNSISuggested) + String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + + Map<String, Object> profileInfo = execution.getVariable("serviceProfile") + Map<String, Object> nstSolution = execution.getVariable("nstSolution") + logger.debug("Get NST selection from OOF: " + nstSolution.toString()) + String nstInfo = """{ + "modelInvariantId":"${nstSolution.invariantUUID}", + "modelVersionId":"${nstSolution.UUID}", + "modelName":"${nstSolution.NSTName}" + }""" + + execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1") + execution.setVariable("nsiSelection_messageType",messageType) + execution.setVariable("nsiSelection_correlator",requestId) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + execution.setVariable("nsiSelection_timeout",timeout) + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo,messageType, profileInfo) + execution.setVariable("nsiSelection_oofRequest",oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) + } + + /** + * process select nsi response + * @param execution + */ + void processOOFResponse(DelegateExecution execution) { + + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams + String OOFResponse = execution.getVariable("nsiSelection_oofResponse") + logger.debug("NSI OOFResponse is: " + OOFResponse) + execution.setVariable("OOFResponse", OOFResponse) + //This needs to be changed to derive a value when we add policy to decide the solution options. + + Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class) + List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions") + Map<String, Object> solutions = nsiSolutions.get(0) + + String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + Boolean isSharable = resourceSharingLevel == "shared" + + if (solutions != null) { + if (isSharable && solutions.get("existingNSI")) { + //sharedNSISolution + processSharedNSISolutions(solutions, execution) + } + else if(solutions.containsKey("newNSISolution")) { + processNewNSISolutions(solutions, execution) + } + } + execution.setVariable("sliceTaskParams", sliceTaskParams) + logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) + logger.debug("*** Completed options Call to OOF ***") + + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") + } + + + private void processNewNSISolutions(Map solutions, DelegateExecution execution) { + int index = 0 + List<Map> newNSISolutions = solutions.get("newNSISolution") + List<Map> NSSImap = new ArrayList<>() + if (newNSISolutions != null && newNSISolutions.size() > 0) { + NSSImap = newNSISolutions.get(index).get("NSSISolutions") as List<Map> + for (Map nssi : NSSImap) { + Map oofSliceProfile = nssi.get("sliceProfile") + String domain = oofSliceProfile.getOrDefault("domainType","") + logger.debug("OOF newNSISolutions SliceProfile: " +oofSliceProfile.toString()+",domain:${domain}") + if(null != domain){ + //TODO +// def nssiSolution = nssi.get("NSSISolution") as Map<String, ?> +// String nssiName = nssiSolution.getOrDefault("NSSIName", "") +// String nssiId = nssiSolution.getOrDefault("NSSIId", "") +// saveNSSIId(nssi, sliceTaskParams) + Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile) + saveSliceProfile(execution, domain, sliceProfile) + + } + } + } + } + + private void processSharedNSISolutions(Map solutions, DelegateExecution execution) { + String nsiName, nsiInstanceId, nssiId, nssiName + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + + Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions"))?.get(0) + nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "") + nsiName = sharedNSIsolution.getOrDefault("NSIName", "") + sliceTaskParams.setSuggestNsiId(nsiInstanceId) + sliceTaskParams.setSuggestNsiName(nsiName) + + //Temporary modification + List NSSIs = sharedNSIsolution.get("NSSIs") + for(Map nssi : NSSIs){ + Map oofSliceProfile = ((List)nssi.get("sliceProfile"))?.get(0) + String domain = oofSliceProfile.getOrDefault("domainType","") + nssiId = nssi.getOrDefault("NSSIId","") + nssiName = nssi.getOrDefault("NSSIName","") + saveNSSIId(domain, nssiId, nssiName,execution) + Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile) + saveSliceProfile(execution, domain, sliceProfile) + logger.debug("OOF sharedNSISolution SliceProfile:"+oofSliceProfile.toString()+",domain:${domain}") + logger.debug("OOF sharedNSISolution nsiInstanceId:${nsiInstanceId}, nsiName:${nsiName}, nssiId:${nssiId}, nssiName:${nssiName}") + } + } + + private void parseServiceProfile(DelegateExecution execution) { + logger.debug("Start parseServiceProfile") + String serviceType = execution.getVariable("serviceType") + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + // set sliceProfile for three domains + if(!sliceTaskParams.getSliceProfileAn()){ + Map<String, Object> sliceProfileAn = getSliceProfile( "AN", execution,null) + saveSliceProfile(execution,"AN",sliceProfileAn) + } + + if(!sliceTaskParams.getSliceProfileTn()){ + Map<String, Object> sliceProfileTn = getSliceProfile( "TN", execution,null) + saveSliceProfile(execution,"TN",sliceProfileTn) + } + + if(!sliceTaskParams.getSliceProfileCn()){ + Map<String, Object> sliceProfileCn = getSliceProfile( "CN", execution,null, ) + saveSliceProfile(execution,"CN",sliceProfileCn) + } + + logger.debug("Finish parseServiceProfile") + } + + private void saveSliceProfile(DelegateExecution execution, String domain, Map<String, Object> sliceProfile){ + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if(domain.equalsIgnoreCase("AN")){ + execution.setVariable("sliceProfileAn", sliceProfile) + sliceTaskParams.setSliceProfileAn(sliceProfile) + logger.debug("sliceProfileAn: " + sliceProfile) + } + else if(domain.equalsIgnoreCase("TN")){ + execution.setVariable("sliceProfileTn", sliceProfile) + sliceTaskParams.setSliceProfileTn(sliceProfile) + logger.debug("sliceProfileTn: " + sliceProfile) + } + else if(domain.equalsIgnoreCase("CN")){ + execution.setVariable("sliceProfileCn", sliceProfile) + sliceTaskParams.setSliceProfileCn(sliceProfile) + logger.debug("sliceProfileCn: " + sliceProfile) + } + } + + private void saveNSSIId(String domain, String nssiId, String nssiName, DelegateExecution execution) { + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if(domain.equalsIgnoreCase("AN")){ + sliceTaskParams.setAnSuggestNssiId(nssiId) + sliceTaskParams.setAnSuggestNssiName(nssiName) + } + else if(domain.equalsIgnoreCase("CN")){ + sliceTaskParams.setCnSuggestNssiId(nssiId) + sliceTaskParams.setCnSuggestNssiName(nssiName) + } + else if(domain.equalsIgnoreCase("TN")){ + sliceTaskParams.setTnSuggestNssiId(nssiId) + sliceTaskParams.setTnSuggestNssiName(nssiName) + } + } + + private Map getSliceProfile(String domain, DelegateExecution execution, Map<String, Object> oofSliceProfile) { + String profileMapStr + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + Integer domainLatency = (Integer) serviceProfile.get("latency")/3 + + if(domain.equalsIgnoreCase("AN")){ + profileMapStr = """ { + "latency": ${domainLatency}, + "sNSSAI": "sNSSAI", + "uEMobilityLevel": "uEMobilityLevel", + "coverageAreaTAList": "coverageAreaTAList", + "5QI": 100 + }""" + } + else if(domain.equalsIgnoreCase("TN")){ + profileMapStr =""" { + "latency":${domainLatency}, + "sNSSAI":"sNSSAI", + "e2eLatency":"latency", + "bandwidth": 100 + }""" + } + else if(domain.equalsIgnoreCase("CN")){ + profileMapStr = """ { + "areaTrafficCapDL":"areaTrafficCapDL", + "maxNumberofUEs":"maxNumberofUEs", + "latency":${domainLatency}, + "expDataRateUL":"expDataRateUL", + "sNSSAI":"sNSSAI", + "areaTrafficCapUL":"areaTrafficCapUL", + "uEMobilityLevel":"uEMobilityLevel", + "expDataRateDL":"expDataRateDL", + "activityFactor":"activityFactor", + "resourceSharingLevel":"resourceSharingLevel" + }""" + } + + logger.debug("Profile map for " + domain + " : " + profileMapStr) + Map<String, Object> profileMaps = objectMapper.readValue(profileMapStr.trim().replaceAll(" ", ""), new TypeReference<Map<String, String>>(){}) + Map<String, Object> sliceProfile = [:] + for (Map.Entry<String, String> profileMap : profileMaps) { + String key = profileMap.key + String value = profileMaps.get(key) + if(null != oofSliceProfile && oofSliceProfile.keySet().contains(key)){ + sliceProfile.put(key, oofSliceProfile.get(key)) + logger.debug("Get from oof, key:${key}, value: ${oofSliceProfile.get(key)}") + } + else if(serviceProfile.keySet().contains(value)){ + sliceProfile.put(key, serviceProfile.get(value)) + } + else{ + sliceProfile.put(key, profileMaps.get(key)) + } + } + return sliceProfile + } + + void processDecomposition(DelegateExecution execution){ + logger.debug("Start processDecomposition") + + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + String nstName = serviceDecomposition.getModelInfo().getModelName() + String nstId = serviceDecomposition.getModelInfo().getModelUuid() + sliceTaskParams.setNstName(nstName) + sliceTaskParams.setNstId(nstId) + + logger.debug("End processDecomposition") + } + + + void prepareNSTDecompose(DelegateExecution execution) { + + String modelUuid = execution.getVariable("nstModelUuid") + String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid") + + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + } + + void prepareNSSTDecompose(DelegateExecution execution) { + Boolean isMoreNSSTtoProcess = false + Integer maxNSST = execution.getVariable("maxNSST") + Integer currentNSST=execution.getVariable("currentNSST") + List<String> nsstModelUUIDList = new ArrayList<>() + nsstModelUUIDList = execution.getVariable("nsstModelUUIDList") + String modelUuid = nsstModelUUIDList.get(currentNSST) + String serviceModelInfo = """{ + "modelInvariantUuid":"", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + currentNSST=currentNSST+1 + if(currentNSST<maxNSST) + isMoreNSSTtoProcess=true + execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess) + execution.setVariable("maxNSST",maxNSST) + execution.setVariable("currentNSST",currentNSST) + } + + + void prepareNSSTlistfromNST(DelegateExecution execution) { + //Need to update this part from decomposition. + logger.trace("Enter prepareNSSTlistfromNST()") + Boolean isMoreNSSTtoProcess = false + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + String nstName = serviceDecomposition.getModelInfo().getModelName() + sliceTaskParams.setNstName(nstName) + String nstId = serviceDecomposition.getModelInfo().getModelUuid() + sliceTaskParams.setNstId(nstId) + execution.setVariable("sliceTaskParams",sliceTaskParams) + + List<ServiceProxy> proxyList = serviceDecomposition.getServiceProxy() + List<String> nsstModelUUIDList = new ArrayList<>() + for(ServiceProxy serviceProxy:proxyList) + nsstModelUUIDList.add(serviceProxy.getSourceModelUuid()) + execution.setVariable("nsstModelUUIDList",nsstModelUUIDList) + Integer maxNSST = nsstModelUUIDList.size() + Integer currentNSST=0 + execution.setVariable("maxNSST",maxNSST) + execution.setVariable("currentNSST",currentNSST) + if(currentNSST<maxNSST) + isMoreNSSTtoProcess=true + execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess) + logger.trace("Exit prepareNSSTlistfromNST()") + + } + + void getNSSTOption(DelegateExecution execution) { + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("subscriptionServiceType") + String nssiInstanceId ="" + String nssiName ="" + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + logger.debug( "get NSI option OOF Url: " + urlString) + boolean isNSISuggested = false + execution.setVariable("isNSISuggested",isNSISuggested) + + //Prepare auth for OOF - Begin + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) + String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + + String basicAuthValue = utils.encrypt(basicAuth, msokey) + if (basicAuthValue != null) { + logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) + try { + authHeader = utils.getBasicAuth(basicAuthValue, msokey) + execution.setVariable("BasicAuthHeaderValue", authHeader) + } catch (Exception ex) { + logger.debug( "Unable to encode username and password string: " + ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + + "encode username and password string") + } + } else { + logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + + "value null") + } + //Prepare auth for OOF - End + //Prepare send request to OOF - Begin + String requestId = execution.getVariable("msoRequestId") + Map<String, Object> profileInfo = execution.getVariable("serviceProfile") + String nsstModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid() + String nsstModelUuid = serviceDecomposition.getModelInfo().getModelUuid() + String nsstInfo = """"NSSTInfo": { + "invariantUUID":"${nsstModelInvariantUuid}", + "UUID":"${nsstModelUuid}" + }""" + String oofRequest = oofUtils.buildSelectNSSIRequest(execution, requestId, nsstInfo ,profileInfo) + + + URL url = new URL(urlString+"/api/oof/v1/selectnssi") + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(oofRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + + if(responseCode != 200){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } + + if(httpResponse.hasEntity()){ + String OOFResponse = httpResponse.readEntity(String.class) + execution.setVariable("OOFResponse", OOFResponse) + nssiInstanceId = jsonUtil.getJsonValue(OOFResponse, "NSSIIInfo.NSSIID") + nssiName = jsonUtil.getJsonValue(OOFResponse, "NSSIInfo.NSSIName") + execution.setVariable("nssiInstanceId",nssiInstanceId) + execution.setVariable("nssiName",nssiName) + } + if(StringUtils.isBlank(nssiInstanceId)){ + logger.debug( "There is no valid NSST suggested by OOF.") + }else + { + try { + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiInstanceId) + AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) + org.onap.aai.domain.yang.ServiceInstance nssi = si.get() + + String domain = nssi.getEnvironmentContext().toString().toUpperCase() + switch (domain) { + case "AN": + sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName()) + break + case "CN": + sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName()) + break + case "TN": + sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName()) + break + default: + break + } + }catch(NotFoundException e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId) + }catch(Exception e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId) + } + } + logger.debug("Prepare NSSI option completed ") + } + + + /** + * new + */ + + private static final ObjectMapper MAPPER = new ObjectMapper() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + private static final String QUERY_SUB_NET_CAPABILITY = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery" + + private static final String QUERY_NSSI_SELECTION_CAPABILITY = "/api/rest/provMns/v1/NSS/NSSISelectionCapability" + + /** + * query Subnet Capability of TN + * @param execution + */ + public void queryTNSubnetCapability(DelegateExecution execution) { + + String vendor = execution.getVariable("vendor") + + List<String> subnetTypes = new ArrayList<>() + subnetTypes.add("TN_FH") + subnetTypes.add("TN_MH") + subnetTypes.add("TN_BH") + + String strRequest = MAPPER.writeValueAsString( + buildQuerySubnetCapRequest(vendor, subnetTypes, NetworkType.TRANSPORT)) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest) + execution.setVariable("subnetCapabilityOfTN", response) + } + + /** + * query Subnet Capability of CN + * @param execution + */ + public void queryCNSubnetCapability(DelegateExecution execution) { + + String vendor = execution.getVariable("vendor") + + List<String> subnetTypes = new ArrayList<>() + subnetTypes.add("CN") + + String strRequest = MAPPER.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetTypes, NetworkType.CORE)) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest) + + execution.setVariable("subnetCapabilityOfCN", response) + } + + /** + * query Subnet Capability of AN + * @param execution + */ + public void queryANSubnetCapability(DelegateExecution execution) { + + String vendor = execution.getVariable("vendor") + + List<String> subnetTypes = new ArrayList<>() + subnetTypes.add("AN-NF") + + String strRequest = MAPPER.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetTypes, NetworkType.ACCESS)) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest) + + execution.setVariable("subnetCapabilityOfAN", response) + } + + /** + * build request body for querying Subnet Capability + * @param vendor + * @param subnetTypes + * @param networkType + * @return + */ + private static String buildQuerySubnetCapRequest(String vendor, List<String> subnetTypes, NetworkType networkType) { + NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest() + + Map<String, Object> paramMap = new HashMap() + paramMap.put("subnetTypes", subnetTypes) + + request.setSubnetCapabilityQuery(MAPPER.writeValueAsString(paramMap)) + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setVendor(vendor) + esrInfo.setNetworkType(networkType) + + request.setEsrInfo(esrInfo) + + String strRequest = MAPPER.writeValueAsString(request) + + return strRequest + } + + /** + * handle response of Subnet Capability, generate SubnetCapabilities Info for request to oof + * @param execution + */ + public void generateSubnetCapabilities(DelegateExecution execution) { + //todo: + execution.setVariable("subnetCapabilities", []) + } + + /** + * prepare the params for decompose nst + * @param execution + */ + public void prepareDecomposeNST(DelegateExecution execution) { + + String modelUuid = execution.getVariable("nstModelUuid") + String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid") + + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("nstServiceModelInfo", serviceModelInfo) + } + + /** + * process the result of NST Decomposition + * @param execution + */ + public void processDecompositionNST(DelegateExecution execution) { + + ServiceDecomposition nstServiceDecomposition = execution.getVariable("nstServiceDecomposition") + //todo: + + } + + + /** + * prepare the params for decompose nsst + * @param execution + */ + public void prepareDecomposeNSST(DelegateExecution execution) { + Boolean isMoreNSSTtoProcess = false + def maxNSST = execution.getVariable("maxNSST") as Integer + def currentNSST = execution.getVariable("currentNSST") as Integer + def nsstModelUUIDList = execution.getVariable("nsstModelUUIDList") as List + String modelUuid = nsstModelUUIDList.get(currentNSST) + String serviceModelInfo = """{ + "modelInvariantUuid":"", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("nsstServiceModelInfo", serviceModelInfo) + currentNSST = currentNSST + 1 + + if(currentNSST < maxNSST) { + isMoreNSSTtoProcess = true + } + + execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess) + execution.setVariable("maxNSST", maxNSST) + execution.setVariable("currentNSST", currentNSST) + + //todo: + } + + /** + * process the result of NSST Decomposition + * @param execution + */ + public void processDecompositionNSST(DelegateExecution execution) { + ServiceDecomposition nsstServiceDecomposition = execution.getVariable("nsstServiceDecomposition") + //todo: + } + + /** + * todo: need rewrite + * prepare select nsi request + * @param execution + */ + public void preNSIRequest(DelegateExecution execution) { + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSI option OOF Url: " + urlString) + + boolean isNSISuggested = true + execution.setVariable("isNSISuggested", isNSISuggested) + String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + + ServiceProfile profileInfo = execution.getVariable("serviceProfile") as ServiceProfile + Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map + logger.debug("Get NST selection from OOF: " + nstSolution.toString()) + + execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1") + execution.setVariable("nsiSelection_messageType", messageType) + execution.setVariable("nsiSelection_correlator", requestId) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution) + execution.setVariable("nsiSelection_timeout", timeout) + + + TemplateInfo nstInfo = new TemplateInfo() + nstInfo.setInvariantUUID(nstSolution.get("invariantUUID") as String) + nstInfo.setUUID(nstSolution.get("UUID") as String) + nstInfo.setName(nstSolution.get("NSTName") as String) + + execution.setVariable("NSTInfo", nstInfo) + + List<TemplateInfo> nsstInfos = execution.getVariable("NSSTInfos") as List<TemplateInfo> + + List<SubnetCapability> subnetCapabilities = execution.getVariable("subnetCapabilities") as List<SubnetCapability> + + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos, + messageType, profileInfo, subnetCapabilities, timeout as Integer) + + execution.setVariable("nsiSelection_oofRequest", oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) + } + + /** + * todo: need rewrite + * process select nsi response + * @param execution + */ + public void processNSIResp(DelegateExecution execution) { + + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams + String OOFResponse = execution.getVariable("nsiSelection_oofResponse") + logger.debug("NSI OOFResponse is: " + OOFResponse) + execution.setVariable("OOFResponse", OOFResponse) + //This needs to be changed to derive a value when we add policy to decide the solution options. + + Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class) + List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions") + Map<String, Object> solutions = nsiSolutions.get(0) + + String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + Boolean isSharable = resourceSharingLevel == "shared" + + if (solutions != null) { + if (isSharable && solutions.get("existingNSI")) { + //sharedNSISolution + processSharedNSISolutions(solutions, execution) + } + else if(solutions.containsKey("newNSISolution")) { + processNewNSISolutions(solutions, execution) + } + } + execution.setVariable("sliceTaskParams", sliceTaskParams) + logger.debug("sliceTaskParams: " + sliceTaskParams.convertToJson()) + logger.debug("*** Completed options Call to OOF ***") + + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") + } + + /** + * get NSSI Selection Capability for AN + * @param execution + */ + public void getNSSISelectionCap4AN(DelegateExecution execution) { + + def vendor = execution.getVariable("vendor") as String + + String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest) + + Map<String, Object> resMap = objectMapper.readValue(response, Map.class) + + String selection = resMap.get("selection") + + + if ("NSMF".equalsIgnoreCase(selection)) { + execution.setVariable("NEED_AN_NSSI_SELECTION", true) + } + } + + /** + * get NSSI Selection Capability for TN + * @param execution + */ + public void getNSSISelectionCap4TN(DelegateExecution execution) { + + def vendor = execution.getVariable("vendor") as String + + String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest) + + Map<String, Object> resMap = objectMapper.readValue(response, Map.class) + + String selection = resMap.get("selection") + + if ("NSMF".equalsIgnoreCase(selection)) { + execution.setVariable("NEED_TN_NSSI_SELECTION", true) + } + } + + /** + * get NSSI Selection Capability for CN + * @param execution + */ + public void getNSSISelectionCap4CN(DelegateExecution execution) { + + def vendor = execution.getVariable("vendor") as String + + String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest) + + Map<String, Object> resMap = objectMapper.readValue(response, Map.class) + + String selection = resMap.get("selection") + + if ("NSMF".equalsIgnoreCase(selection)) { + execution.setVariable("NEED_CN_NSSI_SELECTION", true) + } + } + + /** + * build NSSI Selection Capability Request body to nssmf adapter + * @param vendor + * @param networkType + * @return + */ + private static String buildNSSISelectionReq(String vendor, NetworkType networkType) { + NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest() + EsrInfo esrInfo = new EsrInfo() + esrInfo.setVendor(vendor) + esrInfo.setNetworkType(networkType) + request.setEsrInfo(esrInfo) + + return MAPPER.writeValueAsString(request) + } + + /** + * if exist nssi need to select? + * @param execution + */ + public void handleNssiSelect(DelegateExecution execution) { + + SliceTaskParamsAdapter sliceTaskParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + + execution.setVariable() + } + + /** + * todo: need rewrite + * prepare select nssi request + * @param execution + */ + public void preNSSIRequest(DelegateExecution execution) { + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSI option OOF Url: " + urlString) + + boolean isNSISuggested = true + execution.setVariable("isNSISuggested", isNSISuggested) + String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + + Map<String, Object> profileInfo = execution.getVariable("serviceProfile") as Map + Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map + logger.debug("Get NST selection from OOF: " + nstSolution.toString()) + String nstInfo = """{ + "modelInvariantId":"${nstSolution.invariantUUID}", + "modelVersionId":"${nstSolution.UUID}", + "modelName":"${nstSolution.NSTName}" + }""" + + execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1") + execution.setVariable("nsiSelection_messageType", messageType) + execution.setVariable("nsiSelection_correlator", requestId) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution) + execution.setVariable("nsiSelection_timeout", timeout) + + //todo + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, messageType, profileInfo) + + execution.setVariable("nsiSelection_oofRequest", oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) + } + + /** + * process select nssi response + * @param execution + */ + public void processNSSIResp(DelegateExecution execution) { + + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams + String OOFResponse = execution.getVariable("nsiSelection_oofResponse") + logger.debug("NSI OOFResponse is: " + OOFResponse) + execution.setVariable("OOFResponse", OOFResponse) + //This needs to be changed to derive a value when we add policy to decide the solution options. + + Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class) + List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions") + Map<String, Object> solutions = nsiSolutions.get(0) + + String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + Boolean isSharable = resourceSharingLevel == "shared" + + if (solutions != null) { + if (isSharable && solutions.get("existingNSI")) { + //sharedNSISolution + processSharedNSISolutions(solutions, execution) + } + else if(solutions.containsKey("newNSISolution")) { + processNewNSISolutions(solutions, execution) + } + } + execution.setVariable("sliceTaskParams", sliceTaskParams) + logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) + logger.debug("*** Completed options Call to OOF ***") + + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") + } + + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy new file mode 100644 index 0000000000..534467f6ab --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -0,0 +1,231 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.SliceProfile +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { + + private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class); + JsonUtils jsonUtil = new JsonUtils() + TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() + ExceptionUtil exceptionUtil = new ExceptionUtil() + String Prefix = "DCTN_" + + void preProcessRequest(DelegateExecution execution) { + String msg = "" + logger.trace("Enter preProcessRequest()") + + execution.setVariable("prefix", Prefix) + + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + //here modelVersion is not set, we use modelUuid to decompose the service. + def isDebugLogEnabled = true + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + + logger.trace("Exit preProcessRequest") + } + + + void createSliceProfile(DelegateExecution execution) { + + String sliceserviceInstanceId = execution.getVariable("sliceServiceInstanceId") + String sliceProfileStr = execution.getVariable("sliceProfile") + String sliceProfileId = UUID.randomUUID().toString() + SliceProfile sliceProfile = new SliceProfile(); + sliceProfile.setProfileId(sliceProfileId) + sliceProfile.setLatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) + sliceProfile.setResourceSharingLevel(jsonUtil.getJsonValue(sliceProfileStr, "resourceSharingLevel")) + sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)) //TODO: should be list + + sliceProfile.setE2ELatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) + sliceProfile.setMaxBandwidth(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "maxBandwidth"))) + + //TODO: new API + sliceProfile.setReliability(new Object()) + try { + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, execution.getVariable + ("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, sliceProfileId) + client.create(uri, sliceProfile) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + + void createServiceInstance(DelegateExecution execution) { + + String serviceRole = "TN" + String serviceType = execution.getVariable("subscriptionServiceType") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") + String sliceProfileStr = execution.getVariable("sliceProfile") + try { + org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() + ss.setServiceInstanceId(ssInstanceId) + String sliceInstanceName = execution.getVariable("sliceServiceInstanceName") + ss.setServiceInstanceName(sliceInstanceName) + ss.setServiceType(serviceType) + String serviceStatus = "allocated" + ss.setOrchestrationStatus(serviceStatus) + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + ss.setModelInvariantId(modelInvariantUuid) + ss.setModelVersionId(modelUuid) + String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) + ss.setServiceInstanceLocationId(serviceInstanceLocationid) + String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) + ss.setEnvironmentContext(snssai) + ss.setServiceRole(serviceRole) + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), ssInstanceId) + client.create(uri, ss) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + + void createAllottedResource(DelegateExecution execution) { + String serviceInstanceId = execution.getVariable('sliceServiceInstanceId') + + AAIResourcesClient resourceClient = getAAIClient() + AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + + try { + List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportSliceNetworks")) + + for (String networkStr : networkStrList) { + String allottedResourceId = UUID.randomUUID().toString() + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), + execution.getVariable("sliceserviceInstanceId"), allottedResourceId) + execution.setVariable("allottedResourceUri", allottedResourceUri) + String modelInvariantId = execution.getVariable("modelInvariantUuid") + String modelVersionId = execution.getVariable("modelUuid") + + org.onap.aai.domain.yang.AllottedResource resource = new org.onap.aai.domain.yang.AllottedResource() + resource.setId(allottedResourceId) + resource.setType("TsciNetwork") + resource.setAllottedResourceName("network_" + execution.getVariable("sliceServiceInstanceName")) + resource.setModelInvariantId(modelInvariantId) + resource.setModelVersionId(modelVersionId) + getAAIClient().create(allottedResourceUri, resource) + //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build()) + //getAAIClient().connect(allottedResourceUri,ssServiceuri) + //execution.setVariable("aaiARPath", allottedResourceUri.build().toString()); + + String linkArrayStr = jsonUtil.getJsonValue(networkStr, "connectionLinks") + createLogicalLinksForAllocatedResource(execution, linkArrayStr, serviceInstanceId, allottedResourceId) + } + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage()) + } + } + + void createLogicalLinksForAllocatedResource(DelegateExecution execution, + String linkArrayStr, String serviceInstanceId, + String allottedResourceId) { + + try { + List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) + + for (String linkStr : linkStrList) { + String logicalLinkId = UUID.randomUUID().toString() + String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA") + String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB") + String modelInvariantId = execution.getVariable("modelInvariantUuid") + String modelVersionId = execution.getVariable("modelUuid") + + org.onap.aai.domain.yang.LogicalLink resource = new org.onap.aai.domain.yang.LogicalLink() + resource.setLinkId(logicalLinkId) + resource.setLinkName(epA) + resource.setLinkName2(epB) + resource.setModelInvariantId(modelInvariantId) + resource.setModelVersionId(modelVersionId) + + AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIObjectType.LOGICAL_LINK, logicalLinkId) + getAAIClient().create(logicalLinkUri, resource) + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, + "Exception in createLogicalLinksForAllocatedResource" + ex.getMessage()) + } + } + + void preprocessSdncAllocateTnNssiRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + + logger.trace("STARTED preProcessSDNCActivateRequest Process") + try { + String serviceInstanceId = execution.getVariable("sliceServiceInstanceId") + + String createSDNCRequest = tnNssmfUtils.buildSDNCRequest(execution, serviceInstanceId, "create") + + execution.setVariable("TNNSSMF_SDNCRequest", createSDNCRequest) + logger.debug("Outgoing SDNCRequest is: \n" + createSDNCRequest) + + } catch (Exception e) { + logger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, + "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preProcessSDNCActivateRequest Process") + } + + + void validateSDNCResponse(DelegateExecution execution, String response, String method) { + tnNssmfUtils.validateSDNCResponse(execution, response, method) + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy new file mode 100644 index 0000000000..2ca0da4cbb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy @@ -0,0 +1,556 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.scripts + +import static org.apache.commons.lang3.StringUtils.isBlank + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.* +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.DeAllocateNssi +import org.onap.so.beans.nsmf.EsrInfo +import org.onap.so.beans.nsmf.ServiceInfo +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.oof.adapter.beans.payload.OofRequest +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import com.fasterxml.jackson.databind.ObjectMapper +import com.google.gson.JsonObject + +/** + * Internal AN NSSMF to handle NSSI Deallocation + */ +class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { + + String Prefix="DoDeAllocateAccessNSSI" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + OofUtils oofUtils = new OofUtils() + ObjectMapper objectMapper = new ObjectMapper() + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + private static final Logger logger = LoggerFactory.getLogger(DoDeAllocateAccessNSSI.class) + private static final String ROLE_SLICE_PROFILE = "slice-profile-instance" + private static final String ROLE_NSSI = "nssi" + + private static final String AN_NF = "AN-NF" + private static final String TN_FH = "TN-FH" + private static final String TN_MH = "TN-MH" + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug("${Prefix} - Start preProcessRequest") + + String sliceParams = execution.getVariable("sliceParams") + String sNssaiList = jsonUtil.getJsonValue(sliceParams, "snssaiList") + String anSliceProfileId = jsonUtil.getJsonValue(sliceParams, "sliceProfileId") + String nsiId = jsonUtil.getJsonValue(sliceParams, "nsiId") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String anNssiId = execution.getVariable("serviceInstanceID") + + if(isBlank(sNssaiList) || isBlank(anSliceProfileId) || isBlank(nsiId)) { + String msg = "Input fields cannot be null : Mandatory attributes : [snssaiList, sliceProfileId, nsiId]" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if( isBlank(anNssiId) || isBlank(globalSubscriberId) || isBlank(subscriptionServiceType)) { + String msg = "Missing Input fields from main process : [serviceInstanceID, globalSubscriberId, subscriptionServiceType]" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + execution.setVariable("sNssaiList", sNssaiList) + execution.setVariable("anSliceProfileId", anSliceProfileId) + execution.setVariable("nsiId", nsiId) + execution.setVariable("anNssiId", anNssiId) + + logger.debug("${Prefix} - Preprocessing completed with sliceProfileId : ${anSliceProfileId} , nsiId : ${nsiId} , nssiId : ${anNssiId}") + } + + /** + * Method to fetch AN NSSI Constituents and Slice Profile constituents + * @param execution + */ + void getRelatedInstances(DelegateExecution execution) { + logger.debug("${Prefix} - Get Related Instances") + String anSliceProfileId = execution.getVariable("anSliceProfileId") + String anNssiId = execution.getVariable("anNssiId") + + Map<String,ServiceInstance> relatedSPs = new HashMap<>() + execution.setVariable("relatedSPs", getRelatedInstancesByRole(execution, ROLE_SLICE_PROFILE, anSliceProfileId)) + execution.setVariable("anNfSliceProfileId", getInstanceIdByWorkloadContext(execution.getVariable("relatedSPs"), AN_NF)) + + Map<String,ServiceInstance> relatedNssis = new HashMap<>() + execution.setVariable("relatedNssis", getRelatedInstancesByRole(execution, ROLE_NSSI, anNssiId)) + } + + + /** + * @param execution + */ + void prepareOOFAnNssiTerminationRequest(DelegateExecution execution) { + logger.debug("Start prepareOOFTerminationRequest") + String requestId = execution.getVariable("msoRequestId") + String messageType = "AN_NSSITermination" + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + String serviceInstanceId = execution.getVariable("nsiId") + String anNssiId = execution.getVariable("anNssiId") + String oofRequest = oofUtils.buildTerminateNxiRequest(requestId,anNssiId, ROLE_NSSI,messageType,serviceInstanceId) + OofRequest oofPayload = new OofRequest() + oofPayload.setApiPath("/api/oof/terminate/nxi/v1") + oofPayload.setRequestDetails(oofRequest) + execution.setVariable("oofAnNssiPayload", oofPayload) + logger.debug("Finish prepareOOFTerminationRequest") + + } + + void performOofAnNSSITerminationCall(DelegateExecution execution) { + boolean terminateAnNSSI = callOofAdapter(execution,execution.getVariable("oofAnNssiPayload")) + execution.setVariable("terminateAnNSSI", terminateAnNSSI) + } + + /** + * @param execution + */ + void prepareOOFAnNfNssiTerminationRequest(DelegateExecution execution) { + logger.debug("Start prepareOOFAnNfNssiTerminationRequest") + String requestId = execution.getVariable("msoRequestId") + String messageType = "AN_NF_NSSITermination" + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + String serviceInstanceId = execution.getVariable("anNssiId") + + String anNfNssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"),AN_NF) + execution.setVariable("anNfNssiId", anNfNssiId) + + String oofRequest = oofUtils.buildTerminateNxiRequest(requestId,anNfNssiId, ROLE_NSSI,messageType,serviceInstanceId) + OofRequest oofPayload = new OofRequest() + oofPayload.setApiPath("/api/oof/terminate/nxi/v1") + oofPayload.setRequestDetails(oofRequest) + execution.setVariable("oofAnNfNssiPayload", oofPayload) + logger.debug("Finish prepareOOFAnNfNssiTerminationRequest") + + } + + void performOofAnNfNSSITerminationCall(DelegateExecution execution) { + boolean terminateAnNfNSSI = callOofAdapter(execution,execution.getVariable("oofAnNfNssiPayload")) + execution.setVariable("terminateAnNfNSSI", terminateAnNfNSSI) + if(!terminateAnNfNSSI) { + execution.setVariable("modifyAction",true) + } + } + + void prepareSdnrRequest(DelegateExecution execution) { + + String anNfNssiId = execution.getVariable("anNfNssiId") + String sNssai = execution.getVariable("sNssaiList") + String reqId = execution.getVariable("msoRequestId") + String messageType = "SDNRTerminateResponse" + StringBuilder callbackURL = new StringBuilder(UrnPropertiesReader.getVariable("mso.workflow.message.endpoint", execution)) + callbackURL.append("/").append(messageType).append("/").append(reqId) + + JsonObject input = new JsonObject() + input.addProperty("RANNFNSSIId", anNfNssiId) + input.addProperty("callbackURL", callbackURL.toString()) + input.addProperty("s-NSSAI", sNssai) + + JsonObject Payload = new JsonObject() + Payload.addProperty("version", "1.0") + Payload.addProperty("rpc-name", "TerminateRANSlice") + Payload.addProperty("correlation-id", reqId) + Payload.addProperty("type", "request") + + JsonObject wrapinput = new JsonObject() + wrapinput.addProperty("Action", "deallocate") + + JsonObject CommonHeader = new JsonObject() + CommonHeader.addProperty("TimeStamp", new Date(System.currentTimeMillis()).format("yyyy-MM-ddTHH:mm:ss.sss", TimeZone.getDefault())) + CommonHeader.addProperty("APIver", "1.0") + CommonHeader.addProperty("RequestID", reqId) + CommonHeader.addProperty("SubRequestID", "1") + + JsonObject body = new JsonObject() + body.add("input", wrapinput) + + JsonObject sdnrRequest = new JsonObject() + Payload.add("input", input) + wrapinput.add("Payload", Payload) + wrapinput.add("CommonHeader", CommonHeader) + body.add("input", wrapinput) + sdnrRequest.add("body", body) + + String json = sdnrRequest.toString() + execution.setVariable("sdnrRequest", sdnrRequest) + execution.setVariable("SDNR_messageType", messageType) + execution.setVariable("SDNR_timeout", "PT10M") + + } + + void processSdnrResponse(DelegateExecution execution) { + logger.debug("${Prefix} processing SdnrResponse") + Map<String, Object> resMap = objectMapper.readValue(execution.getVariable("SDNR_Response"),Map.class) + String status = resMap.get("status") + String reason = resMap.get("reason") + if("success".equalsIgnoreCase(status)) { + execution.setVariable("isAnNfTerminated", true) + }else { + execution.setVariable("isAnNfTerminated", false) + logger.debug("AN NF Termination failed with reason ${reason}") + } + logger.debug("${Prefix} processed SdnrResponse") + } + + /** + * @param execution + * @param oofRequest - Request payload to be sent to adapter + * @return + */ + boolean callOofAdapter(DelegateExecution execution, OofRequest oofRequest) { + logger.debug("Start callOofAdapter") + String requestId = execution.getVariable("msoRequestId") + String oofAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.oof.endpoint", execution) + URL requestUrl = new URL(oofAdapterEndpoint) + logger.debug("Calling OOF adapter : ${requestUrl} with payload : ${oofRequest}") + HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.EXTERNAL) + Response httpResponse = httpClient.post(oofRequest) + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + if(responseCode != 200){ + logger.debug("OOF request failed with reason : " + httpResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + }else { + Map<String,Object> response = objectMapper.readValue(httpResponse.getEntity(),Map.class) + boolean terminateResponse = response.get("terminateResponse") + if(!terminateResponse) { + logger.debug("Terminate response is false because " + response.get("reason")) + } + return terminateResponse + } + } + + void deallocateAnNfNssi(DelegateExecution execution) { + logger.debug("${Prefix} - call deallocateAnNfNssi ") + String anNfNssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), AN_NF) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, anNfNssiId) + if (!client.exists(uri)) { + logger.debug("AN NF Service Instance was not found in aai : ${anNfNssiId}") + }else { + client.delete(uri) + } + } + + /** + * Removes relationship between AN NSSI and AN_NF NSSI + * @param execution + */ + void dissociateAnNfNssi(DelegateExecution execution) { + logger.debug("${Prefix} - call dissociateAnNfNssi ") + String anNfNssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), AN_NF) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, anNfNssiId) + if (!client.exists(uri)) { + logger.debug("AN NF Service Instance was not found in aai : ${anNfNssiId}") + }else { + client.delete(uri) + } + } + + /** + * Method to prepare request for AN NSSI modification + * Call Modify AN NSSI in case OOF sends Terminate NSSI=False + * @param execution + */ + void preparejobForANNSSIModification(DelegateExecution execution) { + + String modificationJobId = UUID.randomUUID().toString() + execution.setVariable("modificationJobId", modificationJobId) + + Map<String,Object> sliceParams = objectMapper.readValue(execution.getVariable("sliceParams"), Map.class) + sliceParams.put("modifyAction", "deallocate") + execution.setVariable("modificationsliceParams", sliceParams) + + String serviceId = execution.getVariable("serviceInstanceId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " operationId:" + modificationJobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(modificationJobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Modify-Deallocate") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + void prepareQueryJobStatus(DelegateExecution execution,String jobId,String networkType,String instanceId) { + + String responseId = "1" + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType(networkType) + esrInfo.setVendor("ONAP") + + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.setNssiId(instanceId) + serviceInfo.setNsiId(execution.getVariable("nsiId")) + serviceInfo.setGlobalSubscriberId(globalSubscriberId) + serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + + execution.setVariable("${networkType}_esrInfo", esrInfo) + execution.setVariable("${networkType}_responseId", responseId) + execution.setVariable("${networkType}_serviceInfo", serviceInfo) + + } + + void validateJobStatus(DelegateExecution execution,String responseDescriptor) { + logger.debug("validateJobStatus ${responseDescriptor}") + String status = jsonUtil.getJsonValue(responseDescriptor, "responseDescriptor.status") + String statusDescription = jsonUtil.getJsonValue(responseDescriptor, "responseDescriptor.statusDescription") + if("finished".equalsIgnoreCase(status)) { + execution.setVariable("isSuccess", true) + }else { + execution.setVariable("isSuccess", false) + } + } + + void prepareUpdateJobStatus(DelegateExecution execution,String status,String progress,String statusDescription) { + String serviceId = execution.getVariable("anNssiId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setServiceId(serviceId) + roStatus.setOperationId(jobId) + roStatus.setResourceTemplateUUID(nsiId) + roStatus.setOperType("DeAllocate") + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + } + + void terminateTNFHNssi(DelegateExecution execution) { + logger.debug("Start terminateTNFHNssi in ${Prefix}") + String nssmfRequest = buildDeallocateNssiRequest(execution, TN_FH) + String nssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), TN_FH) + execution.setVariable("tnFHNSSIId", nssiId) + String urlString = "/api/rest/provMns/v1/NSS/nssi/" + nssiId + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + if (nssmfResponse != null) { + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TN_FH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + logger.debug("Exit terminateTNFHNssi in ${Prefix}") + } + + void terminateTNMHNssi(DelegateExecution execution) { + logger.debug("Start terminateTNMHNssi in ${Prefix}") + String nssmfRequest = buildDeallocateNssiRequest(execution, TN_MH) + String nssiId = getInstanceIdByWorkloadContext(execution.getVariable("relatedNssis"), TN_MH) + execution.setVariable("tnMHNSSIId", nssiId) + String urlString = "/api/rest/provMns/v1/NSS/nssi/" + nssiId + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + if (nssmfResponse != null) { + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TN_MH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + logger.debug("Exit terminateTNMHNssi in ${Prefix}") + } + + void deleteRanNfSliceProfileInAAI(DelegateExecution execution) { + logger.debug("${Prefix} delete Ran NF SliceProfile In AAI") + String spId = execution.getVariable("anNfSliceProfileId") + deleteServiceInstanceInAAI(execution, spId) + } + + void deleteTNSliceProfileInAAI(DelegateExecution execution) { + logger.debug("${Prefix} delete TN FH SliceProfile In AAI") + String fhSP = getInstanceIdByWorkloadContext(execution.getVariable("relatedSPs"), TN_FH) + deleteServiceInstanceInAAI(execution, fhSP) + logger.debug("${Prefix} delete TN MH SliceProfile In AAI") + String mhSP = getInstanceIdByWorkloadContext(execution.getVariable("relatedSPs"), TN_MH) + deleteServiceInstanceInAAI(execution, mhSP) + } + + void deleteANNSSI(DelegateExecution execution) { + logger.debug("${Prefix} delete AN NSSI") + String nssiId = execution.getVariable("serviceInstanceID") + deleteServiceInstanceInAAI(execution, nssiId) + } + + /** + * Fetches a collection of service instances with the specific role and maps it based on workload context + * (AN-NF,TN-FH,TN-MH) + * @param execution + * @param role - nssi/slice profile instance + * @param instanceId - id to which the related list to be found + * @return + */ + private Map<String,ServiceInstance> getRelatedInstancesByRole(DelegateExecution execution,String role,String instanceId) { + logger.debug("${Prefix} - Fetching related ${role} from AAI") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + if( isBlank(role) || isBlank(instanceId)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Role and instanceId are mandatory") + } + + Map<String,ServiceInstance> relatedInstances = new HashMap<>() + + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, instanceId) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") + } + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + if(si.isPresent()) { + List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo.toLowerCase() == "service-instance") { + String relatioshipurl = relationship.getRelatedLink() + String serviceInstanceId = + relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) + uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, serviceInstanceId) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}") + } + AAIResultWrapper wrapper01 = client.get(uri, NotFoundException.class) + Optional<ServiceInstance> serviceInstance = wrapper01.asBean(ServiceInstance.class) + if (serviceInstance.isPresent()) { + ServiceInstance instance = serviceInstance.get() + if (role.equalsIgnoreCase(instance.getServiceRole())) { + relatedInstances.put(instance.getWorkloadContext(),instance) + } + } + } + } + } + logger.debug("Found ${relatedInstances.size()} ${role} related to ${instanceId} ") + return relatedInstances + } + + private String getInstanceIdByWorkloadContext(Map<String,ServiceInstance> instances,String workloadContext ) { + String instanceId = instances.get(workloadContext).getServiceInstanceId() + if(instanceId == null) { + throw new BpmnError( 2500, "${workloadContext} NSSI ID is not found.") + } + return instanceId + } + + /** + * Method to handle deallocation of RAN NSSI constituents(TN_FH/TN_MH) + * @param execution + * @param serviceFunction - TN_FH/TN_MH + * @return + */ + private String buildDeallocateNssiRequest(DelegateExecution execution,String serviceFunction) { + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + Map<String, ServiceInstance> relatedNssis = execution.getVariable("relatedNssis") + + String anNssiId = execution.getVariable("anNssiId") + List<String> sNssaiList = execution.getVariable("sNssaiList") + + Map<String, ServiceInstance> relatedSPs = execution.getVariable("relatedSPs") + + DeAllocateNssi deallocateNssi = new DeAllocateNssi() + deallocateNssi.setNsiId(anNssiId) + ServiceInstance tnNssi = relatedNssis.get(serviceFunction) + String nssiId = tnNssi.getServiceInstanceId() + + deallocateNssi.setNssiId(nssiId) + deallocateNssi.setScriptName(tnNssi.getServiceInstanceName()) + deallocateNssi.setSnssaiList(sNssaiList) + deallocateNssi.setSliceProfileId(relatedSPs.get(serviceFunction).getServiceInstanceId()) + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setVendor("ONAP") + esrInfo.setNetworkType("TN") + + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.setServiceInvariantUuid(tnNssi.getModelInvariantId()) + serviceInfo.setServiceUuid(tnNssi.getModelVersionId()) + serviceInfo.setGlobalSubscriberId(globalSubscriberId) + serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + + JsonObject json = new JsonObject() + json.addProperty("deAllocateNssi", objectMapper.writeValueAsString(deallocateNssi)) + json.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + json.addProperty("serviceInfo", objectMapper.writeValueAsString(serviceInfo)) + return json.toString() + + } + + private void deleteServiceInstanceInAAI(DelegateExecution execution,String instanceId) { + try { + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), instanceId) + getAAIClient().delete(serviceInstanceUri) + logger.debug("${Prefix} Exited deleteServiceInstance") + }catch(Exception e){ + logger.debug("Error occured within deleteServiceInstance method: " + e) + } + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy new file mode 100644 index 0000000000..fcb3b52322 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy @@ -0,0 +1,844 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.CloudRegion +import org.onap.aai.domain.yang.Customer +import org.onap.aai.domain.yang.ModelVer +import org.onap.aai.domain.yang.OwningEntities +import org.onap.aai.domain.yang.ServiceSubscription +import org.onap.aai.domain.yang.SliceProfile +import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.Tenant +import org.onap.aai.domain.yang.VfModule +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.requestsdb.RequestsDbConstant +import org.onap.so.serviceinstancebeans.CloudConfiguration +import org.onap.so.serviceinstancebeans.ModelInfo +import org.onap.so.serviceinstancebeans.ModelType +import org.onap.so.serviceinstancebeans.OwningEntity +import org.onap.so.serviceinstancebeans.Project +import org.onap.so.serviceinstancebeans.RequestDetails +import org.onap.so.serviceinstancebeans.RequestInfo +import org.onap.so.serviceinstancebeans.RequestParameters +import org.onap.so.serviceinstancebeans.Resources +import org.onap.so.serviceinstancebeans.Service +import org.onap.so.serviceinstancebeans.SubscriberInfo +import org.onap.so.serviceinstancebeans.VfModules +import org.onap.so.serviceinstancebeans.Vnfs +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import javax.ws.rs.core.Response + +class DoDeallocateCoreNSSI extends AbstractServiceTaskProcessor { + private final String PREFIX ="DoDeallocateCoreNSSI" + + private ExceptionUtil exceptionUtil = new ExceptionUtil() + private RequestDBUtil requestDBUtil = new RequestDBUtil() + private MsoUtils utils = new MsoUtils() + private JsonUtils jsonUtil = new JsonUtils() + + private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateCoreNSSI.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start preProcessRequest") + + def currentNSSI = execution.getVariable("currentNSSI") + if (!currentNSSI) { + String msg = "currentNSSI is null" + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + LOGGER.trace("***** ${PREFIX} Exit preProcessRequest") + } + + + /** + * Queries OOF for NSSI termination + * @param execution + */ + void executeTerminateNSSIQuery(DelegateExecution execution) { + // TO DO: Unit test + LOGGER.trace("${PREFIX} Start executeTerminateNSSIQuery") + + def currentNSSI = execution.getVariable("currentNSSI") + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + + //Prepare auth for OOF + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) + String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + + String basicAuthValue = utils.encrypt(basicAuth, msokey) + if (basicAuthValue != null) { + logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) + try { + authHeader = utils.getBasicAuth(basicAuthValue, msokey) + execution.setVariable("BasicAuthHeaderValue", authHeader) + } catch (Exception ex) { + logger.debug( "Unable to encode username and password string: " + ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + + "encode username and password string") + } + } else { + logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + + "value null") + } + + //Prepare send request to OOF + String oofRequest = buildOOFRequest(execution) + + URL url = new URL(urlString+"/api/oof/terminate/nxi/v1") + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF) + httpClient.addAdditionalHeader("Authorization", authHeader) + httpClient.addAdditionalHeader("Accept", "application/json") + httpClient.addAdditionalHeader("Content-Type", "application/json") + + Response httpResponse = httpClient.post(oofRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + + if(responseCode != 202){ // Accepted + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } + + if(httpResponse.hasEntity()){ + String OOFResponse = httpResponse.readEntity(Boolean.class) + String isTerminateNSSI = jsonUtil.getJsonValue(OOFResponse, "terminateResponse") + + execution.setVariable("isTerminateNSSI", Boolean.parseBoolean(isTerminateNSSI)) + } + + LOGGER.trace("${PREFIX} Exit executeTerminateNSSIQuery") + } + + + /** + * Builds OOF request + * @param execution + * @return + */ + private String buildOOFRequest(DelegateExecution execution) { + + def currentNSSI = execution.getVariable("currentNSSI") + + String nssiId = currentNSSI['nssiId'] + String requestId = execution.getVariable("mso-request-id") + + String request = "{\n" + + " \"type\": \"NSSI\",\n" + + " \"NxIId\": \"${nssiId}\",\n" + + " \"requestInfo\": {\n" + + " \"transactionId\": \"${requestId}\",\n" + + " \"requestId\": \"${requestId}\",\n" + + " \"sourceId\": \"so\",\n" + + " }\n" + + "}" + + return request + } + + + + /** + * Queries Network Service Instance in AAI + * @param execution + */ + void getNetworkServiceInstance(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start getNetworkServiceInstance") + + AAIResourcesClient client = getAAIClient() + + def currentNSSI = execution.getVariable("currentNSSI") + + String globalSubscriberId = currentNSSI['globalSubscriberId'] + String serviceType = currentNSSI['serviceType'] + String nssiId = currentNSSI['nssiId'] + + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) //AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiId) + Optional<ServiceInstance> nssiOpt = client.get(ServiceInstance.class, nssiUri) + + if (nssiOpt.isPresent()) { + ServiceInstance nssi = nssiOpt.get() + currentNSSI['nssi'] = nssi + + ServiceInstance networkServiceInstance = handleNetworkInstance(execution, nssiId, nssiUri, client) + currentNSSI['networkServiceInstance'] = networkServiceInstance + } + else { + String msg = String.format("NSSI %s not found in AAI", nssiId) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + + LOGGER.trace("${PREFIX} Exit getNetworkServiceInstance") + } + + + /** + * Handles Network Service + * @param nssiId + * @param nssiUri + * @param client + * @return Network Service Instance + */ + private ServiceInstance handleNetworkInstance(DelegateExecution execution, String nssiId, AAIResourceUri nssiUri, AAIResourcesClient client ) { + ServiceInstance networkServiceInstance = null + + def currentNSSI = execution.getVariable("currentNSSI") + + AAIResultWrapper wrapper = client.get(nssiUri) + Optional<Relationships> relationships = wrapper.getRelationships() + + if (relationships.isPresent()) { + for (AAIResourceUri networkServiceInstanceUri : relationships.get().getRelatedAAIUris(AAIObjectType.SERVICE_INSTANCE)) { + Optional<ServiceInstance> networkServiceInstanceOpt = client.get(ServiceInstance.class, networkServiceInstanceUri) + if (networkServiceInstanceOpt.isPresent()) { + networkServiceInstance = networkServiceInstanceOpt.get() + + if (networkServiceInstance.getServiceRole().equals("Network Service")) { // Network Service role + currentNSSI['networkServiceInstanceUri'] = networkServiceInstanceUri + break + } + } + else { + String msg = String.format("No Network Service Instance found for NSSI %s in AAI", nssiId) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } + else { + String msg = String.format("No relationship presented for NSSI %s in AAI", nssiId) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + + if(networkServiceInstance == null) { + String msg = String.format("No Network Service Instance found for NSSI %s in AAI", nssiId) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + + return networkServiceInstance + } + + + /** + * Invokes deleteServiceOrder external API + * @param execution + */ + void deleteServiceOrder(DelegateExecution execution) { + // TO DO: Unit test + LOGGER.trace("${PREFIX} Start deleteServiceOrder") + + def currentNSSI = execution.getVariable("currentNSSI") + + try { + //url:/nbi/api/v4/serviceOrder/" + def nbiEndpointUrl = UrnPropertiesReader.getVariable("nbi.endpoint.url", execution) // ??? + + ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance'] + + String url = String.format("${nbiEndpointUrl}/api/v4/serviceOrder/%s", networkServiceInstance.getServiceInstanceId()) // Service Order ID = Network Service Instance ID ??? + + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuthValue = utils.encrypt(basicAuth, msoKey) + String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) + + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.EXTERNAL) + httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Accept", "application/json") + Response httpResponse = httpClient.delete() // check http code ??? + } catch (any) { + String msg = "Exception in DoDeallocateCoreNSSI.deleteServiceOrder. " + any.getCause() + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + LOGGER.trace("${PREFIX} Exit deleteServiceOrder") + } + + + /** + * Queries constitute VNF from Network Service Instance + * @param execution + */ + void getConstituteVNFFromNetworkServiceInst(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start getConstituteVNFFromNetworkServiceInst") + + def currentNSSI = execution.getVariable("currentNSSI") + + AAIResourcesClient client = getAAIClient() + + AAIResourceUri networkServiceInstanceUri = (AAIResourceUri)currentNSSI['networkServiceInstanceUri'] + AAIResultWrapper wrapper = client.get(networkServiceInstanceUri); + Optional<Relationships> relationships = wrapper.getRelationships() + if (relationships.isPresent()) { + for (AAIResourceUri constituteVnfUri : relationships.get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF)) { // ??? + execution.setVariable("constituteVnfUri", constituteVnfUri) + Optional<GenericVnf> constituteVnfOpt = client.get(GenericVnf.class, constituteVnfUri) + if(constituteVnfOpt.isPresent()) { + GenericVnf constituteVnf = constituteVnfOpt.get() + execution.setVariable("constituteVnf", constituteVnf) + } + else { + String msg = String.format("No constitute VNF found for Network Service Instance %s in AAI", ((ServiceInstance)currentNSSI['networkServiceInstance']).getServiceInstanceId()) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + + break // Should be only one constitute VNF + } + } + else { + String msg = String.format("No relationship presented for Network Service Instance %s in AAI", ((ServiceInstance)currentNSSI['networkServiceInstance']).getServiceInstanceId()) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + + LOGGER.trace("${PREFIX} Exit getConstituteVNFFromNetworkServiceInst") + + } + + + /** + * Retrieves NSSI associated profiles from AAI + * @param execution + */ + void getNSSIAssociatedProfiles(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start getNSSIAssociatedProfiles") + + def currentNSSI = execution.getVariable("currentNSSI") + + ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi'] + + List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() + + if(associatedProfiles.isEmpty()) { + String msg = String.format("No associated profiles found for NSSI %s in AAI", nssi.getServiceInstanceId()) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + else { + execution.setVariable("associatedProfiles", associatedProfiles) + } + + LOGGER.trace("${PREFIX} Exit getNSSIAssociatedProfiles") + } + + + /** + * Calculates a final list of S-NSSAI + * @param execution + */ + void calculateSNSSAI(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start calculateSNSSAI") + + List<SliceProfile> associatedProfiles = (List<SliceProfile>)execution.getVariable("associatedProfiles") + + def currentNSSI = execution.getVariable("currentNSSI") + + String currentSNSSAI = currentNSSI['S-NSSAI'] + + List<String> snssais = new ArrayList<>() + + for(SliceProfile associatedProfile:associatedProfiles) { + if(!associatedProfile.getSNssai().equals(currentNSSI)) { // not current S-NSSAI + snssais.add(associatedProfile.getSNssai()) + } + } + + execution.setVariable("S-NSSAIs", snssais) + + LOGGER.trace("${PREFIX} Exit calculateSNSSAI") + } + + + /** + * Invoke PUT Service Instance API + * @param execution + */ + void invokePUTServiceInstance(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start invokePUTServiceInstance") + + def currentNSSI = execution.getVariable("currentNSSI") + + try { + //url:/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfId}" + def nsmfЕndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) // ??? + + ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance'] + + GenericVnf constituteVnf = (GenericVnf)execution.getVariable("constituteVnf") + + String url = String.format("${nsmfЕndpoint}/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId()) // ??? + + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuthValue = utils.encrypt(basicAuth, msoKey) + String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) + + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.EXTERNAL) + httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Accept", "application/json") + + RequestDetails requestDetails = prepareRequestDetails(execution) + ObjectMapper mapper = new ObjectMapper() + String requestDetailsStr = mapper.writeValueAsString(requestDetails) + + Response httpResponse = httpClient.put(requestDetailsStr) // check http code ??? + } catch (any) { + String msg = "Exception in DoDeallocateCoreNSSI.deleteServiceOrder. " + any.getCause() + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + LOGGER.trace("${PREFIX} Exit invokePUTServiceInstance") + } + + + /** + * Prepare model info + * @param execution + * @param requestDetails + * @return + */ + private ModelInfo prepareModelInfo(DelegateExecution execution) { + ModelInfo modelInfo = new ModelInfo() + + modelInfo.setModelType(ModelType.service) + modelInfo.setModelInvariantId(networkServiceInstance.getModelInvariantId()) + + AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, networkServiceInstance.getModelInvariantId()) // model of Network Service Instance ??? + Optional<ModelVer> modelVerOpt = client.get(ModelVer.class, modelVerUrl) + + if (modelVerOpt.isPresent()) { + modelInfo.setModelVersionId(modelVerOpt.get().getModelVersionId()) + modelInfo.setModelName(modelVerOpt.get().getModelName()) + modelInfo.setModelVersion(modelVerOpt.get().getModelVersion()) + } + + + return modelInfo + } + + + /** + * Prepares RequestDetails object + * @param execution + * @return + */ + private RequestDetails prepareRequestDetails(DelegateExecution execution) { + RequestDetails requestDetails = new RequestDetails() + + def currentNSSI = execution.getVariable("currentNSSI") + + String globalSubscriberId = currentNSSI['globalSubscriberId'] + + ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance'] + + + AAIResourcesClient client = getAAIClient() + + // Model Info + requestDetails.setModelInfo(prepareModelInfo(execution)) + + // Subscriber Info + SubscriberInfo subscriberInfo = new SubscriberInfo() + subscriberInfo.setGlobalSubscriberId(globalSubscriberId) + + Customer customer = null + ServiceSubscription serviceSubscription = null + + AAIResourceUri networkServiceInstanceUri = currentNSSI['networkServiceInstanceUri'] + AAIResultWrapper wrapper = client.get(networkServiceInstanceUri) + Optional<Relationships> serviceSubscriptionRelationshipsOps = wrapper.getRelationships() + if(serviceSubscriptionRelationshipsOps.isPresent()) { + List<AAIResourceUri> serviceSubscriptionRelatedAAIUris = serviceSubscriptionRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.SERVICE_SUBSCRIPTION) + if(!(serviceSubscriptionRelatedAAIUris == null || serviceSubscriptionRelatedAAIUris.isEmpty())) { + AAIResourceUri serviceSubscriptionUri = serviceSubscriptionRelatedAAIUris.get(0) // Many-To-One relation + Optional<ServiceSubscription> serviceSubscriptionOpt = client.get(ServiceSubscription.class, serviceSubscriptionUri) + if(serviceSubscriptionOpt.isPresent()) { + serviceSubscription = serviceSubscriptionOpt.get() + } + + wrapper = client.get(serviceSubscriptionUri) + Optional<Relationships> customerRelationshipsOps = wrapper.getRelationships() + if(customerRelationshipsOps.isPresent()) { + List<AAIResourceUri> customerRelatedAAIUris = customerRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.CUSTOMER) + if(!(customerRelatedAAIUris == null || customerRelatedAAIUris.isEmpty())) { + Optional<Customer> customerOpt = client.get(Customer.class, customerRelatedAAIUris.get(0)) // Many-To-One relation + if(customerOpt.isPresent()) { + customer = customerOpt.get() + subscriberInfo.setSubscriberName(customer.getSubscriberName()) + } + } + } + } + + } + requestDetails.setSubscriberInfo(subscriberInfo) + + // Request Info + RequestInfo requestInfo = new RequestInfo() + requestInfo.setInstanceName(networkServiceInstance.getServiceInstanceName()) + + /* No found data to provide ??? + requestInfo.setSource() + requestInfo.setSuppressRollback() + requestInfo.setRequestorId() + requestInfo.setProductFamilyId() + */ + + requestDetails.setRequestInfo(requestInfo) + + + // Request Parameters + RequestParameters requestParameters = new RequestParameters() + + // No found data to provide ??? requestParameters.setaLaCarte() + requestParameters.setSubscriptionServiceType(serviceSubscription.getServiceType()) + + // User params + List<Map<String, Object>> userParams = new ArrayList<>() + // Service + Service service = new Service() + // Model Info + ModelInfo serviceModelInfo = new ModelInfo() + serviceModelInfo.setModelType(ModelType.service) + serviceModelInfo.setModelInvariantId(networkServiceInstance.getModelInvariantId()) + + serviceModelInfo.setModelVersionId(modelInfo.get().getModelVersionId()) + serviceModelInfo.setModelName(modelInfo.get().getModelName()) + serviceModelInfo.setModelVersion(modelInfo.get().getModelVersion()) + + service.setModelInfo(serviceModelInfo) + + // Resources + Resources resources = new Resources() + + CloudRegion cloudRegion = null + AAIResourceUri cloudRegionRelatedAAIUri = null + // VNFs + List<Vnfs> vnfs = new ArrayList<>() + // VNF + Vnfs vnf = new Vnfs() + + // Cloud configuration + CloudConfiguration cloudConfiguration = new CloudConfiguration() + + AAIResourceUri constituteVnfUri = (AAIResourceUri)execution.getVariable("constituteVnfUri") + wrapper = client.get(constituteVnfUri) + Optional<Relationships> constituteVnfOps = wrapper.getRelationships() + if(constituteVnfOps.isPresent()) { + List<AAIResourceUri> cloudRegionRelatedAAIUris = serviceSubscriptionRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) + if(!(cloudRegionRelatedAAIUris == null || cloudRegionRelatedAAIUris.isEmpty())) { + cloudRegionRelatedAAIUri = cloudRegionRelatedAAIUris.get(0) + Optional<CloudRegion> cloudRegionrOpt = client.get(CloudRegion.class, cloudRegionRelatedAAIUris.get(0)) + if(cloudRegionrOpt.isPresent()) { + cloudRegion = cloudRegionrOpt.get() + cloudConfiguration.setLcpCloudRegionId(cloudRegion.getCloudRegionId()) + for(Tenant tenant:cloudRegion.getTenants()) { + cloudConfiguration.setTenantId(tenant.getTenantId()) + break // only one is required + } + + cloudConfiguration.setCloudOwner(cloudRegion.getCloudOwner()) + } + } + } + + vnf.setCloudConfiguration(cloudConfiguration) + + // VF Modules + GenericVnf constituteVnf = execution.getVariable("constituteVnf") + List<VfModules> vfModuless = new ArrayList<>() + for(VfModule vfModule:constituteVnf.getVfModules()) { + VfModules vfmodules = new VfModules() + + ModelInfo vfModuleModelInfo = new ModelInfo() + vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId()) + + AAIResourceUri vfModuleUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, vfModule.getModelInvariantId()) // ??? + Optional<ModelVer> vfModuleModelVerOpt = client.get(ModelVer.class, vfModuleUrl) + + if (vfModuleModelVerOpt.isPresent()) { + vfModuleModelInfo.setModelVersionId(vfModuleModelVerOpt.get().getModelVersionId()) + vfModuleModelInfo.setModelName(vfModuleModelVerOpt.get().getModelName()) + vfModuleModelInfo.setModelVersion(vfModuleModelVerOpt.get().getModelVersion()) + + // No model customization ID + } + vfmodules.setModelInfo(vfModuleModelInfo) + + vfmodules.setInstanceName(vfModule.getVfModuleName()) // ??? + + vfModuless.add(vfmodules) + } + vnf.setVfModules(vfModuless) + + // Model Info + ModelInfo vnfModelInfo = new ModelInfo() + vnfModelInfo.setModelInvariantUuid(constituteVnf.getModelInvariantId()) + AAIResourceUri vnfModelUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, constituteVnf.getModelInvariantId()) // ??? + Optional<ModelVer> vnfModelVerOpt = client.get(ModelVer.class, vnfModelUrl) + + if (vnfModelVerOpt.isPresent()) { + vnfModelInfo.setModelVersionId(vnfModelVerOpt.get().getModelVersionId()) + vnfModelInfo.setModelName(vnfModelVerOpt.get().getModelName()) + vnfModelInfo.setModelVersion(vnfModelVerOpt.get().getModelVersion()) + + // No model customization ID + // No model instance name + } + + vnf.setModelInfo(vnfModelInfo) + + // Instance name + vnf.setInstanceName(constituteVnf.getVnfInstanceId()) + + // Instance params + List<Map<String, Object>> instanceParams = new ArrayList<>() + Map<String, Object> supporrtedNSSAIMap = new HashMap<>() + + // Supported S-NSSAI + List<String> snssais = ( List<String>)execution.getVariable("S-NSSAIs") + supporrtedNSSAIMap.put("supporrtedNSSAI", snssais) // remaining S-NSSAIs ??? there is no status for each s-nssai + instanceParams.add(supporrtedNSSAIMap) + + // No other instance params, e.g. config-type + + vnf.setInstanceParams(instanceParams) + + // No platform data + + vnfs.add(vnf) + resources.setVnfs(vnfs) + + service.setResources(resources) + + Map<String, Object> serviceMap = new HashMap<>() + serviceMap.put("service", service) + userParams.add(serviceMap) + requestParameters.setUserParams(userParams) + + // No other user params + + requestDetails.setRequestParameters(requestParameters) + + // No other request params + + // Cloud configuration + requestDetails.setCloudConfiguration(cloudConfiguration) + + // Owning entity + OwningEntity owningEntity = new OwningEntity() + wrapper = client.get(networkServiceInstanceUri) + Optional<Relationships> owningEntityRelationshipsOps = wrapper.getRelationships() + if(owningEntityRelationshipsOps.isPresent()) { + List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.OWNING_ENTITY) + + if(!(owningEntityRelatedAAIUris == null || owningEntityRelatedAAIUris.isEmpty())) { + Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation + if(owningEntityOpt.isPresent()) { + owningEntity.setOwningEntityId(owningEntityOpt.get().getOwningEntityId()) + owningEntity.setOwningEntityName(owningEntityOpt.get().getOwningEntityName()) + requestDetails.setOwningEntity(owningEntity) + } + } + } + + // Project + Project project = new Project() + if(cloudRegionRelatedAAIUri != null) { + wrapper = client.get(cloudRegionRelatedAAIUri) + Optional<Relationships> cloudRegionOps = wrapper.getRelationships() + if(cloudRegionOps.isPresent()) { + List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedAAIUris(AAIObjectType.PROJECT) + if (!(projectAAIUris == null || projectAAIUris.isEmpty())) { + Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.Project.class, projectAAIUris.get(0)) + if(projectOpt.isPresent()) { + project.setProjectName(projectOpt.get().getProjectName()) + } + } + } + } + requestDetails.setProject(project) + + return requestDetails + } + + + /** + * Removes NSSI association with NSI + * @param execution + */ + void removeNSSIAssociationWithNSI(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start removeNSSIAssociationWithNSI") + + AAIResourcesClient client = getAAIClient() + + def currentNSSI = execution.getVariable("currentNSSI") + + String nssiId = currentNSSI['nssiServiceInstanceId'] + String nsiId = currentNSSI['nsiId'] + + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nsiId) + + try { + getAAIClient().disconnect(nssiUri, nsiUri) + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage()) + } + + LOGGER.trace("${PREFIX} Exit removeNSSIAssociationWithNSI") + } + + + /** + * Removes Slice Profile association with NSSI + * @param execution + */ + void removeSPAssociationWithNSSI(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start removeSPAssociationWithNSSI") + + AAIResourcesClient client = getAAIClient() + + def currentNSSI = execution.getVariable("currentNSSI") + + ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi'] + + String nssiId = currentNSSI['nssiServiceInstanceId'] + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + + List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() + + String currentSNSSAI = currentNSSI['S-NSSAI'] + + associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) }) + + try { + getAAIClient().update(nssiUri, nssi) + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage()) + } + + LOGGER.trace("${PREFIX} Exit removeSPAssociationWithNSSI") + } + + + /** + * Deletes Slice Profile Instance + * @param execution + */ + void deleteSliceProfileInstance(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start deleteSliceProfileInstance") + + AAIResourcesClient client = getAAIClient() + + def currentNSSI = execution.getVariable("currentNSSI") + + ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi'] + + List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() + + String currentSNSSAI = currentNSSI['S-NSSAI'] + + AAIResourceUri sliceProfileUri = null + + for(SliceProfile associatedProfile:associatedProfiles) { + if(!associatedProfile.getSNssai().equals(currentNSSI)) { // not current S-NSSAI + sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, associatedProfile.getProfileId()) + break + } + } + + try { + getAAIClient().delete(sliceProfileUri) + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage()) + } + + LOGGER.trace("${PREFIX} Exit deleteSliceProfileInstance") + } + + + /** + * Delets NSSI Service Instance + * @param execution + */ + void deleteNSSIServiceInstance(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start deleteNSSIServiceInstance") + + AAIResourcesClient client = getAAIClient() + + def currentNSSI = execution.getVariable("currentNSSI") + + String nssiId = currentNSSI['nssiServiceInstanceId'] + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + + try { + getAAIClient().delete(nssiUri) + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI Service Instance delete call: " + e.getMessage()) + } + + LOGGER.trace("${PREFIX} Exit deleteNSSIServiceInstance") + } + + + /** + * Updates operation status + * @param execution + */ + void updateServiceOperationStatus(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start updateServiceOperationStatus") + + def currentNSSI = execution.getVariable("currentNSSI") + + OperationStatus operationStatus = new OperationStatus() + operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String) + operationStatus.setOperationId(currentNSSI['operationId'] as String) + operationStatus.setOperation(currentNSSI['operationType'] as String) + operationStatus.setResult(RequestsDbConstant.Status.FINISHED) + + requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus) + + LOGGER.trace("${PREFIX} Exit updateServiceOperationStatus") + } + + + /** + * Returns AAI client + * @return AAI client + */ + AAIResourcesClient getAAIClient() { + return new AAIResourcesClient() + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index 547cb6cad7..0c795b3bd1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.logging.filter.base.ONAPComponents import org.onap.so.beans.nsmf.DeAllocateNssi +import org.onap.so.beans.nsmf.ServiceInfo import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.JobStatusRequest import org.onap.so.beans.nsmf.JobStatusResponse @@ -44,7 +45,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory - +import org.json.JSONObject import javax.ws.rs.core.Response @@ -126,7 +127,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exit processDecomposition *****") } - + /** * send deallocate request to nssmf * @param execution @@ -140,61 +141,106 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor String nssiId = currentNSSI['nssiServiceInstanceId'] String nsiId = currentNSSI['nsiServiceInstanceId'] String scriptName = execution.getVariable("scriptName") + boolean modifyAction = execution.getVariable("terminateNSI") + String serviceInvariantUuid = currentNSSI['modelInvariantId'] + String serviceUuid = currentNSSI['modelVersionId'] + String globalSubscriberId = currentNSSI['globalSubscriberId'] + String subscriptionServiceType = execution.getVariable("serviceType") + DeAllocateNssi deAllocateNssi = new DeAllocateNssi() deAllocateNssi.setNsiId(nsiId) deAllocateNssi.setNssiId(nssiId) deAllocateNssi.setTerminateNssiOption(0) deAllocateNssi.setSnssaiList(Arrays.asList(snssai)) deAllocateNssi.setScriptName(scriptName) - - NssiDeAllocateRequest deAllocateRequest = new NssiDeAllocateRequest() - deAllocateRequest.setDeAllocateNssi(deAllocateNssi) - deAllocateRequest.setEsrInfo(getEsrInfo(currentNSSI)) - - ObjectMapper mapper = new ObjectMapper() - String nssmfRequest = mapper.writeValueAsString(deAllocateRequest) - - String urlStr = String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s",profileId) + deAllocateNssi.setSliceProfileId(profileId) + deAllocateNssi.setModifyAction(modifyAction) + + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.setServiceInvariantUuid(serviceInvariantUuid) + serviceInfo.setServiceUuid(serviceUuid) + serviceInfo.setGlobalSubscriberId(globalSubscriberId) + serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + + EsrInfo esrInfo = getEsrInfo(currentNSSI) + + execution.setVariable("deAllocateNssi",deAllocateNssi) + execution.setVariable("esrInfo",esrInfo) + execution.setVariable("serviceInfo",serviceInfo) + String nssmfRequest = """ + { + "deAllocateNssi": "${execution.getVariable("deAllocateNssi") as JSONObject}", + "esrInfo": ${execution.getVariable("esrInfo") as JSONObject}, + "serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject} + } + """ + + String urlStr = String.format("/api/rest/provMns/v1/NSS/nssi/%s",nssiId) NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, NssiResponse.class) if (nssmfResponse != null) { - currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" - currentNSSI['jobProgress'] = 0 - execution.setVariable("currentNSSI", currentNSSI) - - LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****") - } else { + currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" + currentNSSI['jobProgress'] = 0 + execution.setVariable("currentNSSI", currentNSSI) + } + else { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") } - + LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****") } - /** +/** * send to nssmf query progress * @param execution */ - void getJobStatus(DelegateExecution execution) + void prepareJobStatusRequest(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") String jobId = currentNSSI['jobId'] String nssiId = currentNSSI['nssiServiceInstanceId'] String nsiId = currentNSSI['nsiServiceInstanceId'] + String serviceInvariantUuid = currentNSSI['modelInvariantId'] + String serviceUuid = currentNSSI['modelVersionId'] + String globalSubscriberId = currentNSSI['globalSubscriberId'] + String subscriptionServiceType = execution.getVariable("serviceType") + String sST = currentNSSI['sST'] + String PLMNIdList = currentNSSI['PLMNIdList'] + String nssiName = currentNSSI['nssiName'] + + execution.setVariable("responseId", "3") + execution.setVariable("esrInfo", getEsrInfo(currentNSSI)) + execution.setVariable("jobId", jobId) + + Map<String, ?> serviceInfoMap = new HashMap<>() + serviceInfoMap.put("nssiId", nssiId) + serviceInfoMap.put("nsiId", nsiId) + serviceInfoMap.put("nssiName", nssiName) + serviceInfoMap.put("sST", sST) + serviceInfoMap.put("PLMNIdList", PLMNIdList) + serviceInfoMap.put("globalSubscriberId", globalSubscriberId) + serviceInfoMap.put("subscriptionServiceType", subscriptionServiceType) + serviceInfoMap.put("serviceInvariantUuid", serviceInvariantUuid) + serviceInfoMap.put("serviceUuid", serviceUuid) + + execution.setVariable("serviceInfo", serviceInfoMap) + } - JobStatusRequest jobStatusRequest = new JobStatusRequest() - jobStatusRequest.setNssiId(nssiId) - jobStatusRequest.setNsiId(nsiId) - jobStatusRequest.setEsrInfo(getEsrInfo(currentNSSI)) - - ObjectMapper mapper = new ObjectMapper() - String nssmfRequest = mapper.writeValueAsString(jobStatusRequest) - - String urlStr = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId) - - JobStatusResponse jobStatusResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, JobStatusResponse.class) - - if (jobStatusResponse != null) { - def progress = jobStatusResponse?.getResponseDescriptor()?.getProgress() + + /** + * send to nssmf query progress + * @param execution + */ + void handleJobStatus(DelegateExecution execution) + { + try + { + String jobStatusResponse = execution.getVariable("responseDescriptor") + String status = jsonUtil.getJsonValue(jobStatusResponse,"status") + def statusDescription = jsonUtil.getJsonValue(jobStatusResponse,"statusDescription") + def progress = jsonUtil.getJsonValue(jobStatusResponse,"progress") + if(!status.equalsIgnoreCase("failed")) + { if(!progress) { LOGGER.error("job progress is null or empty!") @@ -206,61 +252,60 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor execution.setVariable("isNSSIDeAllocated", (currentProgress == 100)) execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress)) currentNSSI['jobProgress'] = currentProgress - - def statusDescription = jobStatusResponse?.getResponseDescriptor()?.getStatusDescription() + currentNSSI['status'] = status currentNSSI['statusDescription'] = statusDescription LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" ) - - } else { + } + else { + execution.setVariable("isNeedUpdateDB", "true") exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") } - + } + catch (any) + { + String msg = "Received a Bad Response from NSSMF." cause-"+any.getCause()" + LOGGER.error(any.printStackTrace()) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } } private EsrInfo getEsrInfo(def currentNSSI) { String domaintype = currentNSSI['domainType'] String vendor = currentNSSI['vendor'] - + EsrInfo info = new EsrInfo() info.setNetworkType(NetworkType.fromString(domaintype)) info.setVendor(vendor) return info } - /** + /** * handle job status * prepare update requestdb * @param execution */ - void handleJobStatus(DelegateExecution execution) + void prepareUpdateOperationStatus(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") int currentProgress = currentNSSI["jobProgress"] def proportion = currentNSSI['proportion'] def statusDes = currentNSSI["statusDescription"] int progress = (currentProgress as int) == 0 ? 0 : (currentProgress as int) / 100 * (proportion as int) - + def status = currentNSSI['status'] + OperationStatus operationStatus = new OperationStatus() operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String) operationStatus.setOperationId(currentNSSI['operationId'] as String) operationStatus.setOperation("DELETE") - operationStatus.setResult("processing") + operationStatus.setResult(status as String) operationStatus.setProgress(progress as String) operationStatus.setOperationContent(statusDes as String) requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus) LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" ) } - - void timeDelay(DelegateExecution execution) { - try { - Thread.sleep(10000); - } catch(InterruptedException e) { - LOGGER.error("Time Delay exception" + e) - } - } - + /** * delete slice profile from aai * @param execution @@ -291,4 +336,4 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exist delSliceProfileFromAAI *****") } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy new file mode 100644 index 0000000000..7681bf9346 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -0,0 +1,169 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import groovy.json.JsonSlurper +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { + String Prefix = "TNDEALLOC_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() + JsonSlurper jsonSlurper = new JsonSlurper() + ObjectMapper objectMapper = new ObjectMapper() + private static final Logger logger = LoggerFactory.getLogger(DoDeallocateTnNssi.class) + + + void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + + execution.setVariable("startTime", System.currentTimeMillis()) + String msg = tnNssmfUtils.getExecutionInputParams(execution) + logger.debug("Deallocate TN NSSI input parameters: " + msg) + + execution.setVariable("prefix", Prefix) + + tnNssmfUtils.setSdncCallbackUrl(execution, true) + logger.debug("SDNC Callback URL: " + execution.getVariable("sdncCallbackUrl")) + + String sliceServiceInstanceId = execution.getVariable("serviceInstanceID") + execution.setVariable("sliceServiceInstanceId", sliceServiceInstanceId) + + String sliceServiceInstanceName = execution.getVariable("servicename") + execution.setVariable("sliceServiceInstanceName", sliceServiceInstanceName) + + + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + //here modelVersion is not set, we use modelUuid to decompose the service. + def isDebugLogEnabled = true + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + logger.debug("Finish preProcessRequest") + } + + void preprocessSdncDeallocateTnNssiRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preprocessSdncDeallocateTnNssiRequest(' + + 'execution=' + execution.getId() + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceID") + + String sdncRequest = tnNssmfUtils.buildSDNCRequest(execution, serviceInstanceId, "deallocate") + + execution.setVariable("TNNSSMF_SDNCRequest", sdncRequest) + logger.debug("Outgoing SDNCRequest is: \n" + sdncRequest) + + } catch (Exception e) { + logger.debug("Exception Occured Processing preprocessSdncDeallocateTnNssiRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preprocessSdncDeallocateTnNssiRequest Process") + } + + + void validateSDNCResponse(DelegateExecution execution, String response, String method) { + tnNssmfUtils.validateSDNCResponse(execution, response, method) + } + + void deleteServiceInstance(DelegateExecution execution) { + try { + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + execution.getVariable("serviceInstanceID")) + client.delete(uri) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoDeallocateTnNssi.deleteServiceInstance. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + public void updateAAIOrchStatus(DelegateExecution execution) { + logger.debug("Start updateAAIOrchStatus") + String tnNssiId = execution.getVariable("serviceInstanceID") + String orchStatus = execution.getVariable("orchestrationStatus") + + try { + ServiceInstance si = new ServiceInstance() + si.setOrchestrationStatus(orchStatus) + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, tnNssiId) + client.update(uri, si) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Finish updateAAIOrchStatus") + } + + void prepareUpdateJobStatus(DelegateExecution execution, + String status, + String progress, + String statusDescription) { + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setServiceId(serviceId) + roStatus.setOperationId(jobId) + roStatus.setResourceTemplateUUID(nsiId) + roStatus.setOperType("Deallocate") + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + } +} + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy index 5354d52fce..2f78c3d551 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy @@ -25,16 +25,20 @@ import org.onap.aai.domain.yang.AllottedResource import org.onap.aai.domain.yang.AllottedResources import org.onap.aai.domain.yang.Relationship import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aai.domain.yang.SliceProfiles +import org.onap.aai.domain.yang.ServiceProfile +import org.onap.aai.domain.yang.ServiceProfiles import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.OofUtils import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory - +import javax.ws.rs.core.Response import javax.ws.rs.NotFoundException import static org.apache.commons.lang3.StringUtils.isBlank @@ -52,6 +56,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank class DoDeleteSliceService extends AbstractServiceTaskProcessor { private final String PREFIX ="DoDeleteSliceService" ExceptionUtil exceptionUtil = new ExceptionUtil() + OofUtils oofUtils = new OofUtils() private static final Logger LOGGER = LoggerFactory.getLogger( DoDeleteSliceService.class) @Override @@ -96,17 +101,47 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { { LOGGER.trace(" *****${PREFIX} Start queryE2ESliceSeriveFromAAI *****") String serviceInstanceId = execution.getVariable("serviceInstanceId") - + try + { String errorMsg = "query e2e slice service from aai failed" AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class) if(si.isPresent()) { String snssai = si.get()?.getEnvironmentContext() + ServiceProfiles serviceProfiles = si.get()?.getServiceProfiles() + ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0) + String serviceProfileId = serviceProfile ? serviceProfile.getProfileId() : "" execution.setVariable("snssai", snssai ?: "") - LOGGER.info("serviceInstanceId: ${serviceInstanceId}, snssai: ${snssai}") + execution.setVariable("serviceProfileId",serviceProfileId) + List<ServiceInstance> sliceProfileList = [] + List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo.toLowerCase() == "service-instance") { + String relatioshipurl = relationship.getRelatedLink() + String instanceId = relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) + AAIResultWrapper wrapper1 = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, instanceId, errorMsg) + Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) + if (serviceInstance.isPresent()) { + ServiceInstance instance = serviceInstance.get() + if ("slice-profile-instance".equalsIgnoreCase(instance.getServiceRole())) { + sliceProfileList.add(instance) + } + } + } + } + execution.setVariable("sliceProfileList",sliceProfileList) + LOGGER.info("serviceInstanceId: ${serviceInstanceId}, snssai: ${snssai}, sliceProfileList: ${sliceProfileList}") } LOGGER.trace(" *****${PREFIX} Exit queryE2ESliceSeriveFromAAI *****") + } + catch (any) + { + String msg = "query E2E slice service from aai failed! cause-"+any.getCause() + LOGGER.error(any.printStackTrace()) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); + } } /** @@ -169,7 +204,15 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { if (relatedTo == "service-instance") { String relatedLink = relationship.getRelatedLink()?:"" - String nssiId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : "" + String instanceId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : "" + AAIResultWrapper wrapper1 = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, instanceId, errorMsg) + Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) + if (serviceInstance.isPresent()) { + ServiceInstance instance = serviceInstance.get() + if ("nssi".equalsIgnoreCase(instance.getServiceRole())) { + nssiId = instance.getServiceInstanceId() + } + } nssiIdList.add(nssiId) msg+="${nssiId}, " } @@ -227,12 +270,24 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { { LOGGER.trace(" *****${PREFIX} Start getCurrentNSSI *****") List<ServiceInstance> nssiInstanceList = execution.getVariable("nssiInstanceList") + List<ServiceInstance> sliceProfileList = execution.getVariable("sliceProfileList") int currentIndex = execution.getVariable("currentNSSIIndex") as int + String profileId = "" ServiceInstance nssi = nssiInstanceList?.get(currentIndex) + for(ServiceInstance sliceProfileInstance : sliceProfileList) { + if(sliceProfileInstance.getWorkloadContext().equalsIgnoreCase(nssi.getWorkloadContext())) + { + profileId = sliceProfileInstance.getServiceInstanceId() + } + } def currentNSSI = [:] currentNSSI['nssiServiceInstanceId'] = nssi?.getServiceInstanceId() currentNSSI['modelInvariantId'] = nssi?.getModelInvariantId() currentNSSI['modelVersionId'] = nssi?.getModelVersionId() + currentNSSI['nssiName'] = nssi?.getServiceInstanceName() + currentNSSI['sST'] = nssi?.getServiceType() + currentNSSI['PLMNIdList'] = nssi?.getServiceInstanceLocationId() + currentNSSI['profileId'] = profileId currentNSSI['snssai'] = execution.getVariable("snssai") ?: "" currentNSSI['nsiServiceInstanceId'] = execution.getVariable("nsiId") ?: "" currentNSSI['operationId'] = execution.getVariable("operationId") ?: "" @@ -271,30 +326,6 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { LOGGER.trace(" *****${PREFIX} Exit parseNextNSSI *****") } - - /** - * query sliceProfile from AAI - * save profileId - * @param execution - */ - void querySliceProfileFromAAI(DelegateExecution execution) - { - LOGGER.trace(" *****${PREFIX} Start querySliceProfileFromAAI *****") - def currentNSSI = execution.getVariable("currentNSSI") - String nssiId = currentNSSI['nssiServiceInstanceId'] - String errorMsg = "query slice profile failed" - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SLICE_PROFILE_ALL, nssiId, errorMsg) - Optional<SliceProfiles> sliceProfiles =wrapper.asBean(SliceProfiles.class) - if(sliceProfiles.isPresent()) - { - String profileId = sliceProfiles.get().getSliceProfile()?.get(0)?.getProfileId() - currentNSSI['profileId'] = profileId ?: "" - LOGGER.info("nssiId: ${nssiId}, profileId: ${profileId}") - } - execution.setVariable("currentNSSI", currentNSSI) - LOGGER.trace(" *****${PREFIX} Exit querySliceProfileFromAAI *****") - } - /** * query AAI * @param execution @@ -317,4 +348,57 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { return wrapper } + void terminateNSIQuery(DelegateExecution execution) + { + logger.debug("Start terminateNSIQuery") + + String requestId = execution.getVariable("msoRequestId") + String nxlId = currentNSSI['nsiServiceInstanceId'] + String nxlType = "NSI" + String messageType = "nsiTerminationResponse" + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) + String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + + String basicAuthValue = utils.encrypt(basicAuth, msokey) + if (basicAuthValue != null) { + logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) + try { + authHeader = utils.getBasicAuth(basicAuthValue, msokey) + execution.setVariable("BasicAuthHeaderValue", authHeader) + } catch (Exception ex) { + logger.debug( "Unable to encode username and password string: " + ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + + "encode username and password string") + } + } else { + logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + + "value null") + } + + URL requestUrl = new URL(oofUrl + "/api/oof/terminate/nxi/v1") + String oofRequest = oofUtils.buildTerminateNxiRequest(requestId, nxlId, nxlType, messageType, serviceInstanceId) + HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.OOF) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(oofRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + + if(responseCode != 200){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } + try { + Map<String, String> resMap = httpResponse.readEntity(Map.class) + boolean terminateResponse = resMap.get("terminateResponse") + execution.setVariable("terminateNSI", terminateResponse) + } catch (Exception ex) { + logger.debug( "Failed to get terminate Response suggested by OOF.") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get terminate Response suggested by OOF.") + } + logger.debug("Finish terminateNSIQuery") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy new file mode 100644 index 0000000000..2e7e728b44 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy @@ -0,0 +1,656 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import java.sql.Timestamp +import java.util.List +import static org.apache.commons.lang3.StringUtils.isBlank +import com.google.gson.JsonObject +import com.fasterxml.jackson.databind.ObjectMapper +import com.google.gson.JsonArray +import org.onap.so.beans.nsmf.AllocateTnNssi +import org.onap.so.beans.nsmf.EsrInfo +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy + +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.SliceProfile +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import javax.ws.rs.NotFoundException + +class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { + + String Prefix="MASS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + OofUtils oofUtils = new OofUtils() + ObjectMapper objectMapper = new ObjectMapper(); + AnNssmfUtils anNssmfUtils = new AnNssmfUtils() + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + private static final Logger logger = LoggerFactory.getLogger(DoModifyAccessNSSI.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + + logger.debug("input variables : msoRequestId - "+execution.getVariable("msoRequestId")+ + " globalSubscriberId - "+execution.getVariable("globalSubscriberId")+ + " serviceInstanceID - "+execution.getVariable("serviceInstanceID")+ + " nsiId - "+execution.getVariable("nsiId")+ + " networkType - "+execution.getVariable("networkType")+ + " subscriptionServiceType - "+execution.getVariable("subscriptionServiceType")+ + " jobId - "+execution.getVariable("jobId")+ + " sliceParams - "+execution.getVariable("sliceParams")+ + " servicename - "+ execution.getVariable("servicename")) + + //validate slice subnet inputs + + String sliceParams = execution.getVariable("sliceParams") + String modifyAction = jsonUtil.getJsonValue(sliceParams, "modifyAction") + if (isBlank(modifyAction)) { + msg = "Input modifyAction is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("modifyAction", modifyAction) + switch(modifyAction) { + case "allocate": + execution.setVariable("isModifyallocate", true) + break + case "deallocate": + execution.setVariable("isModifydeallocate", true) + break + case "reconfigure": + execution.setVariable("isModifyreconfigure", true) + String resourceConfig = jsonUtil.getJsonValue(sliceParams, "resourceConfig") + execution.setVariable("additionalProperties", resourceConfig) + break + default: + logger.debug("Invalid modify Action") + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid modify Action : "+modifyAction) + } + } + List<String> snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "snssaiList")) + String sliceProfileId = jsonUtil.getJsonValue(sliceParams, "sliceProfileId") + if (isBlank(sliceProfileId) || (snssaiList.empty)) { + msg = "Mandatory fields are empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("sliceProfileId", sliceProfileId) + execution.setVariable("snssaiList", snssaiList) + } + String nsiName = jsonUtil.getJsonValue(sliceParams, "nsiInfo.nsiName") + String scriptName = jsonUtil.getJsonValue(sliceParams, "scriptName") + execution.setVariable("nsiName", nsiName) + execution.setVariable("scriptName", scriptName) + execution.setVariable("job_timeout", 10) + execution.setVariable("ranNssiPreferReuse", false) + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in DoModifyAccessNSSI.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + def getSliceProfile = { DelegateExecution execution -> + logger.debug(Prefix + "getSliceProfiles Start") + String instanceId = execution.getVariable("sliceProfileId") + ServiceInstance sliceProfileInstance = getServiceInstance(execution, instanceId) + SliceProfile ranSliceProfile = sliceProfileInstance.getSliceProfiles().getSliceProfile().get(0) + logger.debug("RAN slice profile : "+ranSliceProfile.toString()) + execution.setVariable("RANSliceProfile", ranSliceProfile) + execution.setVariable("ranSliceProfileInstance", sliceProfileInstance) + } + + /* + * Function to subnet capabilities from nssmf adapter + */ + def getSubnetCapabilities = { DelegateExecution execution -> + logger.debug(Prefix+"getSubnetCapabilities method start") + + String tnNssmfRequest = anNssmfUtils.buildCreateTNNSSMFSubnetCapabilityRequest() + + String urlString = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery" + + String tnNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, tnNssmfRequest) + + if (tnNssmfResponse != null) { + String FHCapabilities= jsonUtil.getJsonValue(tnNssmfResponse, "TN_FH") + String MHCapabilities = jsonUtil.getJsonValue(tnNssmfResponse, "TN_MH") + execution.setVariable("FHCapabilities",FHCapabilities) + execution.setVariable("MHCapabilities",MHCapabilities) + + } else { + logger.error("received error message from NSSMF : "+ tnNssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + String anNssmfRequest = anNssmfUtils.buildCreateANNFNSSMFSubnetCapabilityRequest() + + String anNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, anNssmfRequest) + + if (anNssmfResponse != null) { + String ANNFCapabilities = jsonUtil.getJsonValue(anNssmfResponse, "AN_NF") + execution.setVariable("ANNFCapabilities",ANNFCapabilities) + + } else { + logger.error("received error message from NSSMF : "+ anNssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + } + + + /* + * prepare OOF request for RAN NSSI selection + */ + def prepareOofRequestForRanNSS = { DelegateExecution execution -> + logger.debug(Prefix+"prepareOofRequestForRanNSS method start") + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSSI option OOF Url: " + urlString) + + //build oof request body + boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse"); + String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("RANSliceProfile"), Map.class) + ServiceInstance ranSliceProfileInstance = objectMapper.readValue(execution.getVariable("ranSliceProfileInstance"), ServiceInstance.class) + String modelUuid = ranSliceProfileInstance.getModelVersionId() + String modelInvariantUuid = ranSliceProfileInstance.getModelInvariantId() + String modelName = execution.getVariable("servicename") + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + List<String> nsstInfoList = new ArrayList<>() + JsonArray capabilitiesList = new JsonArray() + String FHCapabilities = execution.getVariable("FHCapabilities") + String MHCapabilities = execution.getVariable("MHCapabilities") + String ANNFCapabilities = execution.getVariable("ANNFCapabilities") + JsonObject FH = new JsonObject() + JsonObject MH = new JsonObject() + JsonObject ANNF = new JsonObject() + FH.addProperty("domainType", "TN_FH") + FH.addProperty("capabilityDetails", FHCapabilities) + MH.addProperty("domainType", "TN_MH") + MH.addProperty("capabilityDetails", MHCapabilities) + ANNF.addProperty("domainType", "AN_NF") + ANNF.addProperty("capabilityDetails", FHCapabilities) + capabilitiesList.add(FH) + capabilitiesList.add(MH) + capabilitiesList.add(ANNF) + + execution.setVariable("nssiSelection_Url", "/api/oof/selection/nsi/v1") + execution.setVariable("nssiSelection_messageType",messageType) + execution.setVariable("nssiSelection_correlator",requestId) + execution.setVariable("nssiSelection_timeout",timeout) + String oofRequest = anNssmfUtils.buildSelectRANNSSIRequest(requestId, messageType, modelUuid,modelInvariantUuid, + modelName, profileInfo, nsstInfoList, capabilitiesList, ranNssiPreferReuse) + + execution.setVariable("nssiSelection_oofRequest",oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) + } + + /* + * process OOF response for RAN NSSI selection + */ + def processOofResponseForRanNSS = { DelegateExecution execution -> + logger.debug(Prefix+"processOofResponseForRanNSS method start") + String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse") + String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") + if(requestStatus.equals("completed")) { + List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions")) + boolean existingNSI = jsonUtil.getJsonValue(solution.get(0), "existingNSI") + if(!existingNSI) { + def sliceProfiles = jsonUtil.getJsonValue(solution.get(0), "newNSISolution.sliceProfiles") + execution.setVariable("RanConstituentSliceProfiles", sliceProfiles) + List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(sliceProfiles) + anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution) + logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles) + }else { + String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage") + logger.error("failed to get slice profiles from oof "+ statusMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"failed to get slice profiles from oof "+statusMessage) + } + }else { + String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage") + logger.error("received failed status from oof "+ statusMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage) + } + + } + def getNssisFromAai = { DelegateExecution execution -> + logger.debug(Prefix+"getNssisFromAai method start") + String instanceId = execution.getVariable("serviceInstanceID") + String role = "nssi" + Map<String,ServiceInstance> ranConstituentNssis = getRelatedInstancesByRole(execution, role, instanceId) + logger.debug("getNssisFromAai ranConstituentNssis : "+ranConstituentNssis.toString()) + ranConstituentNssis.each { key, val -> + switch(key) { + case "AN-NF": + execution.setVariable("ANNF_NSSI", val.getServiceInstanceId()) + execution.setVariable("ANNF_nssiName", val.getServiceInstanceName()) + break + case "TN-FH": + execution.setVariable("TNFH_NSSI", val.getServiceInstanceId()) + execution.setVariable("TNFH_nssiName", val.getServiceInstanceName()) + break + case "TN-MH": + execution.setVariable("TNMH_NSSI", val.getServiceInstanceId()) + execution.setVariable("TNMH_nssiName", val.getServiceInstanceName()) + break + default: + logger.error("No expected match found for current domainType "+ key) + exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ key) + } + } + + } + def createSliceProfiles = { DelegateExecution execution -> + logger.debug(Prefix+"createSliceProfiles method start") + anNssmfUtils.createSliceProfilesInAai(execution) + } + def updateRelationshipInAai = { DelegateExecution execution -> + logger.debug(Prefix+"updateRelationshipInAai method start") + String msg = "" + try { + def ANNF_serviceInstanceId = execution.getVariable("ANNF_NSSI") + def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI") + def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI") + def AN_profileInstanceId = execution.getVariable("sliceProfileId") + def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId") + def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId") + def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + Relationship ANNF_relationship = new Relationship() + Relationship TNFH_relationship = new Relationship() + Relationship TNMH_relationship = new Relationship() + + String ANNF_relatedLink = "aai/v16/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}" + String TNFH_relatedLink = "aai/v16/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}" + String TNMH_relatedLink = "aai/v16/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}" + + ANNF_relationship.setRelatedLink(ANNF_relatedLink) + ANNF_relationship.setRelatedTo("service-instance") + ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + TNFH_relationship.setRelatedLink(TNFH_relatedLink) + TNFH_relationship.setRelatedTo("service-instance") + TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + TNMH_relationship.setRelatedLink(TNMH_relatedLink) + TNMH_relationship.setRelatedTo("service-instance") + TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + + // create SliceProfile and NSSI relationship in AAI + anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,TNMH_serviceInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_profileInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_profileInstanceId) + anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_profileInstanceId) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + + msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + def processRanNfModifyRsp = { DelegateExecution execution -> + logger.debug(Prefix+"processRanNfModifyRsp method start") + anNssmfUtils.processRanNfModifyRsp(execution) + } + + def prepareTnFhRequest = { DelegateExecution execution -> + logger.debug(Prefix+"prepareTnFhRequest method start") + + String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "modify-allocate") + String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles" + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + + if (nssmfResponse != null) { + execution.setVariable("nssmfResponse", nssmfResponse) + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TNFH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + logger.debug("Exit prepareTnFhRequest") + + } + def prepareTnMhRequest = { DelegateExecution execution -> + logger.debug(Prefix+"prepareTnMhRequest method start") + + String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "modify-allocate") + String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles" + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + + if (nssmfResponse != null) { + execution.setVariable("nssmfResponse", nssmfResponse) + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TNMH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + logger.debug("Exit prepareTnMhRequest") + } + + def createFhAllocateNssiJobQuery = { DelegateExecution execution -> + logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + createTnAllocateNssiJobQuery(execution, "TN_FH") + } + + def createMhAllocateNssiJobQuery = { DelegateExecution execution -> + logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + createTnAllocateNssiJobQuery(execution, "TN_MH") + } + + private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) { + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType("TN") + esrInfo.setVendor("ONAP") + String esrInfoString = objectMapper.writeValueAsString(esrInfo) + execution.setVariable("esrInfo", esrInfoString) + JsonObject serviceInfo = new JsonObject() + + serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) + String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST") + serviceInfo.addProperty("sST", sST) + serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList"))) + serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) + serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + serviceInfo.addProperty("serviceInvariantUuid", null) + serviceInfo.addProperty("serviceUuid", null) + if(domainType.equals("TN_FH")) { + serviceInfo.addProperty("nssiId", execution.getVariable("TNFH_NSSI")) + serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_nssiName")) + }else if(domainType.equals("TN_MH")) { + serviceInfo.addProperty("nssiId", execution.getVariable("TNMH_NSSI")) + serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_nssiName")) + } + execution.setVariable("serviceInfo", serviceInfo.toString()) + execution.setVariable("responseId", "") + } + + def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution -> + logger.debug(Prefix+"processJobStatusRsp method start") + String jobResponse = execution.getVariable("TNFH_jobResponse") + logger.debug("Job status response "+jobResponse) + String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") + String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + if(status.equalsIgnoreCase("finished")) { + logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) + } + else { + String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + } + } + + def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution -> + logger.debug(Prefix+"processJobStatusRsp method start") + String jobResponse = execution.getVariable("TNMH_jobResponse") + logger.debug("Job status response "+jobResponse) + String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status") + String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi") + if(status.equalsIgnoreCase("finished")) { + logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi) + } + else { + String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription") + logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription) + } + } + + def getSliceProfilesFromAai = { DelegateExecution execution -> + logger.debug(Prefix+"getSliceProfilesFromAai method start") + String instanceId = execution.getVariable("sliceProfileId") + String role = "slice-profile-instance" + Map<String,ServiceInstance> ranConstituentSliceProfiles = getRelatedInstancesByRole(execution, role, instanceId) + logger.debug("getSliceProfilesFromAai ranConstituentSliceProfiles : "+ranConstituentSliceProfiles.toString()) + ranConstituentSliceProfiles.each { key, val -> + switch(key) { + case "AN-NF": + execution.setVariable("ANNF_sliceProfileInstanceId", val.getServiceInstanceId()) + break + case "TN-FH": + execution.setVariable("TNFH_sliceProfileInstanceId", val.getServiceInstanceId()) + break + case "TN-MH": + execution.setVariable("TNMH_sliceProfileInstanceId", val.getServiceInstanceId()) + break + default: + logger.error("No expected match found for current domainType "+ key) + exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ key) + } + } + } + + def prepareTnFhDeallocateRequest = { DelegateExecution execution -> + logger.debug(Prefix+"prepareTnFhDeallocateRequest method start") + String nssmfRequest = anNssmfUtils.buildDeallocateNssiRequest(execution, "TN_FH") + String nssiId = execution.getVariable("TNFH_NSSI") + execution.setVariable("tnFHNSSIId", nssiId) + String urlString = "/api/rest/provMns/v1/NSS/nssi/" + nssiId + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + if (nssmfResponse != null) { + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TN_FH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + } + + def prepareTnMhDeallocateRequest = { DelegateExecution execution -> + logger.debug(Prefix+"prepareTnFhDeallocateRequest method start") + String nssmfRequest = anNssmfUtils.buildDeallocateNssiRequest(execution, "TN_FH") + String nssiId = execution.getVariable("TNFH_NSSI") + execution.setVariable("tnFHNSSIId", nssiId) + String urlString = "/api/rest/provMns/v1/NSS/nssi/" + nssiId + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) + if (nssmfResponse != null) { + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("TN_MH_jobId",jobId) + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") + } + } + + def createFhDeAllocateNssiJobQuery = { DelegateExecution execution -> + logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + createTnAllocateNssiJobQuery(execution, "TN_FH") + } + + def createMhDeAllocateNssiJobQuery = { DelegateExecution execution -> + logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") + createTnAllocateNssiJobQuery(execution, "TN_MH") + } + def deleteFhSliceProfile = { DelegateExecution execution -> + logger.debug(Prefix+"deleteFhSliceProfile method start") + deleteServiceInstanceInAAI(execution,execution.getVariable("TNFH_sliceProfileInstanceId")) + } + def deleteMhSliceProfile = { DelegateExecution execution -> + logger.debug(Prefix+"deleteMhSliceProfile method start") + deleteServiceInstanceInAAI(execution,execution.getVariable("TNMH_sliceProfileInstanceId")) + } + def deleteAnSliceProfile = { DelegateExecution execution -> + logger.debug(Prefix+"deleteAnSliceProfile method start") + deleteServiceInstanceInAAI(execution,execution.getVariable("ANNF_sliceProfileInstanceId")) + } + /** + * update operation status in request db + * + */ + def prepareOperationStatusUpdate = { DelegateExecution execution -> + logger.debug(Prefix + "prepareOperationStatusUpdate Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String nssiId = execution.getVariable("serviceInstanceID") + logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus updateStatus = new ResourceOperationStatus() + updateStatus.setServiceId(serviceId) + updateStatus.setOperationId(jobId) + updateStatus.setResourceTemplateUUID(nsiId) + updateStatus.setResourceInstanceID(nssiId) + updateStatus.setOperType("Modify") + updateStatus.setProgress(100) + updateStatus.setStatus("finished") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) + + logger.debug(Prefix + "prepareOperationStatusUpdate Exit") + } + + def prepareFailedOperationStatusUpdate = { DelegateExecution execution -> + logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String nssiId = execution.getVariable("serviceInstanceID") + logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus updateStatus = new ResourceOperationStatus() + updateStatus.setServiceId(serviceId) + updateStatus.setOperationId(jobId) + updateStatus.setResourceTemplateUUID(nsiId) + updateStatus.setResourceInstanceID(nssiId) + updateStatus.setOperType("Modify") + updateStatus.setProgress(0) + updateStatus.setStatus("failed") + requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) + } + + /** + * @param execution + * @param role - nssi/slice profile instance + * @param instanceId - id to which the related list to be found + * @return + */ + private Map<String,ServiceInstance> getRelatedInstancesByRole(DelegateExecution execution,String role,String instanceId) { + logger.debug("${Prefix} - Fetching related ${role} from AAI") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + Map<String,ServiceInstance> relatedInstances = new HashMap<>() + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, instanceId) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") + } + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + if(si.isPresent()) { + List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship() + for (Relationship relationship : relationshipList) { + String relatedTo = relationship.getRelatedTo() + if (relatedTo.toLowerCase() == "service-instance") { + String relatioshipurl = relationship.getRelatedLink() + String serviceInstanceId = + relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) + + AAIResourcesClient client01 = new AAIResourcesClient() + AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, serviceInstanceId) + if (!client.exists(uri01)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, + "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}") + } + AAIResultWrapper wrapper01 = client01.get(uri01, NotFoundException.class) + Optional<ServiceInstance> serviceInstance = wrapper01.asBean(ServiceInstance.class) + if (serviceInstance.isPresent()) { + ServiceInstance instance = serviceInstance.get() + if (role.equalsIgnoreCase(instance.getServiceRole())) { + relatedInstances.put(instance.getWorkloadContext(),instance) + } + } + } + } + } + logger.debug("Found ${relatedInstances.size()} ${role} related to ${instanceId} ") + return relatedInstances + } + + private ServiceInstance getServiceInstance(DelegateExecution execution, String instanceId) { + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + ServiceInstance serviceInstance = new ServiceInstance() + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, subscriptionServiceType, instanceId) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") + } + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + + if(si.isPresent()) { + serviceInstance = si + } + return serviceInstance + } + private void deleteServiceInstanceInAAI(DelegateExecution execution,String instanceId) { + try { + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), instanceId) + getAAIClient().delete(serviceInstanceUri) + logger.debug("${Prefix} Exited deleteServiceInstance") + }catch(Exception e){ + logger.debug("Error occured within deleteServiceInstance method: " + e) + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy new file mode 100644 index 0000000000..6c12a656f4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy @@ -0,0 +1,732 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.CloudRegion +import org.onap.aai.domain.yang.Customer +import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.ModelVer +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.ServiceSubscription +import org.onap.aai.domain.yang.SliceProfile +import org.onap.aai.domain.yang.Tenant +import org.onap.aai.domain.yang.VfModule +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.db.request.beans.OperationStatus +import org.onap.so.requestsdb.RequestsDbConstant +import org.onap.so.serviceinstancebeans.CloudConfiguration +import org.onap.so.serviceinstancebeans.ModelInfo +import org.onap.so.serviceinstancebeans.ModelType +import org.onap.so.serviceinstancebeans.OwningEntity +import org.onap.so.serviceinstancebeans.Project +import org.onap.so.serviceinstancebeans.RequestDetails +import org.onap.so.serviceinstancebeans.RequestInfo +import org.onap.so.serviceinstancebeans.RequestParameters +import org.onap.so.serviceinstancebeans.Resources +import org.onap.so.serviceinstancebeans.Service +import org.onap.so.serviceinstancebeans.SubscriberInfo +import org.onap.so.serviceinstancebeans.VfModules +import org.onap.so.serviceinstancebeans.Vnfs +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import javax.ws.rs.core.Response + +class DoModifyCoreNSSI extends AbstractServiceTaskProcessor { + + private final String PREFIX ="DoModifyCoreNSSI" + + private ExceptionUtil exceptionUtil = new ExceptionUtil() + private RequestDBUtil requestDBUtil = new RequestDBUtil() + private MsoUtils utils = new MsoUtils() + private JsonUtils jsonUtil = new JsonUtils() + + private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start preProcessRequest") + + def currentNSSI = execution.getVariable("currentNSSI") + if (!currentNSSI) { + String msg = "currentNSSI is null" + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + LOGGER.trace("***** ${PREFIX} Exit preProcessRequest") + } + + + /** + * Queries Network Service Instance in AAI + * @param execution + */ + void getNetworkServiceInstance(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start getNetworkServiceInstance") + + AAIResourcesClient client = getAAIClient() + + def currentNSSI = execution.getVariable("currentNSSI") + + String globalSubscriberId = currentNSSI['globalSubscriberId'] + String serviceType = currentNSSI['serviceType'] + String nssiId = currentNSSI['nssiServiceInstanceId'] + + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) //AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiId) + Optional<ServiceInstance> nssiOpt = client.get(ServiceInstance.class, nssiUri) + + if (nssiOpt.isPresent()) { + ServiceInstance nssi = nssiOpt.get() + execution.setVariable("nssi", nssi) + + execution.setVariable("nssiUri", nssiUrl) + + // Network Service Instance + AAIResultWrapper wrapper = client.get(nssiUri); + Optional<Relationships> relationships = wrapper.getRelationships() + if (relationships.isPresent()) { + for(AAIResourceUri networkServiceInstanceUri: relationships.get().getRelatedAAIUris(AAIObjectType.SERVICE_INSTANCE)){ // ??? + Optional<ServiceInstance> networkServiceInstanceOpt = client.get(ServiceInstance.class, networkServiceInstanceUri) + if(networkServiceInstanceOpt.isPresent()) { + ServiceInstance networkServiceInstance = networkServiceInstanceOpt.get() + + if(networkServiceInstance.getServiceRole().equals("Network Service")) { // Network Service + execution.setVariable("networkServiceInstance", networkServiceInstance) + + execution.setVariable("networkServiceInstanceUri", networkServiceInstanceUri) + break // Should be only one Network Service Instance + } + } + else { + String msg = String.format("No Network Service Instance found for NSSI %s in AAI", nssiId) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + + } + } + else { + String msg = String.format("No relationship presented for NSSI %s in AAI", nssiId) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else { + String msg = String.format("NSSI %s not found in AAI", nssiId) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + + + LOGGER.trace("***** ${PREFIX} Exit getNetworkServiceInstance") + } + + + /** + * Queries constitute VNF from Network Service Instance + * @param execution + */ + void getConstituteVNFFromNetworkServiceInst(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start getConstituteVNFFromNetworkServiceInst") + + AAIResourcesClient client = getAAIClient() + + AAIResourceUri networkServiceInstanceUri = (AAIResourceUri)execution.getVariable("networkServiceInstanceUri") + AAIResultWrapper wrapper = client.get(networkServiceInstanceUri); + Optional<Relationships> relationships = wrapper.getRelationships() + if (relationships.isPresent()) { + for (AAIResourceUri constituteVnfUri : relationships.get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF)) { // ??? + execution.setVariable("constituteVnfUri", constituteVnfUri) + Optional<GenericVnf> constituteVnfOpt = client.get(GenericVnf.class, constituteVnfUri) + if(constituteVnfOpt.isPresent()) { + GenericVnf constituteVnf = constituteVnfOpt.get() + execution.setVariable("constituteVnf", constituteVnf) + } + else { + String msg = String.format("No constitute VNF found for Network Service Instance %s in AAI", ((ServiceInstance)execution.getVariable("networkServiceInstance")).getServiceInstanceId()) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + + execution.setVariable("networkServiceInstanceUri", networkServiceInstanceUri) + break // Should be only one constitute VNF + } + } + else { + String msg = String.format("No relationship presented for Network Service Instance %s in AAI", ((ServiceInstance)execution.getVariable("networkServiceInstance")).getServiceInstanceId()) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + + LOGGER.trace("${PREFIX} Exit getConstituteVNFFromNetworkServiceInst") + + } + + + /** + * Retrieves NSSI associated profiles from AAI + * @param execution + */ + void getNSSIAssociatedProfiles(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start getNSSIAssociatedProfiles") + + AAIResourcesClient client = getAAIClient() + + ServiceInstance nssi = (ServiceInstance)execution.getVariable("nssi") + + List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() + + if(associatedProfiles.isEmpty()) { + String msg = String.format("No associated profiles found for NSSI %s in AAI", nssi.getServiceInstanceId()) + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + else { + execution.setVariable("associatedProfiles", associatedProfiles) + } + + LOGGER.trace("${PREFIX} Exit getNSSIAssociatedProfiles") + } + + + /** + * Calculates a final list of S-NSSAI + * @param execution + */ + void calculateSNSSAI(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start calculateSNSSAI") + + List<SliceProfile> associatedProfiles = (List<SliceProfile>)execution.getVariable("associatedProfiles") + + def currentNSSI = execution.getVariable("currentNSSI") + + String currentSNSSAI = currentNSSI['S-NSSAI'] + + List<String> snssais = new ArrayList<>() + + if((Boolean)execution.getVariable("isCreateSliceProfileInstance" ).equals(Boolean.TRUE)) { // Slice Profile Instance has to be created + for (SliceProfile associatedProfile : associatedProfiles) { + snssais.add(associatedProfile.getSNssai()) + } + + snssais.add(currentSNSSAI) + } + else { // Slice profile instance has to be deleted + for (SliceProfile associatedProfile : associatedProfiles) { + if (!associatedProfile.getSNssai().equals(currentNSSI)) { // not current S-NSSAI + snssais.add(associatedProfile.getSNssai()) + } + } + } + + execution.setVariable("S-NSSAIs", snssais) + + LOGGER.trace("${PREFIX} Exit calculateSNSSAI") + } + + + /** + * Invoke PUT Service Instance API + * @param execution + */ + void invokePUTServiceInstance(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start invokePUTServiceInstance") + + try { + //url:/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfId}" + def nsmfЕndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) // ??? + + ServiceInstance networkServiceInstance = (ServiceInstance)execution.getVariable("networkServiceInstance") + + GenericVnf constituteVnf = (GenericVnf)execution.getVariable("constituteVnf") + + String url = String.format("${nsmfЕndpoint}/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId()) // ??? + + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuthValue = utils.encrypt(basicAuth, msoKey) + String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) + + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.EXTERNAL) + httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Accept", "application/json") + + RequestDetails requestDetails = prepareRequestDetails(execution) + ObjectMapper mapper = new ObjectMapper() + String requestDetailsStr = mapper.writeValueAsString(requestDetails) + + Response httpResponse = httpClient.put(requestDetailsStr) // check http code ??? + } catch (any) { + String msg = "Exception in DoDeallocateCoreNSSI.deleteServiceOrder. " + any.getCause() + LOGGER.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + LOGGER.trace("${PREFIX} Exit invokePUTServiceInstance") + } + + + /** + * Prepare model info + * @param execution + * @param requestDetails + * @return + */ + private ModelInfo prepareModelInfo(DelegateExecution execution) { + ModelInfo modelInfo = new ModelInfo() + + modelInfo.setModelType(ModelType.service) + modelInfo.setModelInvariantId(networkServiceInstance.getModelInvariantId()) + + AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, networkServiceInstance.getModelInvariantId()) // model of Network Service Instance ??? + Optional<ModelVer> modelVerOpt = client.get(ModelVer.class, modelVerUrl) + + if (modelVerOpt.isPresent()) { + modelInfo.setModelVersionId(modelVerOpt.get().getModelVersionId()) + modelInfo.setModelName(modelVerOpt.get().getModelName()) + modelInfo.setModelVersion(modelVerOpt.get().getModelVersion()) + } + + + return modelInfo + } + + + /** + * Prepares RequestDetails object + * @param execution + * @return + */ + private RequestDetails prepareRequestDetails(DelegateExecution execution) { + RequestDetails requestDetails = new RequestDetails() + + def currentNSSI = execution.getVariable("currentNSSI") + + String globalSubscriberId = currentNSSI['globalSubscriberId'] + + ServiceInstance networkServiceInstance = (ServiceInstance)execution.getVariable("networkServiceInstance") + + + AAIResourcesClient client = getAAIClient() + + // Model Info + requestDetails.setModelInfo(prepareModelInfo(execution)) + + // Subscriber Info + SubscriberInfo subscriberInfo = new SubscriberInfo() + subscriberInfo.setGlobalSubscriberId(globalSubscriberId) + + Customer customer = null + ServiceSubscription serviceSubscription = null + + AAIResourceUri networkServiceInstanceUri = execution.getVariable("networkServiceInstanceUri") + AAIResultWrapper wrapper = client.get(networkServiceInstanceUri) + Optional<Relationships> serviceSubscriptionRelationshipsOps = wrapper.getRelationships() + if(serviceSubscriptionRelationshipsOps.isPresent()) { + List<AAIResourceUri> serviceSubscriptionRelatedAAIUris = serviceSubscriptionRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.SERVICE_SUBSCRIPTION) + if(!(serviceSubscriptionRelatedAAIUris == null || serviceSubscriptionRelatedAAIUris.isEmpty())) { + AAIResourceUri serviceSubscriptionUri = serviceSubscriptionRelatedAAIUris.get(0) // Many-To-One relation + Optional<ServiceSubscription> serviceSubscriptionOpt = client.get(ServiceSubscription.class, serviceSubscriptionUri) + if(serviceSubscriptionOpt.isPresent()) { + serviceSubscription = serviceSubscriptionOpt.get() + } + + wrapper = client.get(serviceSubscriptionUri) + Optional<Relationships> customerRelationshipsOps = wrapper.getRelationships() + if(customerRelationshipsOps.isPresent()) { + List<AAIResourceUri> customerRelatedAAIUris = customerRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.CUSTOMER) + if(!(customerRelatedAAIUris == null || customerRelatedAAIUris.isEmpty())) { + Optional<Customer> customerOpt = client.get(Customer.class, customerRelatedAAIUris.get(0)) // Many-To-One relation + if(customerOpt.isPresent()) { + customer = customerOpt.get() + subscriberInfo.setSubscriberName(customer.getSubscriberName()) + } + } + } + } + + } + requestDetails.setSubscriberInfo(subscriberInfo) + + // Request Info + RequestInfo requestInfo = new RequestInfo() + requestInfo.setInstanceName(networkServiceInstance.getServiceInstanceName()) + + /* No found data to provide ??? + requestInfo.setSource() + requestInfo.setSuppressRollback() + requestInfo.setRequestorId() + requestInfo.setProductFamilyId() + */ + + requestDetails.setRequestInfo(requestInfo) + + + // Request Parameters + RequestParameters requestParameters = new RequestParameters() + + // No found data to provide ??? requestParameters.setaLaCarte() + requestParameters.setSubscriptionServiceType(serviceSubscription.getServiceType()) + + // User params + List<Map<String, Object>> userParams = new ArrayList<>() + // Service + Service service = new Service() + // Model Info + ModelInfo serviceModelInfo = new ModelInfo() + serviceModelInfo.setModelType(ModelType.service) + serviceModelInfo.setModelInvariantId(networkServiceInstance.getModelInvariantId()) + + serviceModelInfo.setModelVersionId(modelInfo.get().getModelVersionId()) + serviceModelInfo.setModelName(modelInfo.get().getModelName()) + serviceModelInfo.setModelVersion(modelInfo.get().getModelVersion()) + + service.setModelInfo(serviceModelInfo) + + // Resources + Resources resources = new Resources() + + CloudRegion cloudRegion = null + AAIResourceUri cloudRegionRelatedAAIUri = null + // VNFs + List<Vnfs> vnfs = new ArrayList<>() + // VNF + Vnfs vnf = new Vnfs() + + // Cloud configuration + CloudConfiguration cloudConfiguration = new CloudConfiguration() + + AAIResourceUri constituteVnfUri = (AAIResourceUri)execution.getVariable("constituteVnfUri") + wrapper = client.get(constituteVnfUri) + Optional<Relationships> constituteVnfOps = wrapper.getRelationships() + if(constituteVnfOps.isPresent()) { + List<AAIResourceUri> cloudRegionRelatedAAIUris = serviceSubscriptionRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) + if(!(cloudRegionRelatedAAIUris == null || cloudRegionRelatedAAIUris.isEmpty())) { + cloudRegionRelatedAAIUri = cloudRegionRelatedAAIUris.get(0) + Optional<CloudRegion> cloudRegionrOpt = client.get(CloudRegion.class, cloudRegionRelatedAAIUris.get(0)) + if(cloudRegionrOpt.isPresent()) { + cloudRegion = cloudRegionrOpt.get() + cloudConfiguration.setLcpCloudRegionId(cloudRegion.getCloudRegionId()) + for(Tenant tenant:cloudRegion.getTenants()) { + cloudConfiguration.setTenantId(tenant.getTenantId()) + break // only one is required + } + + cloudConfiguration.setCloudOwner(cloudRegion.getCloudOwner()) + } + } + } + + vnf.setCloudConfiguration(cloudConfiguration) + + // VF Modules + GenericVnf constituteVnf = execution.getVariable("constituteVnf") + List<VfModules> vfModuless = new ArrayList<>() + for(VfModule vfModule:constituteVnf.getVfModules()) { + VfModules vfmodules = new VfModules() + + ModelInfo vfModuleModelInfo = new ModelInfo() + vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId()) + + AAIResourceUri vfModuleUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, vfModule.getModelInvariantId()) // ??? + Optional<ModelVer> vfModuleModelVerOpt = client.get(ModelVer.class, vfModuleUrl) + + if (vfModuleModelVerOpt.isPresent()) { + vfModuleModelInfo.setModelVersionId(vfModuleModelVerOpt.get().getModelVersionId()) + vfModuleModelInfo.setModelName(vfModuleModelVerOpt.get().getModelName()) + vfModuleModelInfo.setModelVersion(vfModuleModelVerOpt.get().getModelVersion()) + + // No model customization ID + } + vfmodules.setModelInfo(vfModuleModelInfo) + + vfmodules.setInstanceName(vfModule.getVfModuleName()) // ??? + + vfModuless.add(vfmodules) + } + vnf.setVfModules(vfModuless) + + // Model Info + ModelInfo vnfModelInfo = new ModelInfo() + vnfModelInfo.setModelInvariantUuid(constituteVnf.getModelInvariantId()) + AAIResourceUri vnfModelUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, constituteVnf.getModelInvariantId()) // ??? + Optional<ModelVer> vnfModelVerOpt = client.get(ModelVer.class, vnfModelUrl) + + if (vnfModelVerOpt.isPresent()) { + vnfModelInfo.setModelVersionId(vnfModelVerOpt.get().getModelVersionId()) + vnfModelInfo.setModelName(vnfModelVerOpt.get().getModelName()) + vnfModelInfo.setModelVersion(vnfModelVerOpt.get().getModelVersion()) + + // No model customization ID + // No model instance name + } + + vnf.setModelInfo(vnfModelInfo) + + // Instance name + vnf.setInstanceName(constituteVnf.getVnfInstanceId()) + + // Instance params + List<Map<String, Object>> instanceParams = new ArrayList<>() + Map<String, Object> supporrtedNSSAIMap = new HashMap<>() + + // Supported S-NSSAI + List<String> snssais = ( List<String>)execution.getVariable("S-NSSAIs") + supporrtedNSSAIMap.put("supporrtedNSSAI", snssais) // remaining S-NSSAIs ??? there is no status for each s-nssai + instanceParams.add(supporrtedNSSAIMap) + + // No other instance params, e.g. config-type + + vnf.setInstanceParams(instanceParams) + + // No platform data + + vnfs.add(vnf) + resources.setVnfs(vnfs) + + service.setResources(resources) + + Map<String, Object> serviceMap = new HashMap<>() + serviceMap.put("service", service) + userParams.add(serviceMap) + requestParameters.setUserParams(userParams) + + // No other user params + + requestDetails.setRequestParameters(requestParameters) + + // No other request params + + // Cloud configuration + requestDetails.setCloudConfiguration(cloudConfiguration) + + // Owning entity + OwningEntity owningEntity = new OwningEntity() + wrapper = client.get(networkServiceInstanceUri) + Optional<Relationships> owningEntityRelationshipsOps = wrapper.getRelationships() + if(owningEntityRelationshipsOps.isPresent()) { + List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.OWNING_ENTITY) + + if(!(owningEntityRelatedAAIUris == null || owningEntityRelatedAAIUris.isEmpty())) { + Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation + if(owningEntityOpt.isPresent()) { + owningEntity.setOwningEntityId(owningEntityOpt.get().getOwningEntityId()) + owningEntity.setOwningEntityName(owningEntityOpt.get().getOwningEntityName()) + requestDetails.setOwningEntity(owningEntity) + } + } + } + + // Project + Project project = new Project() + if(cloudRegionRelatedAAIUri != null) { + wrapper = client.get(cloudRegionRelatedAAIUri) + Optional<Relationships> cloudRegionOps = wrapper.getRelationships() + if(cloudRegionOps.isPresent()) { + List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedAAIUris(AAIObjectType.PROJECT) + if (!(projectAAIUris == null || projectAAIUris.isEmpty())) { + Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.Project.class, projectAAIUris.get(0)) + if(projectOpt.isPresent()) { + project.setProjectName(projectOpt.get().getProjectName()) + } + } + } + } + requestDetails.setProject(project) + + return requestDetails + } + + + /** + * Creates Slice Profile Instance + * @param execution + */ + void createSliceProfileInstance(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start createSliceProfileInstance") + + String sliceProfileID = execution.getVariable("sliceProfileID") + Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn") + Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile") + + SliceProfile sliceProfile = new SliceProfile() + sliceProfile.setServiceAreaDimension("") + sliceProfile.setPayloadSize(0) + sliceProfile.setJitter(0) + sliceProfile.setSurvivalTime(0) + sliceProfile.setExpDataRate(0) + sliceProfile.setTrafficDensity(0) + sliceProfile.setConnDensity(0) + sliceProfile.setSNssai(sliceProfileMap.get("sNSSAI").toString()) + sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString())) + sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString())) + sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString())) + sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString()) + sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString()) + sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString()) + sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString())) + sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString())) + sliceProfile.setProfileId(sliceProfileID) + sliceProfile.setE2ELatency(0) + + try { + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, sliceProfileID) + client.create(uri, sliceProfile) + + execution.setVariable("createdSliceProfile", sliceProfile) + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage()) + } + + LOGGER.trace("${PREFIX} Exit createSliceProfileInstance") + } + + + /** + * Creates Slice Profile association with NSSI + * @param execution + */ + void associateSliceProfileInstanceWithNSSI(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start associateSliceProfileInstanceWithNSSI") + + String sliceProfileID = execution.getVariable("sliceProfileID") + + def currentNSSI = execution.getVariable("currentNSSI") + + String nssiId = currentNSSI['nssiServiceInstanceId'] + + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, sliceProfileID) + + try { + SliceProfile createdSliceProfile = (SliceProfile)execution.getVariable("createdSliceProfile") + ServiceInstance nssi = (ServiceInstance)execution.getVariable("nssi") + List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() + associatedProfiles.add(createdSliceProfile) + + getAAIClient().update(nssiUri, nssi) + + getAAIClient().connect(sliceProfileUri, nsiUri, AAIEdgeLabel.BELONGS_TO) + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage()) + } + + LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI") + } + + + /** + * Removes Slice Profile association with NSSI + * @param execution + */ + void removeSPAssociationWithNSSI(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start removeSPAssociationWithNSSI") + + AAIResourcesClient client = getAAIClient() + + def currentNSSI = execution.getVariable("currentNSSI") + + ServiceInstance nssi = (ServiceInstance)execution.getVariable("nssi") + + String nssiId = currentNSSI['nssiServiceInstanceId'] + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + + List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() + + String currentSNSSAI = currentNSSI['S-NSSAI'] + + associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) }) + + try { + getAAIClient().update(nssiUri, nssi) + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage()) + } + + LOGGER.trace("${PREFIX} Exit removeSPAssociationWithNSSI") + } + + + /** + * Deletes Slice Profile Instance + * @param execution + */ + void deleteSliceProfileInstance(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start deleteSliceProfileInstance") + + AAIResourcesClient client = getAAIClient() + + def currentNSSI = execution.getVariable("currentNSSI") + + ServiceInstance nssi = (ServiceInstance)execution.getVariable("nssi") + + List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() + + String currentSNSSAI = currentNSSI['S-NSSAI'] + + AAIResourceUri sliceProfileUri = null + + for(SliceProfile associatedProfile:associatedProfiles) { + if(!associatedProfile.getSNssai().equals(currentNSSI)) { // not current S-NSSAI + sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, associatedProfile.getProfileId()) + break + } + } + + try { + getAAIClient().delete(sliceProfileUri) + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage()) + } + + LOGGER.trace("${PREFIX} Exit deleteSliceProfileInstance") + } + + + /** + * Updates operation status + * @param execution + */ + void updateServiceOperationStatus(DelegateExecution execution) { + LOGGER.trace("${PREFIX} Start updateServiceOperationStatus") + + def currentNSSI = execution.getVariable("currentNSSI") + + OperationStatus operationStatus = new OperationStatus() + operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String) + operationStatus.setOperationId(currentNSSI['operationId'] as String) + operationStatus.setOperation(currentNSSI['operationType'] as String) + operationStatus.setResult(RequestsDbConstant.Status.FINISHED) + + requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus) + + LOGGER.trace("${PREFIX} Exit updateServiceOperationStatus") + } + + + /** + * Returns AAI client + * @return AAI client + */ + AAIResourcesClient getAAIClient() { + return new AAIResourcesClient() + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy new file mode 100644 index 0000000000..6fdfbe3218 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy @@ -0,0 +1,193 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.json.JsonUtils +import com.fasterxml.jackson.databind.ObjectMapper +import com.google.gson.JsonObject +import java.sql.Timestamp + +import static org.apache.commons.lang3.StringUtils.isBlank +import org.onap.so.bpmn.core.UrnPropertiesReader + +class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { + + String Prefix="MANNFNSS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + ObjectMapper objectMapper = new ObjectMapper(); + AnNssmfUtils anNssmfUtils = new AnNssmfUtils() + + private static final Logger logger = LoggerFactory.getLogger(DoModifyRanNfNssi.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + + logger.debug("input variables : msoRequestId - "+execution.getVariable("msoRequestId")+ + " globalSubscriberId - "+execution.getVariable("globalSubscriberId")+ + " serviceInstanceID - "+execution.getVariable("serviceInstanceID")+ + " subscriptionServiceType - "+execution.getVariable("subscriptionServiceType")+ + " sliceProfileId - "+execution.getVariable("sliceProfileId")+ + " snssaiList - "+execution.getVariable("snssaiList")+ + " modifyAction - "+execution.getVariable("modifyAction")) + + //validate RAN NF slice subnet inputs + + String modifyAction = execution.getVariable("modifyAction") + if (isBlank(modifyAction)) { + msg = "Input modifyAction is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("modifyAction", modifyAction) + switch(modifyAction) { + case "allocate": + String sliceProfile = execution.getVariable("additionalProperties") + execution.setVariable("sliceProfile", sliceProfile) + break + case "reconfigure": + String resourceConfig = execution.getVariable("additionalProperties") + execution.setVariable("resourceConfig", resourceConfig) + break + default: + logger.debug("Invalid modify Action") + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid modify Action : "+modifyAction) + } + } + List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + String sliceProfileId = execution.getVariable("sliceProfileId") + if (isBlank(sliceProfileId) || (snssaiList.empty)) { + msg = "Mandatory fields are empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("sliceProfileId", sliceProfileId) + execution.setVariable("snssaiList", snssaiList) + execution.setVariable("snssai", snssaiList.get(0)) + } + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in DoModifyAccessNssi.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + def createSdnrRequest = { DelegateExecution execution -> + logger.debug(Prefix+"createSdnrRequest method start") + String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId") + String modifyAction = execution.getVariable("modifyAction") + String sdnrRequest = buildSdnrAllocateRequest(execution, modifyAction, "InstantiateRANSlice", callbackUrl) + execution.setVariable("createNSSI_sdnrRequest", sdnrRequest) + execution.setVariable("createNSSI_timeout", "PT10M") + execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId")) + execution.setVariable("createNSSI_messageType", "AsyncSdnrResponse"); + } + + def processSdnrResponse = { DelegateExecution execution -> + logger.debug(Prefix+"processSdnrResponse method start") + String SDNRResponse = execution.getVariable("SDNR_asyncCallbackResponse") + String status = jsonUtil.getJsonValue(SDNRResponse, "status") + if(status.equalsIgnoreCase("success")) { + String nfIds = jsonUtil.getJsonValue(SDNRResponse, "nfIds") + execution.setVariable("ranNfIdsJson", nfIds) + }else { + String reason = jsonUtil.getJsonValue(SDNRResponse, "reason") + logger.error("received failed status from SDNR "+ reason) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from SDNR "+ reason) + } + logger.debug("response from SDNR "+SDNRResponse) + } + + private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) { + + String requestId = execution.getVariable("msoRequestId") + Date date = new Date().getTime() + Timestamp time = new Timestamp(date) + String sliceProfileString + JsonObject response = new JsonObject() + JsonObject body = new JsonObject() + JsonObject input = new JsonObject() + JsonObject commonHeader = new JsonObject() + JsonObject payload = new JsonObject() + JsonObject payloadInput = new JsonObject() + if(action.equals("allocate")) { + Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) + sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) + sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions")) + sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL")) + sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL")) + sliceProfileString = objectMapper.writeValueAsString(sliceProfile) + action = "modify-"+action + payloadInput.add("additionalproperties", new JsonObject()) + }else if(action.equals("deallocate")) { + action = "modify-"+action + Map<String,Object> sliceProfile = new HashMap<>() + sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) + sliceProfile.put("sNSSAI", execution.getVariable("snssai")) + sliceProfileString = objectMapper.writeValueAsString(sliceProfile) + payloadInput.add("additionalproperties", new JsonObject()) + }else if(action.equals("reconfigure")) { + Map<String,Object> sliceProfile = new HashMap<>() + sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) + sliceProfile.put("sNSSAI", execution.getVariable("snssai")) + sliceProfileString = objectMapper.writeValueAsString(sliceProfile) + JsonObject resourceconfig = new JsonObject() + resourceconfig.addProperty("resourceConfig", execution.getVariable("resourceConfig")) + payloadInput.add("additionalproperties", resourceconfig) + } + commonHeader.addProperty("TimeStamp", time.toString()) + commonHeader.addProperty("APIver", "1.0") + commonHeader.addProperty("RequestID", requestId) + commonHeader.addProperty("SubRequestID", "1") + commonHeader.add("RequestTrack", new JsonObject()) + commonHeader.add("Flags", new JsonObject()) + payloadInput.addProperty("sliceProfile", sliceProfileString) + payloadInput.addProperty("RANNFNSSIId", execution.getVariable("serviceInstanceID")) + payloadInput.addProperty("callbackURL", callbackUrl) + payload.add("input", payloadInput) + input.add("CommonHeader", commonHeader) + input.addProperty("Action", action) + input.add("Payload", payload) + body.add("input", input) + response.add("body", body) + response.addProperty("version", "1.0") + response.addProperty("rpc-name", rpcName) + response.addProperty("correlation-id", requestId+"-1") + response.addProperty("type", "request") + return response.toString() + } + +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy new file mode 100644 index 0000000000..0b7a5ff59b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -0,0 +1,401 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import groovy.json.JsonSlurper +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.SliceProfile +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.apache.commons.lang3.StringUtils.isBlank + +public class DoModifyTnNssi extends AbstractServiceTaskProcessor { + String Prefix = "TNMOD_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() + JsonSlurper jsonSlurper = new JsonSlurper() + ObjectMapper objectMapper = new ObjectMapper() + private static final Logger logger = LoggerFactory.getLogger(DoModifyTnNssi.class) + + + void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + execution.setVariable("prefix", Prefix) + String msg = "" + + try { + execution.setVariable("startTime", System.currentTimeMillis()) + msg = tnNssmfUtils.getExecutionInputParams(execution) + logger.debug("Modify TN NSSI input parameters: " + msg) + + execution.setVariable("prefix", Prefix) + + tnNssmfUtils.setSdncCallbackUrl(execution, true) + logger.debug("SDNC Callback URL: " + execution.getVariable("sdncCallbackUrl")) + + String additionalPropJsonStr = execution.getVariable("sliceParams") + + String sliceServiceInstanceId = execution.getVariable("serviceInstanceID") + execution.setVariable("sliceServiceInstanceId", sliceServiceInstanceId) + + String sliceServiceInstanceName = execution.getVariable("servicename") + execution.setVariable("sliceServiceInstanceName", sliceServiceInstanceName) + + String operationId = UUID.randomUUID().toString() + execution.setVariable("operationId", operationId) + + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + //here modelVersion is not set, we use modelUuid to decompose the service. + def isDebugLogEnabled = true + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + + //additional properties + String sliceProfile = jsonUtil.getJsonValue(additionalPropJsonStr, "sliceProfile") + if (isBlank(sliceProfile)) { + msg = "Input sliceProfile is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("sliceProfile", sliceProfile) + } + + String transportSliceNetworks = jsonUtil.getJsonValue(additionalPropJsonStr, "transportSliceNetworks") + if (isBlank(transportSliceNetworks)) { + msg = "Input transportSliceNetworks is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("transportSliceNetworks", transportSliceNetworks) + } + logger.debug("transportSliceNetworks: " + transportSliceNetworks) + + String nsiInfo = jsonUtil.getJsonValue(additionalPropJsonStr, "nsiInfo") + if (isBlank(nsiInfo)) { + msg = "Input nsiInfo is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("nsiInfo", nsiInfo) + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Finish preProcessRequest") + } + + + void deleteServiceInstance(DelegateExecution execution) { + try { + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + execution.getVariable("serviceInstanceID")) + client.delete(uri) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoDeallocateTnNssi.deleteServiceInstance. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + + void getExistingServiceInstance(DelegateExecution execution) { + String serviceInstanceId = execution.getVariable("serviceInstanceID") + + AAIResourcesClient resourceClient = getAAIClient() + AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + + try { + if (resourceClient.exists(ssServiceuri)) { + execution.setVariable("ssi_resourceLink", ssServiceuri.build().toString()) + org.onap.aai.domain.yang.ServiceInstance ss = + resourceClient.get(org.onap.aai.domain.yang.ServiceInstance.class, ssServiceuri) + org.onap.aai.domain.yang.SliceProfile sliceProfile = ss.getSliceProfiles().getSliceProfile().get(0) + execution.setVariable("sliceProfileId", sliceProfile.getProfileId()) + + org.onap.aai.domain.yang.AllottedResources ars = ss.getAllottedResources() + List<org.onap.aai.domain.yang.AllottedResource> arList = ars.getAllottedResource() + List<String> arIdList = new ArrayList<>() + for (org.onap.aai.domain.yang.AllottedResource ar : arList) { + String arId = ar.getId() + arIdList.add(arId) + } + execution.setVariable("arIdList", arIdList) + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " + + "associate allotted resource for service :" + serviceInstanceId) + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + String msg = "Exception in getServiceInstance. " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + } + + public void updateTnNssiInAAI(DelegateExecution execution) { + getExistingServiceInstance(execution) + + updateServiceInstance(execution) + updateSliceProfile(execution) + updateAllottedResource(execution) + } + + void updateServiceInstance(DelegateExecution execution) { + String serviceRole = "TN" + String serviceType = execution.getVariable("subscriptionServiceType") + String sliceProfileStr = execution.getVariable("sliceProfile") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") + try { + org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() + ss.setServiceInstanceId(ssInstanceId) + String sliceInstanceName = execution.getVariable("sliceServiceInstanceName") + ss.setServiceInstanceName(sliceInstanceName) + ss.setServiceType(serviceType) + String serviceStatus = "modified" + ss.setOrchestrationStatus(serviceStatus) + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + ss.setModelInvariantId(modelInvariantUuid) + ss.setModelVersionId(modelUuid) + String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) + ss.setServiceInstanceLocationId(serviceInstanceLocationid) + String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) + ss.setEnvironmentContext(snssai) + ss.setServiceRole(serviceRole) + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), ssInstanceId) + client.update(uri, ss) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void updateSliceProfile(DelegateExecution execution) { + + String sliceserviceInstanceId = execution.getVariable("sliceServiceInstanceId") + String sliceProfileStr = execution.getVariable("sliceProfile") + String sliceProfileId = execution.getVariable("sliceProfileId") + SliceProfile sliceProfile = new SliceProfile(); + sliceProfile.setProfileId(sliceProfileId) + sliceProfile.setLatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) + sliceProfile.setResourceSharingLevel(jsonUtil.getJsonValue(sliceProfileStr, "resourceSharingLevel")) + sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)) //TODO: should be list + + sliceProfile.setE2ELatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) + sliceProfile.setMaxBandwidth(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "maxBandwidth"))) + + //TODO: new API + sliceProfile.setReliability(new Object()) + try { + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, execution.getVariable + ("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, sliceProfileId) + client.update(uri, sliceProfile) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in updateSliceProfile. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void updateAllottedResource(DelegateExecution execution) { + String serviceInstanceId = execution.getVariable('serviceInstanceID') + + List<String> arIdList = execution.getVariable("arIdList") + try { + for (String arId : arIdList) { + AAIResourceUri arUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), + serviceInstanceId, arId) + + getAAIClient().delete(arUri) + } + + List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportSliceNetworks")) + + for (String networkStr : networkStrList) { + String allottedResourceId = UUID.randomUUID().toString() + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), + execution.getVariable("sliceserviceInstanceId"), allottedResourceId) + execution.setVariable("allottedResourceUri", allottedResourceUri) + String modelInvariantId = execution.getVariable("modelInvariantUuid") + String modelVersionId = execution.getVariable("modelUuid") + + org.onap.aai.domain.yang.AllottedResource resource = new org.onap.aai.domain.yang.AllottedResource() + resource.setId(allottedResourceId) + resource.setType("TsciNetwork") + resource.setAllottedResourceName("network_" + execution.getVariable("sliceServiceInstanceName")) + resource.setModelInvariantId(modelInvariantId) + resource.setModelVersionId(modelVersionId) + getAAIClient().create(allottedResourceUri, resource) + + String linkArrayStr = jsonUtil.getJsonValue(networkStr, "connectionLinks") + createLogicalLinksForAllocatedResource(execution, linkArrayStr, serviceInstanceId, allottedResourceId) + } + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage()) + } + } + + void createLogicalLinksForAllocatedResource(DelegateExecution execution, + String linkArrayStr, String serviceInstanceId, + String allottedResourceId) { + + try { + List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) + + for (String linkStr : linkStrList) { + String logicalLinkId = UUID.randomUUID().toString() + String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA") + String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB") + String modelInvariantId = execution.getVariable("modelInvariantUuid") + String modelVersionId = execution.getVariable("modelUuid") + + org.onap.aai.domain.yang.LogicalLink resource = new org.onap.aai.domain.yang.LogicalLink() + resource.setLinkId(logicalLinkId) + resource.setLinkName(epA) + resource.setLinkName2(epB) + resource.setModelInvariantId(modelInvariantId) + resource.setModelVersionId(modelVersionId) + + AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIObjectType.LOGICAL_LINK, logicalLinkId) + getAAIClient().create(logicalLinkUri, resource) + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, + "Exception in createLogicalLinksForAllocatedResource" + ex.getMessage()) + } + } + + + void preprocessSdncModifyTnNssiRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preprocessSdncModifyTnNssiRequest(' + + 'execution=' + execution.getId() + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceID") + + String sdncRequest = tnNssmfUtils.buildSDNCRequest(execution, serviceInstanceId, "modify") + + execution.setVariable("TNNSSMF_SDNCRequest", sdncRequest) + logger.debug("Outgoing SDNCRequest is: \n" + sdncRequest) + + } catch (Exception e) { + logger.debug("Exception Occured Processing preprocessSdncModifyTnNssiRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preprocessSdncModifyTnNssiRequest Process") + } + + + void validateSDNCResponse(DelegateExecution execution, String response, String method) { + tnNssmfUtils.validateSDNCResponse(execution, response, method) + } + + + void updateAAIOrchStatus(DelegateExecution execution) { + logger.debug("Start updateAAIOrchStatus") + String sliceServiceInstanceId = execution.getVariable("sliceServiceInstanceId") + String orchStatus = execution.getVariable("orchestrationStatus") + + try { + ServiceInstance si = new ServiceInstance() + si.setOrchestrationStatus(orchStatus) + AAIResourcesClient client = getAAIClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceServiceInstanceId) + client.update(uri, si) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Finish updateAAIOrchStatus") + } + + void prepareUpdateJobStatus(DelegateExecution execution, + String status, + String progress, + String statusDescription) { + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setServiceId(serviceId) + roStatus.setOperationId(jobId) + roStatus.setResourceTemplateUUID(nsiId) + roStatus.setOperType("Modify") + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + } + +} + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/PNFSoftwareUpgrade.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfSoftwareUpgrade.groovy index 8e7a4f727d..89902209a0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/PNFSoftwareUpgrade.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfSoftwareUpgrade.groovy @@ -31,8 +31,8 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder import org.onap.so.bpmn.core.WorkflowException import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.* -class PNFSoftwareUpgrade extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger(PNFSoftwareUpgrade.class) +class GenericPnfSoftwareUpgrade extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(GenericPnfSoftwareUpgrade.class) ExceptionUtil exceptionUtil = new ExceptionUtil() String prefix = "PnfSwUpgrade_" diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy new file mode 100644 index 0000000000..47489b7b84 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy @@ -0,0 +1,173 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # 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.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank + +class ModifySliceSubnet extends AbstractServiceTaskProcessor { + String Prefix="MSS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI Info + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Modify") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse) + sendWorkflowResponse(execution, 202, modifySyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy new file mode 100644 index 0000000000..5cdf540173 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy @@ -0,0 +1,141 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.scripts + +import groovy.json.JsonSlurper +import org.json.JSONObject +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.onap.so.bpmn.core.UrnPropertiesReader + +public class QueryJobStatus extends AbstractServiceTaskProcessor{ + private static final Logger logger = LoggerFactory.getLogger(QueryJobStatus.class) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + + try{ + String requestId = execution.getVariable("msoRequestId") + logger.debug("RequestId :" + requestId) + String responseId = execution.getVariable("responseId") + String jobId = execution.getVariable("jobId") + def jsonSlurper = new JsonSlurper() + + HashMap<String,?> esrInfo=jsonSlurper.parseText(execution.getVariable("esrInfo")) + logger.debug("esrInfo" + esrInfo.toString()) + + HashMap<String,?> serviceInfo=jsonSlurper.parseText(execution.getVariable("serviceInfo")) + logger.debug("serviceInfo" + serviceInfo.toString()) + + execution.setVariable("esrInfo", esrInfo) + execution.setVariable("serviceInfo", serviceInfo) + + String nssmfEndpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint",execution) + String endPoint = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId) + String url = nssmfEndpoint + endPoint + execution.setVariable("NSSMF_AdapterEndpoint", url) + + String payload = """ + { + "responseId": "${responseId}", + "esrInfo": ${execution.getVariable("esrInfo") as JSONObject}, + "serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject} + } + """ + + execution.setVariable("NSSMF_AdapterRequest", payload.replaceAll("\\s+", "")) + execution.setVariable("startTime", System.currentTimeMillis()) + logger.debug("Outgoing NSSMF_AdapterRequest: \n" + payload) + }catch(Exception e){ + String msg = "Exception in QueryJobStatus.preProcessRequest " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("exit preProcessRequest") + } + + public void checkJobStatus(DelegateExecution execution) { + logger.debug(" *** checkJobStatus *** ") + def NSSMF_ResponseCode = execution.getVariable("NSSMF_ResponseCode") as Integer + logger.debug("NSSMF_ResponseCode:" + NSSMF_ResponseCode) + def NSSMF_Response = execution.getVariable("NSSMF_Response") as String + def status = jsonUtil.getJsonValue(NSSMF_Response, "responseDescriptor.status") + logger.debug("NSSMF_Response" + NSSMF_Response) + + Long startTime = execution.getVariable("startTime") as Long + Long timeout = execution.getVariable("timeout") as Long + timeout = timeout == null ? 600000 : timeout * 60000 + + if(NSSMF_Response != null) { + if (status.equalsIgnoreCase("processing") && (System.currentTimeMillis() - startTime) > timeout) { + handleTimeOut(execution) + } + else if(status.equalsIgnoreCase("finished") || status.equalsIgnoreCase("failed")) { + execution.setVariable("JobStatusCompleted", "TRUE") + } else { + execution.setVariable("JobStatusCompleted", "FALSE") + } + } else { + Map<String, ?> responseDescriptorMap = new HashMap<>() + responseDescriptorMap.put("status","failed") + responseDescriptorMap.put("statusDescription","Exception while querying job status") + String responseDescriptor = """ + { + "responseDescriptor": "${responseDescriptorMap}", + } + """ + execution.setVariable("JobStatusCompleted", "TRUE") + execution.setVariable("NSSMF_Response",responseDescriptor.replaceAll("\\s+", "")) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") + } + logger.debug("exit checkJobStatus") + } + + private handleTimeOut(DelegateExecution execution) { + Map<String, ?> responseDescriptorMap = new HashMap<>() + responseDescriptorMap.put("status","failed") + responseDescriptorMap.put("statusDescription","timeout") + String responseDescriptor = """ + { + "responseDescriptor": "${responseDescriptorMap}", + } + """ + execution.setVariable("JobStatusCompleted", "TRUE") + execution.setVariable("NSSMF_Response",responseDescriptor.replaceAll("\\s+", "")) + } + + public void updateJobStatusDetails(DelegateExecution execution) + { + logger.debug("**updateJobStatusDetails**") + def NSSMF_Response = execution.getVariable("NSSMF_Response") as String + def responseDescriptor = jsonUtil.getJsonValue(NSSMF_Response, "responseDescriptor") + execution.setVariable("responseDescriptor",responseDescriptor) + logger.debug("**exit updateJobStatusDetails") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy new file mode 100644 index 0000000000..3367920064 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -0,0 +1,339 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import com.google.gson.JsonArray +import com.google.gson.JsonObject +import groovy.json.JsonSlurper +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.request.beans.ResourceOperationStatus +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.web.util.UriUtils + +import static org.apache.commons.lang3.StringUtils.isBlank + +class TnAllocateNssi extends AbstractServiceTaskProcessor { + String Prefix = "TNALLOC_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonSlurper jsonSlurper = new JsonSlurper() + ObjectMapper objectMapper = new ObjectMapper() + TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() + private static final Logger logger = LoggerFactory.getLogger(TnAllocateNssi.class) + + void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + execution.setVariable("prefix", Prefix) + String msg = "" + + try { + execution.setVariable("startTime", System.currentTimeMillis()) + + msg = tnNssmfUtils.getExecutionInputParams(execution) + logger.debug("Allocate TN NSSI input parameters: " + msg) + + tnNssmfUtils.setSdncCallbackUrl(execution, true) + logger.debug("SDNC Callback URL: " + execution.getVariable("sdncCallbackUrl")) + + String additionalPropJsonStr = execution.getVariable("sliceParams") + + String tnNssiId = execution.getVariable("serviceInstanceID") + if (isBlank(tnNssiId)) { + tnNssiId = UUID.randomUUID().toString() + } + + String operationId = UUID.randomUUID().toString() + execution.setVariable("operationId", operationId) + + logger.debug("Generate new TN NSSI ID:" + tnNssiId) + tnNssiId = UriUtils.encode(tnNssiId, "UTF-8") + execution.setVariable("sliceServiceInstanceId", tnNssiId) + + String sliceServiceInstanceName = execution.getVariable("servicename") + execution.setVariable("sliceServiceInstanceName", sliceServiceInstanceName) + + //additional properties + String sliceProfile = jsonUtil.getJsonValue(additionalPropJsonStr, "sliceProfile") + if (isBlank(sliceProfile)) { + msg = "Input sliceProfile is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("sliceProfile", sliceProfile) + } + + String transportSliceNetworks = jsonUtil.getJsonValue(additionalPropJsonStr, "transportSliceNetworks") + if (isBlank(transportSliceNetworks)) { + msg = "Input transportSliceNetworks is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("transportSliceNetworks", transportSliceNetworks) + } + logger.debug("transportSliceNetworks: " + transportSliceNetworks) + + String nsiInfoStr = jsonUtil.getJsonValue(additionalPropJsonStr, "nsiInfo") + if (isBlank(nsiInfoStr)) { + msg = "Input nsiInfo is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("nsiInfo", nsiInfoStr) + } + + //nsiId is passed in from caller bpmn + //String nsiIdStr = jsonUtil.getJsonValue(nsiInfo, "nsiId") + //execution.setVariable("nsiId", nsiIdStr) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Finish preProcessRequest") + } + + + void prepareDecomposeService(DelegateExecution execution) { + logger.debug("Start prepareDecomposeService") + String msg = "" + String modelUuid = execution.getVariable("modelUuid") + if (isBlank(modelUuid)) { + msg = "Input modelUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + if (isBlank(modelInvariantUuid)) { + msg = "Input modelInvariantUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("ssServiceModelInfo", serviceModelInfo) + + logger.debug("Finish prepareDecomposeService") + } + + void processDecomposition(DelegateExecution execution) { + logger.debug("Start processDecomposition") + + ServiceDecomposition tnNsstServiceDecomposition = execution.getVariable("tnNsstServiceDecomposition") + logger.debug("tnNsstServiceDecomposition : " + tnNsstServiceDecomposition.toString()) + //TN NSST decomposition + String tnModelVersion = tnNsstServiceDecomposition.getModelInfo().getModelVersion() + String tnModelName = tnNsstServiceDecomposition.getModelInfo().getModelName() + List<ServiceProxy> serviceProxyList = tnNsstServiceDecomposition.getServiceProxy() + List<String> nsstInfoList = new ArrayList<>() + for (ServiceProxy serviceProxy : serviceProxyList) { + String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid() + String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid() + String name = serviceProxy.getModelInfo().getModelName() + String nsstServiceModelInfo = """{ + "UUID":"${nsstModelUuid}", + "invariantUUID":"${nsstModelInvariantUuid}", + "name":"${name}" + }""" + nsstInfoList.add(nsstServiceModelInfo) + } + int currentIndex = 0 + int maxIndex = nsstInfoList.size() + if (maxIndex < 1) { + String msg = "Exception in TN NSST processDecomposition. There is no NSST associated with TN NSST " + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + execution.setVariable("tnNsstInfoList", nsstInfoList) + execution.setVariable("tnModelVersion", tnModelVersion) + execution.setVariable("tnModelName", tnModelName) + execution.setVariable("currentIndex", currentIndex) + execution.setVariable("maxIndex", maxIndex) + + logger.debug("End processDecomposition") + } + + void prepareOofSelection(DelegateExecution execution) { + logger.debug("Start prepareOofSelection") + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug("get NSSI option OOF Url: " + urlString) + //build oof request body + String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) + String modelUuid = execution.getVariable("modelUuid") + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelName = execution.getVariable("tnModelName") + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("nsstInfoList"), List.class) + JsonArray capabilitiesList = new JsonArray() + + execution.setVariable("nssiSelection_Url", "/api/oof/selection/nsi/v1") + execution.setVariable("nssiSelection_messageType", messageType) + execution.setVariable("nssiSelection_correlator", requestId) + execution.setVariable("nssiSelection_timeout", timeout) + String oofRequest = buildSelectTnNssiRequest(requestId, messageType, modelUuid, modelInvariantUuid, + modelName, profileInfo, nsstInfoList, capabilitiesList, false) + execution.setVariable("nssiSelection_oofRequest", oofRequest) + + logger.debug("Finish prepareOofSelection") + } + + String buildSelectTnNssiRequest(String requestId, String messageType, String UUID, String invariantUUID, + String name, Map<String, Object> profileInfo, + List<String> nsstInfoList, JsonArray capabilitiesList, Boolean preferReuse) { + + def transactionId = requestId + logger.debug("transactionId is: " + transactionId) + String correlator = requestId + String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator + ObjectMapper objectMapper = new ObjectMapper() + String profileJson = objectMapper.writeValueAsString(profileInfo) + String nsstInfoListString = objectMapper.writeValueAsString(nsstInfoList) + //Prepare requestInfo object + JsonObject requestInfo = new JsonObject() + requestInfo.addProperty("transactionId", transactionId) + requestInfo.addProperty("requestId", requestId) + requestInfo.addProperty("callbackUrl", callbackUrl) + requestInfo.addProperty("sourceId", "SO") + requestInfo.addProperty("timeout", 600) + requestInfo.addProperty("numSolutions", 1) + + //Prepare serviceInfo object + JsonObject ranNsstInfo = new JsonObject() + ranNsstInfo.addProperty("UUID", UUID) + ranNsstInfo.addProperty("invariantUUID", invariantUUID) + ranNsstInfo.addProperty("name", name) + + JsonObject json = new JsonObject() + json.add("requestInfo", requestInfo) + json.add("NSTInfo", ranNsstInfo) + json.addProperty("serviceProfile", profileJson) + json.addProperty("NSSTInfo", nsstInfoListString) + json.add("subnetCapabilities", capabilitiesList) + json.addProperty("preferReuse", preferReuse) + + return json.toString() + } + + void processOofSelection(DelegateExecution execution) { + logger.debug(Prefix + "processOofSelection method start") + String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse") + String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") + if (requestStatus.equals("completed")) { + List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions")) + boolean existingNSI = jsonUtil.getJsonValue(solution.get(0), "existingNSI") + if (existingNSI) { + def sharedNSISolution = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution") + execution.setVariable("sharedTnNssiSolution", sharedNSISolution) + logger.debug("sharedTnNssiSolution from OOF " + sharedNSISolution) + String tnServiceInstanceId = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution.NSIId") + execution.setVariable("tnServiceInstanceId", tnServiceInstanceId) + org.onap.so.bpmn.core.domain.ServiceInstance serviceInstance = new org.onap.so.bpmn.core.domain.ServiceInstance(); + serviceInstance.setInstanceId(tnServiceInstanceId); + ServiceDecomposition serviceDecomposition = execution.getVariable("tnNsstServiceDecomposition") + serviceDecomposition.setServiceInstance(serviceInstance); + execution.setVariable("tnNsstServiceDecomposition", serviceDecomposition) + execution.setVariable("isOofTnNssiSelected", true) + } else { + def sliceProfiles = jsonUtil.getJsonValue(solution.get(0), "newNSISolution.sliceProfiles") + execution.setVariable("tnConstituentSliceProfiles", sliceProfiles) + execution.setVariable("isOofTnNssiSelected", false) + logger.debug("tnConstituentSliceProfiles list from OOF " + sliceProfiles) + } + } else { + String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage") + logger.error("received failed status from oof " + statusMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a failed Async Response from OOF : " + statusMessage) + } + + logger.debug(Prefix + "processOofSelection method finished") + } + + void updateAAIOrchStatus(DelegateExecution execution) { + logger.debug("Start updateAAIOrchStatus") + String sliceServiceInstanceId = execution.getVariable("sliceServiceInstanceId") + String orchStatus = execution.getVariable("orchestrationStatus") + + try { + ServiceInstance si = new ServiceInstance() + si.setOrchestrationStatus(orchStatus) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceServiceInstanceId) + client.update(uri, si) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Finish updateAAIOrchStatus") + } + + + void prepareUpdateJobStatus(DelegateExecution execution, + String status, + String progress, + String statusDescription) { + String serviceId = execution.getVariable("sliceServiceInstanceId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + + ResourceOperationStatus roStatus = new ResourceOperationStatus() + roStatus.setServiceId(serviceId) + roStatus.setOperationId(jobId) + roStatus.setResourceTemplateUUID(nsiId) + roStatus.setOperType("Allocate") + roStatus.setProgress(progress) + roStatus.setStatus(status) + roStatus.setStatusDescription(statusDescription) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + } + +} + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy new file mode 100644 index 0000000000..a1b883c34e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -0,0 +1,244 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + + +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import static org.apache.commons.lang3.StringUtils.isBlank + +class TnNssmfUtils { + private static final Logger logger = LoggerFactory.getLogger(TnNssmfUtils.class); + + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + MsoUtils msoUtils = new MsoUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + TnNssmfUtils() { + } + + + void setSdncCallbackUrl(DelegateExecution execution, boolean exceptionOnErr) { + setSdncCallbackUrl(execution, "sdncCallbackUrl", exceptionOnErr) + } + + void setSdncCallbackUrl(DelegateExecution execution, String variableName, boolean exceptionOnErr) { + String sdncCallbackUrl = UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback', execution) + + if (isBlank(sdncCallbackUrl) && exceptionOnErr) { + String msg = "mso.workflow.sdncadapter.callback is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable(variableName, sdncCallbackUrl) + } + } + + String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action) { + + String uuid = execution.getVariable('testReqId') // for junits + if (uuid == null) { + uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() + } + + def callbackURL = execution.getVariable("sdncCallbackUrl") + def requestId = execution.getVariable("msoRequestId") + def serviceId = execution.getVariable("sliceServiceInstanceId") + def vnfType = execution.getVariable("serviceType") + def vnfName = execution.getVariable("sliceServiceInstanceName") + def tenantId = execution.getVariable("sliceServiceInstanceId") + def source = execution.getVariable("sliceServiceInstanceId") + def vnfId = execution.getVariable("sliceServiceInstanceId") + def cloudSiteId = execution.getVariable("sliceServiceInstanceId") + def serviceModelInfo = execution.getVariable("serviceModelInfo") + def vnfModelInfo = execution.getVariable("serviceModelInfo") + def globalSubscriberId = execution.getVariable("globalSubscriberId") + + String vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>""" + String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo) + String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo) + + String sdncVNFParamsXml = "" + + if (execution.getVariable("vnfParamsExistFlag") == true) { + sdncVNFParamsXml = buildSDNCParamsXml(execution) + } else { + sdncVNFParamsXml = "" + } + + String sdncRequest = + """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> + <request-action>AllocateTnNssi</request-action> + <source>${MsoUtils.xmlEscape(source)}</source> + <notification-url/> + <order-number/> + <order-version/> + </request-information> + <service-information> + <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> + <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type> + ${serviceEcompModelInformation} + <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id> + <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id> + </service-information> + <vnf-information> + <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> + <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> + ${vnfEcompModelInformation} + </vnf-information> + <vnf-request-input> + ${vnfNameString} + <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant> + <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region> + ${sdncVNFParamsXml} + </vnf-request-input> + </sdncadapterworkflow:SDNCRequestData> + </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" + + logger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + String buildSDNCParamsXml(DelegateExecution execution) { + String params = "" + StringBuilder sb = new StringBuilder() + Map<String, String> paramsMap = execution.getVariable("TNNSSMF_vnfParamsMap") + + for (Map.Entry<String, String> entry : paramsMap.entrySet()) { + String paramsXml + String key = entry.getKey(); + String value = entry.getValue() + paramsXml = """<${key}>$value</$key>""" + params = sb.append(paramsXml) + } + return params + } + + void validateSDNCResponse(DelegateExecution execution, String response, String method) { + validateSDNCResponse(execution, response, method, true) + } + + void validateSDNCResponse(DelegateExecution execution, String response, String method, boolean exceptionOnErr) { + logger.debug("STARTED ValidateSDNCResponse Process") + + String msg + + String prefix = execution.setVariable("prefix") + if (isBlank(prefix)) { + if (exceptionOnErr) { + msg = "validateSDNCResponse: prefix is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + return + } + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + logger.debug("workflowException: " + workflowException) + + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + String sdncResponse = response + if (execution.getVariable(prefix + 'sdncResponseSuccess') == true) { + logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + RollbackData rollbackData = execution.getVariable("rollbackData") + + if (method.equals("allocate")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestAllocate", "true") + } else if (method.equals("deallocate")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestDeallocate", "true") + } else if (method.equals("activate")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestActivate", "true") + } else if (method.equals("deactivate")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestDeactivate", "true") + } else if (method.equals("modify")) { + rollbackData.put("VNFMODULE", "rollbackSDNCRequestModify", "true") + } + execution.setVariable("rollbackData", rollbackData) + } else { + if (exceptionOnErr) { + msg = "validateSDNCResponse: bad Response from SDNC Adapter for " + method + " SDNC Call." + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } + + logger.debug("COMPLETED ValidateSDNCResponse Process") + } + + String getExecutionInputParams(DelegateExecution execution) { + String res = "msoRequestId=" + execution.getVariable("msoRequestId") + + ", modelInvariantUuid=" + execution.getVariable("modelInvariantUuid") + + ", modelUuid=" + execution.getVariable("modelUuid") + + ", serviceInstanceID=" + execution.getVariable("serviceInstanceID") + + ", operationType=" + execution.getVariable("operationType") + + ", globalSubscriberId=" + execution.getVariable("globalSubscriberId") + + ", dummyServiceId=" + execution.getVariable("dummyServiceId") + + ", nsiId=" + execution.getVariable("nsiId") + + ", networkType=" + execution.getVariable("networkType") + + ", subscriptionServiceType=" + execution.getVariable("subscriptionServiceType") + + ", jobId=" + execution.getVariable("jobId") + + ", sliceParams=" + execution.getVariable("sliceParams") + + ", servicename=" + execution.getVariable("servicename") + + return res + } + + String getFirstSnssaiFromSliceProfile(String sliceProfileStr) { + String snssaiListStr = jsonUtil.getJsonValue(sliceProfileStr, "snssaiList") + String snssai = jsonUtil.StringArrayToList(snssaiListStr).get(0) + + return snssai + } + + String getFirstPlmnIdFromSliceProfile(String sliceProfileStr) { + String plmnListStr = jsonUtil.getJsonValue(sliceProfileStr, "plmnIdList") + String res = jsonUtil.StringArrayToList(plmnListStr).get(0) + + return res + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy new file mode 100644 index 0000000000..adb83e7714 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy @@ -0,0 +1,68 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor + +class ActivateSliceSubnetTest { + @Before + void init() throws IOException { + super.init("ActivateSliceSubnet") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + when(mockExecution.getVariable("requestAction")).thenReturn("activateInstance") + ActivateSliceSubnet sliceSubnet = new ActivateSliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("54321") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + ActivateSliceSubnet sliceSubnet = new ActivateSliceSubnet() + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + ActivateSliceSubnet sliceSubnet = new ActivateSliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy new file mode 100644 index 0000000000..a9b4e095e7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy @@ -0,0 +1,135 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # 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.scripts + +import static org.junit.Assert.* +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + + +class AllocateSliceSubnetTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("AllocateSliceSubnet") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("12345") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "name": "eMBB-001", + "modelInvariantUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX", + "modelUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX-UUID", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "networkType": "an/cn/tn", + "additionalProperties": { + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + "perfReqEmbbList ": [ + { + "activityFactor": 50 + } + ] + }, + "maxNumberofUEs": 200, + "coverageAreaTAList": [ + "1", + "2", + "3", + "4" + ], + "latency": 2, + "resourceSharingLevel": "non-shared" + }, + "endPoints": [ + { + "nodeId": "", + "additionalInfo": { + "xxx": "xxx" + } + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + AllocateSliceSubnet sliceSubnet = new AllocateSliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + + when(mockExecution.getVariable("dummyServiceId")).thenReturn("12345") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + + AllocateSliceSubnet sliceSubnet = new AllocateSliceSubnet() + + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + AllocateSliceSubnet sliceSubnet = new AllocateSliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy new file mode 100644 index 0000000000..a254a90576 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy @@ -0,0 +1,72 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor + +class DeAllocateSliceSubnetTest { + + @Before + void init() throws IOException { + super.init("DeAllocateSliceSubnet") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "snssaiList": [ + "001-100001" + ], + "scriptName": "AN1", + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + DeAllocateSliceSubnet sliceSubnet = new DeAllocateSliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("54321") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + DeAllocateSliceSubnet sliceSubnet = new DeAllocateSliceSubnet() + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + DeAllocateSliceSubnet sliceSubnet = new DeAllocateSliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy new file mode 100644 index 0000000000..a39ca04d71 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy @@ -0,0 +1,631 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * 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.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.slf4j.Logger +import org.mockito.Mockito +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory + +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import static org.mockito.ArgumentMatchers.eq + +import javax.ws.rs.NotFoundException + +class DoActivateCoreNSSITest extends MsoGroovyTest { + + DoActivateCoreNSSI doActivate = new DoActivateCoreNSSI() + @Before + void init() throws IOException { + super.init("DoActivateCoreNSSI") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + + setUpMockdataFromCommonActivateSliceSubnet() + doActivate.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("oStatus"), captor.capture()) + def statusValue = captor.getValue() + assertEquals("deactivated", statusValue) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("sNssai"), captor.capture()) + def sNssai = captor.getValue() + assertEquals("01-5B179BD4", sNssai) + + Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testGetNetworkInstanceWithSPInstanceAssociatedWithNssiId(){ + + setUpMockdataFromCommonActivateSliceSubnet() + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + DoActivateCoreNSSI obj = spy(DoActivateCoreNSSI.class) + when(obj.getAAIClient()).thenReturn(client) + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + when(client.exists(resourceUri1)).thenReturn(true) + AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn()) + when(client.get(resourceUri1, NotFoundException.class)).thenReturn(wrapper1) + + //networkServiceInstanceId + when(mockExecution.getVariable("networkServiceInstanceId")).thenReturn("206535e7-77c9-4036-9387-3f1cf57b4379") + + AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "206535e7-77c9-4036-9387-3f1cf57b4379") + when(client.exists(resourceUri2)).thenReturn(true) + AAIResultWrapper wrapper2 = new AAIResultWrapper(mockQueryNS()) + when(client.get(resourceUri2, NotFoundException.class)).thenReturn(wrapper2) + + //Check Vnf + when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "eeb66c6f-36bd-47ad-8294-48f46b1aa912") + when(client.exists(resourceUri3)).thenReturn(true) + AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf()) + when(client.get(resourceUri3, NotFoundException.class)).thenReturn(wrapper3) + + + //Allotted Resources-1 + //when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "0d3d3cce-46a8-486d-816a-954e71697c4e") + when(client.exists(resourceUri4)).thenReturn(true) + AAIResultWrapper wrapper4 = new AAIResultWrapper(mockServiceProfile1()) + when(client.get(resourceUri4, NotFoundException.class)).thenReturn(wrapper4) + + //Allotted Resources-2 + //when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "1c7046f2-a5a3-4d7f-9da8-388ee641a795") + when(client.exists(resourceUri5)).thenReturn(true) + AAIResultWrapper wrapper5 = new AAIResultWrapper(mockServiceProfile2()) + when(client.get(resourceUri5, NotFoundException.class)).thenReturn(wrapper5) + + obj.getNetworkInstanceWithSPInstanceAssociatedWithNssiId(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceId"), captor.capture()) + assertEquals("206535e7-77c9-4036-9387-3f1cf57b4379", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceName"), captor.capture()) + assertEquals("nsi_DemoEmbb", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelInvariantUuid"), captor.capture()) + assertEquals("848c5656-5594-4d41-84bb-7afc7c64765c", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("owningEntityId"), captor.capture()) + assertEquals("OE-generic", captor.getValue()) + + //VnfId + Mockito.verify(mockExecution, times(1)).setVariable(eq("vnfId"), captor.capture()) + assertEquals("eeb66c6f-36bd-47ad-8294-48f46b1aa912", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("snssaiAndOrchStatusList"), captor.capture()) + List<Map<String, Object>> snssaiList = new ArrayList<>() + Map<String, Object> snssaiMap = new LinkedHashMap<>() + snssaiMap.put("snssai", "01-5C83F071") + snssaiMap.put("status", "activated") + snssaiList.add(snssaiMap) + Map<String, Object> snssaiMap1 = new LinkedHashMap<>() + snssaiMap1.put("snssai", "01-5B179BD4") + snssaiMap1.put("status", "activated") + snssaiList.add(snssaiMap1) + assertEquals(snssaiList, captor.getValue()) + + //Verify Project + Mockito.verify(mockExecution, times(1)).setVariable(eq("projectName"), captor.capture()) + assertEquals("Project-generic", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("tenantId"), captor.capture()) + assertEquals("3d5819f1542e4ef9a4ccb0bcb278ca10", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("cloudOwner"), captor.capture()) + assertEquals("k8scloudowner", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lcpCloudRegionId"), captor.capture()) + assertEquals("k8sregion", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("platformName"), captor.capture()) + assertEquals("test", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lineOfBusinessName"), captor.capture()) + assertEquals("LOB-Demonstration", captor.getValue()) + + } + + @Test + void testPrepareVnfInstanceParamsJson() { + List<Map<String, Object>> snssaiList = new ArrayList<>() + Map<String, Object> snssaiMap = new LinkedHashMap<>() + snssaiMap.put("snssai", "01-5C83F071") + snssaiMap.put("status", "activated") + snssaiList.add(snssaiMap) + Map<String, Object> snssaiMap1 = new LinkedHashMap<>() + snssaiMap1.put("snssai", "01-5B179BD4") + snssaiMap1.put("status", "activated") + snssaiList.add(snssaiMap1) + + when(mockExecution.getVariable("snssaiAndOrchStatusList")).thenReturn(snssaiList) + + String returnedJsonAsString= doActivate.prepareVnfInstanceParamsJson(mockExecution) + + String expectedJsonAsString = """{supportedNssai={"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}}""" + assertEquals(expectedJsonAsString, returnedJsonAsString) + } + + + String mockQueryNS() { + return """ + { + "service-instance-id": "206535e7-77c9-4036-9387-3f1cf57b4379", + "service-instance-name": "nsi_DemoEmbb", + "environment-context": "General_Revenue-Bearing", + "workload-context": "Production", + "model-invariant-id": "848c5656-5594-4d41-84bb-7afc7c64765c", + "model-version-id": "2de92587-3395-44e8-bb2c-b9529747e580", + "resource-version": "1599228110527", + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/206535e7-77c9-4036-9387-3f1cf57b4379/service-data/service-topology/", + "orchestration-status": "Assigned", + "relationship-list": { + "relationship": [{ + "related-to": "owning-entity", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/business/owning-entities/owning-entity/OE-generic", + "relationship-data": [{ + "relationship-key": "owning-entity.owning-entity-id", + "relationship-value": "OE-generic" + }] + }, { + "related-to": "generic-vnf", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/network/generic-vnfs/generic-vnf/eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "relationship-data": [{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "eeb66c6f-36bd-47ad-8294-48f46b1aa912" + }], + "related-to-property": [{ + "property-key": "generic-vnf.vnf-name", + "property-value": "vfwuctest 0" + }] + }, { + "related-to": "project", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/projects/project/Project-generic", + "relationship-data": [{ + "relationship-key": "project.project-name", + "relationship-value": "Project-generic" + }] + }] + } +} + """ + } + + String mockQueryVnf() { + + return """ + { + "vnf-id": "eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "vnf-name": "vfwuctest 0", + "vnf-type": "vfwuctest/null", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "ConfigAssigned", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1599228155361", + "model-invariant-id": "1086e068-c932-4b61-ae3b-2d2eb0cbe3ec", + "model-version-id": "7fbb28cf-7dfc-447a-892c-4a3130b371d2", + "model-customization-id": "471b3188-e8f2-470b-9f4d-89e74d45445f", + "relationship-list": { + "relationship": [{ + "related-to": "tenant", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion/tenants/tenant/3d5819f1542e4ef9a4ccb0bcb278ca10", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }, { + "relationship-key": "tenant.tenant-id", + "relationship-value": "3d5819f1542e4ef9a4ccb0bcb278ca10" + }], + "related-to-property": [{ + "property-key": "tenant.tenant-name", + "property-value": "onap-tm5g-dev" + }] + }, { + "related-to": "cloud-region", + "relationship-label": "org.onap.relationships.inventory.LocatedIn", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }], + "related-to-property": [{ + "property-key": "cloud-region.owner-defined-type", + "property-value": "OwnerType" + }] + }, { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vfw-k8s/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "Demonstration" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vfw-k8s" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "vfw-0201" + }] + }, { + "related-to": "platform", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/platforms/platform/test", + "relationship-data": [{ + "relationship-key": "platform.platform-name", + "relationship-value": "test" + }] + }, { + "related-to": "line-of-business", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/lines-of-business/line-of-business/LOB-Demonstration", + "relationship-data": [{ + "relationship-key": "line-of-business.line-of-business-name", + "relationship-value": "LOB-Demonstration" + }] + }] + } +} + """ + } + + String mockServiceProfile1() { + return """ + { + "service-instance-id": "0d3d3cce-46a8-486d-816a-954e71697c4e", + "service-instance-name": "DemoEmbb2", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5C83F071", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d11e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0292", + "service-instance-location-id": "39-00", + "resource-version": "1593511782269", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "31a83df8-5bd0-4df7-a50f-7900476b81a2", + "latency": 3, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 2000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5C83F071", + "resource-version": "1593525640617" + }] + } +} + + """ + } + + String mockServiceProfile2() { + return """ + { + "service-instance-id": "1c7046f2-a5a3-4d7f-9da8-388ee641a795", + "service-instance-name": "DemoEmbb", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5B179BD4", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d12e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0282", + "service-instance-location-id": "39-00", + "resource-version": "1593511782169", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "b86df550-9d70-452b-a5a9-eb8823417255", + "latency": 6, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 1000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5B179BD4", + "resource-version": "1593511356725" + }] + } +} + """ + } + + String mockQuerySliceServiceReturn(){ + String expect = + """{ + "service-instance-id": "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX", + "service-instance-name": "nssi_DemoEmbb", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "da575e8e-0863-4172-88b3-b3a9ead67895", + "model-version-id": "e398c92f-27da-44b9-a717-1dbfc1bdd82e", + "service-instance-location-id": "39-00", + "resource-version": "1593525640482", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }, + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0d3d3cce-46a8-486d-816a-954e71697c4e/allotted-resources/allotted-resource/d63c241a-4c0b-4294-b4c3-5a57421a1769", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "0d3d3cce-46a8-486d-816a-954e71697c4e" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "d63c241a-4c0b-4294-b4c3-5a57421a1769" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb_shared" + }] + }, { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/1c7046f2-a5a3-4d7f-9da8-388ee641a795/allotted-resources/allotted-resource/362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "1c7046f2-a5a3-4d7f-9da8-388ee641a795" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "362e46c2-cd84-45e4-a6c1-77f4ef88328d" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb" + }] + } + ] + } +} + """ + return expect + } + + void setUpMockdataFromCommonActivateSliceSubnet() { + + String bpmnRequest = """ + { + "serviceInstanceID": "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "snssaiList": [ + "01-5B179BD4" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098" + } + } + """ + + String sliceParams ="""{ + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "snssaiList": [ + "01-5B179BD4" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098" + }""" + + when(mockExecution.getVariable("msoRequestId")).thenReturn("5ad89cf9-0569-4a93-4509-d8324321e2be") + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + when(mockExecution.getVariable("nsiId")).thenReturn("NSI-M-001-HDBNJ-NSMF-01-A-ZX") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + when(mockExecution.getVariable("operationType")).thenReturn("deactivateInstance") + when(mockExecution.getVariable("jobId")).thenReturn("5ad89cf9-0569-4a93-9999-d8324321e2be") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(bpmnRequest) + when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams) + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssiTest.groovy new file mode 100644 index 0000000000..93557a48cf --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssiTest.groovy @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.* + +class DoActivateTnNssiTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DoActivateTnNssiTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("f85cbcc0-ad74-45d7-a5a1-17c8744fdb71") + when(mockExecution.getVariable("modelUuid")).thenReturn("36a3a8ea-49a6-4ac8-b06c-89a54544b9b6") + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("eb0863e9-a69b-4b17-8a56-f05ad110bef7") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("operationType")).thenReturn("opTypeTest") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("servicename")).thenReturn("5G-test") + when(mockExecution.getVariable("networkType")).thenReturn("5G-network") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G-service") + when(mockExecution.getVariable("nsiId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("jobId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("operationType")).thenReturn("activateInstance") + when(mockExecution.getVariable("sliceParams")).thenReturn(mockSliceParams()) + + DoActivateTnNssi obj = new DoActivateTnNssi() + obj.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sliceServiceInstanceId"), captor.capture()) + String sliceServiceInstanceId = captor.getValue() + assertNotNull(sliceServiceInstanceId) + } + + @Test + void testPreprocessSdncRequest() { + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("sliceServiceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("sliceServiceInstanceName")).thenReturn("5G-service") + when(mockExecution.getVariable("actionType")).thenReturn("activate") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("f85cbcc0-ad74-45d7-a5a1-17c8744fdb71") + when(mockExecution.getVariable("modelUuid")).thenReturn("36a3a8ea-49a6-4ac8-b06c-89a54544b9b6") + when(mockExecution.getVariable("sliceParams")).thenReturn(mockSliceParams()) + when(mockExecution.getVariable("serviceModelInfo")).thenReturn(mockServiceModelInfo()) +// JsonUtils jsonUtil = new JsonUtils() +// String sliceProfile = jsonUtil.getJsonValue(mockSliceParams(), "sliceProfile") +// when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile) + + DoActivateTnNssi obj = spy(DoActivateTnNssi.class) + + obj.preprocessSdncActOrDeactTnNssiRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("TNNSSMF_SDNCRequest"), captor.capture()) + String request = captor.getValue() + assertNotNull(request) + } + + + private String mockSliceParams() { + String expect = """{ + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + }, + "coverageAreaTAList": [ + ], + "latency": 2, + "maxBandwidth": 100, + "resourceSharingLevel": "non-shared" + }, + "transportSliceNetworks": [ + { + "connectionLinks": [ + { + "transportEndpointA": "tranportEp_ID_XXX", + "transportEndpointB": "tranportEp_ID_YYY" + }, + { + "transportEndpointA": "tranportEp_ID_AAA", + "transportEndpointB": "tranportEp_ID_BBB" + } + ] + }, + { + "connectionLinks": [ + { + "transportEndpointA": "tranportEp_ID_CCC", + "transportEndpointB": "tranportEp_ID_DDD" + }, + { + "transportEndpointA": "tranportEp_ID_EEE", + "transportEndpointB": "tranportEp_ID_FFF" + } + ] + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + }""" + return expect.replaceAll("\\\\s+", "") + } + + private String mockSliceProfile() { + String expect = """{ + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + }, + "coverageAreaTAList": [ + ], + "latency": 2, + "maxBandwidth": 100, + "resourceSharingLevel": "non-shared" + }""" + return expect.replaceAll("\\\\s+", "") + } + + private String mockServiceModelInfo() { + String expect = """{ + "modelInvariantUuid":"f85cbcc0-ad74-45d7-a5a1-17c8744fdb71", + "modelUuid":"36a3a8ea-49a6-4ac8-b06c-89a54544b9b6", + "modelVersion":"" + }""" + return expect.replaceAll("\\\\s+", "") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy new file mode 100644 index 0000000000..dc7a429c2c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * 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.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.mockito.Mockito.when +import static org.mockito.Mockito.times +import static org.mockito.ArgumentMatchers.eq + +class DoAllocateCoreNSSITest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("DoAllocateCoreNSSI") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + + String sliceParams="""{ + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + "perfReqEmbbList ": [{ + "activityFactor": 50 + }] + }, + "maxNumberofUEs": 200, + "coverageAreaTAList": [ + "1", + "2", + "3", + "4" + ], + "latency": 2, + "resourceSharingLevel": "non-shared" + }, + "endPoints": [{ + "nodeId": "", + "additionalInfo": { + "xxx": "xxx" + } + }, + { + "nodeId": "", + "additionalInfo": { + "xxx": "xxx" + } + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" +}""" + String expected = """{"plmnIdList":["460-00","460-01"],"sliceProfileId":"ab9af40f13f721b5f13539d87484098","maxNumberofUEs":200,"latency":2,"snssaiList":["001-100001"],"perfReq":{"perfReqEmbbList ":[{"activityFactor":50}]},"coverageAreaTAList":["1","2","3","4"],"resourceSharingLevel":"non-shared"}""" + when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams) + DoAllocateCoreNSSI allocateNssi = new DoAllocateCoreNSSI() + allocateNssi.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sliceProfile"), captor.capture()) + def sliceProfile = captor.getValue() + assertEquals(expected, sliceProfile) + Mockito.verify(mockExecution, times(3)).setVariable(captor.capture() as String, captor.capture()) + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy new file mode 100644 index 0000000000..1eddf66b86 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy @@ -0,0 +1,118 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * 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.scripts + +import static org.junit.Assert.* + +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import com.fasterxml.jackson.databind.ObjectMapper + +import static org.mockito.Mockito.when +import static org.mockito.Mockito.times +import static org.mockito.Mockito.eq + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("DoAllocateCoreNonSharedSlice") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + + String networkServiceModelInfo=""" { + "modelName" : "5GC-eMBB Service Proxy", + "modelUuid" : "b666119e-4400-47c6-a0c1-bbe050a33b47", + "modelInvariantUuid" : "a26327e1-4a9b-4883-b7a5-5f37dcb7405a", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "cbc12c2a-67e6-4336-9236-eaf51eacdc75", + "modelInstanceName" : "5gcembb_proxy 0" + }""" + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("123456") + when(mockExecution.getVariable("networkServiceModelInfo")).thenReturn(networkServiceModelInfo) + + DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice() + allocateNssi.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelUuid"), captor.capture()) + captor.getValue() + assertEquals("b666119e-4400-47c6-a0c1-bbe050a33b47", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceName"), captor.capture()) + assertEquals("5GC-eMBB", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("orchestrationStatus"), captor.capture()) + assertEquals("created", captor.getValue()) + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture() as String, captor.capture()) + } + + @Test + void testPrepareServiceOrderRequest() { + + String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }" + when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile) + when(mockExecution.getVariable("serviceType")).thenReturn("5g") + when(mockExecution.getVariable("networkServiceName")).thenReturn("5g_embb") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("networkServiceModelUuid")).thenReturn("12345") + + DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice() + allocateNssi.prepareServiceOrderRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("serviceOrderRequest"), captor.capture()) + String value = captor.getValue() + assertNotNull(value) + } + + @Test + void testRetrieveServiceCharacteristicsAsKeyValue() { + + String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }" + Map<String, Object> ServiceCharacteristicValue = new LinkedHashMap<>() + Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>() + ServiceCharacteristicValueObject.put("serviceCharacteristicValue","001-100001") + ServiceCharacteristicValue.put("name", "snssai") + ServiceCharacteristicValue.put("value", ServiceCharacteristicValueObject) + + List expectedList= new ArrayList() + expectedList.add(ServiceCharacteristicValue) + + ObjectMapper objectMapper = new ObjectMapper() + Map<String, Object> serviceCharacteristic = objectMapper.readValue(sliceProfile, Map.class); + + DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice() + List characteristicList=allocateNssi.retrieveServiceCharacteristicsAsKeyValue(serviceCharacteristic) + + assertEquals(expectedList, characteristicList) + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy new file mode 100644 index 0000000000..e5799eca66 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy @@ -0,0 +1,646 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Tech Mahindra + * ================================================================================ + * 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.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.mockito.Mockito +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory + +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import static org.mockito.ArgumentMatchers.eq + +import javax.ws.rs.NotFoundException + +class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { + + DoAllocateCoreSharedSlice allocate = new DoAllocateCoreSharedSlice() + + @Before + void init() throws IOException { + super.init("DoAllocateCoreSharedSlice") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + + String solutions = """ [ + { + "invariantUUID": "y7685f64-5717-4562-b3fc-2c963f66afa6", + "UUID": "8u785f64-5717-4562-b3fc-2c963f66afa6", + "NSSIName": "embb-core-ser", + "NSSIId": "f4485f64-5717-4562-b3fc-2c963f66afa6", + "matchLevel": { + "blob":"content" + } + } + ]""" + String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }" + + setUpBaseMockData() + + when(mockExecution.getVariable("solutions")).thenReturn(solutions) + when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile) + + allocate.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("nssiId"), captor.capture()) + def nssiId = captor.getValue() + assertEquals("f4485f64-5717-4562-b3fc-2c963f66afa6", nssiId) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("sNssai"), captor.capture()) + def sNssai = captor.getValue() + assertEquals("001-100001", sNssai) + + Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + public void tesPrepareSOMacroRequestPayload() { + + String json ="{ \"serviceResources\" : {\r\n\t\"modelInfo\" : {\r\n\t\t\"modelName\" : \"MSOTADevInfra_vSAMP10a_Service\",\r\n\t\t\"modelUuid\" : \"5df8b6de-2083-11e7-93ae-92361f002671\",\r\n\t\t\"modelInvariantUuid\" : \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\t\t\"modelVersion\" : \"1.0\"\r\n\t},\r\n\t\"serviceType\" : \"PortMirroring\",\r\n\t\"serviceRole\" : \"InfraRole\",\r\n\t\"environmentContext\" : \"Luna\",\r\n\t\"workloadContext\" : \"Oxygen\",\r\n\t\"serviceVnfs\": [\r\n\t\r\n\t\t{ \"modelInfo\" : {\r\n\t\t\t\"modelName\" : \"vSAMP10a\",\r\n\t\t\t\"modelUuid\" : \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\t\t\t\"modelInvariantUuid\" : \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\"modelCustomizationUuid\" : \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\t\t\t\"modelInstanceName\" : \"vSAMP10a 1\"\r\n\t\t\t},\r\n\t\t\"toscaNodeType\" : \"VF\",\r\n\t\t\"nfFunction\" \t: null,\r\n\t\t\"nfType\" \t\t: null,\r\n\t\t\"nfRole\" \t\t: null,\r\n\t\t\"nfNamingCode\" \t: null,\r\n\t\t\"multiStageDesign\"\t\t: null,\r\n\t\t\t\"vfModules\": [\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"NetworkFqdnTest4\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"025606c1-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba01a\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2.0\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba01a\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"label\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"NetworkFqdnTest3\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02560575-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"label\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"NetworkFqdnTest5\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"025607e4-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d14cba01a\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d14cba01a\"\r\n\t\t\t\t\t},\t\t\"isBase\" : false,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"label\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10aDEV::PCM::module-2\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"7774b4e4-7d37-11e7-bb31-be2e44b06b34\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"93e9c1d2-7d37-11e7-bb31-be2e44b06b34\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"6728bee8-7d3a-11e7-bb31-be2e44b06b34\"\r\n\t\t\t\t\t},\t\t\"isBase\" : false,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"PCM\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10aDEV::PCM::module-1\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n\t\t\t\t\t},\t\t\"isBase\" : false,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"PCM\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10aDEV::base::module-0\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"base\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10a::base::module-0\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02560de2-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : null,\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"MIGRATED_36e76920-ef30-4793-9979-cbd7d4b2bfc4\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"base\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"base::module-0\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02561381-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : null,\r\n\t\t\t\t\t\t\"modelVersion\" : \"1\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"MIGRATED_51baae4c-b7c7-4f57-b77e-6e01acca89e5\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"module-0\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10a::PCM::module-1\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02560f1b-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : null,\r\n\t\t\t\t\t\t\"modelVersion\" : \"1\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"MIGRATED_e9be2ed7-45b6-479c-b06e-9093899f8ce8\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"PCM\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t}\r\n\t\t\t]\r\n\t\t}\r\n\t],\r\n\t\"serviceNetworks\": [],\r\n\t\"serviceAllottedResources\": [\r\n\t\t{\r\n\t\t\t\"modelInfo\" : {\r\n\t\t\t\t\"modelName\" : \"Tunnel_Xconn\",\r\n\t\t\t\t\"modelUuid\" : \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\t\t\t\t\"modelInvariantUuid\" : \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\"modelCustomizationUuid\" : \"5b9bee43-f537-4fb3-9e8b-4de9f714d28a\",\r\n\t\t\t\t\"modelInstanceName\" : \"Pri_Tunnel_Xconn 9\"\r\n\t\t\t},\r\n\t\t\t\"toscaNodeType\" : null,\r\n\t\t\t\"allottedResourceType\" : null,\r\n\t\t\t\"allottedResourceRole\" : null,\r\n\t\t\t\"providingServiceModelInvariantUuid\" : null,\r\n\t\t\t\"nfFunction\" : null,\r\n\t\t\t\"nfType\" : null,\r\n\t\t\t\"nfRole\" : null,\r\n\t\t\t\"nfNamingCode\" : null\r\n\t\t}\r\n\t],\r\n\t\"serviceConfigs\": [\r\n\t\t{\r\n\t\t\t\"modelInfo\" : {\r\n\t\t\t\t\"modelName\" : \"Mulder\",\r\n\t\t\t\t\"modelUuid\" : \"025606c1-4fff-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInvariantUuid\" : \"025606c1-4eee-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\"modelCustomizationUuid\" : \"025606c1-4ddd-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInstanceName\" : \"X_FILES_001\"\r\n\t\t\t},\r\n\t\t\t\"toscaNodeType\" : \"Scully\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"modelInfo\" : {\r\n\t\t\t\t\"modelName\" : \"Krychuk\",\r\n\t\t\t\t\"modelUuid\" : \"025606c1-5fff-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInvariantUuid\" : \"025606c1-5eee-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\"modelCustomizationUuid\" : \"025606c1-5ddd-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInstanceName\" : \"X_FILES_002\"\r\n\t\t\t},\r\n\t\t\t\"toscaNodeType\" : \"Skinner\"\r\n\t\t}\r\n\t]\r\n\t}}\r\n\r\n" + String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }" + String vnfs="[{\"toscaNodeType\":\"VF\",\"vfModules\":[{\"initialCount\":0,\"vfModuleLabel\":\"label\",\"modelInfo\":{\"modelInvariantUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba01a\",\"modelName\":\"NetworkFqdnTest4\",\"modelVersion\":\"2.0\",\"modelCustomizationUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba01a\",\"modelUuid\":\"025606c1-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":true,\"isBase\":true},{\"initialCount\":0,\"vfModuleLabel\":\"label\",\"modelInfo\":{\"modelInvariantUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\",\"modelName\":\"NetworkFqdnTest3\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\",\"modelUuid\":\"02560575-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":false,\"isBase\":true},{\"initialCount\":0,\"vfModuleLabel\":\"label\",\"modelInfo\":{\"modelInvariantUuid\":\"06bd0a18-65c0-4418-83c7-5b0d14cba01a\",\"modelName\":\"NetworkFqdnTest5\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":\"06bd0a18-65c0-4418-83c7-5b0d14cba01a\",\"modelUuid\":\"025607e4-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":false,\"isBase\":false},{\"initialCount\":0,\"vfModuleLabel\":\"PCM\",\"modelInfo\":{\"modelInvariantUuid\":\"93e9c1d2-7d37-11e7-bb31-be2e44b06b34\",\"modelName\":\"vSAMP10aDEV::PCM::module-2\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"6728bee8-7d3a-11e7-bb31-be2e44b06b34\",\"modelUuid\":\"7774b4e4-7d37-11e7-bb31-be2e44b06b34\"},\"hasVolumeGroup\":true,\"isBase\":false},{\"initialCount\":0,\"vfModuleLabel\":\"PCM\",\"modelInfo\":{\"modelInvariantUuid\":\"64efd51a-2544-11e7-93ae-92361f002671\",\"modelName\":\"vSAMP10aDEV::PCM::module-1\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"b4ea86b4-253f-11e7-93ae-92361f002671\",\"modelUuid\":\"066de97e-253e-11e7-93ae-92361f002671\"},\"hasVolumeGroup\":true,\"isBase\":false},{\"initialCount\":1,\"vfModuleLabel\":\"base\",\"modelInfo\":{\"modelInvariantUuid\":\"78ca26d0-246d-11e7-93ae-92361f002671\",\"modelName\":\"vSAMP10aDEV::base::module-0\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"cb82ffd8-252a-11e7-93ae-92361f002671\",\"modelUuid\":\"20c4431c-246d-11e7-93ae-92361f002671\"},\"hasVolumeGroup\":true,\"isBase\":true},{\"initialCount\":1,\"vfModuleLabel\":\"base\",\"modelInfo\":{\"modelInvariantUuid\":null,\"modelName\":\"vSAMP10a::base::module-0\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"MIGRATED_36e76920-ef30-4793-9979-cbd7d4b2bfc4\",\"modelUuid\":\"02560de2-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":true,\"isBase\":true},{\"initialCount\":1,\"vfModuleLabel\":\"module-0\",\"modelInfo\":{\"modelInvariantUuid\":null,\"modelName\":\"base::module-0\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"MIGRATED_51baae4c-b7c7-4f57-b77e-6e01acca89e5\",\"modelUuid\":\"02561381-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":false,\"isBase\":true},{\"initialCount\":1,\"vfModuleLabel\":\"PCM\",\"modelInfo\":{\"modelInvariantUuid\":null,\"modelName\":\"vSAMP10a::PCM::module-1\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"MIGRATED_e9be2ed7-45b6-479c-b06e-9093899f8ce8\",\"modelUuid\":\"02560f1b-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":true,\"isBase\":true}],\"modelInfo\":{\"modelInvariantUuid\":\"2fff5b20-214b-11e7-93ae-92361f002671\",\"modelName\":\"vSAMP10a\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002671\",\"modelInstanceName\":\"vSAMP10a 1\",\"modelUuid\":\"ff2ae348-214a-11e7-93ae-92361f002671\"},\"nfRole\":null,\"nfType\":null,\"multiStageDesign\":null,\"nfFunction\":null,\"nfNamingCode\":null}]\r\n" + String service = "{\r\n \"modelName\" : \"eMBB-NSST\",\r\n \"modelUuid\" : \"ecfa2329-8765-4665-84e0-a32a2ac2be90\",\r\n \"modelInvariantUuid\" : \"2eeeb5ff-4655-47d8-8aa3-044682246b60\",\r\n \"modelVersion\" : \"1.0\"\r\n }" + + when(mockExecution.getVariable("serviceVnfs")).thenReturn(vnfs) + + when(mockExecution.getVariable("serviceType")).thenReturn("5g") + when(mockExecution.getVariable("vnfs")).thenReturn(vnfs) + when(mockExecution.getVariable("serviceModelInfo")).thenReturn(service) + when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile) + allocate.prepareSOMacroRequestPayload(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("requestPayload"), captor.capture()) + assertNotNull(captor.getValue()) + } + + @Test + void testPrepareVnfInstanceParamsJson() { + List<Map<String, Object>> snssaiList = new ArrayList<>() + Map<String, Object> snssaiMap = new LinkedHashMap<>() + snssaiMap.put("snssai", "01-5C83F071") + snssaiMap.put("status", "activated") + snssaiList.add(snssaiMap) + Map<String, Object> snssaiMap1 = new LinkedHashMap<>() + snssaiMap1.put("snssai", "01-5B179BD4") + snssaiMap1.put("status", "activated") + snssaiList.add(snssaiMap1) + + when(mockExecution.getVariable("snssaiAndOrchStatusList")).thenReturn(snssaiList) + + String returnedJsonAsString= allocate.prepareVnfInstanceParamsJson(mockExecution) + String expectedJsonAsString = """{supportedNssai={"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}}""" + assertEquals(expectedJsonAsString, returnedJsonAsString) + } + + @Test + void testGetNetworkInstanceWithSPInstanceAssociatedWithNssiId(){ + + setUpBaseMockData() + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + DoAllocateCoreSharedSlice obj = spy(DoAllocateCoreSharedSlice.class) + when(obj.getAAIClient()).thenReturn(client) + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + when(client.exists(resourceUri1)).thenReturn(true) + AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn()) + when(client.get(resourceUri1, NotFoundException.class)).thenReturn(wrapper1) + + //networkServiceInstanceId + when(mockExecution.getVariable("networkServiceInstanceId")).thenReturn("206535e7-77c9-4036-9387-3f1cf57b4379") + + AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "206535e7-77c9-4036-9387-3f1cf57b4379") + when(client.exists(resourceUri2)).thenReturn(true) + AAIResultWrapper wrapper2 = new AAIResultWrapper(mockQueryNS()) + when(client.get(resourceUri2, NotFoundException.class)).thenReturn(wrapper2) + + //Check Vnf + when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "eeb66c6f-36bd-47ad-8294-48f46b1aa912") + when(client.exists(resourceUri3)).thenReturn(true) + AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf()) + when(client.get(resourceUri3, NotFoundException.class)).thenReturn(wrapper3) + + + //Allotted Resources-1 + AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "0d3d3cce-46a8-486d-816a-954e71697c4e") + when(client.exists(resourceUri4)).thenReturn(true) + AAIResultWrapper wrapper4 = new AAIResultWrapper(mockServiceProfile1()) + when(client.get(resourceUri4, NotFoundException.class)).thenReturn(wrapper4) + + //Allotted Resources-2 + AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "1c7046f2-a5a3-4d7f-9da8-388ee641a795") + when(client.exists(resourceUri5)).thenReturn(true) + AAIResultWrapper wrapper5 = new AAIResultWrapper(mockServiceProfile2()) + when(client.get(resourceUri5, NotFoundException.class)).thenReturn(wrapper5) + + obj.getNetworkInstanceAssociatedWithNssiId(mockExecution) + + //networkServiceInstanceId + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceId"), captor.capture()) + assertEquals("206535e7-77c9-4036-9387-3f1cf57b4379", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceName"), captor.capture()) + assertEquals("nsi_DemoEmbb", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelInvariantUuid"), captor.capture()) + assertEquals("848c5656-5594-4d41-84bb-7afc7c64765c", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("owningEntityId"), captor.capture()) + assertEquals("OE-generic", captor.getValue()) + + //assertEquals("206535e7-77c9-4036-9387-3f1cf57b4379", captor.getValue()) + + //VnfId + Mockito.verify(mockExecution, times(1)).setVariable(eq("vnfId"), captor.capture()) + assertEquals("eeb66c6f-36bd-47ad-8294-48f46b1aa912", captor.getValue()) + + // + Mockito.verify(mockExecution, times(1)).setVariable(eq("snssaiAndOrchStatusList"), captor.capture()) + List<Map<String, Object>> snssaiList = new ArrayList<>() + Map<String, Object> snssaiMap = new LinkedHashMap<>() + snssaiMap.put("snssai", "01-5C83F071") + snssaiMap.put("orchestrationStatus", "activated") + snssaiList.add(snssaiMap) + Map<String, Object> snssaiMap1 = new LinkedHashMap<>() + snssaiMap1.put("snssai", "01-5B179BD4") + snssaiMap1.put("orchestrationStatus", "activated") + snssaiList.add(snssaiMap1) + assertEquals(snssaiList, captor.getValue()) + + //Verify Project + Mockito.verify(mockExecution, times(1)).setVariable(eq("projectName"), captor.capture()) + assertEquals("Project-generic", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("tenantId"), captor.capture()) + assertEquals("3d5819f1542e4ef9a4ccb0bcb278ca10", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("cloudOwner"), captor.capture()) + assertEquals("k8scloudowner", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lcpCloudRegionId"), captor.capture()) + assertEquals("k8sregion", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("platformName"), captor.capture()) + assertEquals("test", captor.getValue()) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("lineOfBusinessName"), captor.capture()) + assertEquals("LOB-Demonstration", captor.getValue()) + + } + + void setUpBaseMockData() { + + String sliceParams ="""{ + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "snssaiList": [ + "01-5B179BD4" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098" + }""" + + when(mockExecution.getVariable("msoRequestId")).thenReturn("5ad89cf9-0569-4a93-4509-d8324321e2be") + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + when(mockExecution.getVariable("nsiId")).thenReturn("NSI-M-001-HDBNJ-NSMF-01-A-ZX") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + when(mockExecution.getVariable("operationType")).thenReturn("deactivateInstance") + when(mockExecution.getVariable("jobId")).thenReturn("5ad89cf9-0569-4a93-9999-d8324321e2be") + when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams) + } + + String mockQueryNS() { + return """ + { + "service-instance-id": "206535e7-77c9-4036-9387-3f1cf57b4379", + "service-instance-name": "nsi_DemoEmbb", + "environment-context": "General_Revenue-Bearing", + "workload-context": "Production", + "model-invariant-id": "848c5656-5594-4d41-84bb-7afc7c64765c", + "model-version-id": "2de92587-3395-44e8-bb2c-b9529747e580", + "resource-version": "1599228110527", + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/206535e7-77c9-4036-9387-3f1cf57b4379/service-data/service-topology/", + "orchestration-status": "Assigned", + "relationship-list": { + "relationship": [{ + "related-to": "owning-entity", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/business/owning-entities/owning-entity/OE-generic", + "relationship-data": [{ + "relationship-key": "owning-entity.owning-entity-id", + "relationship-value": "OE-generic" + }] + }, { + "related-to": "generic-vnf", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/network/generic-vnfs/generic-vnf/eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "relationship-data": [{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "eeb66c6f-36bd-47ad-8294-48f46b1aa912" + }], + "related-to-property": [{ + "property-key": "generic-vnf.vnf-name", + "property-value": "vfwuctest 0" + }] + }, { + "related-to": "project", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/projects/project/Project-generic", + "relationship-data": [{ + "relationship-key": "project.project-name", + "relationship-value": "Project-generic" + }] + }] + } +} + """ + } + + String mockQueryVnf() { + + return """ + { + "vnf-id": "eeb66c6f-36bd-47ad-8294-48f46b1aa912", + "vnf-name": "vfwuctest 0", + "vnf-type": "vfwuctest/null", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "ConfigAssigned", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1599228155361", + "model-invariant-id": "1086e068-c932-4b61-ae3b-2d2eb0cbe3ec", + "model-version-id": "7fbb28cf-7dfc-447a-892c-4a3130b371d2", + "model-customization-id": "471b3188-e8f2-470b-9f4d-89e74d45445f", + "relationship-list": { + "relationship": [{ + "related-to": "tenant", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion/tenants/tenant/3d5819f1542e4ef9a4ccb0bcb278ca10", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }, { + "relationship-key": "tenant.tenant-id", + "relationship-value": "3d5819f1542e4ef9a4ccb0bcb278ca10" + }], + "related-to-property": [{ + "property-key": "tenant.tenant-name", + "property-value": "onap-tm5g-dev" + }] + }, { + "related-to": "cloud-region", + "relationship-label": "org.onap.relationships.inventory.LocatedIn", + "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "k8scloudowner" + }, { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "k8sregion" + }], + "related-to-property": [{ + "property-key": "cloud-region.owner-defined-type", + "property-value": "OwnerType" + }] + }, { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vfw-k8s/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "Demonstration" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vfw-k8s" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "vfw-0201" + }] + }, { + "related-to": "platform", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/platforms/platform/test", + "relationship-data": [{ + "relationship-key": "platform.platform-name", + "relationship-value": "test" + }] + }, { + "related-to": "line-of-business", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/lines-of-business/line-of-business/LOB-Demonstration", + "relationship-data": [{ + "relationship-key": "line-of-business.line-of-business-name", + "relationship-value": "LOB-Demonstration" + }] + }] + } +} + """ + } + + String mockQuerySliceServiceReturn(){ + String expect = + """{ + "service-instance-id": "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX", + "service-instance-name": "nssi_DemoEmbb", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "da575e8e-0863-4172-88b3-b3a9ead67895", + "model-version-id": "e398c92f-27da-44b9-a717-1dbfc1bdd82e", + "service-instance-location-id": "39-00", + "resource-version": "1593525640482", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }, + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0d3d3cce-46a8-486d-816a-954e71697c4e/allotted-resources/allotted-resource/d63c241a-4c0b-4294-b4c3-5a57421a1769", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "0d3d3cce-46a8-486d-816a-954e71697c4e" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "d63c241a-4c0b-4294-b4c3-5a57421a1769" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb_shared" + }] + }, { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/1c7046f2-a5a3-4d7f-9da8-388ee641a795/allotted-resources/allotted-resource/362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "1c7046f2-a5a3-4d7f-9da8-388ee641a795" + }, { + "relationship-key": "allotted-resource.id", + "relationship-value": "362e46c2-cd84-45e4-a6c1-77f4ef88328d" + }], + "related-to-property": [{ + "property-key": "allotted-resource.description" + }, { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_DemoEmbb" + }] + } + ] + } +} + """ + return expect + } + + String mockServiceProfile1() { + return """{ + "service-instance-id": "0d3d3cce-46a8-486d-816a-954e71697c4e", + "service-instance-name": "DemoEmbb2", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5C83F071", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d11e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0292", + "service-instance-location-id": "39-00", + "resource-version": "1593511782269", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "31a83df8-5bd0-4df7-a50f-7900476b81a2", + "latency": 3, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 2000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5C83F071", + "resource-version": "1593525640617" + }] + } +}""" + } + + String mockServiceProfile2() { + return """{ + "service-instance-id": "1c7046f2-a5a3-4d7f-9da8-388ee641a795", + "service-instance-name": "DemoEmbb", + "service-role": "e2esliceprofile-service", + "environment-context": "01-5B179BD4", + "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d12e", + "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0282", + "service-instance-location-id": "39-00", + "resource-version": "1593511782169", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "DemoEmbb" + }] + }] + }, + "allotted-resources": { + "allotted-resource": [{ + "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d", + "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc", + "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461", + "resource-version": "1593511173712", + "type": "Allotted Resource", + "allotted-resource-name": "Allotted_DemoEmbb", + "relationship-list": { + "relationship": [{ + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c", + "relationship-data": [{ + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_DemoEmbb" + }] + }] + } + }] + }, + "slice-profiles": { + "slice-profile": [{ + "profile-id": "b86df550-9d70-452b-a5a9-eb8823417255", + "latency": 6, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 500, + "exp-data-rate-DL": 1000, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01-5B179BD4", + "resource-version": "1593511356725" + }] + } +}""" + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy new file mode 100644 index 0000000000..33110b6e5b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy @@ -0,0 +1,167 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.* + +class DoAllocateTnNssiTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DoAllocateTnNssiTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("f85cbcc0-ad74-45d7-a5a1-17c8744fdb71") + when(mockExecution.getVariable("modelUuid")).thenReturn("36a3a8ea-49a6-4ac8-b06c-89a54544b9b6") + //when(mockExecution.getVariable("serviceInstanceID")).thenReturn("eb0863e9-a69b-4b17-8a56-f05ad110bef7") + //when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("operationType")).thenReturn("opTypeTest") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("servicename")).thenReturn("5G-test") + when(mockExecution.getVariable("networkType")).thenReturn("5G-network") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G-service") + when(mockExecution.getVariable("nsiId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("jobId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("sliceParams")).thenReturn(mockSliceParams()) + + TnAllocateNssi obj = new TnAllocateNssi() + obj.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sliceServiceInstanceId"), captor.capture()) + String sliceServiceInstanceId = captor.getValue() + assertNotNull(sliceServiceInstanceId) + } + + @Test + void testCreateServiceInstance() { + when(mockExecution.getVariable("sliceServiceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("sliceServiceInstanceName")).thenReturn("5G-service") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("f85cbcc0-ad74-45d7-a5a1-17c8744fdb71") + when(mockExecution.getVariable("modelUuid")).thenReturn("36a3a8ea-49a6-4ac8-b06c-89a54544b9b6") + when(mockExecution.getVariable("sliceProfile")).thenReturn(mockSliceProfile()) + +// JsonUtils jsonUtil = new JsonUtils() +// String sliceProfile = jsonUtil.getJsonValue(mockSliceParams(), "sliceProfile") +// when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile) + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoCreateTnNssiInstance obj = spy(DoCreateTnNssiInstance.class) + when(obj.getAAIClient()).thenReturn(client) + + obj.createServiceInstance(mockExecution) + } + + + private String mockSliceParams() { + String expect = """{ + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + }, + "coverageAreaTAList": [ + ], + "latency": 2, + "maxBandwidth": 100, + "resourceSharingLevel": "non-shared" + }, + "transportSliceNetworks": [ + { + "connectionLinks": [ + { + "transportEndpointA": "tranportEp_ID_XXX", + "transportEndpointB": "tranportEp_ID_YYY" + }, + { + "transportEndpointA": "tranportEp_ID_AAA", + "transportEndpointB": "tranportEp_ID_BBB" + } + ] + }, + { + "connectionLinks": [ + { + "transportEndpointA": "tranportEp_ID_CCC", + "transportEndpointB": "tranportEp_ID_DDD" + }, + { + "transportEndpointA": "tranportEp_ID_EEE", + "transportEndpointB": "tranportEp_ID_FFF" + } + ] + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + }""" + return expect.replaceAll("\\\\s+", "") + } + + private String mockSliceProfile() { + String expect = """{ + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + }, + "coverageAreaTAList": [ + ], + "latency": 2, + "maxBandwidth": 100, + "resourceSharingLevel": "non-shared" + }""" + return expect.replaceAll("\\\\s+", "") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy new file mode 100644 index 0000000000..eac79a9473 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.* + +class DoDeallocateTnNssiTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DeallocateTnNssiTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("f85cbcc0-ad74-45d7-a5a1-17c8744fdb71") + when(mockExecution.getVariable("modelUuid")).thenReturn("36a3a8ea-49a6-4ac8-b06c-89a54544b9b6") + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("eb0863e9-a69b-4b17-8a56-f05ad110bef7") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("operationType")).thenReturn("opTypeTest") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("servicename")).thenReturn("5G-test") + when(mockExecution.getVariable("networkType")).thenReturn("5G-network") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G-service") + when(mockExecution.getVariable("nsiId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("jobId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("sliceParams")).thenReturn(""" + { + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + }, + "coverageAreaTAList": [ + ], + "latency": 2, + "maxBandwidth": 100, + "resourceSharingLevel": "non-shared" + }, + "transportSliceNetworks": [ + { + "connectionLinks": [ + { + "transportEndpointA": "tranportEp_ID_XXX", + "transportEndpointB": "tranportEp_ID_YYY" + }, + { + "transportEndpointA": "tranportEp_ID_AAA", + "transportEndpointB": "tranportEp_ID_BBB" + } + ] + }, + { + "connectionLinks": [ + { + "transportEndpointA": "tranportEp_ID_CCC", + "transportEndpointB": "tranportEp_ID_DDD" + }, + { + "transportEndpointA": "tranportEp_ID_EEE", + "transportEndpointB": "tranportEp_ID_FFF" + } + ] + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + }""".replaceAll("\\\\s+", "")) + + DoDeallocateTnNssi runScript = new DoDeallocateTnNssi() + runScript.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sliceServiceInstanceId"), captor.capture()) + String sliceServiceInstanceId = captor.getValue() + assertNotNull(sliceServiceInstanceId) + } + + @Test + void testDeleteServiceInstance() { + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoDeallocateTnNssi obj = spy(DoDeallocateTnNssi.class) + when(obj.getAAIClient()).thenReturn(client) + doNothing().when(client).delete(serviceInstanceUri) + + obj.deleteServiceInstance(mockExecution) + Mockito.verify(client, times(1)).delete(serviceInstanceUri) + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssiTest.groovy new file mode 100644 index 0000000000..bbbec3bb46 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssiTest.groovy @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.* + +class DoModifyTnNssiTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DoModifyTnNssiTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("f85cbcc0-ad74-45d7-a5a1-17c8744fdb71") + when(mockExecution.getVariable("modelUuid")).thenReturn("36a3a8ea-49a6-4ac8-b06c-89a54544b9b6") + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("eb0863e9-a69b-4b17-8a56-f05ad110bef7") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("operationType")).thenReturn("opTypeTest") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("servicename")).thenReturn("5G-test") + when(mockExecution.getVariable("networkType")).thenReturn("5G-network") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G-service") + when(mockExecution.getVariable("nsiId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("jobId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("operationType")).thenReturn("activateInstance") + when(mockExecution.getVariable("sliceParams")).thenReturn(mockSliceParams()) + + DoModifyTnNssi obj = new DoModifyTnNssi() + obj.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sliceServiceInstanceId"), captor.capture()) + String sliceServiceInstanceId = captor.getValue() + assertNotNull(sliceServiceInstanceId) + } + + @Test + void testUpdateServiceInstance() { + when(mockExecution.getVariable("sliceServiceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("sliceServiceInstanceName")).thenReturn("5G-service") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + when(mockExecution.getVariable("sliceProfileId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2b1") + when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("f85cbcc0-ad74-45d7-a5a1-17c8744fdb71") + when(mockExecution.getVariable("modelUuid")).thenReturn("36a3a8ea-49a6-4ac8-b06c-89a54544b9b6") + when(mockExecution.getVariable("sliceProfile")).thenReturn(mockSliceProfile()) + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoModifyTnNssi obj = spy(DoModifyTnNssi.class) + when(obj.getAAIClient()).thenReturn(client) + + obj.updateServiceInstance(mockExecution) + } + + + private String mockSliceParams() { + String expect = """{ + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + }, + "coverageAreaTAList": [ + ], + "latency": 2, + "maxBandwidth": 100, + "resourceSharingLevel": "non-shared" + }, + "transportSliceNetworks": [ + { + "connectionLinks": [ + { + "transportEndpointA": "tranportEp_ID_XXX", + "transportEndpointB": "tranportEp_ID_YYY" + }, + { + "transportEndpointA": "tranportEp_ID_AAA", + "transportEndpointB": "tranportEp_ID_BBB" + } + ] + }, + { + "connectionLinks": [ + { + "transportEndpointA": "tranportEp_ID_CCC", + "transportEndpointB": "tranportEp_ID_DDD" + }, + { + "transportEndpointA": "tranportEp_ID_EEE", + "transportEndpointB": "tranportEp_ID_FFF" + } + ] + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + }""" + return expect.replaceAll("\\\\s+", "") + } + + private String mockSliceProfile() { + String expect = """{ + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + }, + "coverageAreaTAList": [ + ], + "latency": 2, + "maxBandwidth": 100, + "resourceSharingLevel": "non-shared" + }""" + return expect.replaceAll("\\\\s+", "") + } + + private String mockServiceModelInfo() { + String expect = """{ + "modelInvariantUuid":"f85cbcc0-ad74-45d7-a5a1-17c8744fdb71", + "modelUuid":"36a3a8ea-49a6-4ac8-b06c-89a54544b9b6", + "modelVersion":"" + }""" + return expect.replaceAll("\\\\s+", "") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy new file mode 100644 index 0000000000..b7515a487c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy @@ -0,0 +1,72 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor + +class ModifySliceSubnetTest { + @Before + void init() throws IOException { + super.init("ModifySliceSubnet") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + ModifySliceSubnet sliceSubnet = new ModifySliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("54321") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + ModifySliceSubnet sliceSubnet = new ModifySliceSubnet() + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + ModifySliceSubnet sliceSubnet = new ModifySliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + + @Test + public void test() { + fail("Not yet implemented") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSliceSubnet.bpmn new file mode 100644 index 0000000000..a2b7f4f67a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSliceSubnet.bpmn @@ -0,0 +1,224 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_04ua9m1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="ActivateSliceSubnet" name="ActivateSliceSubnet" isExecutable="true"> + <bpmn:startEvent id="Event_1h6wq31" name="Start"> + <bpmn:outgoing>Flow_1rnck9o</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0r1fyr9" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1rnck9o</bpmn:incoming> + <bpmn:outgoing>Flow_1ruhu5s</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ActivateSliceSubnet() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_19eqlu7" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1da78f4</bpmn:incoming> + <bpmn:outgoing>Flow_17ebcpc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ActivateSliceSubnet() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_150n9jp" name="Whether Network type"> + <bpmn:incoming>Flow_17ebcpc</bpmn:incoming> + <bpmn:outgoing>Flow_1t9x0sg</bpmn:outgoing> + <bpmn:outgoing>Flow_1q1kc3c</bpmn:outgoing> + <bpmn:outgoing>Flow_0ptiwv3</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_07betxq"> + <bpmn:incoming>Flow_0krl0oq</bpmn:incoming> + <bpmn:incoming>Flow_0wwue07</bpmn:incoming> + <bpmn:incoming>Flow_115ylm7</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_1jbt8op" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0wjhvtf</bpmn:incoming> + <bpmn:outgoing>Flow_1da78f4</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1rnck9o" sourceRef="Event_1h6wq31" targetRef="Activity_0r1fyr9" /> + <bpmn:sequenceFlow id="Flow_1da78f4" sourceRef="Activity_1jbt8op" targetRef="Activity_19eqlu7" /> + <bpmn:sequenceFlow id="Flow_17ebcpc" sourceRef="Activity_19eqlu7" targetRef="Gateway_150n9jp" /> + <bpmn:sequenceFlow id="Flow_1t9x0sg" name="Is CN ?" sourceRef="Gateway_150n9jp" targetRef="CallDoActivateCoreNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "CN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1q1kc3c" name="Is TN ?" sourceRef="Gateway_150n9jp" targetRef="CallDoActivateTransportNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:callActivity id="CallDoActivateAccessNSSI" name="Call ANActivateNSSI" calledElement="DoActivateAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="operationType" target="operationType" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0ptiwv3</bpmn:incoming> + <bpmn:outgoing>Flow_0krl0oq</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0ptiwv3" name="Is AN ?" sourceRef="Gateway_150n9jp" targetRef="CallDoActivateAccessNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0krl0oq" sourceRef="CallDoActivateAccessNSSI" targetRef="Event_07betxq" /> + <bpmn:callActivity id="CallDoActivateCoreNSSI" name="Call CNActivateNSSI" calledElement="DoActivateCoreNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="operationType" target="operationType" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1t9x0sg</bpmn:incoming> + <bpmn:outgoing>Flow_0wwue07</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0wwue07" sourceRef="CallDoActivateCoreNSSI" targetRef="Event_07betxq" /> + <bpmn:callActivity id="CallDoActivateTransportNSSI" name="Call TNActivateNSSI" calledElement="DoActivateTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="operationType" target="operationType" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1q1kc3c</bpmn:incoming> + <bpmn:outgoing>Flow_115ylm7</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_115ylm7" sourceRef="CallDoActivateTransportNSSI" targetRef="Event_07betxq" /> + <bpmn:scriptTask id="Activity_13km4np" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1ruhu5s</bpmn:incoming> + <bpmn:outgoing>Flow_0wjhvtf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ActivateSliceSubnet() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1ruhu5s" sourceRef="Activity_0r1fyr9" targetRef="Activity_13km4np" /> + <bpmn:sequenceFlow id="Flow_0wjhvtf" sourceRef="Activity_13km4np" targetRef="Activity_1jbt8op" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateSliceSubnet"> + <bpmndi:BPMNEdge id="Flow_115ylm7_di" bpmnElement="Flow_115ylm7"> + <di:waypoint x="1050" y="360" /> + <di:waypoint x="1140" y="360" /> + <di:waypoint x="1140" y="258" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0wwue07_di" bpmnElement="Flow_0wwue07"> + <di:waypoint x="1050" y="240" /> + <di:waypoint x="1122" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0krl0oq_di" bpmnElement="Flow_0krl0oq"> + <di:waypoint x="1050" y="120" /> + <di:waypoint x="1140" y="120" /> + <di:waypoint x="1140" y="222" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ptiwv3_di" bpmnElement="Flow_0ptiwv3"> + <di:waypoint x="860" y="215" /> + <di:waypoint x="860" y="120" /> + <di:waypoint x="950" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="881" y="166" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1q1kc3c_di" bpmnElement="Flow_1q1kc3c"> + <di:waypoint x="860" y="265" /> + <di:waypoint x="860" y="360" /> + <di:waypoint x="950" y="360" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="882" y="333" width="36" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1t9x0sg_di" bpmnElement="Flow_1t9x0sg"> + <di:waypoint x="885" y="240" /> + <di:waypoint x="950" y="240" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="894" y="222" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_17ebcpc_di" bpmnElement="Flow_17ebcpc"> + <di:waypoint x="770" y="240" /> + <di:waypoint x="835" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1da78f4_di" bpmnElement="Flow_1da78f4"> + <di:waypoint x="620" y="240" /> + <di:waypoint x="670" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ruhu5s_di" bpmnElement="Flow_1ruhu5s"> + <di:waypoint x="330" y="240" /> + <di:waypoint x="390" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1rnck9o_di" bpmnElement="Flow_1rnck9o"> + <di:waypoint x="188" y="240" /> + <di:waypoint x="230" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0wjhvtf_di" bpmnElement="Flow_0wjhvtf"> + <di:waypoint x="490" y="240" /> + <di:waypoint x="520" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Activity_19eqlu7_di" bpmnElement="Activity_19eqlu7"> + <dc:Bounds x="670" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_150n9jp_di" bpmnElement="Gateway_150n9jp" isMarkerVisible="true"> + <dc:Bounds x="835" y="215" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="817" y="258" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_07betxq_di" bpmnElement="Event_07betxq"> + <dc:Bounds x="1122" y="222" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1jbt8op_di" bpmnElement="Activity_1jbt8op"> + <dc:Bounds x="520" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0663qmy_di" bpmnElement="CallDoActivateAccessNSSI"> + <dc:Bounds x="950" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0k9faej_di" bpmnElement="CallDoActivateCoreNSSI"> + <dc:Bounds x="950" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0rmx5qf_di" bpmnElement="CallDoActivateTransportNSSI"> + <dc:Bounds x="950" y="320" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1h6wq31_di" bpmnElement="Event_1h6wq31"> + <dc:Bounds x="152" y="222" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="265" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0r1fyr9_di" bpmnElement="Activity_0r1fyr9"> + <dc:Bounds x="230" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_13km4np_di" bpmnElement="Activity_13km4np"> + <dc:Bounds x="390" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn new file mode 100644 index 0000000000..450faaebca --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn @@ -0,0 +1,219 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_04bdlh3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="AllocateSliceSubnet" name="AllocateSliceSubnet" isExecutable="true"> + <bpmn:startEvent id="Event_16inlk9" name="Start"> + <bpmn:outgoing>Flow_0cmaj9d</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_1hyt0pb" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0cmaj9d</bpmn:incoming> + <bpmn:outgoing>Flow_0ou7wr9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new AllocateSliceSubnet() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1usi32q" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ayd6dj</bpmn:incoming> + <bpmn:outgoing>Flow_0m5n6md</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new AllocateSliceSubnet() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_15a04ct" name="Whether Network type"> + <bpmn:incoming>Flow_0m5n6md</bpmn:incoming> + <bpmn:outgoing>Flow_1fij4ds</bpmn:outgoing> + <bpmn:outgoing>Flow_0g7721r</bpmn:outgoing> + <bpmn:outgoing>Flow_1kk0exp</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_18u424w"> + <bpmn:incoming>Flow_09b50tn</bpmn:incoming> + <bpmn:incoming>Flow_189zwjw</bpmn:incoming> + <bpmn:incoming>Flow_1coedjo</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_0qlstj2" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_18cgkru</bpmn:incoming> + <bpmn:outgoing>Flow_0ayd6dj</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0cmaj9d" sourceRef="Event_16inlk9" targetRef="Activity_1hyt0pb" /> + <bpmn:sequenceFlow id="Flow_0ayd6dj" sourceRef="Activity_0qlstj2" targetRef="Activity_1usi32q" /> + <bpmn:sequenceFlow id="Flow_0m5n6md" sourceRef="Activity_1usi32q" targetRef="Gateway_15a04ct" /> + <bpmn:sequenceFlow id="Flow_1fij4ds" name="Is CN ?" sourceRef="Gateway_15a04ct" targetRef="CallDoAllocateCoreNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "CN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0g7721r" name="Is TN ?" sourceRef="Gateway_15a04ct" targetRef="CallDoAllocateTransportNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1kk0exp" name="Is AN ?" sourceRef="Gateway_15a04ct" targetRef="CallDoAllocateAccessNSSI"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_09b50tn" sourceRef="CallDoAllocateAccessNSSI" targetRef="Event_18u424w" /> + <bpmn:callActivity id="CallDoAllocateAccessNSSI" name="Call ANAllocateNSSI" calledElement="DoAllocateAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="dummyServiceId" target="dummyServiceId" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1kk0exp</bpmn:incoming> + <bpmn:outgoing>Flow_09b50tn</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_1ydx2rx" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ou7wr9</bpmn:incoming> + <bpmn:outgoing>Flow_18cgkru</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new AllocateSliceSubnet() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0ou7wr9" sourceRef="Activity_1hyt0pb" targetRef="Activity_1ydx2rx" /> + <bpmn:sequenceFlow id="Flow_18cgkru" sourceRef="Activity_1ydx2rx" targetRef="Activity_0qlstj2" /> + <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0g7721r</bpmn:incoming> + <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_189zwjw" sourceRef="CallDoAllocateTransportNSSI" targetRef="Event_18u424w" /> + <bpmn:callActivity id="CallDoAllocateCoreNSSI" name="Call CNAllocateNSSI" calledElement="DoAllocateCoreNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="dummyServiceId" target="dummyServiceId" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1fij4ds</bpmn:incoming> + <bpmn:outgoing>Flow_1coedjo</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1coedjo" sourceRef="CallDoAllocateCoreNSSI" targetRef="Event_18u424w" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AllocateSliceSubnet"> + <bpmndi:BPMNEdge id="Flow_1coedjo_di" bpmnElement="Flow_1coedjo"> + <di:waypoint x="1080" y="190" /> + <di:waypoint x="1152" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_189zwjw_di" bpmnElement="Flow_189zwjw"> + <di:waypoint x="1080" y="300" /> + <di:waypoint x="1170" y="300" /> + <di:waypoint x="1170" y="208" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_18cgkru_di" bpmnElement="Flow_18cgkru"> + <di:waypoint x="480" y="190" /> + <di:waypoint x="550" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ou7wr9_di" bpmnElement="Flow_0ou7wr9"> + <di:waypoint x="320" y="190" /> + <di:waypoint x="380" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_09b50tn_di" bpmnElement="Flow_09b50tn"> + <di:waypoint x="1080" y="90" /> + <di:waypoint x="1170" y="90" /> + <di:waypoint x="1170" y="172" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1kk0exp_di" bpmnElement="Flow_1kk0exp"> + <di:waypoint x="890" y="165" /> + <di:waypoint x="890" y="90" /> + <di:waypoint x="980" y="90" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="911" y="125" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0g7721r_di" bpmnElement="Flow_0g7721r"> + <di:waypoint x="890" y="215" /> + <di:waypoint x="890" y="300" /> + <di:waypoint x="980" y="300" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="912" y="273" width="36" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1fij4ds_di" bpmnElement="Flow_1fij4ds"> + <di:waypoint x="915" y="190" /> + <di:waypoint x="980" y="190" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="921" y="172" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0m5n6md_di" bpmnElement="Flow_0m5n6md"> + <di:waypoint x="800" y="190" /> + <di:waypoint x="865" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ayd6dj_di" bpmnElement="Flow_0ayd6dj"> + <di:waypoint x="650" y="190" /> + <di:waypoint x="700" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cmaj9d_di" bpmnElement="Flow_0cmaj9d"> + <di:waypoint x="188" y="190" /> + <di:waypoint x="220" y="190" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_16inlk9_di" bpmnElement="Event_16inlk9"> + <dc:Bounds x="152" y="172" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="215" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1hyt0pb_di" bpmnElement="Activity_1hyt0pb"> + <dc:Bounds x="220" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1usi32q_di" bpmnElement="Activity_1usi32q"> + <dc:Bounds x="700" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_15a04ct_di" bpmnElement="Gateway_15a04ct" isMarkerVisible="true"> + <dc:Bounds x="865" y="165" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="847" y="208" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_18u424w_di" bpmnElement="Event_18u424w"> + <dc:Bounds x="1152" y="172" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0qlstj2_di" bpmnElement="Activity_0qlstj2"> + <dc:Bounds x="550" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ezmthy_di" bpmnElement="CallDoAllocateAccessNSSI"> + <dc:Bounds x="980" y="50" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ydx2rx_di" bpmnElement="Activity_1ydx2rx"> + <dc:Bounds x="380" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_008nbm9_di" bpmnElement="CallDoAllocateTransportNSSI"> + <dc:Bounds x="980" y="260" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_01669p4_di" bpmnElement="CallDoAllocateCoreNSSI"> + <dc:Bounds x="980" y="150" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn index f27794a389..27bd01bda9 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn @@ -1,5 +1,5 @@ <?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> +<bpmn:definitions xmlns:bpmn="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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> <bpmn:process id="CreateSliceService" name="CreateSliceService" isExecutable="true"> <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Slice Service Creation Flow"> <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> @@ -34,12 +34,12 @@ css.processUserOptions(execution)</bpmn:script> def css = new CreateSliceService() css.processDecomposition(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:scriptTask id="ScriptTask_1eo3m4q" name="Get NST Selection" scriptFormat="groovy"> + <bpmn:scriptTask id="ScriptTask_1eo3m4q" name="Prepare NST Selection" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_046irye</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1o23s0i</bpmn:outgoing> + <bpmn:outgoing>Flow_1l8mfej</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def css = new CreateSliceService() -css.getNSTSelection(execution)</bpmn:script> +css.prepareSelectNSTRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_139l55g" name="Call DoCreateSliceServiceInstance " calledElement="DoCreateSliceServiceInstance"> <bpmn:extensionElements> @@ -176,7 +176,7 @@ css.prepareUpdateServiceOperationStatus(execution)</bpmn:script> <bpmn:outgoing>SequenceFlow_1t19ips</bpmn:outgoing> </bpmn:callActivity> <bpmn:scriptTask id="ScriptTask_0o2r07o" name="Prepare Decompose Service " scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1o23s0i</bpmn:incoming> + <bpmn:incoming>Flow_1u4srgq</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0q7yc2c</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new CreateSliceService() @@ -446,7 +446,6 @@ css.sendSyncResponse(execution)</bpmn:script> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_1aaozcg" sourceRef="CallActivity_0v4mw2x" targetRef="ScriptTask_0gb975b" /> <bpmn:sequenceFlow id="SequenceFlow_046irye" sourceRef="ServiceTask_0kd6p6p" targetRef="ScriptTask_1eo3m4q" /> - <bpmn:sequenceFlow id="SequenceFlow_1o23s0i" sourceRef="ScriptTask_1eo3m4q" targetRef="ScriptTask_0o2r07o" /> <bpmn:sequenceFlow id="SequenceFlow_0jrclmc" sourceRef="ScriptTask_0l3d1ai" targetRef="IntermediateThrowEvent_1ex8ke9" /> <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0n4xku8</bpmn:incoming> @@ -457,12 +456,205 @@ def css = new CreateSliceService() css.updateAAIOrchStatus(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ef3voz" /> + <bpmn:sequenceFlow id="Flow_1l8mfej" sourceRef="ScriptTask_1eo3m4q" targetRef="Activity_1ge49xu" /> + <bpmn:callActivity id="Activity_1ge49xu" name="Handle NST Selection OOF request" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nstSelectionUrl" target="apiPath" /> + <camunda:in source="nstSelection_correlator" target="correlator" /> + <camunda:in source="nstSelection_messageType" target="messageType" /> + <camunda:in source="nstSelection_timeout" target="timeout" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nstSelection_oofResponse" /> + <camunda:in source="nstSelection_oofRequest" target="oofRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1l8mfej</bpmn:incoming> + <bpmn:outgoing>Flow_0vq2rmw</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0vq2rmw" sourceRef="Activity_1ge49xu" targetRef="Activity_12v8ykp" /> + <bpmn:scriptTask id="Activity_12v8ykp" name="Process NST Solutions" scriptFormat="groovy"> + <bpmn:incoming>Flow_0vq2rmw</bpmn:incoming> + <bpmn:outgoing>Flow_1u4srgq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def css = new CreateSliceService() +css.processNSTSolutions(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1u4srgq" sourceRef="Activity_12v8ykp" targetRef="ScriptTask_0o2r07o" /> </bpmn:process> <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateSliceService"> + <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> + <di:waypoint x="745" y="801" /> + <di:waypoint x="823" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0jrclmc_di" bpmnElement="SequenceFlow_0jrclmc"> + <di:waypoint x="1540" y="121" /> + <di:waypoint x="1584" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_046irye_di" bpmnElement="SequenceFlow_046irye"> + <di:waypoint x="650" y="121" /> + <di:waypoint x="685" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1aaozcg_di" bpmnElement="SequenceFlow_1aaozcg"> + <di:waypoint x="1115" y="289" /> + <di:waypoint x="1193" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12qt5ci_di" bpmnElement="SequenceFlow_12qt5ci"> + <di:waypoint x="335" y="514" /> + <di:waypoint x="335" y="611" /> + <di:waypoint x="335" y="593" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_16uz2t9_di" bpmnElement="SequenceFlow_16uz2t9"> + <di:waypoint x="385" y="456" /> + <di:waypoint x="467" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fk37v7_di" bpmnElement="SequenceFlow_1fk37v7"> + <di:waypoint x="214" y="456" /> + <di:waypoint x="285" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ey6m1e_di" bpmnElement="SequenceFlow_1ey6m1e"> + <di:waypoint x="930" y="289" /> + <di:waypoint x="1015" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1bevt3a_di" bpmnElement="SequenceFlow_1bevt3a"> + <di:waypoint x="214" y="801" /> + <di:waypoint x="285" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_10ng1vx_di" bpmnElement="SequenceFlow_10ng1vx"> + <di:waypoint x="1471" y="645" /> + <di:waypoint x="1584" y="645" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_19lsayh_di" bpmnElement="SequenceFlow_19lsayh"> + <di:waypoint x="1293" y="645" /> + <di:waypoint x="1371" y="645" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0h2oree_di" bpmnElement="SequenceFlow_0h2oree"> + <di:waypoint x="567" y="456" /> + <di:waypoint x="645" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0477975_di" bpmnElement="SequenceFlow_0477975"> + <di:waypoint x="1471" y="456" /> + <di:waypoint x="1584" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0thd6ny_di" bpmnElement="SequenceFlow_0thd6ny"> + <di:waypoint x="1293" y="456" /> + <di:waypoint x="1371" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1sq6kp6_di" bpmnElement="SequenceFlow_1sq6kp6"> + <di:waypoint x="385" y="289" /> + <di:waypoint x="467" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0q7yc2c_di" bpmnElement="SequenceFlow_0q7yc2c"> + <di:waypoint x="1240" y="121" /> + <di:waypoint x="1280" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> + <di:waypoint x="1297" y="801" /> + <di:waypoint x="1375" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0lbdfmt_di" bpmnElement="SequenceFlow_0lbdfmt"> + <di:waypoint x="1105" y="801" /> + <di:waypoint x="1197" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1o1tu0f_di" bpmnElement="SequenceFlow_1o1tu0f"> + <di:waypoint x="214" y="289" /> + <di:waypoint x="285" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0t094g7_di" bpmnElement="SequenceFlow_0t094g7"> + <di:waypoint x="510" y="121" /> + <di:waypoint x="550" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_11rbv41_di" bpmnElement="SequenceFlow_11rbv41"> + <di:waypoint x="1475" y="801" /> + <di:waypoint x="1585" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0klb3ey_di" bpmnElement="SequenceFlow_0klb3ey"> + <di:waypoint x="923" y="801" /> + <di:waypoint x="1005" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0n4xku8_di" bpmnElement="SequenceFlow_0n4xku8"> + <di:waypoint x="538" y="801" /> + <di:waypoint x="645" y="801" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="584" y="783" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1c6ka9h_di" bpmnElement="SequenceFlow_1c6ka9h"> + <di:waypoint x="513" y="826" /> + <di:waypoint x="513" y="926" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="521" y="832" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0mlrlbv_di" bpmnElement="SequenceFlow_0mlrlbv"> + <di:waypoint x="385" y="801" /> + <di:waypoint x="488" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_18kur12_di" bpmnElement="SequenceFlow_18kur12"> + <di:waypoint x="1293" y="289" /> + <di:waypoint x="1371" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0it2g9j_di" bpmnElement="SequenceFlow_0it2g9j"> + <di:waypoint x="1471" y="289" /> + <di:waypoint x="1584" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1g8m7tq_di" bpmnElement="SequenceFlow_1g8m7tq"> + <di:waypoint x="745" y="289" /> + <di:waypoint x="830" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1p8vxo5_di" bpmnElement="SequenceFlow_1p8vxo5"> + <di:waypoint x="567" y="289" /> + <di:waypoint x="645" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1t19ips_di" bpmnElement="SequenceFlow_1t19ips"> + <di:waypoint x="1380" y="121" /> + <di:waypoint x="1440" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_038lb9m_di" bpmnElement="SequenceFlow_038lb9m"> + <di:waypoint x="1065" y="481" /> + <di:waypoint x="1065" y="645" /> + <di:waypoint x="1193" y="645" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1067" y="560" width="27" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12t5exy_di" bpmnElement="SequenceFlow_12t5exy"> + <di:waypoint x="1090" y="456" /> + <di:waypoint x="1193" y="456" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1121.5" y="438" width="42" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_197cm2e_di" bpmnElement="SequenceFlow_197cm2e"> + <di:waypoint x="930" y="456" /> + <di:waypoint x="1040" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1cv0wop_di" bpmnElement="SequenceFlow_1cv0wop"> + <di:waypoint x="745" y="456" /> + <di:waypoint x="830" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> + <di:waypoint x="350" y="121" /> + <di:waypoint x="410" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> + <di:waypoint x="214" y="121" /> + <di:waypoint x="250" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1l8mfej_di" bpmnElement="Flow_1l8mfej"> + <di:waypoint x="785" y="121" /> + <di:waypoint x="830" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0vq2rmw_di" bpmnElement="Flow_0vq2rmw"> + <di:waypoint x="930" y="121" /> + <di:waypoint x="1000" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1u4srgq_di" bpmnElement="Flow_1u4srgq"> + <di:waypoint x="1100" y="121" /> + <di:waypoint x="1140" y="121" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> <dc:Bounds x="178" y="103" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -475,9 +667,6 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <dc:Bounds x="168" y="481" width="60" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> - <dc:Bounds x="285" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1jgtb0y_di" bpmnElement="ScriptTask_1jgtb0y"> <dc:Bounds x="830" y="416" width="100" height="80" /> </bpmndi:BPMNShape> @@ -487,12 +676,6 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <dc:Bounds x="1027" y="413" width="78" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_0l3d1ai_di" bpmnElement="ScriptTask_0l3d1ai"> - <dc:Bounds x="1370" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1eo3m4q_di" bpmnElement="ScriptTask_1eo3m4q"> - <dc:Bounds x="830" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_139l55g_di" bpmnElement="CallActivity_139l55g"> <dc:Bounds x="645" y="249" width="100" height="80" /> </bpmndi:BPMNShape> @@ -514,9 +697,53 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <bpmndi:BPMNShape id="EndEvent_0x406rw_di" bpmnElement="EndEvent_0x406rw"> <dc:Bounds x="495" y="926" width="36" height="36" /> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0l3d1ai_di" bpmnElement="ScriptTask_0l3d1ai"> + <dc:Bounds x="1440" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1bnkmaz_di" bpmnElement="CallActivity_1bnkmaz"> + <dc:Bounds x="1280" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0o2r07o_di" bpmnElement="ScriptTask_0o2r07o"> + <dc:Bounds x="1140" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="250" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0yce5sp_di" bpmnElement="Activity_12v8ykp"> + <dc:Bounds x="1000" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0uymgnp_di" bpmnElement="Activity_1ge49xu"> + <dc:Bounds x="830" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1eo3m4q_di" bpmnElement="ScriptTask_1eo3m4q"> + <dc:Bounds x="685" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0kd6p6p_di" bpmnElement="ServiceTask_0kd6p6p"> + <dc:Bounds x="550" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1xxag1o_di" bpmnElement="ScriptTask_1xxag1o"> + <dc:Bounds x="410" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> <dc:Bounds x="685" y="1080" width="781" height="196" /> </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1079" y="1184" /> + <di:waypoint x="1353" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="751" y="1184" /> + <di:waypoint x="979" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="715" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1353" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="979" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1ef3voz_di" bpmnElement="ScriptTask_1ef3voz"> <dc:Bounds x="823" y="761" width="100" height="80" /> </bpmndi:BPMNShape> @@ -526,9 +753,6 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <dc:Bounds x="1593" y="826" width="20" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1xxag1o_di" bpmnElement="ScriptTask_1xxag1o"> - <dc:Bounds x="468" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateThrowEvent_1ex8ke9_di" bpmnElement="IntermediateThrowEvent_1ex8ke9"> <dc:Bounds x="1584" y="103" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -544,15 +768,6 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> <dc:Bounds x="1197" y="761" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_0kd6p6p_di" bpmnElement="ServiceTask_0kd6p6p"> - <dc:Bounds x="645" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_1bnkmaz_di" bpmnElement="CallActivity_1bnkmaz"> - <dc:Bounds x="1193" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_0o2r07o_di" bpmnElement="ScriptTask_0o2r07o"> - <dc:Bounds x="1015" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0b7senu_di" bpmnElement="ScriptTask_0b7senu"> <dc:Bounds x="285" y="249" width="100" height="80" /> </bpmndi:BPMNShape> @@ -613,197 +828,18 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <bpmndi:BPMNShape id="EndEvent_0bh0kwx_di" bpmnElement="EndEvent_0bh0kwx"> <dc:Bounds x="317" y="593" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> - <di:waypoint x="214" y="121" /> - <di:waypoint x="285" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> - <di:waypoint x="385" y="121" /> - <di:waypoint x="468" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1cv0wop_di" bpmnElement="SequenceFlow_1cv0wop"> - <di:waypoint x="745" y="456" /> - <di:waypoint x="830" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_197cm2e_di" bpmnElement="SequenceFlow_197cm2e"> - <di:waypoint x="930" y="456" /> - <di:waypoint x="1040" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_12t5exy_di" bpmnElement="SequenceFlow_12t5exy"> - <di:waypoint x="1090" y="456" /> - <di:waypoint x="1193" y="456" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1121.5" y="438" width="42" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_038lb9m_di" bpmnElement="SequenceFlow_038lb9m"> - <di:waypoint x="1065" y="481" /> - <di:waypoint x="1065" y="645" /> - <di:waypoint x="1193" y="645" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1067" y="560" width="27" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1t19ips_di" bpmnElement="SequenceFlow_1t19ips"> - <di:waypoint x="1293" y="121" /> - <di:waypoint x="1370" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1p8vxo5_di" bpmnElement="SequenceFlow_1p8vxo5"> - <di:waypoint x="567" y="289" /> - <di:waypoint x="645" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1g8m7tq_di" bpmnElement="SequenceFlow_1g8m7tq"> - <di:waypoint x="745" y="289" /> - <di:waypoint x="830" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0it2g9j_di" bpmnElement="SequenceFlow_0it2g9j"> - <di:waypoint x="1471" y="289" /> - <di:waypoint x="1584" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_18kur12_di" bpmnElement="SequenceFlow_18kur12"> - <di:waypoint x="1293" y="289" /> - <di:waypoint x="1371" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0mlrlbv_di" bpmnElement="SequenceFlow_0mlrlbv"> - <di:waypoint x="385" y="801" /> - <di:waypoint x="488" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1c6ka9h_di" bpmnElement="SequenceFlow_1c6ka9h"> - <di:waypoint x="513" y="826" /> - <di:waypoint x="513" y="926" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="521" y="832" width="15" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0n4xku8_di" bpmnElement="SequenceFlow_0n4xku8"> - <di:waypoint x="538" y="801" /> - <di:waypoint x="645" y="801" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="584" y="783" width="18" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0klb3ey_di" bpmnElement="SequenceFlow_0klb3ey"> - <di:waypoint x="923" y="801" /> - <di:waypoint x="1005" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_11rbv41_di" bpmnElement="SequenceFlow_11rbv41"> - <di:waypoint x="1475" y="801" /> - <di:waypoint x="1585" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0t094g7_di" bpmnElement="SequenceFlow_0t094g7"> - <di:waypoint x="568" y="121" /> - <di:waypoint x="645" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1o1tu0f_di" bpmnElement="SequenceFlow_1o1tu0f"> - <di:waypoint x="214" y="289" /> - <di:waypoint x="285" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0lbdfmt_di" bpmnElement="SequenceFlow_0lbdfmt"> - <di:waypoint x="1105" y="801" /> - <di:waypoint x="1197" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> - <di:waypoint x="1297" y="801" /> - <di:waypoint x="1375" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0q7yc2c_di" bpmnElement="SequenceFlow_0q7yc2c"> - <di:waypoint x="1115" y="121" /> - <di:waypoint x="1193" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1sq6kp6_di" bpmnElement="SequenceFlow_1sq6kp6"> - <di:waypoint x="385" y="289" /> - <di:waypoint x="467" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0thd6ny_di" bpmnElement="SequenceFlow_0thd6ny"> - <di:waypoint x="1293" y="456" /> - <di:waypoint x="1371" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0477975_di" bpmnElement="SequenceFlow_0477975"> - <di:waypoint x="1471" y="456" /> - <di:waypoint x="1584" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0h2oree_di" bpmnElement="SequenceFlow_0h2oree"> - <di:waypoint x="567" y="456" /> - <di:waypoint x="645" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_19lsayh_di" bpmnElement="SequenceFlow_19lsayh"> - <di:waypoint x="1293" y="645" /> - <di:waypoint x="1371" y="645" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_10ng1vx_di" bpmnElement="SequenceFlow_10ng1vx"> - <di:waypoint x="1471" y="645" /> - <di:waypoint x="1584" y="645" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1bevt3a_di" bpmnElement="SequenceFlow_1bevt3a"> - <di:waypoint x="214" y="801" /> - <di:waypoint x="285" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1ey6m1e_di" bpmnElement="SequenceFlow_1ey6m1e"> - <di:waypoint x="930" y="289" /> - <di:waypoint x="1015" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> - <dc:Bounds x="715" y="1166" width="36" height="36" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> - <dc:Bounds x="1353" y="1166" width="36" height="36" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> - <dc:Bounds x="979" y="1144" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> - <di:waypoint x="751" y="1184" /> - <di:waypoint x="979" y="1184" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> - <di:waypoint x="1079" y="1184" /> - <di:waypoint x="1353" y="1184" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ReceiveTask_0zkpdpa_di" bpmnElement="Task_1b5t88h"> <dc:Bounds x="285" y="416" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1fk37v7_di" bpmnElement="SequenceFlow_1fk37v7"> - <di:waypoint x="214" y="456" /> - <di:waypoint x="285" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_16uz2t9_di" bpmnElement="SequenceFlow_16uz2t9"> - <di:waypoint x="385" y="456" /> - <di:waypoint x="467" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="BoundaryEvent_15igwk2_di" bpmnElement="BoundaryEvent_0clo9pv"> - <dc:Bounds x="317" y="478" width="36" height="36" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_12qt5ci_di" bpmnElement="SequenceFlow_12qt5ci"> - <di:waypoint x="335" y="514" /> - <di:waypoint x="335" y="611" /> - <di:waypoint x="335" y="593" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0v4mw2x_di" bpmnElement="CallActivity_0v4mw2x"> <dc:Bounds x="1015" y="249" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1aaozcg_di" bpmnElement="SequenceFlow_1aaozcg"> - <di:waypoint x="1115" y="289" /> - <di:waypoint x="1193" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_046irye_di" bpmnElement="SequenceFlow_046irye"> - <di:waypoint x="745" y="121" /> - <di:waypoint x="830" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1o23s0i_di" bpmnElement="SequenceFlow_1o23s0i"> - <di:waypoint x="930" y="121" /> - <di:waypoint x="1015" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0jrclmc_di" bpmnElement="SequenceFlow_0jrclmc"> - <di:waypoint x="1470" y="121" /> - <di:waypoint x="1584" y="121" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> <dc:Bounds x="645" y="761" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> - <di:waypoint x="745" y="801" /> - <di:waypoint x="823" y="801" /> - </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="BoundaryEvent_15igwk2_di" bpmnElement="BoundaryEvent_0clo9pv"> + <dc:Bounds x="317" y="478" width="36" height="36" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeAllocateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeAllocateSliceSubnet.bpmn new file mode 100644 index 0000000000..bf08c6e630 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeAllocateSliceSubnet.bpmn @@ -0,0 +1,224 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1stoy5y" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DeAllocateSliceSubnet" name="DeallocateSliceSubnet" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>Flow_143ck2k</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="Flow_143ck2k" sourceRef="StartEvent_1" targetRef="Activity_0zyhkvj" /> + <bpmn:scriptTask id="Activity_0zyhkvj" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_143ck2k</bpmn:incoming> + <bpmn:outgoing>Flow_0pttfuf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DeAllocateSliceSubnet() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0c6o2o7" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1c1j5i1</bpmn:incoming> + <bpmn:outgoing>Flow_1kljyhj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DeAllocateSliceSubnet() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1dykbz9" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_04jsg9s</bpmn:incoming> + <bpmn:outgoing>Flow_1c1j5i1</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0pttfuf" sourceRef="Activity_0zyhkvj" targetRef="Activity_1fj0cge" /> + <bpmn:sequenceFlow id="Flow_1c1j5i1" sourceRef="Activity_1dykbz9" targetRef="Activity_0c6o2o7" /> + <bpmn:scriptTask id="Activity_1fj0cge" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0pttfuf</bpmn:incoming> + <bpmn:outgoing>Flow_04jsg9s</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DeAllocateSliceSubnet() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_04jsg9s" sourceRef="Activity_1fj0cge" targetRef="Activity_1dykbz9" /> + <bpmn:exclusiveGateway id="Gateway_1jagvdq" name="Whether Network type"> + <bpmn:incoming>Flow_1kljyhj</bpmn:incoming> + <bpmn:outgoing>Flow_0fp8gep</bpmn:outgoing> + <bpmn:outgoing>Flow_0zwyxxc</bpmn:outgoing> + <bpmn:outgoing>Flow_0roz1jy</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:callActivity id="Activity_02dflyr" name="Call TNDeallocateNSSI" calledElement="DoDeallocateTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0fp8gep</bpmn:incoming> + <bpmn:outgoing>Flow_1hij53h</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="Activity_1ceupdn" name="Call CNDeallocateNSSI" calledElement="DoDeallocateCoreNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0roz1jy</bpmn:incoming> + <bpmn:outgoing>Flow_1fth8go</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="Activity_0li16m1" name="Call ANDeallocateNSSI" calledElement="DoDeallocateAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0zwyxxc</bpmn:incoming> + <bpmn:outgoing>Flow_1l74oic</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:endEvent id="Event_1ecylff"> + <bpmn:incoming>Flow_1hij53h</bpmn:incoming> + <bpmn:incoming>Flow_1fth8go</bpmn:incoming> + <bpmn:incoming>Flow_1l74oic</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0fp8gep" name="Is TN ?" sourceRef="Gateway_1jagvdq" targetRef="Activity_02dflyr"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0zwyxxc" name="Is AN ?" sourceRef="Gateway_1jagvdq" targetRef="Activity_0li16m1"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0roz1jy" name="Is CN ?" sourceRef="Gateway_1jagvdq" targetRef="Activity_1ceupdn"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "CN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1hij53h" sourceRef="Activity_02dflyr" targetRef="Event_1ecylff" /> + <bpmn:sequenceFlow id="Flow_1fth8go" sourceRef="Activity_1ceupdn" targetRef="Event_1ecylff" /> + <bpmn:sequenceFlow id="Flow_1l74oic" sourceRef="Activity_0li16m1" targetRef="Event_1ecylff" /> + <bpmn:sequenceFlow id="Flow_1kljyhj" sourceRef="Activity_0c6o2o7" targetRef="Gateway_1jagvdq" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeAllocateSliceSubnet"> + <bpmndi:BPMNEdge id="Flow_1kljyhj_di" bpmnElement="Flow_1kljyhj"> + <di:waypoint x="890" y="250" /> + <di:waypoint x="975" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1l74oic_di" bpmnElement="Flow_1l74oic"> + <di:waypoint x="1190" y="120" /> + <di:waypoint x="1280" y="120" /> + <di:waypoint x="1280" y="232" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1fth8go_di" bpmnElement="Flow_1fth8go"> + <di:waypoint x="1190" y="250" /> + <di:waypoint x="1262" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1hij53h_di" bpmnElement="Flow_1hij53h"> + <di:waypoint x="1190" y="360" /> + <di:waypoint x="1280" y="360" /> + <di:waypoint x="1280" y="268" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0roz1jy_di" bpmnElement="Flow_0roz1jy"> + <di:waypoint x="1025" y="250" /> + <di:waypoint x="1090" y="250" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1035" y="232" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0zwyxxc_di" bpmnElement="Flow_0zwyxxc"> + <di:waypoint x="1000" y="225" /> + <di:waypoint x="1000" y="120" /> + <di:waypoint x="1090" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="964" y="129" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fp8gep_di" bpmnElement="Flow_0fp8gep"> + <di:waypoint x="1000" y="275" /> + <di:waypoint x="1000" y="360" /> + <di:waypoint x="1090" y="360" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1000" y="345" width="36" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_04jsg9s_di" bpmnElement="Flow_04jsg9s"> + <di:waypoint x="520" y="250" /> + <di:waypoint x="600" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1c1j5i1_di" bpmnElement="Flow_1c1j5i1"> + <di:waypoint x="700" y="250" /> + <di:waypoint x="790" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0pttfuf_di" bpmnElement="Flow_0pttfuf"> + <di:waypoint x="330" y="250" /> + <di:waypoint x="420" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_143ck2k_di" bpmnElement="Flow_143ck2k"> + <di:waypoint x="168" y="250" /> + <di:waypoint x="230" y="250" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="132" y="232" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="138" y="275" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1jawdkz_di" bpmnElement="Activity_0zyhkvj"> + <dc:Bounds x="230" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1n1ajr4_di" bpmnElement="Activity_0c6o2o7"> + <dc:Bounds x="790" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1dykbz9_di" bpmnElement="Activity_1dykbz9"> + <dc:Bounds x="600" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1fj0cge_di" bpmnElement="Activity_1fj0cge"> + <dc:Bounds x="420" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1jagvdq_di" bpmnElement="Gateway_1jagvdq" isMarkerVisible="true"> + <dc:Bounds x="975" y="225" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="957" y="268" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_02dflyr_di" bpmnElement="Activity_02dflyr"> + <dc:Bounds x="1090" y="320" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ceupdn_di" bpmnElement="Activity_1ceupdn"> + <dc:Bounds x="1090" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0li16m1_di" bpmnElement="Activity_0li16m1"> + <dc:Bounds x="1090" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1ecylff_di" bpmnElement="Event_1ecylff"> + <dc:Bounds x="1262" y="232" width="36" height="36" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn index 1722137056..36f6221da9 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn @@ -56,7 +56,7 @@ taskProcessor.prepareCompletion(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_05haut5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_09y0mpc</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_00psvtk" name="Call FalloutHandler" calledElement="FalloutHandler"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSWUPDownload.bpmn index 5d523194bb..6a0b260a70 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSWUPDownload.bpmn @@ -1,10 +1,10 @@ <?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0474hns" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.0"> - <bpmn:process id="PNFSWUPDownload" name="PNFSWUPDownload" isExecutable="true"> +<bpmn:definitions xmlns:bpmn="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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0474hns" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="GenericPnfSWUPDownload" name="GenericPnfSWUPDownload" isExecutable="true"> <bpmn:startEvent id="download_StartEvent" name="Start Flow"> <bpmn:outgoing>SequenceFlow_1fdclh0</bpmn:outgoing> </bpmn:startEvent> - <bpmn:serviceTask id="ServiceTask_1mpt2eq" name="NF Download Dispatcher" camunda:delegateExpression="${NfSoftwareUpgradeDispatcher}"> + <bpmn:serviceTask id="ServiceTask_1mpt2eq" name="NF Download Dispatcher" camunda:delegateExpression="${GenericPnfDispatcher}"> <bpmn:incoming>SequenceFlow_1fdclh0</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0kusy70</bpmn:outgoing> </bpmn:serviceTask> @@ -95,7 +95,7 @@ <bpmn:incoming>SequenceFlow_0swi04u</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1ppn4a8</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_0ikcgtm" name="Call FalloutHandler" calledElement="FalloutHandler"> @@ -117,7 +117,7 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_0kusy70</bpmn:incoming> <bpmn:outgoing>SequenceFlow_12155q6</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.sendResponse(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_0kusy70" sourceRef="ServiceTask_1mpt2eq" targetRef="ScriptTask_1ankfw8" /> @@ -125,7 +125,7 @@ pnfSwUpgrade.sendResponse(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_1d2rfyx</bpmn:incoming> <bpmn:outgoing>SequenceFlow_183s0wo</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_0tq2dug" name="Complete Process" calledElement="CompleteMsoProcess"> @@ -143,7 +143,89 @@ pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> </bpmn:process> <bpmn:error id="Error_1q14dnd" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSWUPDownload"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericPnfSWUPDownload"> + <bpmndi:BPMNEdge id="SequenceFlow_0mjjdia_di" bpmnElement="SequenceFlow_0mjjdia"> + <di:waypoint x="455" y="481" /> + <di:waypoint x="512" y="481" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1d2rfyx_di" bpmnElement="SequenceFlow_1d2rfyx"> + <di:waypoint x="925" y="260" /> + <di:waypoint x="970" y="260" /> + <di:waypoint x="970" y="410" /> + <di:waypoint x="160" y="410" /> + <di:waypoint x="160" y="481" /> + <di:waypoint x="202" y="481" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="938" y="242" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_183s0wo_di" bpmnElement="SequenceFlow_183s0wo"> + <di:waypoint x="302" y="481" /> + <di:waypoint x="355" y="481" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kusy70_di" bpmnElement="SequenceFlow_0kusy70"> + <di:waypoint x="370" y="121" /> + <di:waypoint x="440" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qznt4u_di" bpmnElement="SequenceFlow_0qznt4u"> + <di:waypoint x="665" y="260" /> + <di:waypoint x="720" y="260" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="671" y="242" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1gawssm_di" bpmnElement="SequenceFlow_1gawssm"> + <di:waypoint x="900" y="285" /> + <di:waypoint x="900" y="344" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="912" y="290" width="32" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1kaikh5_di" bpmnElement="SequenceFlow_1kaikh5"> + <di:waypoint x="820" y="260" /> + <di:waypoint x="875" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1tfbzn1_di" bpmnElement="SequenceFlow_1tfbzn1"> + <di:waypoint x="380" y="285" /> + <di:waypoint x="380" y="344" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="384" y="292" width="32" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0s6i4o9_di" bpmnElement="SequenceFlow_0s6i4o9"> + <di:waypoint x="405" y="260" /> + <di:waypoint x="480" y="260" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="398" y="242" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ccldpp_di" bpmnElement="SequenceFlow_1ccldpp"> + <di:waypoint x="300" y="260" /> + <di:waypoint x="355" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_078xmlz_di" bpmnElement="SequenceFlow_078xmlz"> + <di:waypoint x="640" y="285" /> + <di:waypoint x="640" y="344" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="650" y="291" width="32" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0o6b6a8_di" bpmnElement="SequenceFlow_0o6b6a8"> + <di:waypoint x="580" y="260" /> + <di:waypoint x="615" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12155q6_di" bpmnElement="SequenceFlow_12155q6"> + <di:waypoint x="540" y="121" /> + <di:waypoint x="570" y="121" /> + <di:waypoint x="570" y="190" /> + <di:waypoint x="160" y="190" /> + <di:waypoint x="160" y="260" /> + <di:waypoint x="200" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fdclh0_di" bpmnElement="SequenceFlow_1fdclh0"> + <di:waypoint x="208" y="121" /> + <di:waypoint x="270" y="121" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="StartEvent_1k8gssq_di" bpmnElement="download_StartEvent"> <dc:Bounds x="172" y="103" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -186,68 +268,21 @@ pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> <bpmndi:BPMNShape id="ServiceTask_1nl90ao_di" bpmnElement="ServiceTask_1nl90ao"> <dc:Bounds x="200" y="220" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1fdclh0_di" bpmnElement="SequenceFlow_1fdclh0"> - <di:waypoint x="208" y="121" /> - <di:waypoint x="270" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_12155q6_di" bpmnElement="SequenceFlow_12155q6"> - <di:waypoint x="540" y="121" /> - <di:waypoint x="570" y="121" /> - <di:waypoint x="570" y="190" /> - <di:waypoint x="160" y="190" /> - <di:waypoint x="160" y="260" /> - <di:waypoint x="200" y="260" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0o6b6a8_di" bpmnElement="SequenceFlow_0o6b6a8"> - <di:waypoint x="580" y="260" /> - <di:waypoint x="615" y="260" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_078xmlz_di" bpmnElement="SequenceFlow_078xmlz"> - <di:waypoint x="640" y="285" /> - <di:waypoint x="640" y="344" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="650" y="291" width="32" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1ccldpp_di" bpmnElement="SequenceFlow_1ccldpp"> - <di:waypoint x="300" y="260" /> - <di:waypoint x="355" y="260" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0s6i4o9_di" bpmnElement="SequenceFlow_0s6i4o9"> - <di:waypoint x="405" y="260" /> - <di:waypoint x="480" y="260" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="398" y="242" width="43" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1tfbzn1_di" bpmnElement="SequenceFlow_1tfbzn1"> - <di:waypoint x="380" y="285" /> - <di:waypoint x="380" y="344" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="384" y="292" width="32" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1kaikh5_di" bpmnElement="SequenceFlow_1kaikh5"> - <di:waypoint x="820" y="260" /> - <di:waypoint x="875" y="260" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1gawssm_di" bpmnElement="SequenceFlow_1gawssm"> - <di:waypoint x="900" y="285" /> - <di:waypoint x="900" y="344" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="912" y="290" width="32" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0qznt4u_di" bpmnElement="SequenceFlow_0qznt4u"> - <di:waypoint x="665" y="260" /> - <di:waypoint x="720" y="260" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="671" y="242" width="43" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_02e59i3_di" bpmnElement="SubProcess_02e59i3" isExpanded="true"> <dc:Bounds x="190" y="580" width="650" height="190" /> </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0swi04u_di" bpmnElement="SequenceFlow_0swi04u"> + <di:waypoint x="298" y="680" /> + <di:waypoint x="360" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ppn4a8_di" bpmnElement="SequenceFlow_1ppn4a8"> + <di:waypoint x="460" y="680" /> + <di:waypoint x="530" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ahmdun_di" bpmnElement="SequenceFlow_1ahmdun"> + <di:waypoint x="630" y="680" /> + <di:waypoint x="702" y="680" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="StartEvent_0uftj43_di" bpmnElement="StartEvent_0uftj43"> <dc:Bounds x="262" y="662" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -266,50 +301,15 @@ pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> <dc:Bounds x="712" y="705" width="18" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1ahmdun_di" bpmnElement="SequenceFlow_1ahmdun"> - <di:waypoint x="630" y="680" /> - <di:waypoint x="702" y="680" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1ppn4a8_di" bpmnElement="SequenceFlow_1ppn4a8"> - <di:waypoint x="460" y="680" /> - <di:waypoint x="530" y="680" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0swi04u_di" bpmnElement="SequenceFlow_0swi04u"> - <di:waypoint x="298" y="680" /> - <di:waypoint x="360" y="680" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1ankfw8_di" bpmnElement="ScriptTask_1ankfw8"> <dc:Bounds x="440" y="81" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0kusy70_di" bpmnElement="SequenceFlow_0kusy70"> - <di:waypoint x="370" y="121" /> - <di:waypoint x="440" y="121" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_17f7m2t_di" bpmnElement="ScriptTask_17f7m2t"> <dc:Bounds x="202" y="441" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0tq2dug_di" bpmnElement="CallActivity_0tq2dug"> <dc:Bounds x="355" y="441" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_183s0wo_di" bpmnElement="SequenceFlow_183s0wo"> - <di:waypoint x="302" y="481" /> - <di:waypoint x="355" y="481" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1d2rfyx_di" bpmnElement="SequenceFlow_1d2rfyx"> - <di:waypoint x="925" y="260" /> - <di:waypoint x="970" y="260" /> - <di:waypoint x="970" y="410" /> - <di:waypoint x="160" y="410" /> - <di:waypoint x="160" y="481" /> - <di:waypoint x="202" y="481" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="938" y="242" width="43" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0mjjdia_di" bpmnElement="SequenceFlow_0mjjdia"> - <di:waypoint x="455" y="481" /> - <di:waypoint x="512" y="481" /> - </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSoftwareUpgrade.bpmn index 4ff0af4549..9b8ce4a7b7 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSoftwareUpgrade.bpmn @@ -1,10 +1,10 @@ <?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1yd8m0g" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.0"> - <bpmn:process id="PNFSoftwareUpgrade" name="PNFSoftwareUpgrade" isExecutable="true"> +<bpmn:definitions xmlns:bpmn="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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1yd8m0g" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="GenericPnfSoftwareUpgrade" name="GenericPnfSoftwareUpgrade" isExecutable="true"> <bpmn:startEvent id="softwareUpgrade_startEvent" name="Start Flow"> <bpmn:outgoing>SequenceFlow_1ng4b6l</bpmn:outgoing> </bpmn:startEvent> - <bpmn:serviceTask id="ServiceTask_042uz7n" name="NF Upgrade Dispatcher" camunda:delegateExpression="${NfSoftwareUpgradeDispatcher}"> + <bpmn:serviceTask id="ServiceTask_042uz7n" name="NF Upgrade Dispatcher" camunda:delegateExpression="${GenericPnfDispatcher}"> <bpmn:incoming>SequenceFlow_1ng4b6l</bpmn:incoming> <bpmn:outgoing>SequenceFlow_12ejx4m</bpmn:outgoing> </bpmn:serviceTask> @@ -123,7 +123,7 @@ <bpmn:incoming>SequenceFlow_12ejx4m</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ks3p41</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.sendResponse(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_0ks3p41" sourceRef="ScriptTask_10klpg8" targetRef="ServiceTask_0slpahe" /> @@ -131,7 +131,7 @@ pnfSwUpgrade.sendResponse(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_1atiydu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ipc3nt</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_0ipc3nt" sourceRef="ScriptTask_1igtc83" targetRef="CallActivity_0o1mi8u" /> @@ -152,7 +152,7 @@ pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_05haut5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_09y0mpc</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_00psvtk" name="Call FalloutHandler" calledElement="FalloutHandler"> @@ -173,7 +173,111 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:process> <bpmn:error id="Error_12cpov5" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSoftwareUpgrade"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericPnfSoftwareUpgrade"> + <bpmndi:BPMNEdge id="SequenceFlow_0tle5zb_di" bpmnElement="SequenceFlow_0tle5zb"> + <di:waypoint x="480" y="480" /> + <di:waypoint x="532" y="480" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0ipc3nt_di" bpmnElement="SequenceFlow_0ipc3nt"> + <di:waypoint x="320" y="480" /> + <di:waypoint x="380" y="480" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0ks3p41_di" bpmnElement="SequenceFlow_0ks3p41"> + <di:waypoint x="540" y="120" /> + <di:waypoint x="570" y="120" /> + <di:waypoint x="570" y="190" /> + <di:waypoint x="180" y="190" /> + <di:waypoint x="180" y="260" /> + <di:waypoint x="220" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_084orr1_di" bpmnElement="SequenceFlow_084orr1"> + <di:waypoint x="1050" y="260" /> + <di:waypoint x="1090" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0j26xlx_di" bpmnElement="SequenceFlow_0j26xlx"> + <di:waypoint x="320" y="260" /> + <di:waypoint x="355" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0g3qcd0_di" bpmnElement="SequenceFlow_0g3qcd0"> + <di:waypoint x="1190" y="260" /> + <di:waypoint x="1225" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_015y785_di" bpmnElement="SequenceFlow_015y785"> + <di:waypoint x="820" y="260" /> + <di:waypoint x="845" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0cchgih_di" bpmnElement="SequenceFlow_0cchgih"> + <di:waypoint x="560" y="260" /> + <di:waypoint x="615" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0eiif6e_di" bpmnElement="SequenceFlow_0eiif6e"> + <di:waypoint x="895" y="260" /> + <di:waypoint x="950" y="260" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="898" y="242" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1atiydu_di" bpmnElement="SequenceFlow_1atiydu"> + <di:waypoint x="1275" y="260" /> + <di:waypoint x="1320" y="260" /> + <di:waypoint x="1320" y="410" /> + <di:waypoint x="180" y="410" /> + <di:waypoint x="180" y="480" /> + <di:waypoint x="220" y="480" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1277" y="242" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1eljvek_di" bpmnElement="SequenceFlow_1eljvek"> + <di:waypoint x="665" y="260" /> + <di:waypoint x="720" y="260" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="668" y="242" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1p0axph_di" bpmnElement="SequenceFlow_1p0axph"> + <di:waypoint x="1250" y="285" /> + <di:waypoint x="1250" y="342" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1254" y="293" width="32" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0dqnb6c_di" bpmnElement="SequenceFlow_0dqnb6c"> + <di:waypoint x="870" y="285" /> + <di:waypoint x="870" y="342" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="874" y="293" width="32" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1lr7vgu_di" bpmnElement="SequenceFlow_1lr7vgu"> + <di:waypoint x="640" y="285" /> + <di:waypoint x="640" y="342" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="644" y="293" width="32" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0piri91_di" bpmnElement="SequenceFlow_0piri91"> + <di:waypoint x="380" y="285" /> + <di:waypoint x="380" y="342" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="384" y="293" width="32" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1nsmyr5_di" bpmnElement="SequenceFlow_1nsmyr5"> + <di:waypoint x="405" y="260" /> + <di:waypoint x="460" y="260" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="408" y="242" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ng4b6l_di" bpmnElement="SequenceFlow_1ng4b6l"> + <di:waypoint x="198" y="120" /> + <di:waypoint x="270" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12ejx4m_di" bpmnElement="SequenceFlow_12ejx4m"> + <di:waypoint x="370" y="120" /> + <di:waypoint x="440" y="120" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="softwareUpgrade_startEvent"> <dc:Bounds x="162" y="102" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -183,20 +287,12 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <bpmndi:BPMNShape id="ServiceTask_042uz7n_di" bpmnElement="ServiceTask_042uz7n"> <dc:Bounds x="270" y="80" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_12ejx4m_di" bpmnElement="SequenceFlow_12ejx4m"> - <di:waypoint x="370" y="120" /> - <di:waypoint x="440" y="120" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1w3jv30_di" bpmnElement="softwareUpgrade_endEvent"> <dc:Bounds x="532" y="462" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="542" y="505" width="18" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1ng4b6l_di" bpmnElement="SequenceFlow_1ng4b6l"> - <di:waypoint x="198" y="120" /> - <di:waypoint x="270" y="120" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0v3l3wv_di" bpmnElement="ExclusiveGateway_0v3l3wv" isMarkerVisible="true"> <dc:Bounds x="615" y="235" width="50" height="50" /> <bpmndi:BPMNLabel> @@ -212,160 +308,59 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <bpmndi:BPMNShape id="ExclusiveGateway_0x6h0ni_di" bpmnElement="ExclusiveGateway_0x6h0ni" isMarkerVisible="true"> <dc:Bounds x="355" y="235" width="50" height="50" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1nsmyr5_di" bpmnElement="SequenceFlow_1nsmyr5"> - <di:waypoint x="405" y="260" /> - <di:waypoint x="460" y="260" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="408" y="242" width="43" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_180lm4y_di" bpmnElement="EndEvent_180lm4y"> <dc:Bounds x="362" y="342" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0piri91_di" bpmnElement="SequenceFlow_0piri91"> - <di:waypoint x="380" y="285" /> - <di:waypoint x="380" y="342" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="384" y="293" width="32" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1lr7vgu_di" bpmnElement="SequenceFlow_1lr7vgu"> - <di:waypoint x="640" y="285" /> - <di:waypoint x="640" y="342" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="644" y="293" width="32" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0ch3fef_di" bpmnElement="ExclusiveGateway_0ch3fef" isMarkerVisible="true"> <dc:Bounds x="845" y="235" width="50" height="50" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1ms4wdz_di" bpmnElement="EndEvent_1ms4wdz"> <dc:Bounds x="852" y="342" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0dqnb6c_di" bpmnElement="SequenceFlow_0dqnb6c"> - <di:waypoint x="870" y="285" /> - <di:waypoint x="870" y="342" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="874" y="293" width="32" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_1ny9b1z_di" bpmnElement="ExclusiveGateway_1ny9b1z" isMarkerVisible="true"> <dc:Bounds x="1225" y="235" width="50" height="50" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0l6n6x5_di" bpmnElement="EndEvent_0l6n6x5"> <dc:Bounds x="1232" y="342" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1p0axph_di" bpmnElement="SequenceFlow_1p0axph"> - <di:waypoint x="1250" y="285" /> - <di:waypoint x="1250" y="342" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1254" y="293" width="32" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1eljvek_di" bpmnElement="SequenceFlow_1eljvek"> - <di:waypoint x="665" y="260" /> - <di:waypoint x="720" y="260" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="668" y="242" width="43" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1atiydu_di" bpmnElement="SequenceFlow_1atiydu"> - <di:waypoint x="1275" y="260" /> - <di:waypoint x="1320" y="260" /> - <di:waypoint x="1320" y="410" /> - <di:waypoint x="180" y="410" /> - <di:waypoint x="180" y="480" /> - <di:waypoint x="220" y="480" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1277" y="242" width="43" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0eiif6e_di" bpmnElement="SequenceFlow_0eiif6e"> - <di:waypoint x="895" y="260" /> - <di:waypoint x="950" y="260" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="898" y="242" width="43" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0x5cje8_di" bpmnElement="ServiceTask_0x5cje8"> <dc:Bounds x="460" y="220" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0cchgih_di" bpmnElement="SequenceFlow_0cchgih"> - <di:waypoint x="560" y="260" /> - <di:waypoint x="615" y="260" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_02lxf48_di" bpmnElement="ServiceTask_02lxf48"> <dc:Bounds x="720" y="220" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_015y785_di" bpmnElement="SequenceFlow_015y785"> - <di:waypoint x="820" y="260" /> - <di:waypoint x="845" y="260" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0y2uysu_di" bpmnElement="ServiceTask_0y2uysu"> <dc:Bounds x="1090" y="220" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0g3qcd0_di" bpmnElement="SequenceFlow_0g3qcd0"> - <di:waypoint x="1190" y="260" /> - <di:waypoint x="1225" y="260" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0slpahe_di" bpmnElement="ServiceTask_0slpahe"> <dc:Bounds x="220" y="220" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0j26xlx_di" bpmnElement="SequenceFlow_0j26xlx"> - <di:waypoint x="320" y="260" /> - <di:waypoint x="355" y="260" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1jo8vn7_di" bpmnElement="ServiceTask_1jo8vn7"> <dc:Bounds x="950" y="220" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_084orr1_di" bpmnElement="SequenceFlow_084orr1"> - <di:waypoint x="1050" y="260" /> - <di:waypoint x="1090" y="260" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_10klpg8_di" bpmnElement="ScriptTask_10klpg8"> <dc:Bounds x="440" y="80" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0ks3p41_di" bpmnElement="SequenceFlow_0ks3p41"> - <di:waypoint x="540" y="120" /> - <di:waypoint x="570" y="120" /> - <di:waypoint x="570" y="190" /> - <di:waypoint x="180" y="190" /> - <di:waypoint x="180" y="260" /> - <di:waypoint x="220" y="260" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1igtc83_di" bpmnElement="ScriptTask_1igtc83"> <dc:Bounds x="220" y="440" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0ipc3nt_di" bpmnElement="SequenceFlow_0ipc3nt"> - <di:waypoint x="320" y="480" /> - <di:waypoint x="380" y="480" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0o1mi8u_di" bpmnElement="CallActivity_0o1mi8u"> <dc:Bounds x="380" y="440" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0tle5zb_di" bpmnElement="SequenceFlow_0tle5zb"> - <di:waypoint x="480" y="480" /> - <di:waypoint x="532" y="480" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0gov132_di" bpmnElement="ScriptTask_0gov132"> - <dc:Bounds x="540" y="630" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_00psvtk_di" bpmnElement="CallActivity_00psvtk"> - <dc:Bounds x="710" y="630" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_1vq2glg_di" bpmnElement="EndEvent_1vq2glg"> - <dc:Bounds x="882" y="652" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="892" y="695" width="18" height="14" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNShape id="SubProcess_02p6q4s_di" bpmnElement="SubProcess_02p6q4s" isExpanded="true"> + <dc:Bounds x="370" y="570" width="650" height="190" /> </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1tcjlty_di" bpmnElement="SequenceFlow_1tcjlty"> + <di:waypoint x="810" y="670" /> + <di:waypoint x="882" y="670" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_09y0mpc_di" bpmnElement="SequenceFlow_09y0mpc"> <di:waypoint x="640" y="670" /> <di:waypoint x="710" y="670" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1tcjlty_di" bpmnElement="SequenceFlow_1tcjlty"> - <di:waypoint x="810" y="670" /> - <di:waypoint x="882" y="670" /> + <bpmndi:BPMNEdge id="SequenceFlow_05haut5_di" bpmnElement="SequenceFlow_05haut5"> + <di:waypoint x="478" y="670" /> + <di:waypoint x="540" y="670" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="StartEvent_1r4h504_di" bpmnElement="StartEvent_149ecdm"> <dc:Bounds x="442" y="652" width="36" height="36" /> @@ -373,13 +368,18 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <dc:Bounds x="422" y="693" width="76" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="SubProcess_02p6q4s_di" bpmnElement="SubProcess_02p6q4s" isExpanded="true"> - <dc:Bounds x="370" y="570" width="650" height="190" /> + <bpmndi:BPMNShape id="ScriptTask_0gov132_di" bpmnElement="ScriptTask_0gov132"> + <dc:Bounds x="540" y="630" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_00psvtk_di" bpmnElement="CallActivity_00psvtk"> + <dc:Bounds x="710" y="630" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1vq2glg_di" bpmnElement="EndEvent_1vq2glg"> + <dc:Bounds x="882" y="652" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="892" y="695" width="18" height="14" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_05haut5_di" bpmnElement="SequenceFlow_05haut5"> - <di:waypoint x="478" y="670" /> - <di:waypoint x="540" y="670" /> - </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ModifySliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ModifySliceSubnet.bpmn new file mode 100644 index 0000000000..38ddf2edcd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ModifySliceSubnet.bpmn @@ -0,0 +1,224 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0fme930" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="ModifySliceSubnet" name="ModifySliceSubnet" isExecutable="true"> + <bpmn:startEvent id="Event_05idy03" name="Start"> + <bpmn:outgoing>Flow_1t0w8dn</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0kd9pxx" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1t0w8dn</bpmn:incoming> + <bpmn:outgoing>Flow_0fzchbl</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ModifySliceSubnet() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1dzkfh2" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1q030ul</bpmn:incoming> + <bpmn:outgoing>Flow_0ps6iyc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ModifySliceSubnet() +nss.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1baxf7k" name="Whether Network type"> + <bpmn:incoming>Flow_0ps6iyc</bpmn:incoming> + <bpmn:outgoing>Flow_15luvlg</bpmn:outgoing> + <bpmn:outgoing>Flow_0usuozn</bpmn:outgoing> + <bpmn:outgoing>Flow_1dfyoe6</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_103vvkf"> + <bpmn:incoming>Flow_1b2k523</bpmn:incoming> + <bpmn:incoming>Flow_0pklfqu</bpmn:incoming> + <bpmn:incoming>Flow_1bbqkjv</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_0ptby3d" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1grhlet</bpmn:incoming> + <bpmn:outgoing>Flow_1q030ul</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1t0w8dn" sourceRef="Event_05idy03" targetRef="Activity_0kd9pxx" /> + <bpmn:sequenceFlow id="Flow_0fzchbl" sourceRef="Activity_0kd9pxx" targetRef="Activity_1s8ojcr" /> + <bpmn:sequenceFlow id="Flow_1q030ul" sourceRef="Activity_0ptby3d" targetRef="Activity_1dzkfh2" /> + <bpmn:sequenceFlow id="Flow_0ps6iyc" sourceRef="Activity_1dzkfh2" targetRef="Gateway_1baxf7k" /> + <bpmn:sequenceFlow id="Flow_15luvlg" name="Is TN ?" sourceRef="Gateway_1baxf7k" targetRef="Activity_192bdyv"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "TN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0usuozn" name="Is AN ?" sourceRef="Gateway_1baxf7k" targetRef="Activity_0t1g4mp"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "AN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="Activity_1s8ojcr" name="Init Resource Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0fzchbl</bpmn:incoming> + <bpmn:outgoing>Flow_1grhlet</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new ModifySliceSubnet() +nss.prepareInitOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1grhlet" sourceRef="Activity_1s8ojcr" targetRef="Activity_0ptby3d" /> + <bpmn:callActivity id="Activity_0t1g4mp" name="Call ANModifyNSSI" calledElement="DoModifyAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0usuozn</bpmn:incoming> + <bpmn:outgoing>Flow_1b2k523</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1b2k523" sourceRef="Activity_0t1g4mp" targetRef="Event_103vvkf" /> + <bpmn:callActivity id="Activity_0v2hxmv" name="Call CNModifyNSSI" calledElement="DoModifyCoreNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1dfyoe6</bpmn:incoming> + <bpmn:outgoing>Flow_0pklfqu</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="Activity_192bdyv" name="Call TNModifyNSSI" calledElement="DoModifyTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_15luvlg</bpmn:incoming> + <bpmn:outgoing>Flow_1bbqkjv</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0pklfqu" sourceRef="Activity_0v2hxmv" targetRef="Event_103vvkf" /> + <bpmn:sequenceFlow id="Flow_1dfyoe6" name="Is CN ?" sourceRef="Gateway_1baxf7k" targetRef="Activity_0v2hxmv"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("networkType") == "CN"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1bbqkjv" sourceRef="Activity_192bdyv" targetRef="Event_103vvkf" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ModifySliceSubnet"> + <bpmndi:BPMNEdge id="Flow_0usuozn_di" bpmnElement="Flow_0usuozn"> + <di:waypoint x="830" y="245" /> + <di:waypoint x="830" y="140" /> + <di:waypoint x="920" y="140" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="794" y="149" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_15luvlg_di" bpmnElement="Flow_15luvlg"> + <di:waypoint x="830" y="295" /> + <di:waypoint x="830" y="380" /> + <di:waypoint x="920" y="380" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="830" y="365" width="36" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1dfyoe6_di" bpmnElement="Flow_1dfyoe6"> + <di:waypoint x="855" y="270" /> + <di:waypoint x="920" y="270" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="865" y="252" width="37" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ps6iyc_di" bpmnElement="Flow_0ps6iyc"> + <di:waypoint x="740" y="270" /> + <di:waypoint x="805" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1q030ul_di" bpmnElement="Flow_1q030ul"> + <di:waypoint x="590" y="270" /> + <di:waypoint x="640" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fzchbl_di" bpmnElement="Flow_0fzchbl"> + <di:waypoint x="310" y="270" /> + <di:waypoint x="340" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1t0w8dn_di" bpmnElement="Flow_1t0w8dn"> + <di:waypoint x="188" y="270" /> + <di:waypoint x="210" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1grhlet_di" bpmnElement="Flow_1grhlet"> + <di:waypoint x="440" y="270" /> + <di:waypoint x="490" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b2k523_di" bpmnElement="Flow_1b2k523"> + <di:waypoint x="1020" y="140" /> + <di:waypoint x="1110" y="140" /> + <di:waypoint x="1110" y="252" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0pklfqu_di" bpmnElement="Flow_0pklfqu"> + <di:waypoint x="1020" y="270" /> + <di:waypoint x="1092" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1bbqkjv_di" bpmnElement="Flow_1bbqkjv"> + <di:waypoint x="1020" y="380" /> + <di:waypoint x="1110" y="380" /> + <di:waypoint x="1110" y="288" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Activity_1dzkfh2_di" bpmnElement="Activity_1dzkfh2"> + <dc:Bounds x="640" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1baxf7k_di" bpmnElement="Gateway_1baxf7k" isMarkerVisible="true"> + <dc:Bounds x="805" y="245" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="787" y="288" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_103vvkf_di" bpmnElement="Event_103vvkf"> + <dc:Bounds x="1092" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ptby3d_di" bpmnElement="Activity_0ptby3d"> + <dc:Bounds x="490" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_05idy03_di" bpmnElement="Event_05idy03"> + <dc:Bounds x="152" y="252" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="295" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0kd9pxx_di" bpmnElement="Activity_0kd9pxx"> + <dc:Bounds x="210" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1s8ojcr_di" bpmnElement="Activity_1s8ojcr"> + <dc:Bounds x="340" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0t1g4mp_di" bpmnElement="Activity_0t1g4mp"> + <dc:Bounds x="920" y="100" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0v2hxmv_di" bpmnElement="Activity_0v2hxmv"> + <dc:Bounds x="920" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_192bdyv_di" bpmnElement="Activity_192bdyv"> + <dc:Bounds x="920" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn index a1d4178962..8ff1a1efec 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn @@ -12,19 +12,21 @@ <bpmn:incoming>Flow_10jgbxm</bpmn:incoming> <bpmn:terminateEventDefinition id="TerminateEventDefinition_1pnutu7" /> </bpmn:endEvent> - <bpmn:exclusiveGateway id="Gateway_02fectw" default="Flow_0y1ebox"> + <bpmn:exclusiveGateway id="Gateway_02fectw"> <bpmn:incoming>Flow_1y3cptr</bpmn:incoming> <bpmn:outgoing>Flow_0y1ebox</bpmn:outgoing> <bpmn:outgoing>Flow_0mbp7mv</bpmn:outgoing> + <bpmn:outgoing>Flow_19tmp99</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:endEvent id="Event_0ldlupa"> <bpmn:incoming>Flow_0y1ebox</bpmn:incoming> <bpmn:errorEventDefinition id="ErrorEventDefinition_1dih7c9" errorRef="Error_01a8p43" /> </bpmn:endEvent> - <bpmn:exclusiveGateway id="Gateway_1nr51kr" default="Flow_0mxq0qe"> - <bpmn:incoming>Flow_0trmo7s</bpmn:incoming> - <bpmn:outgoing>Flow_1z06yyv</bpmn:outgoing> + <bpmn:exclusiveGateway id="Gateway_1nr51kr"> + <bpmn:incoming>Flow_0zjsp5x</bpmn:incoming> <bpmn:outgoing>Flow_0mxq0qe</bpmn:outgoing> + <bpmn:outgoing>Flow_05x2cqc</bpmn:outgoing> + <bpmn:outgoing>Flow_02elm5b</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:endEvent id="Event_16k9r1c"> <bpmn:incoming>Flow_0mxq0qe</bpmn:incoming> @@ -40,7 +42,7 @@ <bpmn:errorEventDefinition id="ErrorEventDefinition_16r0jc3" errorRef="Error_04y00c4" /> </bpmn:endEvent> <bpmn:serviceTask id="Activity_0snmatn" name="Service Level Upgrade" camunda:delegateExpression="${ServiceLevelUpgrade}"> - <bpmn:incoming>Flow_1z06yyv</bpmn:incoming> + <bpmn:incoming>Flow_02elm5b</bpmn:incoming> <bpmn:outgoing>Flow_01gwzx9</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="Activity_0ft7fa2" name="Service Level Postcheck" camunda:delegateExpression="${ServiceLevelPostcheck}"> @@ -48,21 +50,14 @@ <bpmn:outgoing>Flow_1ru18s3</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="Activity_09bqns0" name="Service Level Preparation" camunda:delegateExpression="${ServiceLevelPreparation}"> - <bpmn:incoming>Flow_1v0mxe7</bpmn:incoming> - <bpmn:outgoing>Flow_1p4xkdj</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:scriptTask id="Activity_0qgmx7a" name="Send Response" scriptFormat="groovy"> <bpmn:incoming>Flow_1b392qs</bpmn:incoming> - <bpmn:outgoing>Flow_1v0mxe7</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() -pnfSwUpgrade.sendResponse(execution)</bpmn:script> - </bpmn:scriptTask> + <bpmn:outgoing>Flow_1ptk2a3</bpmn:outgoing> + </bpmn:serviceTask> <bpmn:scriptTask id="Activity_1n4rk7m" name="Prepare Completion" scriptFormat="groovy"> <bpmn:incoming>Flow_0l67uzl</bpmn:incoming> <bpmn:outgoing>Flow_0frhsd0</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="Activity_1lz38px" name="Complete Process" calledElement="CompleteMsoProcess"> @@ -78,7 +73,7 @@ pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> <bpmn:incoming>Flow_0iayg6u</bpmn:incoming> <bpmn:outgoing>Flow_0lb7zv5</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="Activity_0ai3z2q" name="Call FalloutHandler" calledElement="FalloutHandler"> @@ -94,24 +89,23 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <bpmn:sequenceFlow id="Flow_0iayg6u" sourceRef="Event_08f3m9h" targetRef="Activity_1k2f3ha" /> </bpmn:subProcess> <bpmn:sequenceFlow id="Flow_0nrz340" sourceRef="Event_02mc8tr" targetRef="Activity_18vue7u" /> - <bpmn:sequenceFlow id="Flow_1b392qs" sourceRef="Activity_18vue7u" targetRef="Activity_0qgmx7a" /> + <bpmn:sequenceFlow id="Flow_1b392qs" sourceRef="Activity_18vue7u" targetRef="Activity_09bqns0" /> <bpmn:sequenceFlow id="Flow_10jgbxm" sourceRef="Activity_1lz38px" targetRef="Event_12983th" /> - <bpmn:sequenceFlow id="Flow_01gwzx9" sourceRef="Activity_0snmatn" targetRef="Activity_1q4o9fx" /> - <bpmn:sequenceFlow id="Flow_0y1ebox" name="Failure" sourceRef="Gateway_02fectw" targetRef="Event_0ldlupa" /> - <bpmn:sequenceFlow id="Flow_1p4xkdj" sourceRef="Activity_09bqns0" targetRef="Activity_0n17xou" /> - <bpmn:sequenceFlow id="Flow_1z06yyv" name="Success" sourceRef="Gateway_1nr51kr" targetRef="Activity_0snmatn"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:sequenceFlow id="Flow_01gwzx9" sourceRef="Activity_0snmatn" targetRef="Activity_0e6w886" /> + <bpmn:sequenceFlow id="Flow_0y1ebox" name="Failure" sourceRef="Gateway_02fectw" targetRef="Event_0ldlupa"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${!execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0mxq0qe" name="Failure" sourceRef="Gateway_1nr51kr" targetRef="Event_16k9r1c"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${!execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="Flow_0mxq0qe" name="Failure" sourceRef="Gateway_1nr51kr" targetRef="Event_16k9r1c" /> <bpmn:sequenceFlow id="Flow_1ru18s3" sourceRef="Activity_0ft7fa2" targetRef="Gateway_1vq11i7" /> <bpmn:sequenceFlow id="Flow_1tcnzdx" name="Failure" sourceRef="Gateway_1vq11i7" targetRef="Event_03tpudy" /> <bpmn:sequenceFlow id="Flow_0l67uzl" name="Success" sourceRef="Gateway_1vq11i7" targetRef="Activity_1n4rk7m"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="Flow_1v0mxe7" sourceRef="Activity_0qgmx7a" targetRef="Activity_09bqns0" /> <bpmn:sequenceFlow id="Flow_0frhsd0" sourceRef="Activity_1n4rk7m" targetRef="Activity_1lz38px" /> <bpmn:sequenceFlow id="Flow_0mbp7mv" name="Success" sourceRef="Gateway_02fectw" targetRef="Activity_1hp67qz"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("pnfCounter") >= execution.getVariable("pnfSize")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:callActivity id="Activity_0n17xou" name="BPMN to Execute" calledElement="${healthCheckWorkflow}"> <bpmn:extensionElements> @@ -123,10 +117,9 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <camunda:in source="isRollback" target="isRollback" /> <camunda:in source="pnfName" target="pnfName" /> </bpmn:extensionElements> - <bpmn:incoming>Flow_1p4xkdj</bpmn:incoming> - <bpmn:outgoing>Flow_0trmo7s</bpmn:outgoing> + <bpmn:incoming>Flow_0rpnl02</bpmn:incoming> + <bpmn:outgoing>Flow_0zjsp5x</bpmn:outgoing> </bpmn:callActivity> - <bpmn:sequenceFlow id="Flow_0trmo7s" sourceRef="Activity_0n17xou" targetRef="Gateway_1nr51kr" /> <bpmn:callActivity id="Activity_1q4o9fx" name="BPMN to Execute" calledElement="${softwareUpgradeWorkflow}"> <bpmn:extensionElements> <camunda:in source="bpmnRequest" target="bpmnRequest" /> @@ -137,7 +130,7 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <camunda:in source="isRollback" target="isRollback" /> <camunda:in source="pnfName" target="pnfName" /> </bpmn:extensionElements> - <bpmn:incoming>Flow_01gwzx9</bpmn:incoming> + <bpmn:incoming>Flow_0g6gkgx</bpmn:incoming> <bpmn:outgoing>Flow_1y3cptr</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="Flow_1y3cptr" sourceRef="Activity_1q4o9fx" targetRef="Gateway_02fectw" /> @@ -151,7 +144,7 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <bpmn:outgoing>Flow_05ohtnj</bpmn:outgoing> <bpmn:outgoing>Flow_0ny61qm</bpmn:outgoing> </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="Flow_05ohtnj" name="Success " sourceRef="Gateway_18ch73t" targetRef="Activity_0ft7fa2"> + <bpmn:sequenceFlow id="Flow_05ohtnj" name="Success " sourceRef="Gateway_18ch73t" targetRef="Activity_0ft7fa2"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="Event_1fhov6x"> @@ -159,6 +152,29 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <bpmn:errorEventDefinition id="ErrorEventDefinition_0od3xnw" errorRef="Error_01a8p43" /> </bpmn:endEvent> <bpmn:sequenceFlow id="Flow_0ny61qm" name="Failure " sourceRef="Gateway_18ch73t" targetRef="Event_1fhov6x" /> + <bpmn:sequenceFlow id="Flow_1ptk2a3" sourceRef="Activity_09bqns0" targetRef="Activity_02vp5np" /> + <bpmn:sequenceFlow id="Flow_0rpnl02" sourceRef="Activity_02vp5np" targetRef="Activity_0n17xou" /> + <bpmn:sequenceFlow id="Flow_0g6gkgx" sourceRef="Activity_0e6w886" targetRef="Activity_1q4o9fx" /> + <bpmn:sequenceFlow id="Flow_0zjsp5x" sourceRef="Activity_0n17xou" targetRef="Gateway_1nr51kr" /> + <bpmn:sequenceFlow id="Flow_19tmp99" name="pick next pnf" sourceRef="Gateway_02fectw" targetRef="Activity_0e6w886"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("pnfCounter") < execution.getVariable("pnfSize")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_05x2cqc" name="pick next pnf" sourceRef="Gateway_1nr51kr" targetRef="Activity_02vp5np"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("pnfCounter") < execution.getVariable("pnfSize")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_02elm5b" name="Success" sourceRef="Gateway_1nr51kr" targetRef="Activity_0snmatn"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("pnfCounter") >= execution.getVariable("pnfSize")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="Activity_02vp5np" name="Pnf Counter Execution for HC" camunda:expression="${ServiceLevelPreparation.pnfCounterExecution(execution)}"> + <bpmn:incoming>Flow_1ptk2a3</bpmn:incoming> + <bpmn:incoming>Flow_05x2cqc</bpmn:incoming> + <bpmn:outgoing>Flow_0rpnl02</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="Activity_0e6w886" name="Pnf Counter Execution for SWU" camunda:expression="${ServiceLevelUpgrade.pnfCounterExecution(execution)}"> + <bpmn:incoming>Flow_01gwzx9</bpmn:incoming> + <bpmn:incoming>Flow_19tmp99</bpmn:incoming> + <bpmn:outgoing>Flow_0g6gkgx</bpmn:outgoing> + </bpmn:serviceTask> </bpmn:process> <bpmn:error id="Error_01a8p43" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn:error id="Error_0e5owqi" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> @@ -166,212 +182,237 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <bpmn:error id="Error_04y00c4" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ServiceLevelUpgrade"> + <bpmndi:BPMNEdge id="Flow_02elm5b_di" bpmnElement="Flow_02elm5b"> + <di:waypoint x="1140" y="198" /> + <di:waypoint x="1140" y="240" /> + <di:waypoint x="210" y="240" /> + <di:waypoint x="210" y="330" /> + <di:waypoint x="262" y="330" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1148" y="222" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_05x2cqc_di" bpmnElement="Flow_05x2cqc"> + <di:waypoint x="1140" y="166" /> + <di:waypoint x="1140" y="100" /> + <di:waypoint x="810" y="100" /> + <di:waypoint x="810" y="142" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="944" y="82" width="63" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_19tmp99_di" bpmnElement="Flow_19tmp99"> + <di:waypoint x="804" y="314" /> + <di:waypoint x="804" y="260" /> + <di:waypoint x="488" y="260" /> + <di:waypoint x="488" y="290" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="616" y="242" width="63" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0zjsp5x_di" bpmnElement="Flow_0zjsp5x"> + <di:waypoint x="1030" y="182" /> + <di:waypoint x="1124" y="182" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0g6gkgx_di" bpmnElement="Flow_0g6gkgx"> + <di:waypoint x="538" y="330" /> + <di:waypoint x="590" y="330" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0rpnl02_di" bpmnElement="Flow_0rpnl02"> + <di:waypoint x="860" y="182" /> + <di:waypoint x="930" y="182" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ptk2a3_di" bpmnElement="Flow_1ptk2a3"> + <di:waypoint x="600" y="182" /> + <di:waypoint x="760" y="182" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0ny61qm_di" bpmnElement="Flow_0ny61qm"> - <di:waypoint x="1190" y="278" /> - <di:waypoint x="1190" y="334" /> + <di:waypoint x="1140" y="346" /> + <di:waypoint x="1140" y="404" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1152" y="290" width="35" height="27" /> + <dc:Bounds x="1102" y="362" width="35" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_05ohtnj_di" bpmnElement="Flow_05ohtnj"> - <di:waypoint x="1206" y="262" /> - <di:waypoint x="1300" y="262" /> - <di:waypoint x="1300" y="372" /> + <di:waypoint x="1156" y="330" /> + <di:waypoint x="1310" y="330" /> + <di:waypoint x="1310" y="490" /> + <di:waypoint x="1190" y="490" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1232" y="244" width="43" height="40" /> + <dc:Bounds x="1318" y="406" width="43" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0dyc3kv_di" bpmnElement="Flow_0dyc3kv"> - <di:waypoint x="1120" y="262" /> - <di:waypoint x="1174" y="262" /> + <di:waypoint x="1030" y="330" /> + <di:waypoint x="1124" y="330" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1y3cptr_di" bpmnElement="Flow_1y3cptr"> - <di:waypoint x="860" y="262" /> - <di:waypoint x="904" y="262" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_0trmo7s_di" bpmnElement="Flow_0trmo7s"> - <di:waypoint x="450" y="262" /> - <di:waypoint x="501" y="262" /> + <di:waypoint x="690" y="330" /> + <di:waypoint x="788" y="330" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0mbp7mv_di" bpmnElement="Flow_0mbp7mv"> - <di:waypoint x="936" y="262" /> - <di:waypoint x="1020" y="262" /> + <di:waypoint x="820" y="330" /> + <di:waypoint x="930" y="330" /> <bpmndi:BPMNLabel> - <dc:Bounds x="948" y="248" width="43" height="14" /> + <dc:Bounds x="845" y="316" width="43" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0frhsd0_di" bpmnElement="Flow_0frhsd0"> - <di:waypoint x="312" y="482" /> - <di:waypoint x="372" y="482" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_1v0mxe7_di" bpmnElement="Flow_1v0mxe7"> - <di:waypoint x="532" y="122" /> - <di:waypoint x="562" y="122" /> - <di:waypoint x="562" y="192" /> - <di:waypoint x="172" y="192" /> - <di:waypoint x="172" y="262" /> - <di:waypoint x="212" y="262" /> + <di:waypoint x="362" y="579" /> + <di:waypoint x="450" y="579" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0l67uzl_di" bpmnElement="Flow_0l67uzl"> - <di:waypoint x="1054" y="412" /> - <di:waypoint x="172" y="412" /> - <di:waypoint x="172" y="482" /> - <di:waypoint x="212" y="482" /> + <di:waypoint x="964" y="490" /> + <di:waypoint x="210" y="490" /> + <di:waypoint x="210" y="579" /> + <di:waypoint x="262" y="579" /> <bpmndi:BPMNLabel> - <dc:Bounds x="663" y="398" width="43" height="14" /> + <dc:Bounds x="612" y="476" width="43" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1tcnzdx_di" bpmnElement="Flow_1tcnzdx"> - <di:waypoint x="1070" y="428" /> - <di:waypoint x="1070" y="494" /> + <di:waypoint x="980" y="506" /> + <di:waypoint x="980" y="554" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1032" y="451" width="35" height="14" /> + <dc:Bounds x="942" y="526" width="35" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1ru18s3_di" bpmnElement="Flow_1ru18s3"> - <di:waypoint x="1250" y="412" /> - <di:waypoint x="1086" y="412" /> + <di:waypoint x="1090" y="490" /> + <di:waypoint x="996" y="490" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0mxq0qe_di" bpmnElement="Flow_0mxq0qe"> - <di:waypoint x="517" y="278" /> - <di:waypoint x="517" y="334" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="472" y="296" width="35" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_1z06yyv_di" bpmnElement="Flow_1z06yyv"> - <di:waypoint x="533" y="262" /> - <di:waypoint x="590" y="262" /> + <di:waypoint x="1156" y="182" /> + <di:waypoint x="1284" y="182" /> <bpmndi:BPMNLabel> - <dc:Bounds x="540" y="248" width="43" height="14" /> + <dc:Bounds x="1192" y="163" width="35" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_1p4xkdj_di" bpmnElement="Flow_1p4xkdj"> - <di:waypoint x="312" y="262" /> - <di:waypoint x="350" y="262" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0y1ebox_di" bpmnElement="Flow_0y1ebox"> - <di:waypoint x="920" y="278" /> - <di:waypoint x="918" y="335" /> + <di:waypoint x="804" y="346" /> + <di:waypoint x="804" y="414" /> <bpmndi:BPMNLabel> - <dc:Bounds x="879" y="296" width="35" height="14" /> + <dc:Bounds x="813" y="374" width="35" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_01gwzx9_di" bpmnElement="Flow_01gwzx9"> - <di:waypoint x="690" y="262" /> - <di:waypoint x="760" y="262" /> + <di:waypoint x="362" y="330" /> + <di:waypoint x="438" y="330" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_10jgbxm_di" bpmnElement="Flow_10jgbxm"> - <di:waypoint x="472" y="482" /> - <di:waypoint x="524" y="480" /> + <di:waypoint x="550" y="580" /> + <di:waypoint x="624" y="580" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1b392qs_di" bpmnElement="Flow_1b392qs"> - <di:waypoint x="362" y="122" /> - <di:waypoint x="432" y="122" /> + <di:waypoint x="362" y="182" /> + <di:waypoint x="500" y="182" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0nrz340_di" bpmnElement="Flow_0nrz340"> - <di:waypoint x="186" y="120" /> - <di:waypoint x="262" y="122" /> + <di:waypoint x="186" y="180" /> + <di:waypoint x="262" y="182" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="Event_02mc8tr_di" bpmnElement="Event_02mc8tr"> - <dc:Bounds x="154" y="104" width="32" height="32" /> + <dc:Bounds x="154" y="164" width="32" height="32" /> <bpmndi:BPMNLabel> <dc:Bounds x="-6" y="-188" width="51" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_18vue7u_di" bpmnElement="Activity_18vue7u"> - <dc:Bounds x="262" y="82" width="100" height="80" /> + <dc:Bounds x="262" y="142" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_02fectw_di" bpmnElement="Gateway_02fectw" isMarkerVisible="true"> + <dc:Bounds x="788" y="314" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1nr51kr_di" bpmnElement="Gateway_1nr51kr" isMarkerVisible="true"> + <dc:Bounds x="1124" y="166" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_16k9r1c_di" bpmnElement="Event_16k9r1c"> + <dc:Bounds x="1284" y="166" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0snmatn_di" bpmnElement="Activity_0snmatn"> + <dc:Bounds x="262" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_09bqns0_di" bpmnElement="Activity_09bqns0"> + <dc:Bounds x="500" y="142" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0ldlupa_di" bpmnElement="Event_0ldlupa"> + <dc:Bounds x="788" y="414" width="32" height="32" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1lz38px_di" bpmnElement="Activity_1lz38px"> + <dc:Bounds x="450" y="539" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1n4rk7m_di" bpmnElement="Activity_1n4rk7m"> + <dc:Bounds x="262" y="539" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_12983th_di" bpmnElement="Event_12983th"> - <dc:Bounds x="524" y="464" width="32" height="32" /> + <dc:Bounds x="624" y="565" width="32" height="32" /> <bpmndi:BPMNLabel> <dc:Bounds x="-132" y="-188" width="20" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Gateway_02fectw_di" bpmnElement="Gateway_02fectw" isMarkerVisible="true"> - <dc:Bounds x="904" y="246" width="32" height="32" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_0ldlupa_di" bpmnElement="Event_0ldlupa"> - <dc:Bounds x="905" y="334" width="32" height="32" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Gateway_1nr51kr_di" bpmnElement="Gateway_1nr51kr" isMarkerVisible="true"> - <dc:Bounds x="501" y="246" width="32" height="32" /> + <bpmndi:BPMNShape id="Activity_0n17xou_di" bpmnElement="Activity_0n17xou"> + <dc:Bounds x="930" y="142" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_16k9r1c_di" bpmnElement="Event_16k9r1c"> - <dc:Bounds x="501" y="334" width="32" height="32" /> + <bpmndi:BPMNShape id="Activity_1q4o9fx_di" bpmnElement="Activity_1q4o9fx"> + <dc:Bounds x="590" y="290" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Gateway_1vq11i7_di" bpmnElement="Gateway_1vq11i7" isMarkerVisible="true"> - <dc:Bounds x="1054" y="396" width="32" height="32" /> + <bpmndi:BPMNShape id="Activity_1hp67qz_di" bpmnElement="Activity_1hp67qz"> + <dc:Bounds x="930" y="290" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_03tpudy_di" bpmnElement="Event_03tpudy"> - <dc:Bounds x="1054" y="494" width="32" height="32" /> + <bpmndi:BPMNShape id="Gateway_18ch73t_di" bpmnElement="Gateway_18ch73t" isMarkerVisible="true"> + <dc:Bounds x="1124" y="314" width="32" height="32" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0snmatn_di" bpmnElement="Activity_0snmatn"> - <dc:Bounds x="590" y="222" width="100" height="80" /> + <bpmndi:BPMNShape id="Event_1fhov6x_di" bpmnElement="Event_1fhov6x"> + <dc:Bounds x="1124" y="404" width="32" height="32" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0ft7fa2_di" bpmnElement="Activity_0ft7fa2"> - <dc:Bounds x="1250" y="372" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_1bjlebw_di" bpmnElement="Activity_02vp5np"> + <dc:Bounds x="760" y="142" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_09bqns0_di" bpmnElement="Activity_09bqns0"> - <dc:Bounds x="212" y="222" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_1knf0nl_di" bpmnElement="Activity_0e6w886"> + <dc:Bounds x="438" y="290" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0qgmx7a_di" bpmnElement="Activity_0qgmx7a"> - <dc:Bounds x="432" y="82" width="100" height="80" /> + <bpmndi:BPMNShape id="Event_03tpudy_di" bpmnElement="Event_03tpudy"> + <dc:Bounds x="964" y="554" width="32" height="32" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_1n4rk7m_di" bpmnElement="Activity_1n4rk7m"> - <dc:Bounds x="212" y="442" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_0ft7fa2_di" bpmnElement="Activity_0ft7fa2"> + <dc:Bounds x="1090" y="450" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_1lz38px_di" bpmnElement="Activity_1lz38px"> - <dc:Bounds x="372" y="442" width="100" height="80" /> + <bpmndi:BPMNShape id="Gateway_1vq11i7_di" bpmnElement="Gateway_1vq11i7" isMarkerVisible="true"> + <dc:Bounds x="964" y="474" width="32" height="32" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0ui6tp1_di" bpmnElement="Activity_0ui6tp1" isExpanded="true"> - <dc:Bounds x="362" y="572" width="650" height="190" /> + <dc:Bounds x="362" y="810" width="650" height="190" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="Flow_0iayg6u_di" bpmnElement="Flow_0iayg6u"> - <di:waypoint x="466" y="670" /> - <di:waypoint x="532" y="672" /> + <di:waypoint x="466" y="908" /> + <di:waypoint x="532" y="910" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0lb7zv5_di" bpmnElement="Flow_0lb7zv5"> - <di:waypoint x="632" y="672" /> - <di:waypoint x="702" y="672" /> + <di:waypoint x="632" y="910" /> + <di:waypoint x="702" y="910" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1peoyur_di" bpmnElement="Flow_1peoyur"> - <di:waypoint x="802" y="672" /> - <di:waypoint x="874" y="670" /> + <di:waypoint x="802" y="910" /> + <di:waypoint x="874" y="908" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="Event_08f3m9h_di" bpmnElement="Event_08f3m9h"> - <dc:Bounds x="434" y="654" width="32" height="32" /> + <dc:Bounds x="434" y="892" width="32" height="32" /> <bpmndi:BPMNLabel> <dc:Bounds x="-161" y="-188" width="78" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1k2f3ha_di" bpmnElement="Activity_1k2f3ha"> - <dc:Bounds x="532" y="632" width="100" height="80" /> + <dc:Bounds x="532" y="870" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0ai3z2q_di" bpmnElement="Activity_0ai3z2q"> - <dc:Bounds x="702" y="632" width="100" height="80" /> + <dc:Bounds x="702" y="870" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_0ngb9wx_di" bpmnElement="Event_0ngb9wx"> - <dc:Bounds x="874" y="654" width="32" height="32" /> + <dc:Bounds x="874" y="892" width="32" height="32" /> <bpmndi:BPMNLabel> <dc:Bounds x="-132" y="-188" width="20" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0n17xou_di" bpmnElement="Activity_0n17xou"> - <dc:Bounds x="350" y="222" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_1q4o9fx_di" bpmnElement="Activity_1q4o9fx"> - <dc:Bounds x="760" y="222" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_1hp67qz_di" bpmnElement="Activity_1hp67qz"> - <dc:Bounds x="1020" y="222" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Gateway_18ch73t_di" bpmnElement="Gateway_18ch73t" isMarkerVisible="true"> - <dc:Bounds x="1174" y="246" width="32" height="32" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Event_1fhov6x_di" bpmnElement="Event_1fhov6x"> - <dc:Bounds x="1174" y="334" width="32" height="32" /> - </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateAccessNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateAccessNSSI.bpmn new file mode 100644 index 0000000000..d81f5465b3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateAccessNSSI.bpmn @@ -0,0 +1,1012 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0rh5ux5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoActivateAccessNSSI" name="DoActivateAccessNSSI" isExecutable="true"> + <bpmn:startEvent id="Event_055gbp2" name="Start"> + <bpmn:outgoing>Flow_0rh43xe</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="Flow_0rh43xe" sourceRef="Event_055gbp2" targetRef="Activity_1fv6ljk" /> + <bpmn:sequenceFlow id="Flow_14z4acw" sourceRef="Activity_1fv6ljk" targetRef="Activity_089t9fj" /> + <bpmn:exclusiveGateway id="Gateway_12oq1sa" name="Should update AN NF SP status?" default="Flow_0523saw"> + <bpmn:incoming>Flow_00yl2jk</bpmn:incoming> + <bpmn:outgoing>Flow_00fb28f</bpmn:outgoing> + <bpmn:outgoing>Flow_0523saw</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_00yl2jk" sourceRef="Activity_1atych2" targetRef="Gateway_12oq1sa" /> + <bpmn:sequenceFlow id="Flow_00fb28f" sourceRef="Gateway_12oq1sa" targetRef="Activity_0iluozh"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("shouldChangeAN_NF_SPStatus") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:intermediateThrowEvent id="Event_1n5z71a" name="Goto TN NSSI Activation"> + <bpmn:incoming>Flow_0mtkhmv</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0x6han6" name="TNNSSIActivation" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="Event_0kkeo9m" name="TN NSSI Activation"> + <bpmn:outgoing>Flow_1q7frye</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_0j5y3mw" name="TNNSSIActivation" /> + </bpmn:intermediateCatchEvent> + <bpmn:intermediateThrowEvent id="Event_09ey569" name="Goto AN NSSI Activation"> + <bpmn:incoming>Flow_1b6vtso</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_05qiudr" name="AN_NSSI_Activation" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_0523saw" sourceRef="Gateway_12oq1sa" targetRef="Event_0rzo7gj" /> + <bpmn:intermediateThrowEvent id="Event_0rzo7gj" name="Check TN NSSI Activation"> + <bpmn:incoming>Flow_0523saw</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0s7s95j" name="TNNSSIActivation" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_1cnfilb" sourceRef="Event_1azfo77" targetRef="Activity_1j0xkqc" /> + <bpmn:endEvent id="Event_0gx3ps0" name="End"> + <bpmn:incoming>Flow_1876ml0</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_10f44ab" sourceRef="Activity_089t9fj" targetRef="Activity_19myg2v" /> + <bpmn:exclusiveGateway id="Gateway_0xcg677" name="shouldChangeSPStatus?" default="Flow_0g9k299"> + <bpmn:incoming>Flow_0uxerfg</bpmn:incoming> + <bpmn:outgoing>Flow_00vt4gf</bpmn:outgoing> + <bpmn:outgoing>Flow_0g9k299</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0uxerfg" sourceRef="Activity_19myg2v" targetRef="Gateway_0xcg677" /> + <bpmn:sequenceFlow id="Flow_00vt4gf" name="Yes" sourceRef="Gateway_0xcg677" targetRef="Activity_1atych2"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("shouldChangeSPStatus") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0g9k299" name="No" sourceRef="Gateway_0xcg677" targetRef="Event_0ocuo1o" /> + <bpmn:exclusiveGateway id="Gateway_0nr3me0" name="Shoud updateTN FH SP status" default="Flow_10b15um"> + <bpmn:incoming>Flow_1yd57bl</bpmn:incoming> + <bpmn:outgoing>Flow_0zjaac9</bpmn:outgoing> + <bpmn:outgoing>Flow_10b15um</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_1yd57bl" sourceRef="Activity_1fzg56b" targetRef="Gateway_0nr3me0" /> + <bpmn:sequenceFlow id="Flow_1q7frye" sourceRef="Event_0kkeo9m" targetRef="Activity_1fzg56b" /> + <bpmn:sequenceFlow id="Flow_0zjaac9" name="Yes" sourceRef="Gateway_0nr3me0" targetRef="Activity_0gtw2p7"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("shouldChangeTN_FH_SPStatus") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_10b15um" sourceRef="Gateway_0nr3me0" targetRef="Event_1nqpg0o" /> + <bpmn:intermediateCatchEvent id="Event_0j998yp" name="TN MH NSSI Activation"> + <bpmn:outgoing>Flow_0wvzz2r</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1jmgd64" name="TNMHNSSIActivation" /> + </bpmn:intermediateCatchEvent> + <bpmn:intermediateThrowEvent id="Event_1nqpg0o" name="Call TN MH NSSI Activation"> + <bpmn:incoming>Flow_10b15um</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_1fw9349" name="TNMHNSSIActivation" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateThrowEvent id="Event_0ki3ncn" name="GotoTN MH NSSI Activation"> + <bpmn:incoming>Flow_1qszzfv</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_1hh8o8h" name="TNMHNSSIActivation" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateThrowEvent id="Event_1djcl9x" name="Ca AN NSSI Activation"> + <bpmn:incoming>Flow_00clpwn</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_02qbzt2" name="AN_NSSI_Activation" /> + </bpmn:intermediateThrowEvent> + <bpmn:exclusiveGateway id="Gateway_0cemhjv" name="Shoud updateTN MH SP status" default="Flow_00clpwn"> + <bpmn:incoming>Flow_0q02qno</bpmn:incoming> + <bpmn:outgoing>Flow_00clpwn</bpmn:outgoing> + <bpmn:outgoing>Flow_147tw7h</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0q02qno" sourceRef="Activity_068a0cy" targetRef="Gateway_0cemhjv" /> + <bpmn:sequenceFlow id="Flow_00clpwn" sourceRef="Gateway_0cemhjv" targetRef="Event_1djcl9x" /> + <bpmn:sequenceFlow id="Flow_0wvzz2r" sourceRef="Event_0j998yp" targetRef="Activity_068a0cy" /> + <bpmn:sequenceFlow id="Flow_147tw7h" sourceRef="Gateway_0cemhjv" targetRef="Activity_02vl5kt"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("shouldChangeTN_MH_SPStatus") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="Activity_089t9fj" name="Fetch Related NSSIs and Slice profile" scriptFormat="groovy"> + <bpmn:incoming>Flow_14z4acw</bpmn:incoming> + <bpmn:outgoing>Flow_10f44ab</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.getRelatedInstances(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1fv6ljk" name="Preprocess request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0rh43xe</bpmn:incoming> + <bpmn:outgoing>Flow_14z4acw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_19myg2v" name="Check AN Slice profile status" scriptFormat="groovy"> + <bpmn:incoming>Flow_10f44ab</bpmn:incoming> + <bpmn:outgoing>Flow_0uxerfg</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.getSPOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1atych2" name="Check Orchestration status of AN NF sliceprofile" scriptFormat="groovy"> + <bpmn:incoming>Flow_00vt4gf</bpmn:incoming> + <bpmn:outgoing>Flow_00yl2jk</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.getAnNfSPOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0iluozh" name="Prepare RAN NF NSSI activation request" scriptFormat="groovy"> + <bpmn:incoming>Flow_00fb28f</bpmn:incoming> + <bpmn:outgoing>Flow_1gxv9id</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.prepareSdnrActivationRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_0u2aqld" name="Call SDNR subprocess" calledElement="DoHandleSdnrDmaapRequest"> + <bpmn:extensionElements> + <camunda:in source="sdnrRequest" target="sdnrRequest" /> + <camunda:in source="SDNR_messageType" target="messageType" /> + <camunda:in source="SDNR_timeout" target="timeout" /> + <camunda:in source="msoRequestId" target="correlator" /> + <camunda:out source="asyncCallbackResponse" target="SDNR_Response" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1gxv9id</bpmn:incoming> + <bpmn:outgoing>Flow_0o7xomf</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1gxv9id" sourceRef="Activity_0iluozh" targetRef="Activity_0u2aqld" /> + <bpmn:scriptTask id="Activity_1hr68mt" name="Process sdnr response" scriptFormat="groovy"> + <bpmn:incoming>Flow_0o7xomf</bpmn:incoming> + <bpmn:outgoing>Flow_1myzbqw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.processSdnrResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1xwu5f0" name="Is Success response" default="Flow_1v4zg98"> + <bpmn:incoming>Flow_1myzbqw</bpmn:incoming> + <bpmn:outgoing>Flow_1yrel0t</bpmn:outgoing> + <bpmn:outgoing>Flow_1v4zg98</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_0yfi3mj" name="ActivationWorkflowError"> + <bpmn:incoming>Flow_1v4zg98</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1n2vwxe" errorRef="Error_1beg2za" /> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_03sbng2" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1sroz8o</bpmn:incoming> + <bpmn:outgoing>Flow_0rizzsm</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator..prepareUpdateJobStatus(execution,"processing","40","AN NF NSSI activation completed")</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_08yj5gq" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0rizzsm</bpmn:incoming> + <bpmn:outgoing>Flow_0mtkhmv</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1yrel0t" name="Yes" sourceRef="Gateway_1xwu5f0" targetRef="Activity_09e5oh6"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isANactivationSuccess") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1v4zg98" sourceRef="Gateway_1xwu5f0" targetRef="Event_0yfi3mj" /> + <bpmn:sequenceFlow id="Flow_0rizzsm" sourceRef="Activity_03sbng2" targetRef="Activity_08yj5gq" /> + <bpmn:sequenceFlow id="Flow_0o7xomf" sourceRef="Activity_0u2aqld" targetRef="Activity_1hr68mt" /> + <bpmn:sequenceFlow id="Flow_1myzbqw" sourceRef="Activity_1hr68mt" targetRef="Gateway_1xwu5f0" /> + <bpmn:sequenceFlow id="Flow_1sroz8o" sourceRef="Activity_09e5oh6" targetRef="Activity_03sbng2" /> + <bpmn:subProcess id="Activity_1aesimf" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_156ogc4"> + <bpmn:outgoing>Flow_0tw7xsp</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_06h72ej" errorRef="Error_1beg2za" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1n2qjvx"> + <bpmn:incoming>Flow_0y0r82m</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_1eedm9e" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_1bqk5yt</bpmn:incoming> + <bpmn:outgoing>Flow_0y0r82m</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1szd5yp" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_075rb1i</bpmn:incoming> + <bpmn:outgoing>Flow_1bqk5yt</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:scriptTask id="Activity_0lpw3j7" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0tw7xsp</bpmn:incoming> + <bpmn:outgoing>Flow_075rb1i</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.prepareUpdateJobStatus(execution,"failed","0","AN NSSI activation Failed")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0y0r82m" sourceRef="Activity_1eedm9e" targetRef="Event_1n2qjvx" /> + <bpmn:sequenceFlow id="Flow_075rb1i" sourceRef="Activity_0lpw3j7" targetRef="Activity_1szd5yp" /> + <bpmn:sequenceFlow id="Flow_0tw7xsp" sourceRef="Event_156ogc4" targetRef="Activity_0lpw3j7" /> + <bpmn:sequenceFlow id="Flow_1bqk5yt" sourceRef="Activity_1szd5yp" targetRef="Activity_1eedm9e" /> + </bpmn:subProcess> + <bpmn:subProcess id="Activity_0hioign" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:scriptTask id="Activity_1f3cipf" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_0cvs8zk</bpmn:incoming> + <bpmn:outgoing>Flow_01jdnrt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:endEvent id="Event_18qzt1n"> + <bpmn:incoming>Flow_01jdnrt</bpmn:incoming> + </bpmn:endEvent> + <bpmn:startEvent id="Event_0lvvn7i"> + <bpmn:outgoing>Flow_0cvs8zk</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0c93dlp" /> + </bpmn:startEvent> + <bpmn:sequenceFlow id="Flow_01jdnrt" sourceRef="Activity_1f3cipf" targetRef="Event_18qzt1n" /> + <bpmn:sequenceFlow id="Flow_0cvs8zk" sourceRef="Event_0lvvn7i" targetRef="Activity_1f3cipf" /> + </bpmn:subProcess> + <bpmn:scriptTask id="Activity_09e5oh6" name="Update RAN NF NSSI and SP status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1yrel0t</bpmn:incoming> + <bpmn:outgoing>Flow_1sroz8o</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.updateAnNfStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0mtkhmv" sourceRef="Activity_08yj5gq" targetRef="Event_1n5z71a" /> + <bpmn:scriptTask id="Activity_1fzg56b" name="Check TN FH Slice profile status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1q7frye</bpmn:incoming> + <bpmn:outgoing>Flow_1yd57bl</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.getTnFhSPOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0gtw2p7" name="Handle TN FH NSSI Activation" scriptFormat="groovy"> + <bpmn:incoming>Flow_0zjaac9</bpmn:incoming> + <bpmn:outgoing>Flow_0heuc95</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.doTnFhNssiActivation(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_07cr1m2" name="Prepare job status query" scriptFormat="groovy"> + <bpmn:incoming>Flow_0heuc95</bpmn:incoming> + <bpmn:outgoing>Flow_1w3h345</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String jobId = execution.getVariable("TN_FH_jobId") +String networkType="tn" +String nssiid=execution.getVariable("tnFhNssiId") + +def def activator = new DoActivateAccessNSSI() +activator.prepareQueryJobStatus(execution, jobId,networkType, nssiid)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_03hbxfi" name="QueryJobStatus" calledElement="QueryJobStatus"> + <bpmn:extensionElements> + <camunda:in source="tn_esrInfo" target="esrInfo" /> + <camunda:in source="tn_responseId" target="responseId" /> + <camunda:in source="TN_FH_jobId" target="jobId" /> + <camunda:in source="tn_serviceInfo" target="serviceInfo" /> + <camunda:out source="responseDescriptor" target="tn_responseDescriptor" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1w3h345</bpmn:incoming> + <bpmn:outgoing>Flow_16pqv7g</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_0br2i5b" name="Validate jobstatus" scriptFormat="groovy"> + <bpmn:incoming>Flow_16pqv7g</bpmn:incoming> + <bpmn:outgoing>Flow_1i0s8nu</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String responseDescriptor = execution.getVariable("tn_responseDescriptor") + +def activator = new DoActivateAccessNSSI() +activator.validateJobStatus(execution, responseDescriptor)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1ot96tc" name="Is Job complete?" default="Flow_0ajre96"> + <bpmn:incoming>Flow_1i0s8nu</bpmn:incoming> + <bpmn:outgoing>Flow_0bukcmf</bpmn:outgoing> + <bpmn:outgoing>Flow_0ajre96</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_1w3h345" sourceRef="Activity_07cr1m2" targetRef="Activity_03hbxfi" /> + <bpmn:sequenceFlow id="Flow_16pqv7g" sourceRef="Activity_03hbxfi" targetRef="Activity_0br2i5b" /> + <bpmn:sequenceFlow id="Flow_1i0s8nu" sourceRef="Activity_0br2i5b" targetRef="Gateway_1ot96tc" /> + <bpmn:sequenceFlow id="Flow_0heuc95" sourceRef="Activity_0gtw2p7" targetRef="Activity_07cr1m2" /> + <bpmn:sequenceFlow id="Flow_0bukcmf" name="Yes" sourceRef="Gateway_1ot96tc" targetRef="Activity_1xirwg3"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isSuccess") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0ajre96" sourceRef="Gateway_1ot96tc" targetRef="Event_0uco28x" /> + <bpmn:endEvent id="Event_0uco28x" name="ActivationWorkflowError"> + <bpmn:incoming>Flow_0ajre96</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0p0lfhq" errorRef="Error_1beg2za" /> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_1t28p4r" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1ldkgyg</bpmn:incoming> + <bpmn:outgoing>Flow_1qszzfv</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1ldkgyg" sourceRef="Activity_1o0a55b" targetRef="Activity_1t28p4r" /> + <bpmn:sequenceFlow id="Flow_1qszzfv" sourceRef="Activity_1t28p4r" targetRef="Event_0ki3ncn" /> + <bpmn:scriptTask id="Activity_1o0a55b" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1b95clk</bpmn:incoming> + <bpmn:outgoing>Flow_1ldkgyg</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.prepareUpdateJobStatus(execution,"processing","60","TN FH NSSI activation completed")</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_068a0cy" name="Check TN MH Slice profile status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0wvzz2r</bpmn:incoming> + <bpmn:outgoing>Flow_0q02qno</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.getTnMhSPOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:intermediateCatchEvent id="Event_1azfo77" name="AN NSSI Activation"> + <bpmn:outgoing>Flow_1cnfilb</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_05vnzdd" name="AN_NSSI_Activation" /> + </bpmn:intermediateCatchEvent> + <bpmn:scriptTask id="Activity_02vl5kt" name="Handle TN MH NSSI Activation" scriptFormat="groovy"> + <bpmn:incoming>Flow_147tw7h</bpmn:incoming> + <bpmn:outgoing>Flow_1s0xcf5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +def activator = new DoActivateAccessNSSI() +activator.doTnMhNssiActivation(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1kszh5k" name="Prepare job status query" scriptFormat="groovy"> + <bpmn:incoming>Flow_1s0xcf5</bpmn:incoming> + <bpmn:outgoing>Flow_0sqsq1x</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String jobId = execution.getVariable("TN_MH_jobId") +String networkType="tn" +String nssiid=execution.getVariable("tnMhNssiId") + +def def activator = new DoActivateAccessNSSI() +activator.prepareQueryJobStatus(execution, jobId,networkType, nssiid)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_09jt4b0" name="QueryJobStatus" calledElement="QueryJobStatus"> + <bpmn:extensionElements> + <camunda:in source="tn_esrInfo" target="esrInfo" /> + <camunda:in source="tn_responseId" target="responseId" /> + <camunda:in source="TN_MH_jobId" target="jobId" /> + <camunda:in source="tn_serviceInfo" target="serviceInfo" /> + <camunda:out source="responseDescriptor" target="tn_responseDescriptor" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0sqsq1x</bpmn:incoming> + <bpmn:outgoing>Flow_0b7aq1k</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_1su25xm" name="Validate jobstatus" scriptFormat="groovy"> + <bpmn:incoming>Flow_0b7aq1k</bpmn:incoming> + <bpmn:outgoing>Flow_0to1idt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String responseDescriptor = execution.getVariable("tn_responseDescriptor") + +def activator = new DoActivateAccessNSSI() +activator.validateJobStatus(execution, responseDescriptor)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_114io6q" name="Is Job complete?" default="Flow_0rzuxa0"> + <bpmn:incoming>Flow_0to1idt</bpmn:incoming> + <bpmn:outgoing>Flow_1i4cc7e</bpmn:outgoing> + <bpmn:outgoing>Flow_0rzuxa0</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_08ecfyj" name="ActivationWorkflowError"> + <bpmn:incoming>Flow_0rzuxa0</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0ptrcor" errorRef="Error_1beg2za" /> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_0ftm8b6" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0k5cyz7</bpmn:incoming> + <bpmn:outgoing>Flow_1wx5w6i</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.prepareUpdateJobStatus(execution,"processing","80","TN MH NSSI activation completed")</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1xnstqr" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1wx5w6i</bpmn:incoming> + <bpmn:outgoing>Flow_1b6vtso</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0sqsq1x" sourceRef="Activity_1kszh5k" targetRef="Activity_09jt4b0" /> + <bpmn:sequenceFlow id="Flow_0b7aq1k" sourceRef="Activity_09jt4b0" targetRef="Activity_1su25xm" /> + <bpmn:sequenceFlow id="Flow_0to1idt" sourceRef="Activity_1su25xm" targetRef="Gateway_114io6q" /> + <bpmn:sequenceFlow id="Flow_1i4cc7e" name="Yes" sourceRef="Gateway_114io6q" targetRef="Activity_0xmezab"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isSuccess") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0rzuxa0" sourceRef="Gateway_114io6q" targetRef="Event_08ecfyj" /> + <bpmn:sequenceFlow id="Flow_1wx5w6i" sourceRef="Activity_0ftm8b6" targetRef="Activity_1xnstqr" /> + <bpmn:sequenceFlow id="Flow_1s0xcf5" sourceRef="Activity_02vl5kt" targetRef="Activity_1kszh5k" /> + <bpmn:sequenceFlow id="Flow_1b6vtso" sourceRef="Activity_1xnstqr" targetRef="Event_09ey569" /> + <bpmn:sequenceFlow id="Flow_1b95clk" sourceRef="Activity_1xirwg3" targetRef="Activity_1o0a55b" /> + <bpmn:scriptTask id="Activity_1xirwg3" name="Update TN FH SP and NSSI Orch Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0bukcmf</bpmn:incoming> + <bpmn:outgoing>Flow_1b95clk</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.updateTNFHStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0xmezab" name="Update TN FH SP and NSSI Orch Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1i4cc7e</bpmn:incoming> + <bpmn:outgoing>Flow_0k5cyz7</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +def activator = new DoActivateAccessNSSI() +activator.updateTNFHStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0k5cyz7" sourceRef="Activity_0xmezab" targetRef="Activity_0ftm8b6" /> + <bpmn:scriptTask id="Activity_1j0xkqc" name="Check Orch status for AN NSSI activation" scriptFormat="groovy"> + <bpmn:incoming>Flow_1cnfilb</bpmn:incoming> + <bpmn:outgoing>Flow_0cblklk</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +def activator = new DoActivateAccessNSSI() +activator.updateANStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0huy5ph" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0cblklk</bpmn:incoming> + <bpmn:outgoing>Flow_06nfip0</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activator = new DoActivateAccessNSSI() +activator.prepareUpdateJobStatus(execution,"finished","100","AN NSSI activation completed")</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1tbardv" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_06nfip0</bpmn:incoming> + <bpmn:outgoing>Flow_1876ml0</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_06nfip0" sourceRef="Activity_0huy5ph" targetRef="Activity_1tbardv" /> + <bpmn:sequenceFlow id="Flow_0cblklk" sourceRef="Activity_1j0xkqc" targetRef="Activity_0huy5ph" /> + <bpmn:sequenceFlow id="Flow_1876ml0" sourceRef="Activity_1tbardv" targetRef="Event_0gx3ps0" /> + <bpmn:intermediateThrowEvent id="Event_0ocuo1o" name="Goto AN NSSI activation"> + <bpmn:incoming>Flow_0g9k299</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_1h9r8pc" name="AN_NSSI_Activation" /> + </bpmn:intermediateThrowEvent> + </bpmn:process> + <bpmn:error id="Error_1beg2za" name="ActivationWorkflowError" errorCode="2500" /> + <bpmn:error id="Error_0vgjqok" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoActivateAccessNSSI"> + <bpmndi:BPMNEdge id="Flow_1876ml0_di" bpmnElement="Flow_1876ml0"> + <di:waypoint x="660" y="940" /> + <di:waypoint x="712" y="940" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cblklk_di" bpmnElement="Flow_0cblklk"> + <di:waypoint x="350" y="940" /> + <di:waypoint x="390" y="940" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_06nfip0_di" bpmnElement="Flow_06nfip0"> + <di:waypoint x="490" y="940" /> + <di:waypoint x="560" y="940" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0k5cyz7_di" bpmnElement="Flow_0k5cyz7"> + <di:waypoint x="1330" y="690" /> + <di:waypoint x="1410" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b95clk_di" bpmnElement="Flow_1b95clk"> + <di:waypoint x="1320" y="450" /> + <di:waypoint x="1410" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b6vtso_di" bpmnElement="Flow_1b6vtso"> + <di:waypoint x="1680" y="690" /> + <di:waypoint x="1742" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1s0xcf5_di" bpmnElement="Flow_1s0xcf5"> + <di:waypoint x="580" y="690" /> + <di:waypoint x="640" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1wx5w6i_di" bpmnElement="Flow_1wx5w6i"> + <di:waypoint x="1510" y="690" /> + <di:waypoint x="1580" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0rzuxa0_di" bpmnElement="Flow_0rzuxa0"> + <di:waypoint x="1140" y="715" /> + <di:waypoint x="1140" y="762" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1i4cc7e_di" bpmnElement="Flow_1i4cc7e"> + <di:waypoint x="1165" y="690" /> + <di:waypoint x="1230" y="690" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1168" y="672" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0to1idt_di" bpmnElement="Flow_0to1idt"> + <di:waypoint x="1070" y="690" /> + <di:waypoint x="1115" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0b7aq1k_di" bpmnElement="Flow_0b7aq1k"> + <di:waypoint x="900" y="690" /> + <di:waypoint x="970" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0sqsq1x_di" bpmnElement="Flow_0sqsq1x"> + <di:waypoint x="740" y="690" /> + <di:waypoint x="800" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1qszzfv_di" bpmnElement="Flow_1qszzfv"> + <di:waypoint x="1680" y="450" /> + <di:waypoint x="1732" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ldkgyg_di" bpmnElement="Flow_1ldkgyg"> + <di:waypoint x="1510" y="450" /> + <di:waypoint x="1580" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ajre96_di" bpmnElement="Flow_0ajre96"> + <di:waypoint x="1130" y="475" /> + <di:waypoint x="1130" y="522" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0bukcmf_di" bpmnElement="Flow_0bukcmf"> + <di:waypoint x="1155" y="450" /> + <di:waypoint x="1220" y="450" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1158" y="432" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0heuc95_di" bpmnElement="Flow_0heuc95"> + <di:waypoint x="580" y="450" /> + <di:waypoint x="630" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1i0s8nu_di" bpmnElement="Flow_1i0s8nu"> + <di:waypoint x="1060" y="450" /> + <di:waypoint x="1105" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16pqv7g_di" bpmnElement="Flow_16pqv7g"> + <di:waypoint x="890" y="450" /> + <di:waypoint x="960" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1w3h345_di" bpmnElement="Flow_1w3h345"> + <di:waypoint x="730" y="450" /> + <di:waypoint x="790" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0mtkhmv_di" bpmnElement="Flow_0mtkhmv"> + <di:waypoint x="2110" y="230" /> + <di:waypoint x="2152" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1sroz8o_di" bpmnElement="Flow_1sroz8o"> + <di:waypoint x="1800" y="230" /> + <di:waypoint x="1870" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1myzbqw_di" bpmnElement="Flow_1myzbqw"> + <di:waypoint x="1500" y="230" /> + <di:waypoint x="1565" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0o7xomf_di" bpmnElement="Flow_0o7xomf"> + <di:waypoint x="1340" y="230" /> + <di:waypoint x="1400" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0rizzsm_di" bpmnElement="Flow_0rizzsm"> + <di:waypoint x="1970" y="230" /> + <di:waypoint x="2010" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1v4zg98_di" bpmnElement="Flow_1v4zg98"> + <di:waypoint x="1590" y="255" /> + <di:waypoint x="1590" y="302" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1yrel0t_di" bpmnElement="Flow_1yrel0t"> + <di:waypoint x="1615" y="230" /> + <di:waypoint x="1700" y="230" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1649" y="212" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1gxv9id_di" bpmnElement="Flow_1gxv9id"> + <di:waypoint x="1180" y="230" /> + <di:waypoint x="1240" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_147tw7h_di" bpmnElement="Flow_147tw7h"> + <di:waypoint x="435" y="690" /> + <di:waypoint x="480" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0wvzz2r_di" bpmnElement="Flow_0wvzz2r"> + <di:waypoint x="198" y="690" /> + <di:waypoint x="240" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_00clpwn_di" bpmnElement="Flow_00clpwn"> + <di:waypoint x="410" y="715" /> + <di:waypoint x="410" y="800" /> + <di:waypoint x="482" y="800" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0q02qno_di" bpmnElement="Flow_0q02qno"> + <di:waypoint x="340" y="690" /> + <di:waypoint x="385" y="690" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_10b15um_di" bpmnElement="Flow_10b15um"> + <di:waypoint x="410" y="475" /> + <di:waypoint x="410" y="560" /> + <di:waypoint x="482" y="560" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0zjaac9_di" bpmnElement="Flow_0zjaac9"> + <di:waypoint x="435" y="450" /> + <di:waypoint x="480" y="450" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="449" y="432" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1q7frye_di" bpmnElement="Flow_1q7frye"> + <di:waypoint x="198" y="450" /> + <di:waypoint x="240" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1yd57bl_di" bpmnElement="Flow_1yd57bl"> + <di:waypoint x="340" y="450" /> + <di:waypoint x="385" y="450" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0g9k299_di" bpmnElement="Flow_0g9k299"> + <di:waypoint x="690" y="205" /> + <di:waypoint x="690" y="100" /> + <di:waypoint x="752" y="100" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="698" y="150" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_00vt4gf_di" bpmnElement="Flow_00vt4gf"> + <di:waypoint x="715" y="230" /> + <di:waypoint x="800" y="230" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="749" y="212" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0uxerfg_di" bpmnElement="Flow_0uxerfg"> + <di:waypoint x="620" y="230" /> + <di:waypoint x="665" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_10f44ab_di" bpmnElement="Flow_10f44ab"> + <di:waypoint x="480" y="230" /> + <di:waypoint x="520" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1cnfilb_di" bpmnElement="Flow_1cnfilb"> + <di:waypoint x="198" y="940" /> + <di:waypoint x="250" y="940" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0523saw_di" bpmnElement="Flow_0523saw"> + <di:waypoint x="990" y="205" /> + <di:waypoint x="990" y="130" /> + <di:waypoint x="1062" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_00fb28f_di" bpmnElement="Flow_00fb28f"> + <di:waypoint x="1015" y="230" /> + <di:waypoint x="1080" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_00yl2jk_di" bpmnElement="Flow_00yl2jk"> + <di:waypoint x="900" y="230" /> + <di:waypoint x="965" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_14z4acw_di" bpmnElement="Flow_14z4acw"> + <di:waypoint x="340" y="230" /> + <di:waypoint x="380" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0rh43xe_di" bpmnElement="Flow_0rh43xe"> + <di:waypoint x="198" y="230" /> + <di:waypoint x="240" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_055gbp2_di" bpmnElement="Event_055gbp2"> + <dc:Bounds x="162" y="212" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="168" y="255" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_12oq1sa_di" bpmnElement="Gateway_12oq1sa" isMarkerVisible="true"> + <dc:Bounds x="965" y="205" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="945" y="265" width="90" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1v7p5kl_di" bpmnElement="Event_1n5z71a"> + <dc:Bounds x="2152" y="212" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2137" y="255" width="71" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_01vyapf_di" bpmnElement="Event_0kkeo9m"> + <dc:Bounds x="162" y="432" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="157" y="475" width="48" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1u3s42m_di" bpmnElement="Event_09ey569"> + <dc:Bounds x="1742" y="672" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1728" y="715" width="71" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_01fudey_di" bpmnElement="Event_0rzo7gj"> + <dc:Bounds x="1062" y="112" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1042" y="155" width="78" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0gx3ps0_di" bpmnElement="Event_0gx3ps0"> + <dc:Bounds x="712" y="922" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="720" y="965" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0xcg677_di" bpmnElement="Gateway_0xcg677" isMarkerVisible="true"> + <dc:Bounds x="665" y="205" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="647" y="262" width="86" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0nr3me0_di" bpmnElement="Gateway_0nr3me0" isMarkerVisible="true"> + <dc:Bounds x="385" y="425" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="370" y="395" width="84" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0j998yp_di" bpmnElement="Event_0j998yp"> + <dc:Bounds x="162" y="672" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="150" y="715" width="64" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_05lm9ln_di" bpmnElement="Event_1nqpg0o"> + <dc:Bounds x="482" y="542" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="457" y="585" width="86" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0wv22e3_di" bpmnElement="Event_0ki3ncn"> + <dc:Bounds x="1732" y="432" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1706" y="475" width="88" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1djcl9x_di" bpmnElement="Event_1djcl9x"> + <dc:Bounds x="482" y="782" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="469" y="825" width="62" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0cemhjv_di" bpmnElement="Gateway_0cemhjv" isMarkerVisible="true"> + <dc:Bounds x="385" y="665" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="368" y="635" width="84" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_00e6sqq_di" bpmnElement="Activity_089t9fj"> + <dc:Bounds x="380" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_147vycg_di" bpmnElement="Activity_1fv6ljk"> + <dc:Bounds x="240" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1465ih9_di" bpmnElement="Activity_19myg2v"> + <dc:Bounds x="520" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16l1ykw_di" bpmnElement="Activity_1atych2"> + <dc:Bounds x="800" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_10uophi_di" bpmnElement="Activity_0iluozh"> + <dc:Bounds x="1080" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0u2aqld_di" bpmnElement="Activity_0u2aqld"> + <dc:Bounds x="1240" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1hr68mt_di" bpmnElement="Activity_1hr68mt"> + <dc:Bounds x="1400" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1xwu5f0_di" bpmnElement="Gateway_1xwu5f0" isMarkerVisible="true"> + <dc:Bounds x="1565" y="205" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1564" y="175" width="54" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0yfi3mj_di" bpmnElement="Event_0yfi3mj"> + <dc:Bounds x="1572" y="302" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1607" y="286" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_03sbng2_di" bpmnElement="Activity_03sbng2"> + <dc:Bounds x="1870" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_08yj5gq_di" bpmnElement="Activity_08yj5gq"> + <dc:Bounds x="2010" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1aesimf_di" bpmnElement="Activity_1aesimf" isExpanded="true"> + <dc:Bounds x="210" y="1130" width="770" height="170" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_1bqk5yt_di" bpmnElement="Flow_1bqk5yt"> + <di:waypoint x="630" y="1234" /> + <di:waypoint x="710" y="1234" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0tw7xsp_di" bpmnElement="Flow_0tw7xsp"> + <di:waypoint x="278" y="1234" /> + <di:waypoint x="380" y="1234" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_075rb1i_di" bpmnElement="Flow_075rb1i"> + <di:waypoint x="480" y="1234" /> + <di:waypoint x="530" y="1234" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0y0r82m_di" bpmnElement="Flow_0y0r82m"> + <di:waypoint x="810" y="1234" /> + <di:waypoint x="892" y="1234" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_156ogc4_di" bpmnElement="Event_156ogc4"> + <dc:Bounds x="242" y="1216" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1n2qjvx_di" bpmnElement="Event_1n2qjvx"> + <dc:Bounds x="892" y="1216" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1eedm9e_di" bpmnElement="Activity_1eedm9e"> + <dc:Bounds x="710" y="1194" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1szd5yp_di" bpmnElement="Activity_1szd5yp"> + <dc:Bounds x="530" y="1194" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0lpw3j7_di" bpmnElement="Activity_0lpw3j7"> + <dc:Bounds x="380" y="1194" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0hioign_di" bpmnElement="Activity_0hioign" isExpanded="true"> + <dc:Bounds x="320" y="1420" width="440" height="140" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0cvs8zk_di" bpmnElement="Flow_0cvs8zk"> + <di:waypoint x="408" y="1481" /> + <di:waypoint x="473" y="1481" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_01jdnrt_di" bpmnElement="Flow_01jdnrt"> + <di:waypoint x="573" y="1481" /> + <di:waypoint x="672" y="1481" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Activity_1f3cipf_di" bpmnElement="Activity_1f3cipf"> + <dc:Bounds x="473" y="1441" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_18qzt1n_di" bpmnElement="Event_18qzt1n"> + <dc:Bounds x="672" y="1463" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0lvvn7i_di" bpmnElement="Event_0lvvn7i"> + <dc:Bounds x="372" y="1463" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1u5yry2_di" bpmnElement="Activity_09e5oh6"> + <dc:Bounds x="1700" y="190" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ng1vyl_di" bpmnElement="Activity_1fzg56b"> + <dc:Bounds x="240" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1vabe3f_di" bpmnElement="Activity_0gtw2p7"> + <dc:Bounds x="480" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_07cr1m2_di" bpmnElement="Activity_07cr1m2"> + <dc:Bounds x="630" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_03hbxfi_di" bpmnElement="Activity_03hbxfi"> + <dc:Bounds x="790" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0br2i5b_di" bpmnElement="Activity_0br2i5b"> + <dc:Bounds x="960" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1ot96tc_di" bpmnElement="Gateway_1ot96tc" isMarkerVisible="true"> + <dc:Bounds x="1105" y="425" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1088" y="395" width="84" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0h9nwqd_di" bpmnElement="Event_0uco28x"> + <dc:Bounds x="1112" y="522" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1088" y="565" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1t28p4r_di" bpmnElement="Activity_1t28p4r"> + <dc:Bounds x="1580" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_03o12kw_di" bpmnElement="Activity_1o0a55b"> + <dc:Bounds x="1410" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1hkx6j5_di" bpmnElement="Activity_068a0cy"> + <dc:Bounds x="240" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_18xtkyi_di" bpmnElement="Event_1azfo77"> + <dc:Bounds x="162" y="922" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="156" y="965" width="48" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wvru6z_di" bpmnElement="Activity_02vl5kt"> + <dc:Bounds x="480" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1kszh5k_di" bpmnElement="Activity_1kszh5k"> + <dc:Bounds x="640" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_09jt4b0_di" bpmnElement="Activity_09jt4b0"> + <dc:Bounds x="800" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1su25xm_di" bpmnElement="Activity_1su25xm"> + <dc:Bounds x="970" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_114io6q_di" bpmnElement="Gateway_114io6q" isMarkerVisible="true"> + <dc:Bounds x="1115" y="665" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1098" y="641" width="84" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_08ecfyj_di" bpmnElement="Event_08ecfyj"> + <dc:Bounds x="1122" y="762" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1098" y="805" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ftm8b6_di" bpmnElement="Activity_0ftm8b6"> + <dc:Bounds x="1410" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1xnstqr_di" bpmnElement="Activity_1xnstqr"> + <dc:Bounds x="1580" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_15f8u0i_di" bpmnElement="Activity_1xirwg3"> + <dc:Bounds x="1220" y="410" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0xmezab_di" bpmnElement="Activity_0xmezab"> + <dc:Bounds x="1230" y="650" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_17abdcy_di" bpmnElement="Activity_1j0xkqc"> + <dc:Bounds x="250" y="900" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0huy5ph_di" bpmnElement="Activity_0huy5ph"> + <dc:Bounds x="390" y="900" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1tbardv_di" bpmnElement="Activity_1tbardv"> + <dc:Bounds x="560" y="900" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0kp0sqc_di" bpmnElement="Event_0ocuo1o"> + <dc:Bounds x="752" y="82" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="735" y="125" width="71" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn new file mode 100644 index 0000000000..b422545e84 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn @@ -0,0 +1,420 @@ +<?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_1r4k2c2" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="DoActivateCoreNSSI" name="DoActivateCoreNSSI" isExecutable="true"> + <bpmn:startEvent id="StartEvent_0lgslwq" name="Start"> + <bpmn:outgoing>SequenceFlow_0wwo1lh</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="ScriptTask_1x13jc1" name="Pre-process request Check operationType" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0wwo1lh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_139ejmn</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0usuysi" name="Call AAI get VNF/VFs and model info" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1654pt0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_09nihof</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.getServiceVNFAndVFsFromCatalogDB(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1t06mlw" name="Prepare request payload for SO macro service api" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_09nihof</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0fbr356</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareSOMacroRequestPayLoad(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0lxbaxd" name="Call AAI update sliceProlie service Instance status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1e20i9g</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0j0egoi</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.updateSliceProfileOrchestrationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1rjha8r" name="get NSSI instance with relationships and sliceProfile instance" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_139ejmn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1654pt0</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.getNetworkInstanceWithSPInstanceAssociatedWithNssiId(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1tfpgcs" name="PUT SO Macro" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1mi4waj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0rjd7tg</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.sendPutRequestToSOMacro(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1frasll" name="Prepare Call CheckServiceProcessStatus" scriptFormat="groovy"> + <bpmn:incoming>Flow_039sx2v</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_18x9gdi</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareCallCheckProcessStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_11hntoj" name="CallCheckServiceProcessStatus" calledElement="CheckServiceProcessStatus"> + <bpmn:extensionElements> + <camunda:in source="networkServiceInstanceId" target="serviceInstanceId" /> + <camunda:in source="macroOperationId" target="operationId" /> + <camunda:in source="successConditions" target="successConditions" /> + <camunda:in source="errorConditions" target="errorConditions" /> + <camunda:in source="processServiceType" target="processServiceType" /> + <camunda:in source="timeOut" target="timeOut" /> + <camunda:out source="operationStatus" target="result" /> + <camunda:out source="operationContent" target="reason" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="isTimeOut" target="isTimeOut" /> + <camunda:in source="subOperationType" target="operationType" /> + <camunda:in source="initProgress" target="initProgress" /> + <camunda:in source="endProgress" target="endProgress" /> + <camunda:in source="serviceInstanceID" target="parentServiceInstanceId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="operationId" target="parentOperationId" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_18x9gdi</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1l9ry0a</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_1sfn88d" name="Prepare update Service operation status " scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1l9ry0a</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0wx21io</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0wwo1lh" sourceRef="StartEvent_0lgslwq" targetRef="ScriptTask_1x13jc1" /> + <bpmn:sequenceFlow id="SequenceFlow_139ejmn" sourceRef="ScriptTask_1x13jc1" targetRef="ScriptTask_1rjha8r" /> + <bpmn:sequenceFlow id="SequenceFlow_1654pt0" sourceRef="ScriptTask_1rjha8r" targetRef="ScriptTask_0usuysi" /> + <bpmn:sequenceFlow id="SequenceFlow_09nihof" sourceRef="ScriptTask_0usuysi" targetRef="ScriptTask_1t06mlw" /> + <bpmn:sequenceFlow id="SequenceFlow_1l9ry0a" sourceRef="CallActivity_11hntoj" targetRef="ScriptTask_1sfn88d" /> + <bpmn:sequenceFlow id="SequenceFlow_0fbr356" sourceRef="ScriptTask_1t06mlw" targetRef="IntermediateThrowEvent_0gueutz" /> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0gueutz" name="Call SO macro api"> + <bpmn:incoming>SequenceFlow_0fbr356</bpmn:incoming> + <bpmn:linkEventDefinition name="CallSO" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="SequenceFlow_1mi4waj" sourceRef="IntermediateThrowEvent_150o0dl" targetRef="ScriptTask_1tfpgcs" /> + <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_150o0dl" name="Call SO macro api"> + <bpmn:outgoing>SequenceFlow_1mi4waj</bpmn:outgoing> + <bpmn:linkEventDefinition name="CallSO" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_0rjd7tg" sourceRef="ScriptTask_1tfpgcs" targetRef="Gateway_03lo8jx" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_02nqn2k" name="is TimeOut?" default="SequenceFlow_07u1gfw"> + <bpmn:incoming>SequenceFlow_0wx21io</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1e20i9g</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_07u1gfw</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0wx21io" sourceRef="ScriptTask_1sfn88d" targetRef="ExclusiveGateway_02nqn2k" /> + <bpmn:sequenceFlow id="SequenceFlow_1e20i9g" name="No" sourceRef="ExclusiveGateway_02nqn2k" targetRef="ScriptTask_0lxbaxd"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isTimeOut") == "NO")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="EndEvent_1061mty" name="End"> + <bpmn:incoming>SequenceFlow_0v0dntm</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_18x9gdi" sourceRef="ScriptTask_1frasll" targetRef="CallActivity_11hntoj" /> + <bpmn:exclusiveGateway id="Gateway_03lo8jx" name="is SO Response OK?" default="Flow_1jchhgj"> + <bpmn:incoming>SequenceFlow_0rjd7tg</bpmn:incoming> + <bpmn:outgoing>Flow_039sx2v</bpmn:outgoing> + <bpmn:outgoing>Flow_1jchhgj</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_039sx2v" name="Yes" sourceRef="Gateway_03lo8jx" targetRef="ScriptTask_1frasll"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isSOResponseSucceed" ) == "yes")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="ServiceTask_02x7eqy" name="Update Service Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1jchhgj</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0j0egoi</bpmn:incoming> + <bpmn:incoming>SequenceFlow_07u1gfw</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0v0dntm</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0v0dntm" sourceRef="ServiceTask_02x7eqy" targetRef="EndEvent_1061mty" /> + <bpmn:sequenceFlow id="Flow_1jchhgj" name="No" sourceRef="Gateway_03lo8jx" targetRef="ServiceTask_02x7eqy" /> + <bpmn:sequenceFlow id="SequenceFlow_0j0egoi" sourceRef="ScriptTask_0lxbaxd" targetRef="ServiceTask_02x7eqy" /> + <bpmn:sequenceFlow id="SequenceFlow_07u1gfw" name="Yes" sourceRef="ExclusiveGateway_02nqn2k" targetRef="ServiceTask_02x7eqy" /> + <bpmn:subProcess id="Activity_1tmdw60" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_159txw2"> + <bpmn:outgoing>Flow_149oqyp</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_15ur8z3" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_0c1ec2y"> + <bpmn:incoming>Flow_1qooaff</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_0u3yna7" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_1iqw69c</bpmn:incoming> + <bpmn:outgoing>Flow_1qooaff</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0u4a0ry" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_149oqyp</bpmn:incoming> + <bpmn:outgoing>Flow_1dh5sht</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_11422x1" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1dh5sht</bpmn:incoming> + <bpmn:outgoing>Flow_1iqw69c</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1iqw69c" sourceRef="Activity_11422x1" targetRef="Activity_0u3yna7" /> + <bpmn:sequenceFlow id="Flow_1dh5sht" sourceRef="Activity_0u4a0ry" targetRef="Activity_11422x1" /> + <bpmn:sequenceFlow id="Flow_149oqyp" sourceRef="Event_159txw2" targetRef="Activity_0u4a0ry" /> + <bpmn:sequenceFlow id="Flow_1qooaff" sourceRef="Activity_0u3yna7" targetRef="Event_0c1ec2y" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoActivateCoreNSSI"> + <bpmndi:BPMNEdge id="SequenceFlow_07u1gfw_di" bpmnElement="SequenceFlow_07u1gfw"> + <di:waypoint x="976" y="319" /> + <di:waypoint x="1123" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1041" y="301" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0j0egoi_di" bpmnElement="SequenceFlow_0j0egoi"> + <di:waypoint x="1099" y="258" /> + <di:waypoint x="1173" y="258" /> + <di:waypoint x="1173" y="279" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="376" y="387" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jchhgj_di" bpmnElement="Flow_1jchhgj"> + <di:waypoint x="400" y="344" /> + <di:waypoint x="400" y="450" /> + <di:waypoint x="1190" y="450" /> + <di:waypoint x="1190" y="360" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="788" y="432" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0v0dntm_di" bpmnElement="SequenceFlow_0v0dntm"> + <di:waypoint x="1223" y="319" /> + <di:waypoint x="1263" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="483" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_039sx2v_di" bpmnElement="Flow_039sx2v"> + <di:waypoint x="425" y="319" /> + <di:waypoint x="470" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="439" y="301" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_18x9gdi_di" bpmnElement="SequenceFlow_18x9gdi"> + <di:waypoint x="570" y="319" /> + <di:waypoint x="610" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-180.5" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1e20i9g_di" bpmnElement="SequenceFlow_1e20i9g"> + <di:waypoint x="951" y="294" /> + <di:waypoint x="951" y="258" /> + <di:waypoint x="999" y="258" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="959" y="273" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0wx21io_di" bpmnElement="SequenceFlow_0wx21io"> + <di:waypoint x="868" y="319" /> + <di:waypoint x="926" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="137" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0rjd7tg_di" bpmnElement="SequenceFlow_0rjd7tg"> + <di:waypoint x="330" y="319" /> + <di:waypoint x="375" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-336" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1mi4waj_di" bpmnElement="SequenceFlow_1mi4waj"> + <di:waypoint x="178" y="319" /> + <di:waypoint x="230" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-489.5" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0fbr356_di" bpmnElement="SequenceFlow_0fbr356"> + <di:waypoint x="1020" y="120" /> + <di:waypoint x="1132" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="384" y="249" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1l9ry0a_di" bpmnElement="SequenceFlow_1l9ry0a"> + <di:waypoint x="710" y="319" /> + <di:waypoint x="768" y="319" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-21" y="448" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_09nihof_di" bpmnElement="SequenceFlow_09nihof"> + <di:waypoint x="820" y="120" /> + <di:waypoint x="920" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-460" y="189" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1654pt0_di" bpmnElement="SequenceFlow_1654pt0"> + <di:waypoint x="610" y="120" /> + <di:waypoint x="720" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-910" y="189" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_139ejmn_di" bpmnElement="SequenceFlow_139ejmn"> + <di:waypoint x="430" y="120" /> + <di:waypoint x="510" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-381" y="245" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0wwo1lh_di" bpmnElement="SequenceFlow_0wwo1lh"> + <di:waypoint x="242" y="120" /> + <di:waypoint x="330" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-489.5" y="249" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_0lgslwq_di" bpmnElement="StartEvent_0lgslwq"> + <dc:Bounds x="206" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="211" y="142" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1x13jc1_di" bpmnElement="ScriptTask_1x13jc1"> + <dc:Bounds x="330" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0usuysi_di" bpmnElement="ScriptTask_0usuysi"> + <dc:Bounds x="720" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1t06mlw_di" bpmnElement="ScriptTask_1t06mlw"> + <dc:Bounds x="920" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0lxbaxd_di" bpmnElement="ScriptTask_0lxbaxd"> + <dc:Bounds x="999" y="218" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1rjha8r_di" bpmnElement="ScriptTask_1rjha8r"> + <dc:Bounds x="510" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tfpgcs_di" bpmnElement="ScriptTask_1tfpgcs"> + <dc:Bounds x="230" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1frasll_di" bpmnElement="ScriptTask_1frasll"> + <dc:Bounds x="470" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_11hntoj_di" bpmnElement="CallActivity_11hntoj"> + <dc:Bounds x="610" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1sfn88d_di" bpmnElement="ScriptTask_1sfn88d"> + <dc:Bounds x="768" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_1808y0j_di" bpmnElement="IntermediateThrowEvent_0gueutz"> + <dc:Bounds x="1132" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1106" y="142" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_11m7660_di" bpmnElement="IntermediateThrowEvent_150o0dl"> + <dc:Bounds x="142" y="301" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="115" y="341" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_02nqn2k_di" bpmnElement="ExclusiveGateway_02nqn2k" isMarkerVisible="true"> + <dc:Bounds x="926" y="294" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="922" y="354" width="59" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1061mty_di" bpmnElement="EndEvent_1061mty"> + <dc:Bounds x="1263" y="301" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1271" y="344" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_03lo8jx_di" bpmnElement="Gateway_03lo8jx" isMarkerVisible="true"> + <dc:Bounds x="375" y="294" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="360" y="264" width="80" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_02x7eqy_di" bpmnElement="ServiceTask_02x7eqy"> + <dc:Bounds x="1123" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1tmdw60_di" bpmnElement="Activity_1tmdw60" isExpanded="true"> + <dc:Bounds x="400" y="560" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_1qooaff_di" bpmnElement="Flow_1qooaff"> + <di:waypoint x="960" y="664" /> + <di:waypoint x="1068" y="664" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_149oqyp_di" bpmnElement="Flow_149oqyp"> + <di:waypoint x="466" y="664" /> + <di:waypoint x="530" y="664" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1dh5sht_di" bpmnElement="Flow_1dh5sht"> + <di:waypoint x="630" y="664" /> + <di:waypoint x="690" y="664" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1iqw69c_di" bpmnElement="Flow_1iqw69c"> + <di:waypoint x="790" y="664" /> + <di:waypoint x="860" y="664" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_159txw2_di" bpmnElement="Event_159txw2"> + <dc:Bounds x="430" y="646" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0c1ec2y_di" bpmnElement="Event_0c1ec2y"> + <dc:Bounds x="1068" y="646" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0u3yna7_di" bpmnElement="Activity_0u3yna7"> + <dc:Bounds x="860" y="624" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0u4a0ry_di" bpmnElement="Activity_0u4a0ry"> + <dc:Bounds x="530" y="624" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_11422x1_di" bpmnElement="Activity_11422x1"> + <dc:Bounds x="690" y="624" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateTransportNSSI.bpmn new file mode 100644 index 0000000000..8ecce46ac0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateTransportNSSI.bpmn @@ -0,0 +1,207 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoActivateTransportNSSI" name="DoActivateTransportNSSI" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Activate/Deactivate TN NSSMF Work Flow"> + <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:subProcess id="SubProcess_1yv9i68" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_1omdx56"> + <bpmn:outgoing>SequenceFlow_1w67v6s</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_06xcioh" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1jx3026"> + <bpmn:incoming>SequenceFlow_08mlzwz</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1swzdpw" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1w67v6s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08mlzwz</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1w67v6s" sourceRef="StartEvent_1omdx56" targetRef="ScriptTask_1swzdpw" /> + <bpmn:sequenceFlow id="SequenceFlow_08mlzwz" sourceRef="ScriptTask_1swzdpw" targetRef="EndEvent_1jx3026" /> + </bpmn:subProcess> + <bpmn:endEvent id="EndEvent_05h01gx" name="End"> + <bpmn:incoming>Flow_1032bi1</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoActivateTnNssi() +runScript.prepareUpdateJobStatus(execution,"finished","100","Activate or Deactivate successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_03s744c" sourceRef="StartEvent_1nbljfd" targetRef="ScriptTask_1tc44ge" /> + <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_0nhxd67" /> + <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def actionType = execution.getVariable("actionType") +execution.setVariable("orchestrationStatus", actionType) +def runScript = new DoActivateTnNssi() +runScript.updateAAIOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ssh2l9" /> + <bpmn:scriptTask id="Activity_1tw8eyy" name="PreProcess SDNC Activate or Deactivate TN NSSI Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> + <bpmn:outgoing>Flow_0cpctye</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoActivateTnNssi() +runScript.preprocessSdncActOrDeactTnNssiRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0cpctye" sourceRef="Activity_1tw8eyy" targetRef="Activity_0p20esb" /> + <bpmn:callActivity id="Activity_0p20esb" name="Call SDNC Adapter: Activate/Deactivate TN NSSI" calledElement="sdncAdapter"> + <bpmn:extensionElements> + <camunda:in source="TNNSSMF_SDNCRequest" target="sdncAdapterWorkflowRequest" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> + <camunda:in source="mso-service-instance-id" target="mso-service-instance-id" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="sdncAdapterResponse" target="TNNSSMF_SDNCAdapterResponse" /> + <camunda:out source="SDNCA_SuccessIndicator" target="SDNCA_SuccessIndicator" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0cpctye</bpmn:incoming> + <bpmn:outgoing>Flow_0fuabjs</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0fuabjs" sourceRef="Activity_0p20esb" targetRef="Activity_0phv8e5" /> + <bpmn:scriptTask id="Activity_0phv8e5" name="Postprocess SDNC Activate/Deactivate TN NSSI Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0fuabjs</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1jdb2oq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String response = execution.getVariable("TNNSSMF_SDNCAdapterResponse") + +def runScript = new DoActivateTnNssi() +runScript.validateSDNCResponse(execution, response)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1jdb2oq" sourceRef="Activity_0phv8e5" targetRef="ScriptTask_19uxoi8" /> + <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03s744c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07e12rt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoActivateTnNssi() +runScript.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Activity_1tw8eyy" /> + <bpmn:serviceTask id="Activity_0nhxd67" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1qv8qw1</bpmn:incoming> + <bpmn:outgoing>Flow_1032bi1</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1032bi1" sourceRef="Activity_0nhxd67" targetRef="EndEvent_05h01gx" /> + </bpmn:process> + <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> + <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoActivateTransportNSSI"> + <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> + <di:waypoint x="385" y="121" /> + <di:waypoint x="509" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq"> + <di:waypoint x="1080" y="121" /> + <di:waypoint x="1220" y="121" /> + <di:waypoint x="1220" y="210" /> + <di:waypoint x="335" y="210" /> + <di:waypoint x="335" y="310" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fuabjs_di" bpmnElement="Flow_0fuabjs"> + <di:waypoint x="850" y="121" /> + <di:waypoint x="959" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cpctye_di" bpmnElement="Flow_0cpctye"> + <di:waypoint x="630" y="121" /> + <di:waypoint x="729" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> + <di:waypoint x="385" y="350" /> + <di:waypoint x="530" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> + <di:waypoint x="630" y="350" /> + <di:waypoint x="740" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> + <di:waypoint x="214" y="121" /> + <di:waypoint x="285" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1032bi1_di" bpmnElement="Flow_1032bi1"> + <di:waypoint x="840" y="350" /> + <di:waypoint x="1002" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> + <dc:Bounds x="178" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="163" y="146" width="81" height="53" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0nhxd67_di" bpmnElement="Activity_0nhxd67"> + <dc:Bounds x="740" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> + <dc:Bounds x="685" y="1080" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1079" y="1184" /> + <di:waypoint x="1353" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="751" y="1184" /> + <di:waypoint x="979" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="715" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1353" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="979" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> + <dc:Bounds x="1002" y="332" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1010" y="375" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> + <dc:Bounds x="530" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> + <dc:Bounds x="285" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1tw8eyy_di" bpmnElement="Activity_1tw8eyy"> + <dc:Bounds x="509" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0p20esb_di" bpmnElement="Activity_0p20esb"> + <dc:Bounds x="729" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5"> + <dc:Bounds x="959" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="285" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateAccessNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateAccessNSSI.bpmn new file mode 100644 index 0000000000..9c12200657 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateAccessNSSI.bpmn @@ -0,0 +1,960 @@ +<?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: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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_05od9yd" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.1"> + <bpmn:process id="DoAllocateAccessNSSI" name="DoAllocateAccessNSSI" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>Flow_163f3sq</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_1jj3kh9" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_163f3sq</bpmn:incoming> + <bpmn:outgoing>Flow_0tica8m</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0vhvubq" name="Get Subnet capabilities" scriptFormat="groovy"> + <bpmn:incoming>Flow_00f37fu</bpmn:incoming> + <bpmn:outgoing>Flow_1w8whur</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.getSubnetCapabilities(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_11vdo22" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_0833cha</bpmn:incoming> + <bpmn:outgoing>Flow_1xw4abx</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.prepareOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1nfx154" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1xw4abx</bpmn:incoming> + <bpmn:outgoing>Flow_0ll5x3u</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:endEvent id="Event_0vh1hs2"> + <bpmn:incoming>Flow_0ll5x3u</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0833cha" sourceRef="Event_05jtdqp" targetRef="Activity_11vdo22" /> + <bpmn:sequenceFlow id="Flow_1xw4abx" sourceRef="Activity_11vdo22" targetRef="Activity_1nfx154" /> + <bpmn:sequenceFlow id="Flow_0ll5x3u" sourceRef="Activity_1nfx154" targetRef="Event_0vh1hs2" /> + <bpmn:sequenceFlow id="Flow_1x3y2tg" sourceRef="Event_18r5xkz" targetRef="Activity_03dgcg5" /> + <bpmn:scriptTask id="Activity_19laorl" name="prepare OOF request for RAN NF NSSI selection" scriptFormat="groovy"> + <bpmn:incoming>Flow_0rb4j9r</bpmn:incoming> + <bpmn:outgoing>Flow_0d0f3ie</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.prepareOofRequestForRanNfNSS(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_03dgcg5" name="send allocate FH NSSI request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1x3y2tg</bpmn:incoming> + <bpmn:outgoing>Flow_0qhjtre</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.prepareTnFhRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_18y4ijb" name="send allocate MH NSSI request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0zhr499</bpmn:incoming> + <bpmn:outgoing>Flow_04thflx</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.prepareTnMhRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:intermediateCatchEvent id="Event_05jtdqp" name="Start operation status update"> + <bpmn:outgoing>Flow_0833cha</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_05sogjc" name="OperationStatusUpdate" /> + </bpmn:intermediateCatchEvent> + <bpmn:intermediateThrowEvent id="Event_0u9308h" name="Go to start operation status update"> + <bpmn:incoming>Flow_0kcvava</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_1o9trjv" name="OperationStatusUpdate" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="Event_18r5xkz" name="start TN allocate"> + <bpmn:outgoing>Flow_1x3y2tg</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_15hz0uh" name="startTnAllocate" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="Flow_0zhr499" sourceRef="Activity_0qn2fvh" targetRef="Activity_18y4ijb" /> + <bpmn:scriptTask id="Activity_0qn2fvh" name="process Job status response" scriptFormat="groovy"> + <bpmn:incoming>Flow_16z59pu</bpmn:incoming> + <bpmn:outgoing>Flow_0zhr499</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.processFhAllocateNssiJobStatusRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_12szahe" name="Process OOF response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1b14415</bpmn:incoming> + <bpmn:outgoing>Flow_1h7iq8l</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.processOofResponseForRanNSS(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0vwhzem" name="prepare OOF request for RAN NSSI selection" scriptFormat="groovy"> + <bpmn:incoming>Flow_1w8whur</bpmn:incoming> + <bpmn:outgoing>Flow_0tkzfhb</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.prepareOofRequestForRanNSS(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_163f3sq" sourceRef="StartEvent_1" targetRef="Activity_1jj3kh9" /> + <bpmn:exclusiveGateway id="Gateway_1aesepd" name="Is Response NSSI?" default="Flow_0k39zt8"> + <bpmn:incoming>Flow_09tjspa</bpmn:incoming> + <bpmn:outgoing>Flow_1ipsxgh</bpmn:outgoing> + <bpmn:outgoing>Flow_0k39zt8</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:intermediateThrowEvent id="Event_142r2sx" name="Go to start operation status update"> + <bpmn:incoming>Flow_0k8yakp</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_08wuatj" name="OperationStatusUpdate" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateThrowEvent id="Event_15zn4zi" name="Goto start TN allocate"> + <bpmn:incoming>Flow_1exjm0h</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_13crcza" name="startTnAllocate" /> + </bpmn:intermediateThrowEvent> + <bpmn:scriptTask id="Activity_1pxd5wf" name="Process OOF response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1nkqrpd</bpmn:incoming> + <bpmn:outgoing>Flow_1f9rw3m</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.processOofResponseForRanNfNSS(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_0en9ki5" name="Is Response NSSI?" default="Flow_178fenq"> + <bpmn:incoming>Flow_1ryi6ym</bpmn:incoming> + <bpmn:outgoing>Flow_178fenq</bpmn:outgoing> + <bpmn:outgoing>Flow_0kn30g3</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="Activity_0a95zgv" name="prepare SDNR request" scriptFormat="groovy"> + <bpmn:incoming>Flow_178fenq</bpmn:incoming> + <bpmn:outgoing>Flow_1pbiznt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.createSdnrRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_118je0o" name="process SDNR response" scriptFormat="groovy"> + <bpmn:incoming>Flow_05yqmnj</bpmn:incoming> + <bpmn:outgoing>Flow_0ikdlkf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.processSdnrResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1ipsxgh" name="yes" sourceRef="Gateway_1aesepd" targetRef="Activity_0xawnmh"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isRspRanNssi" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_178fenq" name="No" sourceRef="Gateway_0en9ki5" targetRef="Activity_0a95zgv" /> + <bpmn:sequenceFlow id="Flow_1w8whur" sourceRef="Activity_0vhvubq" targetRef="Activity_0vwhzem" /> + <bpmn:sequenceFlow id="Flow_0tkzfhb" sourceRef="Activity_0vwhzem" targetRef="Activity_1u28lyv" /> + <bpmn:sequenceFlow id="Flow_1h7iq8l" sourceRef="Activity_12szahe" targetRef="Event_0s8t1ji" /> + <bpmn:intermediateThrowEvent id="Event_0s8t1ji" name="Go to start NSSI allocate"> + <bpmn:incoming>Flow_1h7iq8l</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0yzxmpv" name="NSSIAllocate" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="Event_1glt41l" name="start NSSI allocate"> + <bpmn:outgoing>Flow_09tjspa</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_05u2hpg" name="NSSIAllocate" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="Flow_09tjspa" sourceRef="Event_1glt41l" targetRef="Gateway_1aesepd" /> + <bpmn:sequenceFlow id="Flow_0k39zt8" name="No" sourceRef="Gateway_1aesepd" targetRef="Activity_0fdm3in" /> + <bpmn:scriptTask id="Activity_0p02joo" name="Prepare Decompose Service " scriptFormat="groovy"> + <bpmn:incoming>Flow_0tica8m</bpmn:incoming> + <bpmn:outgoing>Flow_0mcd9bo</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.prepareDecomposeService(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0tica8m" sourceRef="Activity_1jj3kh9" targetRef="Activity_0p02joo" /> + <bpmn:callActivity id="Activity_1u28lyv" name="Call DoCreateSubnetOption" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nssiSelection_Url" target="apiPath" /> + <camunda:in source="nssiSelection_correlator" target="correlator" /> + <camunda:in source="nssiSelection_messageType" target="messageType" /> + <camunda:in source="nssiSelection_timeout" target="timeout" /> + <camunda:in source="nssiSelection_oofRequest" target="oofRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nssiSelection_asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0tkzfhb</bpmn:incoming> + <bpmn:outgoing>Flow_1b14415</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1b14415" sourceRef="Activity_1u28lyv" targetRef="Activity_12szahe" /> + <bpmn:callActivity id="Activity_1ux83hz" name="Query Job status" calledElement="QueryJobStatus "> + <bpmn:extensionElements> + <camunda:in source="esrInfo" target="esrInfo" /> + <camunda:in source="serviceInfo" target="serviceInfo" /> + <camunda:in source="TNFH_jobId" target="jobId" /> + <camunda:out source="jobResponse" target="TNFH_jobResponse" /> + <camunda:in source="responseId" target="responseId" /> + <camunda:in source="job_timeout" target="timeout" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1p48xbl</bpmn:incoming> + <bpmn:outgoing>Flow_16z59pu</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_16z59pu" sourceRef="Activity_1ux83hz" targetRef="Activity_0qn2fvh" /> + <bpmn:callActivity id="Activity_0c0cq9d" name="Query Job status" calledElement="QueryJobStatus "> + <bpmn:extensionElements> + <camunda:in source="esrInfo" target="esrInfo" /> + <camunda:in source="serviceInfo" target="serviceInfo" /> + <camunda:in source="TNMH_jobId" target="jobId" /> + <camunda:out source="jobResponse" target="TNMH_jobResponse" /> + <camunda:in source="responseId" target="responseId" /> + <camunda:in source="job_timeout" target="timeout" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0fdetmo</bpmn:incoming> + <bpmn:outgoing>Flow_1v3wpa2</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="Activity_0y9xgkl" name="Call DoCreateSubnetOption" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nssiSelection_Url" target="apiPath" /> + <camunda:in source="nssiSelection_correlator" target="correlator" /> + <camunda:in source="nssiSelection_messageType" target="messageType" /> + <camunda:in source="nssiSelection_timeout" target="timeout" /> + <camunda:in source="nssiSelection_oofRequest" target="oofRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nfNssiSelection_asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0d0f3ie</bpmn:incoming> + <bpmn:outgoing>Flow_1nkqrpd</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1nkqrpd" sourceRef="Activity_0y9xgkl" targetRef="Activity_1pxd5wf" /> + <bpmn:sequenceFlow id="Flow_0kn30g3" name="yes" sourceRef="Gateway_0en9ki5" targetRef="Activity_08i0hzk"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isRspRanNfNssi" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:callActivity id="Activity_0vbzhej" name="call sdnr for RAN NF NSSI creation" calledElement="DoHandleSdnrDmaapRequest"> + <bpmn:extensionElements> + <camunda:in source="createNSSI_sdnrRequest" target="sdnrRequest" /> + <camunda:out source="asyncCallbackResponse" target="SDNR_asyncCallbackResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="createNSSI_correlator" target="correlator" /> + <camunda:in source="createNSSI_messageType" target="messageType" /> + <camunda:in source="createNSSI_timeout" target="timeout" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1pbiznt</bpmn:incoming> + <bpmn:outgoing>Flow_05yqmnj</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1pbiznt" sourceRef="Activity_0a95zgv" targetRef="Activity_0vbzhej" /> + <bpmn:sequenceFlow id="Flow_05yqmnj" sourceRef="Activity_0vbzhej" targetRef="Activity_118je0o" /> + <bpmn:sequenceFlow id="Flow_0qhjtre" sourceRef="Activity_03dgcg5" targetRef="Activity_12vtq69" /> + <bpmn:sequenceFlow id="Flow_04thflx" sourceRef="Activity_18y4ijb" targetRef="Activity_0qpy2sg" /> + <bpmn:scriptTask id="Activity_0zn4e4n" name="process Job status response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1v3wpa2</bpmn:incoming> + <bpmn:outgoing>Flow_0bd6dhi</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.processMhAllocateNssiJobStatusRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1v3wpa2" sourceRef="Activity_0c0cq9d" targetRef="Activity_0zn4e4n" /> + <bpmn:scriptTask id="Activity_1ll0nr1" name="Process Decomposition" scriptFormat="groovy"> + <bpmn:incoming>Flow_1i10qog</bpmn:incoming> + <bpmn:outgoing>Flow_00f37fu</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.processDecomposition(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_00f37fu" sourceRef="Activity_1ll0nr1" targetRef="Activity_0vhvubq" /> + <bpmn:callActivity id="Activity_06hcbu6" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="ranNsstServiceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0mcd9bo</bpmn:incoming> + <bpmn:outgoing>Flow_1i10qog</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0mcd9bo" sourceRef="Activity_0p02joo" targetRef="Activity_06hcbu6" /> + <bpmn:sequenceFlow id="Flow_1i10qog" sourceRef="Activity_06hcbu6" targetRef="Activity_1ll0nr1" /> + <bpmn:scriptTask id="Activity_1aweui4" name="post process RAN NF NSSI modify" scriptFormat="groovy"> + <bpmn:incoming>Flow_1k3vqxg</bpmn:incoming> + <bpmn:outgoing>Flow_0n1mh5c</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.processRanNfModifyRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1bjike9" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1k0z6lp</bpmn:incoming> + <bpmn:outgoing>Flow_10j50jb</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1k0z6lp" sourceRef="Activity_0xawnmh" targetRef="Activity_1bjike9" /> + <bpmn:scriptTask id="Activity_0xawnmh" name="prepare Modify Access NSSI inputs" scriptFormat="groovy"> + <bpmn:incoming>Flow_1ipsxgh</bpmn:incoming> + <bpmn:outgoing>Flow_1k0z6lp</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.prepareModifyAccessNssiInputs(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_0ffp1no" name="Query Job status" calledElement="QueryJobStatus "> + <bpmn:extensionElements> + <camunda:in source="esrInfo" target="esrInfo" /> + <camunda:in source="serviceInfo" target="serviceInfo" /> + <camunda:in source="modifyRanNssiJobId" target="jobId" /> + <camunda:out source="jobResponse" target="jobResponse" /> + <camunda:in source="responseId" target="responseId" /> + <camunda:in source="job_timeout" target="timeout" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0ile39j</bpmn:incoming> + <bpmn:outgoing>Flow_0mmpy7h</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_0yfrqtb" name="process Job status response" scriptFormat="groovy"> + <bpmn:incoming>Flow_0mmpy7h</bpmn:incoming> + <bpmn:outgoing>Flow_0k8yakp</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.processModifyJobStatusRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0mmpy7h" sourceRef="Activity_0ffp1no" targetRef="Activity_0yfrqtb" /> + <bpmn:sequenceFlow id="Flow_0k8yakp" sourceRef="Activity_0yfrqtb" targetRef="Event_142r2sx" /> + <bpmn:sequenceFlow id="Flow_0ile39j" sourceRef="Activity_1k94obj" targetRef="Activity_0ffp1no" /> + <bpmn:scriptTask id="Activity_1k94obj" name="prepare query job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_05s0wso</bpmn:incoming> + <bpmn:outgoing>Flow_0ile39j</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.createModifyNssiQueryJobStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_16w4zg9" name="Call ANModifyNSSI" calledElement="DoModifyAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="RANServiceInstanceId" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="modifyRanNssiJobId" target="jobId" /> + <camunda:in source="modifySliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_10j50jb</bpmn:incoming> + <bpmn:outgoing>Flow_05s0wso</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_10j50jb" sourceRef="Activity_1bjike9" targetRef="Activity_16w4zg9" /> + <bpmn:sequenceFlow id="Flow_05s0wso" sourceRef="Activity_16w4zg9" targetRef="Activity_1k94obj" /> + <bpmn:scriptTask id="Activity_0fdm3in" name="Prepare Decompose Service " scriptFormat="groovy"> + <bpmn:incoming>Flow_0k39zt8</bpmn:incoming> + <bpmn:incoming>Flow_083bb3k</bpmn:incoming> + <bpmn:outgoing>Flow_0reg6l5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.prepareNsstDecomposeService(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_0a7a04p" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="nsstServiceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0reg6l5</bpmn:incoming> + <bpmn:outgoing>Flow_0jdjta3</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:exclusiveGateway id="Gateway_1cmraqs" name="Is all nsst decomposed?" default="Flow_083bb3k"> + <bpmn:incoming>Flow_0y78v1q</bpmn:incoming> + <bpmn:outgoing>Flow_0rb4j9r</bpmn:outgoing> + <bpmn:outgoing>Flow_083bb3k</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="Activity_1nmk2rt" name="Process Decomposition" scriptFormat="groovy"> + <bpmn:incoming>Flow_0jdjta3</bpmn:incoming> + <bpmn:outgoing>Flow_0y78v1q</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.processNsstDecomposition(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0reg6l5" sourceRef="Activity_0fdm3in" targetRef="Activity_0a7a04p" /> + <bpmn:sequenceFlow id="Flow_0jdjta3" sourceRef="Activity_0a7a04p" targetRef="Activity_1nmk2rt" /> + <bpmn:sequenceFlow id="Flow_0y78v1q" sourceRef="Activity_1nmk2rt" targetRef="Gateway_1cmraqs" /> + <bpmn:sequenceFlow id="Flow_0rb4j9r" name="yes" sourceRef="Gateway_1cmraqs" targetRef="Activity_19laorl"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isAllNsstsDecomposed" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0d0f3ie" sourceRef="Activity_19laorl" targetRef="Activity_0y9xgkl" /> + <bpmn:scriptTask id="Activity_027ic3j" name="create slice profiles in AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_1f9rw3m</bpmn:incoming> + <bpmn:outgoing>Flow_1ryi6ym</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.createSliceProfilesInAai(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1f9rw3m" sourceRef="Activity_1pxd5wf" targetRef="Activity_027ic3j" /> + <bpmn:sequenceFlow id="Flow_1ryi6ym" sourceRef="Activity_027ic3j" targetRef="Gateway_0en9ki5" /> + <bpmn:scriptTask id="Activity_12vtq69" name="prepare query job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0qhjtre</bpmn:incoming> + <bpmn:outgoing>Flow_1p48xbl</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.createFhAllocateNssiJobQuery(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1p48xbl" sourceRef="Activity_12vtq69" targetRef="Activity_1ux83hz" /> + <bpmn:scriptTask id="Activity_0qpy2sg" name="prepare query job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_04thflx</bpmn:incoming> + <bpmn:outgoing>Flow_0fdetmo</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.createMhAllocateNssiJobQuery(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0fdetmo" sourceRef="Activity_0qpy2sg" targetRef="Activity_0c0cq9d" /> + <bpmn:scriptTask id="Activity_0pa8al6" name="create RAN NSSI and RAN NF NSSI in AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ikdlkf</bpmn:incoming> + <bpmn:outgoing>Flow_1exjm0h</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.updateAaiWithRANInstances(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0ikdlkf" sourceRef="Activity_118je0o" targetRef="Activity_0pa8al6" /> + <bpmn:sequenceFlow id="Flow_1exjm0h" sourceRef="Activity_0pa8al6" targetRef="Event_15zn4zi" /> + <bpmn:sequenceFlow id="Flow_0bd6dhi" sourceRef="Activity_0zn4e4n" targetRef="Activity_0vf28ld" /> + <bpmn:sequenceFlow id="Flow_0kcvava" sourceRef="Activity_0vf28ld" targetRef="Event_0u9308h" /> + <bpmn:scriptTask id="Activity_0vf28ld" name="update AAI relationships"> + <bpmn:incoming>Flow_0bd6dhi</bpmn:incoming> + <bpmn:outgoing>Flow_0kcvava</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.updateAairelationships(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:subProcess id="Activity_0bcs8g1" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_077lf7i"> + <bpmn:outgoing>Flow_18rrdsq</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1chyysm" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1p00v8c"> + <bpmn:incoming>Flow_0c9dr7z</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_084fqbd" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_0umohws</bpmn:incoming> + <bpmn:outgoing>Flow_0c9dr7z</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0c9dr7z" sourceRef="Activity_084fqbd" targetRef="Event_1p00v8c" /> + <bpmn:scriptTask id="Activity_1adxijg" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_18rrdsq</bpmn:incoming> + <bpmn:outgoing>Flow_11qgtdm</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoAllocateAccessNSSI() +nss.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_0p0mwue" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_11qgtdm</bpmn:incoming> + <bpmn:outgoing>Flow_0umohws</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_18rrdsq" sourceRef="Event_077lf7i" targetRef="Activity_1adxijg" /> + <bpmn:sequenceFlow id="Flow_11qgtdm" sourceRef="Activity_1adxijg" targetRef="Activity_0p0mwue" /> + <bpmn:sequenceFlow id="Flow_0umohws" sourceRef="Activity_0p0mwue" targetRef="Activity_084fqbd" /> + </bpmn:subProcess> + <bpmn:intermediateThrowEvent id="Event_1cqde7p" name="Goto start TN allocate"> + <bpmn:incoming>Flow_0n1mh5c</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0da795k" name="startTnAllocate" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_0n1mh5c" sourceRef="Activity_1aweui4" targetRef="Event_1cqde7p" /> + <bpmn:callActivity id="Activity_08i0hzk" name="DoModifyRanNfNssi" calledElement="DoModifyRanNfNssi"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="ANNF_NSSI" target="serviceInstanceID" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="ANNF_sliceProfileInstanceId" target="sliceProfileId" /> + <camunda:in source="snssaiList" target="snssaiList" /> + <camunda:out source="ranNfStatus" target="ranNfStatus" /> + <camunda:in source="modifyAction" target="modifyAction" /> + <camunda:in source="ranNfSliceProfile" target="additionalProperties" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0kn30g3</bpmn:incoming> + <bpmn:outgoing>Flow_1k3vqxg</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1k3vqxg" sourceRef="Activity_08i0hzk" targetRef="Activity_1aweui4" /> + <bpmn:sequenceFlow id="Flow_083bb3k" sourceRef="Gateway_1cmraqs" targetRef="Activity_0fdm3in" /> + </bpmn:process> + <bpmn:message id="Message_1r7nv8u" name="WorkflowMessage" /> + <bpmn:error id="Error_047rteq" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateAccessNSSI"> + <bpmndi:BPMNEdge id="Flow_0kcvava_di" bpmnElement="Flow_0kcvava"> + <di:waypoint x="1800" y="820" /> + <di:waypoint x="1882" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0bd6dhi_di" bpmnElement="Flow_0bd6dhi"> + <di:waypoint x="1620" y="820" /> + <di:waypoint x="1700" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1exjm0h_di" bpmnElement="Flow_1exjm0h"> + <di:waypoint x="1850" y="680" /> + <di:waypoint x="1882" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ikdlkf_di" bpmnElement="Flow_0ikdlkf"> + <di:waypoint x="1720" y="680" /> + <di:waypoint x="1750" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fdetmo_di" bpmnElement="Flow_0fdetmo"> + <di:waypoint x="1260" y="820" /> + <di:waypoint x="1340" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1p48xbl_di" bpmnElement="Flow_1p48xbl"> + <di:waypoint x="580" y="820" /> + <di:waypoint x="640" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ryi6ym_di" bpmnElement="Flow_1ryi6ym"> + <di:waypoint x="1330" y="531" /> + <di:waypoint x="1355" y="531" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1f9rw3m_di" bpmnElement="Flow_1f9rw3m"> + <di:waypoint x="1210" y="531" /> + <di:waypoint x="1230" y="531" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0d0f3ie_di" bpmnElement="Flow_0d0f3ie"> + <di:waypoint x="950" y="530" /> + <di:waypoint x="980" y="530" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0rb4j9r_di" bpmnElement="Flow_0rb4j9r"> + <di:waypoint x="815" y="529" /> + <di:waypoint x="833" y="529" /> + <di:waypoint x="833" y="530" /> + <di:waypoint x="850" y="530" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="824" y="543" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0y78v1q_di" bpmnElement="Flow_0y78v1q"> + <di:waypoint x="720" y="529" /> + <di:waypoint x="765" y="529" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0jdjta3_di" bpmnElement="Flow_0jdjta3"> + <di:waypoint x="600" y="529" /> + <di:waypoint x="620" y="529" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0reg6l5_di" bpmnElement="Flow_0reg6l5"> + <di:waypoint x="470" y="529" /> + <di:waypoint x="485" y="529" /> + <di:waypoint x="485" y="530" /> + <di:waypoint x="500" y="530" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_05s0wso_di" bpmnElement="Flow_05s0wso"> + <di:waypoint x="770" y="380" /> + <di:waypoint x="810" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_10j50jb_di" bpmnElement="Flow_10j50jb"> + <di:waypoint x="630" y="380" /> + <di:waypoint x="670" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ile39j_di" bpmnElement="Flow_0ile39j"> + <di:waypoint x="910" y="380" /> + <di:waypoint x="950" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0k8yakp_di" bpmnElement="Flow_0k8yakp"> + <di:waypoint x="1190" y="380" /> + <di:waypoint x="1242" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0mmpy7h_di" bpmnElement="Flow_0mmpy7h"> + <di:waypoint x="1050" y="380" /> + <di:waypoint x="1090" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1k0z6lp_di" bpmnElement="Flow_1k0z6lp"> + <di:waypoint x="490" y="380" /> + <di:waypoint x="530" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1i10qog_di" bpmnElement="Flow_1i10qog"> + <di:waypoint x="630" y="120" /> + <di:waypoint x="690" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0mcd9bo_di" bpmnElement="Flow_0mcd9bo"> + <di:waypoint x="480" y="120" /> + <di:waypoint x="530" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_00f37fu_di" bpmnElement="Flow_00f37fu"> + <di:waypoint x="790" y="120" /> + <di:waypoint x="830" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1v3wpa2_di" bpmnElement="Flow_1v3wpa2"> + <di:waypoint x="1440" y="820" /> + <di:waypoint x="1520" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_04thflx_di" bpmnElement="Flow_04thflx"> + <di:waypoint x="1100" y="820" /> + <di:waypoint x="1160" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0qhjtre_di" bpmnElement="Flow_0qhjtre"> + <di:waypoint x="410" y="820" /> + <di:waypoint x="480" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_05yqmnj_di" bpmnElement="Flow_05yqmnj"> + <di:waypoint x="1580" y="680" /> + <di:waypoint x="1620" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1pbiznt_di" bpmnElement="Flow_1pbiznt"> + <di:waypoint x="1430" y="680" /> + <di:waypoint x="1480" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0kn30g3_di" bpmnElement="Flow_0kn30g3"> + <di:waypoint x="1403" y="529" /> + <di:waypoint x="1460" y="529" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1413" y="513" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1nkqrpd_di" bpmnElement="Flow_1nkqrpd"> + <di:waypoint x="1080" y="531" /> + <di:waypoint x="1110" y="531" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16z59pu_di" bpmnElement="Flow_16z59pu"> + <di:waypoint x="740" y="820" /> + <di:waypoint x="810" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b14415_di" bpmnElement="Flow_1b14415"> + <di:waypoint x="1200" y="120" /> + <di:waypoint x="1240" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0tica8m_di" bpmnElement="Flow_0tica8m"> + <di:waypoint x="340" y="120" /> + <di:waypoint x="380" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0k39zt8_di" bpmnElement="Flow_0k39zt8"> + <di:waypoint x="270" y="405" /> + <di:waypoint x="270" y="529" /> + <di:waypoint x="370" y="529" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="249" y="421" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_09tjspa_di" bpmnElement="Flow_09tjspa"> + <di:waypoint x="198" y="380" /> + <di:waypoint x="245" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1h7iq8l_di" bpmnElement="Flow_1h7iq8l"> + <di:waypoint x="1340" y="120" /> + <di:waypoint x="1372" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0tkzfhb_di" bpmnElement="Flow_0tkzfhb"> + <di:waypoint x="1060" y="120" /> + <di:waypoint x="1100" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1w8whur_di" bpmnElement="Flow_1w8whur"> + <di:waypoint x="930" y="120" /> + <di:waypoint x="960" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_178fenq_di" bpmnElement="Flow_178fenq"> + <di:waypoint x="1380" y="556" /> + <di:waypoint x="1380" y="640" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1386" y="574" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ipsxgh_di" bpmnElement="Flow_1ipsxgh"> + <di:waypoint x="295" y="380" /> + <di:waypoint x="390" y="380" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="319" y="363" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_163f3sq_di" bpmnElement="Flow_163f3sq"> + <di:waypoint x="198" y="120" /> + <di:waypoint x="240" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0zhr499_di" bpmnElement="Flow_0zhr499"> + <di:waypoint x="910" y="820" /> + <di:waypoint x="1000" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1x3y2tg_di" bpmnElement="Flow_1x3y2tg"> + <di:waypoint x="228" y="820" /> + <di:waypoint x="310" y="820" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ll5x3u_di" bpmnElement="Flow_0ll5x3u"> + <di:waypoint x="600" y="1010" /> + <di:waypoint x="692" y="1010" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1xw4abx_di" bpmnElement="Flow_1xw4abx"> + <di:waypoint x="420" y="1010" /> + <di:waypoint x="500" y="1010" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0833cha_di" bpmnElement="Flow_0833cha"> + <di:waypoint x="228" y="1010" /> + <di:waypoint x="320" y="1010" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0n1mh5c_di" bpmnElement="Flow_0n1mh5c"> + <di:waypoint x="1690" y="529" /> + <di:waypoint x="1742" y="529" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1k3vqxg_di" bpmnElement="Flow_1k3vqxg"> + <di:waypoint x="1560" y="529" /> + <di:waypoint x="1590" y="529" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_083bb3k_di" bpmnElement="Flow_083bb3k"> + <di:waypoint x="790" y="554" /> + <di:waypoint x="790" y="730" /> + <di:waypoint x="420" y="730" /> + <di:waypoint x="420" y="569" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="162" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="167" y="152" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_01iduqx_di" bpmnElement="Activity_1jj3kh9"> + <dc:Bounds x="240" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1gdi5bo_di" bpmnElement="Activity_0vhvubq"> + <dc:Bounds x="830" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_11vdo22_di" bpmnElement="Activity_11vdo22"> + <dc:Bounds x="320" y="970" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1nfx154_di" bpmnElement="Activity_1nfx154"> + <dc:Bounds x="500" y="970" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0vh1hs2_di" bpmnElement="Event_0vh1hs2"> + <dc:Bounds x="692" y="992" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0icw8wt_di" bpmnElement="Activity_19laorl"> + <dc:Bounds x="850" y="490" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_10z6k5t_di" bpmnElement="Activity_03dgcg5"> + <dc:Bounds x="310" y="780" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1dracjc_di" bpmnElement="Activity_18y4ijb"> + <dc:Bounds x="1000" y="780" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0g0i472_di" bpmnElement="Event_05jtdqp"> + <dc:Bounds x="192" y="992" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="174" y="1035" width="73" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1ea1h0i_di" bpmnElement="Event_0u9308h"> + <dc:Bounds x="1882" y="802" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1860" y="850" width="79" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1fj3anx_di" bpmnElement="Event_18r5xkz"> + <dc:Bounds x="192" y="802" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="170" y="845" width="81" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0nm8unl_di" bpmnElement="Activity_0qn2fvh"> + <dc:Bounds x="810" y="780" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_12szahe_di" bpmnElement="Activity_12szahe"> + <dc:Bounds x="1240" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1oepxwk_di" bpmnElement="Activity_0vwhzem"> + <dc:Bounds x="960" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1aesepd_di" bpmnElement="Gateway_1aesepd" isMarkerVisible="true"> + <dc:Bounds x="245" y="355" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="239" y="326" width="62" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_142r2sx_di" bpmnElement="Event_142r2sx"> + <dc:Bounds x="1242" y="362" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1220" y="397" width="79" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_15zn4zi_di" bpmnElement="Event_15zn4zi"> + <dc:Bounds x="1882" y="662" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1868" y="705" width="67" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1pxd5wf_di" bpmnElement="Activity_1pxd5wf"> + <dc:Bounds x="1110" y="491" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0en9ki5_di" bpmnElement="Gateway_0en9ki5" isMarkerVisible="true"> + <dc:Bounds x="1355" y="506" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1349" y="476" width="62" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0a95zgv_di" bpmnElement="Activity_0a95zgv"> + <dc:Bounds x="1330" y="640" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_118je0o_di" bpmnElement="Activity_118je0o"> + <dc:Bounds x="1620" y="640" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0qwruv5_di" bpmnElement="Event_0s8t1ji"> + <dc:Bounds x="1372" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1351" y="145" width="81" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1vfrb2l_di" bpmnElement="Event_1glt41l"> + <dc:Bounds x="162" y="362" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="155" y="405" width="51" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0p02joo_di" bpmnElement="Activity_0p02joo"> + <dc:Bounds x="380" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1u28lyv_di" bpmnElement="Activity_1u28lyv"> + <dc:Bounds x="1100" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ux83hz_di" bpmnElement="Activity_1ux83hz"> + <dc:Bounds x="640" y="780" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0c0cq9d_di" bpmnElement="Activity_0c0cq9d"> + <dc:Bounds x="1340" y="780" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0y9xgkl_di" bpmnElement="Activity_0y9xgkl"> + <dc:Bounds x="980" y="491" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0vbzhej_di" bpmnElement="Activity_0vbzhej"> + <dc:Bounds x="1480" y="640" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0zn4e4n_di" bpmnElement="Activity_0zn4e4n"> + <dc:Bounds x="1520" y="780" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ll0nr1_di" bpmnElement="Activity_1ll0nr1"> + <dc:Bounds x="690" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_06hcbu6_di" bpmnElement="Activity_06hcbu6"> + <dc:Bounds x="530" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1xke4xc_di" bpmnElement="Activity_1aweui4"> + <dc:Bounds x="1590" y="489" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1bjike9_di" bpmnElement="Activity_1bjike9"> + <dc:Bounds x="530" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_02rsimm_di" bpmnElement="Activity_0xawnmh"> + <dc:Bounds x="390" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ffp1no_di" bpmnElement="Activity_0ffp1no"> + <dc:Bounds x="950" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0yfrqtb_di" bpmnElement="Activity_0yfrqtb"> + <dc:Bounds x="1090" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wagv3s_di" bpmnElement="Activity_1k94obj"> + <dc:Bounds x="810" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16w4zg9_di" bpmnElement="Activity_16w4zg9"> + <dc:Bounds x="670" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0fdm3in_di" bpmnElement="Activity_0fdm3in"> + <dc:Bounds x="370" y="489" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0a7a04p_di" bpmnElement="Activity_0a7a04p"> + <dc:Bounds x="500" y="489" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1cmraqs_di" bpmnElement="Gateway_1cmraqs" isMarkerVisible="true"> + <dc:Bounds x="765" y="504" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="755" y="467" width="70" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1nmk2rt_di" bpmnElement="Activity_1nmk2rt"> + <dc:Bounds x="620" y="489" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_027ic3j_di" bpmnElement="Activity_027ic3j"> + <dc:Bounds x="1230" y="491" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_12vtq69_di" bpmnElement="Activity_12vtq69"> + <dc:Bounds x="480" y="780" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0qpy2sg_di" bpmnElement="Activity_0qpy2sg"> + <dc:Bounds x="1160" y="780" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0pa8al6_di" bpmnElement="Activity_0pa8al6"> + <dc:Bounds x="1750" y="640" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1riw9uv_di" bpmnElement="Activity_0vf28ld"> + <dc:Bounds x="1700" y="780" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1cqde7p_di" bpmnElement="Event_1cqde7p"> + <dc:Bounds x="1742" y="511" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1728" y="554" width="67" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_08i0hzk_di" bpmnElement="Activity_08i0hzk"> + <dc:Bounds x="1460" y="489" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0bcs8g1_di" bpmnElement="Activity_0bcs8g1" isExpanded="true"> + <dc:Bounds x="410" y="1160" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0umohws_di" bpmnElement="Flow_0umohws"> + <di:waypoint x="800" y="1264" /> + <di:waypoint x="870" y="1264" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_11qgtdm_di" bpmnElement="Flow_11qgtdm"> + <di:waypoint x="640" y="1264" /> + <di:waypoint x="700" y="1264" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_18rrdsq_di" bpmnElement="Flow_18rrdsq"> + <di:waypoint x="476" y="1264" /> + <di:waypoint x="540" y="1264" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0c9dr7z_di" bpmnElement="Flow_0c9dr7z"> + <di:waypoint x="970" y="1264" /> + <di:waypoint x="1078" y="1264" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_077lf7i_di" bpmnElement="Event_077lf7i"> + <dc:Bounds x="440" y="1246" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1p00v8c_di" bpmnElement="Event_1p00v8c"> + <dc:Bounds x="1078" y="1246" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_084fqbd_di" bpmnElement="Activity_084fqbd"> + <dc:Bounds x="870" y="1224" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1adxijg_di" bpmnElement="Activity_1adxijg"> + <dc:Bounds x="540" y="1224" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0p0mwue_di" bpmnElement="Activity_0p0mwue"> + <dc:Bounds x="700" y="1224" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn new file mode 100644 index 0000000000..92407e9b2a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn @@ -0,0 +1,309 @@ +<?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" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_19c8rxx" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="DoAllocateCoreNSSI" name="DoAllocateCoreNSSI" isExecutable="true"> + <bpmn:startEvent id="allocateNSSI_startEvent" name="Start"> + <bpmn:outgoing>SequenceFlow_0bjz7up</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_0bjz7up" sourceRef="allocateNSSI_startEvent" targetRef="processRequest_ScriptTask" /> + <bpmn:sequenceFlow id="SequenceFlow_1xiszom" sourceRef="processRequest_ScriptTask" targetRef="ScriptTask_13krb7d" /> + <bpmn:sequenceFlow id="SequenceFlow_1r5aycw" sourceRef="ScriptTask_0ybe0w9" targetRef="Activity_16u5d39" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1xjahhp" default="SequenceFlow_1scva4p"> + <bpmn:incoming>Flow_0kbpihh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1scva4p</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1ygklb8</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1scva4p" name="No Existing s-nssai" sourceRef="ExclusiveGateway_1xjahhp" targetRef="CallActivity_0ue7vug" /> + <bpmn:sequenceFlow id="SequenceFlow_1ygklb8" sourceRef="ExclusiveGateway_1xjahhp" targetRef="CallActivity_0e6drr2"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("solutions") !="" }</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0enouyb" sourceRef="ScriptTask_13krb7d" targetRef="ScriptTask_0ybe0w9" /> + <bpmn:endEvent id="EndEvent_1e80uuk" name="End"> + <bpmn:incoming>SequenceFlow_0tytimn</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0tubodn</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="processRequest_ScriptTask" name="Preprocess request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0bjz7up</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1xiszom</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNSSI() +allocateNssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_13krb7d" name="Get NSST name from CatalogDB" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1xiszom</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0enouyb</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNSSI() +allocateNssi.getNSSTName(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0ybe0w9" name="Prepare OOF request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0enouyb</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1r5aycw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNSSI() +allocateNssi.prepareOOFRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_0ue7vug" name="Call non-shared slice flow" calledElement="DoAllocateCoreNonSharedSlice"> + <bpmn:extensionElements> + <camunda:in source="coreServiceInstanceId" target="serviceInstanceId" /> + <camunda:in source="networkServiceModelInfo" target="networkServiceModelInfo" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="nsstName" target="nsstName" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:in source="servicename" target="servicename" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="sliceProfile" target="sliceProfile" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1scva4p</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0tubodn</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="CallActivity_0e6drr2" name="Call shared slice flow " calledElement="DoAllocateCoreSharedSlice"> + <bpmn:extensionElements> + <camunda:in source="solutions" target="solutions" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="nsstName" target="nsstName" /> + <camunda:in source="dummyServiceId" target="dummyServiceId" /> + <camunda:in source="networkServiceModelInfo" target="networkServiceModelInfo" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:in source="servicename" target="servicename" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="sliceProfile" target="sliceProfile" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1ygklb8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0tytimn</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_0tytimn" sourceRef="CallActivity_0e6drr2" targetRef="EndEvent_1e80uuk" /> + <bpmn:sequenceFlow id="SequenceFlow_0tubodn" sourceRef="CallActivity_0ue7vug" targetRef="EndEvent_1e80uuk" /> + <bpmn:callActivity id="Activity_16u5d39" name="Call DoHandleOofRequest" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="NSSI_apiPath" target="apiPath" /> + <camunda:in source="NSSI_correlator" target="correlator" /> + <camunda:in source="NSSI_messageType" target="messageType" /> + <camunda:in source="NSSI_timeout" target="timeout" /> + <camunda:in source="NSSI_oofRequest" target="oofRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="NSSI_asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1r5aycw</bpmn:incoming> + <bpmn:outgoing>Flow_1navrbe</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1navrbe" sourceRef="Activity_16u5d39" targetRef="ScriptTask_1bg09vu" /> + <bpmn:scriptTask id="ScriptTask_1bg09vu" name="Process OOF Async ressponse" scriptFormat="groovy"> + <bpmn:incoming>Flow_1navrbe</bpmn:incoming> + <bpmn:outgoing>Flow_0kbpihh</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNSSI() +allocateNssi.processOOFAsyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0kbpihh" sourceRef="ScriptTask_1bg09vu" targetRef="ExclusiveGateway_1xjahhp" /> + <bpmn:subProcess id="Activity_0nliikd" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_0jeyy28"> + <bpmn:outgoing>Flow_1bd9s44</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_00bn0ig" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_0f5seph"> + <bpmn:incoming>Flow_1rrkw3k</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_016fs4l" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_1jn84pa</bpmn:incoming> + <bpmn:outgoing>Flow_1rrkw3k</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1wmb5hd" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_1bd9s44</bpmn:incoming> + <bpmn:outgoing>Flow_167qlhy</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi= new DoAllocateCoreNSSI() +allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_0frxrqx" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_167qlhy</bpmn:incoming> + <bpmn:outgoing>Flow_1jn84pa</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1jn84pa" sourceRef="Activity_0frxrqx" targetRef="Activity_016fs4l" /> + <bpmn:sequenceFlow id="Flow_167qlhy" sourceRef="Activity_1wmb5hd" targetRef="Activity_0frxrqx" /> + <bpmn:sequenceFlow id="Flow_1bd9s44" sourceRef="Event_0jeyy28" targetRef="Activity_1wmb5hd" /> + <bpmn:sequenceFlow id="Flow_1rrkw3k" sourceRef="Activity_016fs4l" targetRef="Event_0f5seph" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateCoreNSSI"> + <bpmndi:BPMNEdge id="Flow_0kbpihh_di" bpmnElement="Flow_0kbpihh"> + <di:waypoint x="868" y="180" /> + <di:waypoint x="929" y="180" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="753.5" y="155" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1navrbe_di" bpmnElement="Flow_1navrbe"> + <di:waypoint x="735" y="180" /> + <di:waypoint x="768" y="180" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0tubodn_di" bpmnElement="SequenceFlow_0tubodn"> + <di:waypoint x="1096" y="115" /> + <di:waypoint x="1136" y="115" /> + <di:waypoint x="1136" y="184" /> + <di:waypoint x="1176" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1051" y="143.5" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0tytimn_di" bpmnElement="SequenceFlow_0tytimn"> + <di:waypoint x="1096" y="266" /> + <di:waypoint x="1136" y="266" /> + <di:waypoint x="1136" y="184" /> + <di:waypoint x="1176" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1051" y="219" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0enouyb_di" bpmnElement="SequenceFlow_0enouyb"> + <di:waypoint x="468" y="184" /> + <di:waypoint x="501" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="339.5" y="163" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ygklb8_di" bpmnElement="SequenceFlow_1ygklb8"> + <di:waypoint x="954" y="205" /> + <di:waypoint x="954" y="266" /> + <di:waypoint x="996" y="266" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="824" y="229.5" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1scva4p_di" bpmnElement="SequenceFlow_1scva4p"> + <di:waypoint x="954" y="155" /> + <di:waypoint x="954" y="115" /> + <di:waypoint x="996" y="115" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="897" y="116" width="56" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1r5aycw_di" bpmnElement="SequenceFlow_1r5aycw"> + <di:waypoint x="601" y="184" /> + <di:waypoint x="635" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="470.5" y="163" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1xiszom_di" bpmnElement="SequenceFlow_1xiszom"> + <di:waypoint x="343" y="184" /> + <di:waypoint x="368" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="210.5" y="163" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0bjz7up_di" bpmnElement="SequenceFlow_0bjz7up"> + <di:waypoint x="195" y="184" /> + <di:waypoint x="243" y="184" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="74" y="163" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="allocateNSSI_startEvent"> + <dc:Bounds x="159" y="166" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="166" y="209" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1xjahhp_di" bpmnElement="ExclusiveGateway_1xjahhp" isMarkerVisible="true"> + <dc:Bounds x="929" y="155" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="975" y="284" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1e80uuk_di" bpmnElement="EndEvent_1e80uuk"> + <dc:Bounds x="1176" y="166" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1184" y="209" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1eo0wn0_di" bpmnElement="processRequest_ScriptTask"> + <dc:Bounds x="243" y="144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0cs9cfh_di" bpmnElement="ScriptTask_13krb7d"> + <dc:Bounds x="368" y="144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1v669aj_di" bpmnElement="ScriptTask_0ybe0w9"> + <dc:Bounds x="501" y="144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_04schfi_di" bpmnElement="CallActivity_0ue7vug"> + <dc:Bounds x="996" y="75" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1vy16mp_di" bpmnElement="CallActivity_0e6drr2"> + <dc:Bounds x="996" y="226" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16u5d39_di" bpmnElement="Activity_16u5d39"> + <dc:Bounds x="635" y="144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_19cc8m2_di" bpmnElement="ScriptTask_1bg09vu"> + <dc:Bounds x="768" y="140" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0nliikd_di" bpmnElement="Activity_0nliikd" isExpanded="true"> + <dc:Bounds x="300" y="360" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_1rrkw3k_di" bpmnElement="Flow_1rrkw3k"> + <di:waypoint x="860" y="464" /> + <di:waypoint x="968" y="464" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1bd9s44_di" bpmnElement="Flow_1bd9s44"> + <di:waypoint x="366" y="464" /> + <di:waypoint x="430" y="464" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_167qlhy_di" bpmnElement="Flow_167qlhy"> + <di:waypoint x="530" y="464" /> + <di:waypoint x="590" y="464" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jn84pa_di" bpmnElement="Flow_1jn84pa"> + <di:waypoint x="690" y="464" /> + <di:waypoint x="760" y="464" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_0jeyy28_di" bpmnElement="Event_0jeyy28"> + <dc:Bounds x="330" y="446" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0f5seph_di" bpmnElement="Event_0f5seph"> + <dc:Bounds x="968" y="446" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_016fs4l_di" bpmnElement="Activity_016fs4l"> + <dc:Bounds x="760" y="424" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wmb5hd_di" bpmnElement="Activity_1wmb5hd"> + <dc:Bounds x="430" y="424" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0frxrqx_di" bpmnElement="Activity_0frxrqx"> + <dc:Bounds x="590" y="424" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNonSharedSlice.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNonSharedSlice.bpmn new file mode 100644 index 0000000000..22eeceea51 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNonSharedSlice.bpmn @@ -0,0 +1,368 @@ +<?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" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_021ltql" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="DoAllocateCoreNonSharedSlice" name="DoAllocateCoreNonSharedSlice" isExecutable="true"> + <bpmn:startEvent id="StartEvent_0niin4a" name="Start"> + <bpmn:outgoing>SequenceFlow_0vxnxew</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_09xlga4" default="Flow_0ebyiqk"> + <bpmn:incoming>SequenceFlow_0pkw03j</bpmn:incoming> + <bpmn:outgoing>Flow_1xofp8o</bpmn:outgoing> + <bpmn:outgoing>Flow_0ebyiqk</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0vxnxew" sourceRef="StartEvent_0niin4a" targetRef="Activity_0kvdq8n" /> + <bpmn:sequenceFlow id="SequenceFlow_1terk7m" sourceRef="Task_0n4n0mx" targetRef="Task_0nowehc" /> + <bpmn:sequenceFlow id="SequenceFlow_0pkw03j" sourceRef="Task_1p5lbp7" targetRef="ExclusiveGateway_09xlga4" /> + <bpmn:scriptTask id="Task_0n4n0mx" name="Call AAI Create NSSI" scriptFormat="groovy"> + <bpmn:incoming>Flow_13lzgo4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1terk7m</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.createNSSIinAAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_0nowehc" name="Prepare serviceOrder request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1terk7m</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0qeif6i</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.prepareServiceOrderRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_1p5lbp7" name="Call serviceOrder api" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0cqjgbm</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0pkw03j</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.postNBIServiceOrder(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1xofp8o" name="ACK" sourceRef="ExclusiveGateway_09xlga4" targetRef="Task_15tmmrz"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("ServiceOrderId" ) != null && execution.getVariable("ServiceOrderId" ) != "" )}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:exclusiveGateway id="ExclusiveGateway_0bq5wvj" name="Status = processing" default="Flow_1hjbkma"> + <bpmn:incoming>SequenceFlow_1g8lnjx</bpmn:incoming> + <bpmn:outgoing>Flow_1hjbkma</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0zuc4mh</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1g8lnjx" sourceRef="Task_15tmmrz" targetRef="ExclusiveGateway_0bq5wvj" /> + <bpmn:endEvent id="EndEvent_1pb7jxo" name="End"> + <bpmn:incoming>Flow_0ginxdy</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_13lzgo4" sourceRef="Activity_0kvdq8n" targetRef="Task_0n4n0mx" /> + <bpmn:scriptTask id="Activity_0kvdq8n" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0vxnxew</bpmn:incoming> + <bpmn:outgoing>Flow_13lzgo4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_15tmmrz" name="Call Get ServiceOrder Progress" scriptFormat="groovy"> + <bpmn:incoming>Flow_1xofp8o</bpmn:incoming> + <bpmn:incoming>Flow_0d9xaja</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1g8lnjx</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.getNBIServiceOrderProgress(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_19ywbh2" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0ebyiqk</bpmn:incoming> + <bpmn:incoming>Flow_140j38y</bpmn:incoming> + <bpmn:outgoing>Flow_0ginxdy</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0ebyiqk" name="Failed" sourceRef="ExclusiveGateway_09xlga4" targetRef="Activity_19ywbh2" /> + <bpmn:sequenceFlow id="Flow_1hjbkma" sourceRef="ExclusiveGateway_0bq5wvj" targetRef="Activity_0luwonx" /> + <bpmn:sequenceFlow id="Flow_0ginxdy" sourceRef="Activity_19ywbh2" targetRef="EndEvent_1pb7jxo" /> + <bpmn:sequenceFlow id="SequenceFlow_0zuc4mh" name="Yes" sourceRef="ExclusiveGateway_0bq5wvj" targetRef="Activity_0h5vkls"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("status" ) == "processing" )}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0d9xaja" sourceRef="Activity_0h5vkls" targetRef="Task_15tmmrz" /> + <bpmn:scriptTask id="Activity_0h5vkls" name="Time Delay" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0zuc4mh</bpmn:incoming> + <bpmn:outgoing>Flow_0d9xaja</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.timeDelay(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0luwonx" name="Call AAI associate NSSI with network service instance" scriptFormat="groovy"> + <bpmn:incoming>Flow_1hjbkma</bpmn:incoming> + <bpmn:outgoing>Flow_140j38y</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.updateRelationship(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_140j38y" sourceRef="Activity_0luwonx" targetRef="Activity_19ywbh2" /> + <bpmn:sequenceFlow id="SequenceFlow_0qeif6i" sourceRef="Task_0nowehc" targetRef="IntermediateThrowEvent_0m8avak" /> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0m8avak" name="callServiceOrder"> + <bpmn:incoming>SequenceFlow_0qeif6i</bpmn:incoming> + <bpmn:linkEventDefinition name="callServiceOrder" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0nz9fnn" name="callServiceOrder"> + <bpmn:outgoing>SequenceFlow_0cqjgbm</bpmn:outgoing> + <bpmn:linkEventDefinition name="callServiceOrder" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_0cqjgbm" sourceRef="IntermediateThrowEvent_0nz9fnn" targetRef="Task_1p5lbp7" /> + <bpmn:subProcess id="Activity_0uegdhh" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_054d9nj"> + <bpmn:outgoing>Flow_022y6dc</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1e3e8ia" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1kmtbm7"> + <bpmn:incoming>Flow_0luurk9</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_1ov9qpp" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_07lojd9</bpmn:incoming> + <bpmn:outgoing>Flow_0luurk9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_016j574" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_022y6dc</bpmn:incoming> + <bpmn:outgoing>Flow_0g444ik</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreNonSharedSlice() +allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1wz7ppl" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0g444ik</bpmn:incoming> + <bpmn:outgoing>Flow_07lojd9</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0luurk9" sourceRef="Activity_1ov9qpp" targetRef="Event_1kmtbm7" /> + <bpmn:sequenceFlow id="Flow_022y6dc" sourceRef="Event_054d9nj" targetRef="Activity_016j574" /> + <bpmn:sequenceFlow id="Flow_0g444ik" sourceRef="Activity_016j574" targetRef="Activity_1wz7ppl" /> + <bpmn:sequenceFlow id="Flow_07lojd9" sourceRef="Activity_1wz7ppl" targetRef="Activity_1ov9qpp" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateCoreNonSharedSlice"> + <bpmndi:BPMNEdge id="SequenceFlow_0cqjgbm_di" bpmnElement="SequenceFlow_0cqjgbm"> + <di:waypoint x="188" y="295" /> + <di:waypoint x="250" y="295" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="219" y="274" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qeif6i_di" bpmnElement="SequenceFlow_0qeif6i"> + <di:waypoint x="672" y="117" /> + <di:waypoint x="732" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="702" y="96" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_140j38y_di" bpmnElement="Flow_140j38y"> + <di:waypoint x="825" y="379" /> + <di:waypoint x="868" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="801.5" y="354" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0d9xaja_di" bpmnElement="Flow_0d9xaja"> + <di:waypoint x="589" y="483" /> + <di:waypoint x="508" y="483" /> + <di:waypoint x="508" y="419" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="503.5" y="458" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0zuc4mh_di" bpmnElement="SequenceFlow_0zuc4mh"> + <di:waypoint x="639" y="404" /> + <di:waypoint x="639" y="443" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="649" y="414" width="19" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ginxdy_di" bpmnElement="Flow_0ginxdy"> + <di:waypoint x="968" y="379" /> + <di:waypoint x="1013" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="945.5" y="354" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1hjbkma_di" bpmnElement="Flow_1hjbkma"> + <di:waypoint x="664" y="379" /> + <di:waypoint x="725" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="649.5" y="354" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ebyiqk_di" bpmnElement="Flow_0ebyiqk"> + <di:waypoint x="449" y="295" /> + <di:waypoint x="918" y="295" /> + <di:waypoint x="918" y="339" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="669" y="277" width="30" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_13lzgo4_di" bpmnElement="Flow_13lzgo4"> + <di:waypoint x="350" y="117" /> + <di:waypoint x="412" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="456" y="92" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1g8lnjx_di" bpmnElement="SequenceFlow_1g8lnjx"> + <di:waypoint x="558" y="379" /> + <di:waypoint x="614" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="541" y="358" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1xofp8o_di" bpmnElement="Flow_1xofp8o"> + <di:waypoint x="424" y="320" /> + <di:waypoint x="424" y="379" /> + <di:waypoint x="458" y="379" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="396" y="344" width="24" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0pkw03j_di" bpmnElement="SequenceFlow_0pkw03j"> + <di:waypoint x="350" y="295" /> + <di:waypoint x="399" y="295" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="329.5" y="274" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1terk7m_di" bpmnElement="SequenceFlow_1terk7m"> + <di:waypoint x="512" y="117" /> + <di:waypoint x="572" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="617" y="96" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0vxnxew_di" bpmnElement="SequenceFlow_0vxnxew"> + <di:waypoint x="188" y="117" /> + <di:waypoint x="250" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="294" y="96" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_0niin4a_di" bpmnElement="StartEvent_0niin4a"> + <dc:Bounds x="152" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="142" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_09xlga4_di" bpmnElement="ExclusiveGateway_09xlga4" isMarkerVisible="true"> + <dc:Bounds x="399" y="270" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-256" y="579" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0rs2nd3_di" bpmnElement="Task_0n4n0mx"> + <dc:Bounds x="412" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0m5z0ww_di" bpmnElement="Task_0nowehc"> + <dc:Bounds x="572" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1d5c0io_di" bpmnElement="Task_1p5lbp7"> + <dc:Bounds x="250" y="255" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0bq5wvj_di" bpmnElement="ExclusiveGateway_0bq5wvj" isMarkerVisible="true"> + <dc:Bounds x="614" y="354" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="613" y="332" width="54" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1pb7jxo_di" bpmnElement="EndEvent_1pb7jxo"> + <dc:Bounds x="1013" y="361" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1021" y="404" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0e7umcn_di" bpmnElement="Activity_0kvdq8n"> + <dc:Bounds x="250" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_18jxe7s_di" bpmnElement="Task_15tmmrz"> + <dc:Bounds x="458" y="339" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_19ywbh2_di" bpmnElement="Activity_19ywbh2"> + <dc:Bounds x="868" y="339" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_07789nc_di" bpmnElement="Activity_0h5vkls"> + <dc:Bounds x="589" y="443" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0luwonx_di" bpmnElement="Activity_0luwonx"> + <dc:Bounds x="725" y="339" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0fs6uqw_di" bpmnElement="IntermediateThrowEvent_0m8avak"> + <dc:Bounds x="732" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="714" y="139" width="83" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_16ljm3v_di" bpmnElement="IntermediateThrowEvent_0nz9fnn"> + <dc:Bounds x="152" y="277" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="130" y="317" width="83" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0uegdhh_di" bpmnElement="Activity_0uegdhh" isExpanded="true"> + <dc:Bounds x="231" y="580" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0luurk9_di" bpmnElement="Flow_0luurk9"> + <di:waypoint x="791" y="684" /> + <di:waypoint x="899" y="684" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_022y6dc_di" bpmnElement="Flow_022y6dc"> + <di:waypoint x="297" y="684" /> + <di:waypoint x="361" y="684" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0g444ik_di" bpmnElement="Flow_0g444ik"> + <di:waypoint x="461" y="684" /> + <di:waypoint x="521" y="684" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_07lojd9_di" bpmnElement="Flow_07lojd9"> + <di:waypoint x="621" y="684" /> + <di:waypoint x="691" y="684" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_054d9nj_di" bpmnElement="Event_054d9nj"> + <dc:Bounds x="261" y="666" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1kmtbm7_di" bpmnElement="Event_1kmtbm7"> + <dc:Bounds x="899" y="666" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ov9qpp_di" bpmnElement="Activity_1ov9qpp"> + <dc:Bounds x="691" y="644" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_016j574_di" bpmnElement="Activity_016j574"> + <dc:Bounds x="361" y="644" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wz7ppl_di" bpmnElement="Activity_1wz7ppl"> + <dc:Bounds x="521" y="644" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreSharedSlice.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreSharedSlice.bpmn new file mode 100644 index 0000000000..0a482beca0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreSharedSlice.bpmn @@ -0,0 +1,367 @@ +<?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_1px21lh" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="DoAllocateCoreSharedSlice" name="DoAllocateCoreSharedSlice" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>SequenceFlow_1ym7ydc</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_1ym7ydc" sourceRef="StartEvent_1" targetRef="Activity_1264hec" /> + <bpmn:endEvent id="EndEvent_1av4kxa" name="End"> + <bpmn:incoming>Flow_09uu75h</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0da7dao" sourceRef="Activity_0no0sxa" targetRef="Task_16983t3" /> + <bpmn:scriptTask id="Task_1htaioi" name="Call AAI get network service instance associated with NSSI id" scriptFormat="groovy"> + <bpmn:incoming>Flow_1r07vnu</bpmn:incoming> + <bpmn:outgoing>Flow_1973d9m</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.getNetworkInstanceAssociatedWithNssiId(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1r07vnu" sourceRef="Activity_1264hec" targetRef="Task_1htaioi" /> + <bpmn:scriptTask id="Activity_1264hec" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1ym7ydc</bpmn:incoming> + <bpmn:outgoing>Flow_1r07vnu</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1973d9m" sourceRef="Task_1htaioi" targetRef="Activity_0no0sxa" /> + <bpmn:scriptTask id="Task_16983t3" name="Prepare request payload for SO macro service call" scriptFormat="groovy"> + <bpmn:incoming>Flow_0da7dao</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1j1qqcs</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.prepareSOMacroRequestPayload(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_12jcmzc" name="PUT SO Macro" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_013bc74</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08q2fd9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.sendPutRequestToSOMacro(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0ge2y0l" name="Prepare Call CheckServiceProcessStatus" scriptFormat="groovy"> + <bpmn:incoming>Flow_0x7shtq</bpmn:incoming> + <bpmn:outgoing>Flow_1c9nkx4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.prepareCallCheckProcessStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_19xwwnc" name="CallCheckServiceProcessStatus" calledElement="CheckServiceProcessStatus"> + <bpmn:extensionElements> + <camunda:in source="networkServiceInstanceId" target="serviceInstanceId" /> + <camunda:in source="macroOperationId" target="operationId" /> + <camunda:in source="successConditions" target="successConditions" /> + <camunda:in source="errorConditions" target="errorConditions" /> + <camunda:in source="processServiceType" target="processServiceType" /> + <camunda:in source="timeOut" target="timeOut" /> + <camunda:out source="operationStatus" target="result" /> + <camunda:out source="operationContent" target="reason" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="isTimeOut" target="isTimeOut" /> + <camunda:in source="subOperationType" target="operationType" /> + <camunda:in source="initProgress" target="initProgress" /> + <camunda:in source="endProgress" target="endProgress" /> + <camunda:in source="serviceInstanceID" target="parentServiceInstanceId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="operationId" target="parentOperationId" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1c9nkx4</bpmn:incoming> + <bpmn:outgoing>Flow_0c94gye</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1c9nkx4" sourceRef="Activity_0ge2y0l" targetRef="Activity_19xwwnc" /> + <bpmn:sequenceFlow id="Flow_0c94gye" sourceRef="Activity_19xwwnc" targetRef="Activity_1t49t6c" /> + <bpmn:scriptTask id="Activity_0no0sxa" name="Get VNF/VFs modelInfo from CatalogDB" scriptFormat="groovy"> + <bpmn:incoming>Flow_1973d9m</bpmn:incoming> + <bpmn:outgoing>Flow_0da7dao</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.getServiceVNFAndVFsFromCatalogDB(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1t49t6c" name="Prepare Update Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0c94gye</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1re5jor</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_0t6viuq" name="Update Service Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1re5jor</bpmn:incoming> + <bpmn:incoming>Flow_1nn15tq</bpmn:incoming> + <bpmn:outgoing>Flow_09uu75h</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_09uu75h" sourceRef="Activity_0t6viuq" targetRef="EndEvent_1av4kxa" /> + <bpmn:sequenceFlow id="SequenceFlow_08q2fd9" sourceRef="Activity_12jcmzc" targetRef="Gateway_0sfmiku" /> + <bpmn:sequenceFlow id="SequenceFlow_1re5jor" sourceRef="Activity_1t49t6c" targetRef="Activity_0t6viuq" /> + <bpmn:sequenceFlow id="SequenceFlow_1j1qqcs" sourceRef="Task_16983t3" targetRef="IntermediateThrowEvent_09rhn4h" /> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_09rhn4h" name="Call SO macro api"> + <bpmn:incoming>SequenceFlow_1j1qqcs</bpmn:incoming> + <bpmn:linkEventDefinition name="CallSO" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0qh9wy2" name="Call SO macro api"> + <bpmn:outgoing>SequenceFlow_013bc74</bpmn:outgoing> + <bpmn:linkEventDefinition name="CallSO" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_013bc74" sourceRef="IntermediateThrowEvent_0qh9wy2" targetRef="Activity_12jcmzc" /> + <bpmn:exclusiveGateway id="Gateway_0sfmiku" name="is SO Response OK?" default="Flow_0x7shtq"> + <bpmn:incoming>SequenceFlow_08q2fd9</bpmn:incoming> + <bpmn:outgoing>Flow_0x7shtq</bpmn:outgoing> + <bpmn:outgoing>Flow_1nn15tq</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0x7shtq" name="Yes" sourceRef="Gateway_0sfmiku" targetRef="Activity_0ge2y0l" /> + <bpmn:sequenceFlow id="Flow_1nn15tq" name="No" sourceRef="Gateway_0sfmiku" targetRef="Activity_0t6viuq"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isSOResponseSucceed" ) == "no")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:subProcess id="Activity_08h38js" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_07tr56z"> + <bpmn:outgoing>Flow_0nauwik</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_154c21j" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_02arrfq"> + <bpmn:incoming>Flow_0y8rsb3</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_1150yu6" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_128o22z</bpmn:incoming> + <bpmn:outgoing>Flow_0y8rsb3</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0sqggtb" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_0nauwik</bpmn:incoming> + <bpmn:outgoing>Flow_0kadgoq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def allocateNssi = new DoAllocateCoreSharedSlice() +allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1btidug" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0kadgoq</bpmn:incoming> + <bpmn:outgoing>Flow_128o22z</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0y8rsb3" sourceRef="Activity_1150yu6" targetRef="Event_02arrfq" /> + <bpmn:sequenceFlow id="Flow_0nauwik" sourceRef="Event_07tr56z" targetRef="Activity_0sqggtb" /> + <bpmn:sequenceFlow id="Flow_0kadgoq" sourceRef="Activity_0sqggtb" targetRef="Activity_1btidug" /> + <bpmn:sequenceFlow id="Flow_128o22z" sourceRef="Activity_1btidug" targetRef="Activity_1150yu6" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateCoreSharedSlice"> + <bpmndi:BPMNEdge id="Flow_1nn15tq_di" bpmnElement="Flow_1nn15tq"> + <di:waypoint x="420" y="306" /> + <di:waypoint x="420" y="360" /> + <di:waypoint x="967" y="360" /> + <di:waypoint x="967" y="321" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="687" y="342" width="14" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0x7shtq_di" bpmnElement="Flow_0x7shtq"> + <di:waypoint x="445" y="281" /> + <di:waypoint x="484" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="456" y="263" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_013bc74_di" bpmnElement="SequenceFlow_013bc74"> + <di:waypoint x="218" y="281" /> + <di:waypoint x="260" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="252" y="340" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1j1qqcs_di" bpmnElement="SequenceFlow_1j1qqcs"> + <di:waypoint x="896" y="120" /> + <di:waypoint x="949" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="862.5" y="179" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1re5jor_di" bpmnElement="SequenceFlow_1re5jor"> + <di:waypoint x="878" y="281" /> + <di:waypoint x="917" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="837.5" y="340" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_08q2fd9_di" bpmnElement="SequenceFlow_08q2fd9"> + <di:waypoint x="360" y="281" /> + <di:waypoint x="395" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="402" y="340" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_09uu75h_di" bpmnElement="Flow_09uu75h"> + <di:waypoint x="1017" y="281" /> + <di:waypoint x="1056" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="931.5" y="336" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0c94gye_di" bpmnElement="Flow_0c94gye"> + <di:waypoint x="736" y="281" /> + <di:waypoint x="778" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="652" y="336" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1c9nkx4_di" bpmnElement="Flow_1c9nkx4"> + <di:waypoint x="584" y="281" /> + <di:waypoint x="636" y="281" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="505" y="336" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1973d9m_di" bpmnElement="Flow_1973d9m"> + <di:waypoint x="600" y="120" /> + <di:waypoint x="654" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="522" y="175" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1r07vnu_di" bpmnElement="Flow_1r07vnu"> + <di:waypoint x="440" y="120" /> + <di:waypoint x="500" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0da7dao_di" bpmnElement="Flow_0da7dao"> + <di:waypoint x="754" y="120" /> + <di:waypoint x="796" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="670" y="175" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ym7ydc_di" bpmnElement="SequenceFlow_1ym7ydc"> + <di:waypoint x="284" y="120" /> + <di:waypoint x="340" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="207" y="179" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="248" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="254" y="145" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1av4kxa_di" bpmnElement="EndEvent_1av4kxa"> + <dc:Bounds x="1056" y="263" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1064" y="306" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16cbdb6_di" bpmnElement="Task_1htaioi"> + <dc:Bounds x="500" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wo5rx5_di" bpmnElement="Activity_1264hec"> + <dc:Bounds x="340" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0csnjjc_di" bpmnElement="Task_16983t3"> + <dc:Bounds x="796" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_05dh84g_di" bpmnElement="Activity_12jcmzc"> + <dc:Bounds x="260" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ge2y0l_di" bpmnElement="Activity_0ge2y0l"> + <dc:Bounds x="484" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_19xwwnc_di" bpmnElement="Activity_19xwwnc"> + <dc:Bounds x="636" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0k70k5i_di" bpmnElement="Activity_0no0sxa"> + <dc:Bounds x="654" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0mb2ssd_di" bpmnElement="Activity_1t49t6c"> + <dc:Bounds x="778" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0t6viuq_di" bpmnElement="Activity_0t6viuq"> + <dc:Bounds x="917" y="241" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_06785ru_di" bpmnElement="IntermediateThrowEvent_09rhn4h"> + <dc:Bounds x="949" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="923" y="142" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_09u3rdp_di" bpmnElement="IntermediateThrowEvent_0qh9wy2"> + <dc:Bounds x="182" y="263" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="156" y="303" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0sfmiku_di" bpmnElement="Gateway_0sfmiku" isMarkerVisible="true"> + <dc:Bounds x="395" y="256" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="380" y="226" width="80" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_08h38js_di" bpmnElement="Activity_08h38js" isExpanded="true"> + <dc:Bounds x="250" y="440" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_128o22z_di" bpmnElement="Flow_128o22z"> + <di:waypoint x="640" y="544" /> + <di:waypoint x="710" y="544" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0kadgoq_di" bpmnElement="Flow_0kadgoq"> + <di:waypoint x="480" y="544" /> + <di:waypoint x="540" y="544" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0nauwik_di" bpmnElement="Flow_0nauwik"> + <di:waypoint x="316" y="544" /> + <di:waypoint x="380" y="544" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0y8rsb3_di" bpmnElement="Flow_0y8rsb3"> + <di:waypoint x="810" y="544" /> + <di:waypoint x="918" y="544" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_07tr56z_di" bpmnElement="Event_07tr56z"> + <dc:Bounds x="280" y="526" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_02arrfq_di" bpmnElement="Event_02arrfq"> + <dc:Bounds x="918" y="526" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1150yu6_di" bpmnElement="Activity_1150yu6"> + <dc:Bounds x="710" y="504" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0sqggtb_di" bpmnElement="Activity_0sqggtb"> + <dc:Bounds x="380" y="504" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1btidug_di" bpmnElement="Activity_1btidug"> + <dc:Bounds x="540" y="504" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSIV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSIV2.bpmn new file mode 100644 index 0000000000..071960a972 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSIV2.bpmn @@ -0,0 +1,598 @@ +<?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" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> + <bpmn:process id="DoAllocateNSIandNSSIV2" name="DoAllocateNSIandNSSIV2" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1ym3sha" name="Start"> + <bpmn:outgoing>SequenceFlow_0xgfj7z</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_0xgfj7z" sourceRef="StartEvent_1ym3sha" targetRef="Task_027u6m6" /> + <bpmn:scriptTask id="Task_027u6m6" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0xgfj7z</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_00aukg6</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dansi = new DoAllocateNSIandNSSI() +dansi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0qorxd9" name="Process NSI options" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_00aukg6</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ggo6s5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dansi = new DoAllocateNSIandNSSI() +dansi.retriveSliceOption(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_00aukg6" sourceRef="Task_027u6m6" targetRef="ScriptTask_0qorxd9" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_00pt1ek" name="Is nsi option available?" default="SequenceFlow_0c986i9"> + <bpmn:incoming>SequenceFlow_1ggo6s5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0c986i9</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_03ye8m4</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1ggo6s5" sourceRef="ScriptTask_0qorxd9" targetRef="ExclusiveGateway_00pt1ek" /> + <bpmn:sequenceFlow id="SequenceFlow_0c986i9" sourceRef="ExclusiveGateway_00pt1ek" targetRef="ScriptTask_1tizl6b" /> + <bpmn:scriptTask id="ScriptTask_1tizl6b" name="create NSI in AAI and Update relationship" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0c986i9</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1k3cspv</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createNSIinAAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1k3cspv" sourceRef="ScriptTask_1tizl6b" targetRef="ScriptTask_1r6kuwy" /> + <bpmn:sequenceFlow id="SequenceFlow_03ye8m4" sourceRef="ExclusiveGateway_00pt1ek" targetRef="ScriptTask_07sgklo"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSIOptionAvailable" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0fx1nyj" name="GoTo Create Slice Profile"> + <bpmn:incoming>SequenceFlow_0t0wddg</bpmn:incoming> + <bpmn:incoming>SequenceFlow_05ovikm</bpmn:incoming> + <bpmn:linkEventDefinition name="CreateSliceProfile" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0k54pph" name="Create Slice Profile"> + <bpmn:outgoing>SequenceFlow_0ct8yh4</bpmn:outgoing> + <bpmn:linkEventDefinition name="CreateSliceProfile" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_0ct8yh4" sourceRef="IntermediateThrowEvent_0k54pph" targetRef="ExclusiveGateway_00ufetn" /> + <bpmn:parallelGateway id="ExclusiveGateway_00ufetn"> + <bpmn:incoming>SequenceFlow_0ct8yh4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1m68yca</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0k5iu2n</bpmn:outgoing> + </bpmn:parallelGateway> + <bpmn:sequenceFlow id="SequenceFlow_1m68yca" sourceRef="ExclusiveGateway_00ufetn" targetRef="Task_1tv7jy5" /> + <bpmn:sequenceFlow id="SequenceFlow_0k5iu2n" sourceRef="ExclusiveGateway_00ufetn" targetRef="Task_1en3luv" /> + <bpmn:callActivity id="CallActivity_1yh9tiq" name="Call DoAllocateNSSI(RAN)" calledElement="DoAllocateNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="nsstInput" target="nsstInput" /> + <camunda:in source="serviceProfile" target="serviceProfile" /> + <camunda:in source="sliceProfileTn" target="sliceProfileTn" /> + <camunda:in source="sliceProfileCn" target="sliceProfileCn" /> + <camunda:in source="sliceProfileAn" target="sliceProfileAn" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="uuiRequest" target="uuiRequest" /> + <camunda:in source="nsiServiceInstanceId" target="nsiServiceInstanceId" /> + <camunda:in source="nsiServiceInstanceName" target="nsiServiceInstanceName" /> + <camunda:in source="nssiserviceModelInfo" target="nssiserviceModelInfo" /> + <camunda:in source="sliceTaskParams" target="sliceTaskParams" /> + <camunda:in source="taskId" target="CSSOT_taskId" /> + <camunda:in source="taskName" target="CSSOT_name" /> + <camunda:in source="taskStatus" target="CSSOT_status" /> + <camunda:in source="isManual" target="CSSOT_isManual" /> + <camunda:in source="isNSIOptionAvailable" target="isNSIOptionAvailable" /> + <camunda:in source="anSliceTaskInfo" target="sliceTaskInfo" /> + <camunda:out source="nssiAllocateResult" target="nssiAllocateResult" /> + <camunda:in source="AnAllocateNssiNbiRequest" target="nbiRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0npsyye</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1xb5nx1</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_1hfjn79" sourceRef="Task_1tv7jy5" targetRef="ScriptTask_1r2li91" /> + <bpmn:callActivity id="CallActivity_1ixah3o" name="Call DoAllocateNSSI(Core)" calledElement="DoAllocateNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="nsstInput" target="nsstInput" /> + <camunda:in source="serviceProfile" target="serviceProfile" /> + <camunda:in source="sliceProfileTn" target="sliceProfileTn" /> + <camunda:in source="sliceProfileCn" target="sliceProfileCn" /> + <camunda:in source="sliceProfileAn" target="sliceProfileAn" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="uuiRequest" target="uuiRequest" /> + <camunda:in source="nsiServiceInstanceId" target="nsiServiceInstanceId" /> + <camunda:in source="nsiServiceInstanceName" target="nsiServiceInstanceName" /> + <camunda:in source="nssiserviceModelInfo" target="nssiserviceModelInfo" /> + <camunda:in source="sliceTaskParams" target="sliceTaskParams" /> + <camunda:in source="taskId" target="CSSOT_taskId" /> + <camunda:in source="taskName" target="CSSOT_name" /> + <camunda:in source="taskStatus" target="CSSOT_status" /> + <camunda:in source="isManual" target="CSSOT_isManual" /> + <camunda:in source="isNSIOptionAvailable" target="isNSIOptionAvailable" /> + <camunda:in source="cnSliceTaskInfo" target="sliceTaskInfo" /> + <camunda:in source="domainType" target="domainType" /> + <camunda:out source="nssiAllocateResult" target="nssiAllocateResult" /> + <camunda:in source="CnAllocateNssiNbiRequest" target="nbiRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0cwbtmr</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1l74seh</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_0f36cu2" sourceRef="Task_1en3luv" targetRef="Task_1g8n8iz" /> + <bpmn:sequenceFlow id="SequenceFlow_1xb5nx1" sourceRef="CallActivity_1yh9tiq" targetRef="ScriptTask_0mls87v" /> + <bpmn:parallelGateway id="ExclusiveGateway_19ru3hp"> + <bpmn:incoming>SequenceFlow_1gkb7iy</bpmn:incoming> + <bpmn:incoming>SequenceFlow_03zglrh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0ax2c4p</bpmn:outgoing> + </bpmn:parallelGateway> + <bpmn:scriptTask id="ScriptTask_07sgklo" name="Update relationship between NSI and Service Profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03ye8m4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0t0wddg</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.updateRelationship(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0t0wddg" sourceRef="ScriptTask_07sgklo" targetRef="IntermediateThrowEvent_0fx1nyj" /> + <bpmn:scriptTask id="ScriptTask_1r6kuwy" name="create relationship between nsi and SP" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1k3cspv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_05ovikm</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createRelationship(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_05ovikm" sourceRef="ScriptTask_1r6kuwy" targetRef="IntermediateThrowEvent_0fx1nyj" /> + <bpmn:scriptTask id="Task_1tv7jy5" name="Create RAN Slice Profile Instance" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1m68yca</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1hfjn79</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createAnSliceProfileInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1r2li91" name="Create RAN Slice Profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1hfjn79</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0zbd2tq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createAnSliceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0zbd2tq" sourceRef="ScriptTask_1r2li91" targetRef="ScriptTask_0s8vhha" /> + <bpmn:scriptTask id="Task_1en3luv" name="Create Core Slice Profile Instance" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0k5iu2n</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0f36cu2</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createCnSliceProfileInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_1g8n8iz" name="Create Core Slice Profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0f36cu2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1wffel4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createCnSliceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0ax2c4p" sourceRef="ExclusiveGateway_19ru3hp" targetRef="EndEvent_02c8wsp" /> + <bpmn:scriptTask id="ScriptTask_0stnvp3" name="Create TN (BH) Slice Profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0paqrtx</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1d48cil</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createTnBHSliceProfileInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1f4o46q" name="Create TN(BH) Slice Profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1d48cil</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_00dexhy</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createTnBHSliceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_0b28wlb" name="Call DoAllocateNSSI(TN)" calledElement="DoAllocateNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="nsstInput" target="nsstInput" /> + <camunda:in source="serviceProfile" target="serviceProfile" /> + <camunda:in source="sliceProfileTn" target="sliceProfileTn" /> + <camunda:in source="sliceProfileCn" target="sliceProfileCn" /> + <camunda:in source="sliceProfileAn" target="sliceProfileAn" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="uuiRequest" target="uuiRequest" /> + <camunda:in source="nsiServiceInstanceId" target="nsiServiceInstanceId" /> + <camunda:in source="nsiServiceInstanceName" target="nsiServiceInstanceName" /> + <camunda:in source="nssiserviceModelInfo" target="nssiserviceModelInfo" /> + <camunda:in source="sliceTaskParams" target="sliceTaskParams" /> + <camunda:in source="taskId" target="CSSOT_taskId" /> + <camunda:in source="taskName" target="CSSOT_name" /> + <camunda:in source="taskStatus" target="CSSOT_status" /> + <camunda:in source="isManual" target="CSSOT_isManual" /> + <camunda:in source="isNSIOptionAvailable" target="isNSIOptionAvailable" /> + <camunda:in source="tnBHSliceTaskInfo" target="sliceTaskInfo" /> + <camunda:out source="nssiAllocateResult" target="nssiAllocateResult" /> + <camunda:in source="TnBHAllocateNssiNbiRequest" target="nbiRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_01isn2q</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1omynpt</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_1d48cil" sourceRef="ScriptTask_0stnvp3" targetRef="ScriptTask_1f4o46q" /> + <bpmn:sequenceFlow id="SequenceFlow_00dexhy" sourceRef="ScriptTask_1f4o46q" targetRef="ScriptTask_0ci5g6y" /> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_08wpvhs" name="Create Tn SliceProfile"> + <bpmn:outgoing>SequenceFlow_0paqrtx</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1beugxy" name="CreateTnSliceProfile" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_0paqrtx" sourceRef="IntermediateCatchEvent_08wpvhs" targetRef="ScriptTask_0stnvp3" /> + <bpmn:scriptTask id="ScriptTask_0sssiii" name="Update relationship between NSI and NSSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1omynpt</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_150xio1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1me5mt6" name="Update relationship between Slice Profile and Service Profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_150xio1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_040fu80</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0vrzjir" name="Update RelationShip between SliceProfile and NSSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_040fu80</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1uti8ls</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_150xio1" sourceRef="ScriptTask_0sssiii" targetRef="ScriptTask_1me5mt6" /> + <bpmn:sequenceFlow id="SequenceFlow_040fu80" sourceRef="ScriptTask_1me5mt6" targetRef="ScriptTask_0vrzjir" /> + <bpmn:scriptTask id="ScriptTask_0mls87v" name="Update relationship between NSI and NSSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1xb5nx1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0xx5bwa</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0xx5bwa" sourceRef="ScriptTask_0mls87v" targetRef="ScriptTask_0g8dgo6" /> + <bpmn:scriptTask id="ScriptTask_0g8dgo6" name="Update relationship between Slice Profile and Service Profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0xx5bwa</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1sckufj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1sckufj" sourceRef="ScriptTask_0g8dgo6" targetRef="ScriptTask_0blxroa" /> + <bpmn:scriptTask id="ScriptTask_0blxroa" name="Update RelationShip between SliceProfile and NSSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1sckufj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1gkb7iy</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1gkb7iy" sourceRef="ScriptTask_0blxroa" targetRef="ExclusiveGateway_19ru3hp" /> + <bpmn:scriptTask id="ScriptTask_0z9x5uh" name="Update relationship between NSI and NSSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1l74seh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0jqxxjq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_09197ms" name="Update relationship between Slice Profile and Service Profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0jqxxjq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_02qun80</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_127nizg" name="Update RelationShip between SliceProfile and NSSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_02qun80</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_03zglrh</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1l74seh" sourceRef="CallActivity_1ixah3o" targetRef="ScriptTask_0z9x5uh" /> + <bpmn:sequenceFlow id="SequenceFlow_0jqxxjq" sourceRef="ScriptTask_0z9x5uh" targetRef="ScriptTask_09197ms" /> + <bpmn:sequenceFlow id="SequenceFlow_02qun80" sourceRef="ScriptTask_09197ms" targetRef="ScriptTask_127nizg" /> + <bpmn:sequenceFlow id="SequenceFlow_03zglrh" sourceRef="ScriptTask_127nizg" targetRef="ExclusiveGateway_19ru3hp" /> + <bpmn:sequenceFlow id="SequenceFlow_1omynpt" sourceRef="CallActivity_0b28wlb" targetRef="ScriptTask_0sssiii" /> + <bpmn:endEvent id="EndEvent_0elqlhv"> + <bpmn:incoming>SequenceFlow_1uti8ls</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1uti8ls" sourceRef="ScriptTask_0vrzjir" targetRef="EndEvent_0elqlhv" /> + <bpmn:intermediateThrowEvent id="EndEvent_02c8wsp" name="GoTo Create Tn SliceProfile"> + <bpmn:incoming>SequenceFlow_0ax2c4p</bpmn:incoming> + <bpmn:linkEventDefinition name="CreateTnSliceProfile" /> + </bpmn:intermediateThrowEvent> + <bpmn:scriptTask id="ScriptTask_0s8vhha" name="prepare Allocate An Nssi" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0zbd2tq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0npsyye</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0npsyye" sourceRef="ScriptTask_0s8vhha" targetRef="CallActivity_1yh9tiq" /> + <bpmn:scriptTask id="ScriptTask_0z0ec5b" name="prepare Allocate An Nssi" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1wffel4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0cwbtmr</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateCnNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0cwbtmr" sourceRef="ScriptTask_0z0ec5b" targetRef="CallActivity_1ixah3o" /> + <bpmn:sequenceFlow id="SequenceFlow_1wffel4" sourceRef="Task_1g8n8iz" targetRef="ScriptTask_0z0ec5b" /> + <bpmn:scriptTask id="ScriptTask_0ci5g6y" name="prepare Allocate Tn-BH Nssi" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_00dexhy</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_01isn2q</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateTnBHNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_01isn2q" sourceRef="ScriptTask_0ci5g6y" targetRef="CallActivity_0b28wlb" /> + </bpmn:process> + <bpmn:message id="Message_1i10pf1" name="Message_2mc69tg" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateNSIandNSSIV2"> + <bpmndi:BPMNShape id="StartEvent_1ym3sha_di" bpmnElement="StartEvent_1ym3sha"> + <dc:Bounds x="138" y="122" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="144" y="165" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0xgfj7z_di" bpmnElement="SequenceFlow_0xgfj7z"> + <di:waypoint x="174" y="140" /> + <di:waypoint x="224" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0q0td74_di" bpmnElement="Task_027u6m6"> + <dc:Bounds x="224" y="100" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0qorxd9_di" bpmnElement="ScriptTask_0qorxd9"> + <dc:Bounds x="404" y="100" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_00aukg6_di" bpmnElement="SequenceFlow_00aukg6"> + <di:waypoint x="324" y="140" /> + <di:waypoint x="404" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_00pt1ek_di" bpmnElement="ExclusiveGateway_00pt1ek" isMarkerVisible="true"> + <dc:Bounds x="609" y="115" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="604" y="78" width="59" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ggo6s5_di" bpmnElement="SequenceFlow_1ggo6s5"> + <di:waypoint x="504" y="140" /> + <di:waypoint x="609" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0c986i9_di" bpmnElement="SequenceFlow_0c986i9"> + <di:waypoint x="659" y="140" /> + <di:waypoint x="800" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1tizl6b_di" bpmnElement="ScriptTask_1tizl6b"> + <dc:Bounds x="800" y="100" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1k3cspv_di" bpmnElement="SequenceFlow_1k3cspv"> + <di:waypoint x="900" y="140" /> + <di:waypoint x="970" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03ye8m4_di" bpmnElement="SequenceFlow_03ye8m4"> + <di:waypoint x="634" y="165" /> + <di:waypoint x="634" y="260" /> + <di:waypoint x="930" y="260" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0zuxkap_di" bpmnElement="IntermediateThrowEvent_0fx1nyj"> + <dc:Bounds x="1412" y="122" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1388" y="92" width="90" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_1u7g80x_di" bpmnElement="IntermediateThrowEvent_0k54pph"> + <dc:Bounds x="138" y="502" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="126" y="545" width="60" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0ct8yh4_di" bpmnElement="SequenceFlow_0ct8yh4"> + <di:waypoint x="174" y="520" /> + <di:waypoint x="239" y="520" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ParallelGateway_0q9h79n_di" bpmnElement="ExclusiveGateway_00ufetn"> + <dc:Bounds x="239" y="495" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1m68yca_di" bpmnElement="SequenceFlow_1m68yca"> + <di:waypoint x="264" y="495" /> + <di:waypoint x="264" y="440" /> + <di:waypoint x="310" y="440" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0k5iu2n_di" bpmnElement="SequenceFlow_0k5iu2n"> + <di:waypoint x="264" y="545" /> + <di:waypoint x="264" y="630" /> + <di:waypoint x="310" y="630" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_1yh9tiq_di" bpmnElement="CallActivity_1yh9tiq"> + <dc:Bounds x="730" y="400" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1hfjn79_di" bpmnElement="SequenceFlow_1hfjn79"> + <di:waypoint x="410" y="440" /> + <di:waypoint x="440" y="440" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_1ixah3o_di" bpmnElement="CallActivity_1ixah3o"> + <dc:Bounds x="730" y="590" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0f36cu2_di" bpmnElement="SequenceFlow_0f36cu2"> + <di:waypoint x="410" y="630" /> + <di:waypoint x="440" y="630" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1xb5nx1_di" bpmnElement="SequenceFlow_1xb5nx1"> + <di:waypoint x="830" y="440" /> + <di:waypoint x="880" y="440" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ParallelGateway_15vgf7c_di" bpmnElement="ExclusiveGateway_19ru3hp"> + <dc:Bounds x="1325" y="505" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_07sgklo_di" bpmnElement="ScriptTask_07sgklo"> + <dc:Bounds x="930" y="220" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0t0wddg_di" bpmnElement="SequenceFlow_0t0wddg"> + <di:waypoint x="1030" y="260" /> + <di:waypoint x="1430" y="260" /> + <di:waypoint x="1430" y="158" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1r6kuwy_di" bpmnElement="ScriptTask_1r6kuwy"> + <dc:Bounds x="970" y="100" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_05ovikm_di" bpmnElement="SequenceFlow_05ovikm"> + <di:waypoint x="1070" y="140" /> + <di:waypoint x="1412" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_17cq3xj_di" bpmnElement="Task_1tv7jy5"> + <dc:Bounds x="310" y="400" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1r2li91_di" bpmnElement="ScriptTask_1r2li91"> + <dc:Bounds x="440" y="400" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0zbd2tq_di" bpmnElement="SequenceFlow_0zbd2tq"> + <di:waypoint x="540" y="440" /> + <di:waypoint x="584" y="440" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_01n5nmt_di" bpmnElement="Task_1en3luv"> + <dc:Bounds x="310" y="590" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0juh1xy_di" bpmnElement="Task_1g8n8iz"> + <dc:Bounds x="440" y="590" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0ax2c4p_di" bpmnElement="SequenceFlow_0ax2c4p"> + <di:waypoint x="1375" y="530" /> + <di:waypoint x="1412" y="530" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0stnvp3_di" bpmnElement="ScriptTask_0stnvp3"> + <dc:Bounds x="310" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1f4o46q_di" bpmnElement="ScriptTask_1f4o46q"> + <dc:Bounds x="440" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0b28wlb_di" bpmnElement="CallActivity_0b28wlb"> + <dc:Bounds x="730" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1d48cil_di" bpmnElement="SequenceFlow_1d48cil"> + <di:waypoint x="410" y="880" /> + <di:waypoint x="440" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_00dexhy_di" bpmnElement="SequenceFlow_00dexhy"> + <di:waypoint x="540" y="880" /> + <di:waypoint x="584" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateCatchEvent_08wpvhs_di" bpmnElement="IntermediateCatchEvent_08wpvhs"> + <dc:Bounds x="138" y="862" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="129" y="905" width="56" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0paqrtx_di" bpmnElement="SequenceFlow_0paqrtx"> + <di:waypoint x="174" y="880" /> + <di:waypoint x="310" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0sssiii_di" bpmnElement="ScriptTask_0sssiii"> + <dc:Bounds x="880" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1me5mt6_di" bpmnElement="ScriptTask_1me5mt6"> + <dc:Bounds x="1050" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0vrzjir_di" bpmnElement="ScriptTask_0vrzjir"> + <dc:Bounds x="1210" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_150xio1_di" bpmnElement="SequenceFlow_150xio1"> + <di:waypoint x="980" y="880" /> + <di:waypoint x="1050" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_040fu80_di" bpmnElement="SequenceFlow_040fu80"> + <di:waypoint x="1150" y="880" /> + <di:waypoint x="1210" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0mls87v_di" bpmnElement="ScriptTask_0mls87v"> + <dc:Bounds x="880" y="400" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0xx5bwa_di" bpmnElement="SequenceFlow_0xx5bwa"> + <di:waypoint x="980" y="440" /> + <di:waypoint x="1040" y="440" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0g8dgo6_di" bpmnElement="ScriptTask_0g8dgo6"> + <dc:Bounds x="1040" y="400" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1sckufj_di" bpmnElement="SequenceFlow_1sckufj"> + <di:waypoint x="1140" y="440" /> + <di:waypoint x="1190" y="440" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0blxroa_di" bpmnElement="ScriptTask_0blxroa"> + <dc:Bounds x="1190" y="400" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1gkb7iy_di" bpmnElement="SequenceFlow_1gkb7iy"> + <di:waypoint x="1290" y="440" /> + <di:waypoint x="1350" y="440" /> + <di:waypoint x="1350" y="505" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0z9x5uh_di" bpmnElement="ScriptTask_0z9x5uh"> + <dc:Bounds x="880" y="590" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_09197ms_di" bpmnElement="ScriptTask_09197ms"> + <dc:Bounds x="1040" y="590" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_127nizg_di" bpmnElement="ScriptTask_127nizg"> + <dc:Bounds x="1190" y="590" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1l74seh_di" bpmnElement="SequenceFlow_1l74seh"> + <di:waypoint x="830" y="630" /> + <di:waypoint x="880" y="630" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0jqxxjq_di" bpmnElement="SequenceFlow_0jqxxjq"> + <di:waypoint x="980" y="630" /> + <di:waypoint x="1040" y="630" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_02qun80_di" bpmnElement="SequenceFlow_02qun80"> + <di:waypoint x="1140" y="630" /> + <di:waypoint x="1190" y="630" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03zglrh_di" bpmnElement="SequenceFlow_03zglrh"> + <di:waypoint x="1290" y="630" /> + <di:waypoint x="1350" y="630" /> + <di:waypoint x="1350" y="555" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1omynpt_di" bpmnElement="SequenceFlow_1omynpt"> + <di:waypoint x="830" y="880" /> + <di:waypoint x="880" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_0elqlhv_di" bpmnElement="EndEvent_0elqlhv"> + <dc:Bounds x="1412" y="862" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1uti8ls_di" bpmnElement="SequenceFlow_1uti8ls"> + <di:waypoint x="1310" y="880" /> + <di:waypoint x="1412" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0gz4vi6_di" bpmnElement="EndEvent_02c8wsp"> + <dc:Bounds x="1412" y="512" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1392" y="555" width="79" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0s8vhha_di" bpmnElement="ScriptTask_0s8vhha"> + <dc:Bounds x="584" y="400" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0npsyye_di" bpmnElement="SequenceFlow_0npsyye"> + <di:waypoint x="684" y="440" /> + <di:waypoint x="730" y="440" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0z0ec5b_di" bpmnElement="ScriptTask_0z0ec5b"> + <dc:Bounds x="584" y="590" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0cwbtmr_di" bpmnElement="SequenceFlow_0cwbtmr"> + <di:waypoint x="684" y="630" /> + <di:waypoint x="730" y="630" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1wffel4_di" bpmnElement="SequenceFlow_1wffel4"> + <di:waypoint x="540" y="630" /> + <di:waypoint x="584" y="630" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0ci5g6y_di" bpmnElement="ScriptTask_0ci5g6y"> + <dc:Bounds x="584" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_01isn2q_di" bpmnElement="SequenceFlow_01isn2q"> + <di:waypoint x="684" y="880" /> + <di:waypoint x="730" y="880" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSIV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSIV2.bpmn new file mode 100644 index 0000000000..bcb48a60e6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSIV2.bpmn @@ -0,0 +1,233 @@ +<?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" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> + <bpmn:process id="DoAllocateNSSIV2" name="DoAllocateNSSIV2" isExecutable="true"> + <bpmn:startEvent id="StartEvent_0zs8ezi" name="Start"> + <bpmn:outgoing>SequenceFlow_07xkshs</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="ScriptTask_0n2z0z7" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_07xkshs</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0h6mn7j</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_07xkshs" sourceRef="StartEvent_0zs8ezi" targetRef="ScriptTask_0n2z0z7" /> + <bpmn:scriptTask id="ScriptTask_15a7mua" name="send allocate request to NSSMF adapter" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1iw5oad</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1wclf50</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.sendCreateRequestNSSMF(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_11w6bb3" name="Is NSSI sharable?"> + <bpmn:incoming>SequenceFlow_0ib27f2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1iw5oad</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0haiyzv</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="ScriptTask_16zhp9e" name="send modify request to NSSMF adapter" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0haiyzv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ellzst</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.sendUpdateRequestNSSMF(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0jx00mv"> + <bpmn:incoming>SequenceFlow_1wclf50</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1ellzst</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0ejdefw</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1iw5oad" name="No" sourceRef="ExclusiveGateway_11w6bb3" targetRef="ScriptTask_15a7mua"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("nssmfOperation" ) == "create")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1wclf50" sourceRef="ScriptTask_15a7mua" targetRef="ExclusiveGateway_0jx00mv" /> + <bpmn:sequenceFlow id="SequenceFlow_0haiyzv" name="yes" sourceRef="ExclusiveGateway_11w6bb3" targetRef="ScriptTask_16zhp9e"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("nssmfOperation" ) == "update")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1ellzst" sourceRef="ScriptTask_16zhp9e" targetRef="ExclusiveGateway_0jx00mv" /> + <bpmn:sequenceFlow id="SequenceFlow_0h6mn7j" sourceRef="ScriptTask_0n2z0z7" targetRef="ScriptTask_1e7tchy" /> + <bpmn:scriptTask id="ScriptTask_1e7tchy" name="Prepare NSSI Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0h6mn7j</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0ib27f2</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.getNSSTInfo(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0ib27f2" sourceRef="ScriptTask_1e7tchy" targetRef="ExclusiveGateway_11w6bb3" /> + <bpmn:sequenceFlow id="SequenceFlow_0ejdefw" sourceRef="ExclusiveGateway_0jx00mv" targetRef="Task_1ym947s" /> + <bpmn:scriptTask id="Task_1ym947s" name="Query NSSI progress from adapter" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0ejdefw</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0gpgxw4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0p9gd2n</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.queryNSSIStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0ki1c4k" name="Prepare Update Orchestration Task" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0p9gd2n</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ozi7ed</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.prepareUpdateOrchestrationTask(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_0knipxf" name="Call HandleOrchestrationTask" calledElement="HandleOrchestrationTask"> + <bpmn:extensionElements> + <camunda:out source="statusCode" target="CSSOT_dbResponseCode" /> + <camunda:out source="response" target="CSSOT_dbResponse" /> + <camunda:in source="CSSOT_taskId" target="taskId" /> + <camunda:in source="msoRequestId" target="requestId" /> + <camunda:in source="CSSOT_name" target="taskName" /> + <camunda:in source="CSSOT_status" target="taskStatus" /> + <camunda:in source="CSSOT_isManual" target="isManual" /> + <camunda:in source="CSSOT_paramJson" target="paramJson" /> + <camunda:in source="CSSOT_requestMethod" target="method" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1ozi7ed</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0hgv9c5</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_1ozi7ed" sourceRef="ScriptTask_0ki1c4k" targetRef="CallActivity_0knipxf" /> + <bpmn:sequenceFlow id="SequenceFlow_0p9gd2n" sourceRef="Task_1ym947s" targetRef="ScriptTask_0ki1c4k" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_11gv703" name="Completed"> + <bpmn:incoming>SequenceFlow_0hgv9c5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0y5jr25</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_170frn3</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0hgv9c5" sourceRef="CallActivity_0knipxf" targetRef="ExclusiveGateway_11gv703" /> + <bpmn:scriptTask id="ScriptTask_1s7bt3s" name="Time delay" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0y5jr25</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0gpgxw4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.timeDelay(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0y5jr25" name="false" sourceRef="ExclusiveGateway_11gv703" targetRef="ScriptTask_1s7bt3s" /> + <bpmn:sequenceFlow id="SequenceFlow_0gpgxw4" sourceRef="ScriptTask_1s7bt3s" targetRef="Task_1ym947s" /> + <bpmn:sequenceFlow id="SequenceFlow_170frn3" sourceRef="ExclusiveGateway_11gv703" targetRef="IntermediateThrowEvent_10xe1qh"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("nssmfOperation" ) == "update")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="IntermediateThrowEvent_10xe1qh"> + <bpmn:incoming>SequenceFlow_170frn3</bpmn:incoming> + </bpmn:endEvent> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateNSSIV2"> + <bpmndi:BPMNShape id="StartEvent_0zs8ezi_di" bpmnElement="StartEvent_0zs8ezi"> + <dc:Bounds x="147" y="272" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="152" y="313" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0n2z0z7_di" bpmnElement="ScriptTask_0n2z0z7"> + <dc:Bounds x="235" y="250" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_07xkshs_di" bpmnElement="SequenceFlow_07xkshs"> + <di:waypoint x="183" y="290" /> + <di:waypoint x="235" y="290" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_15a7mua_di" bpmnElement="ScriptTask_15a7mua"> + <dc:Bounds x="660" y="430" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_11w6bb3_di" bpmnElement="ExclusiveGateway_11w6bb3" isMarkerVisible="true"> + <dc:Bounds x="591" y="265" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="645" y="283" width="89" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_16zhp9e_di" bpmnElement="ScriptTask_16zhp9e"> + <dc:Bounds x="660" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0jx00mv_di" bpmnElement="ExclusiveGateway_0jx00mv" isMarkerVisible="true"> + <dc:Bounds x="785" y="265" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1iw5oad_di" bpmnElement="SequenceFlow_1iw5oad"> + <di:waypoint x="616" y="315" /> + <di:waypoint x="616" y="470" /> + <di:waypoint x="660" y="470" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="631" y="393" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1wclf50_di" bpmnElement="SequenceFlow_1wclf50"> + <di:waypoint x="760" y="470" /> + <di:waypoint x="810" y="470" /> + <di:waypoint x="810" y="315" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0haiyzv_di" bpmnElement="SequenceFlow_0haiyzv"> + <di:waypoint x="616" y="265" /> + <di:waypoint x="616" y="121" /> + <di:waypoint x="660" y="121" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="635" y="173" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ellzst_di" bpmnElement="SequenceFlow_1ellzst"> + <di:waypoint x="760" y="121" /> + <di:waypoint x="810" y="121" /> + <di:waypoint x="810" y="265" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0h6mn7j_di" bpmnElement="SequenceFlow_0h6mn7j"> + <di:waypoint x="335" y="290" /> + <di:waypoint x="410" y="290" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1e7tchy_di" bpmnElement="ScriptTask_1e7tchy"> + <dc:Bounds x="410" y="250" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0ib27f2_di" bpmnElement="SequenceFlow_0ib27f2"> + <di:waypoint x="510" y="290" /> + <di:waypoint x="591" y="290" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0ejdefw_di" bpmnElement="SequenceFlow_0ejdefw"> + <di:waypoint x="835" y="290" /> + <di:waypoint x="910" y="290" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0bt5d96_di" bpmnElement="Task_1ym947s"> + <dc:Bounds x="910" y="250" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0ki1c4k_di" bpmnElement="ScriptTask_0ki1c4k"> + <dc:Bounds x="1090" y="250" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0knipxf_di" bpmnElement="CallActivity_0knipxf"> + <dc:Bounds x="1238" y="250" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ozi7ed_di" bpmnElement="SequenceFlow_1ozi7ed"> + <di:waypoint x="1190" y="290" /> + <di:waypoint x="1238" y="290" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0p9gd2n_di" bpmnElement="SequenceFlow_0p9gd2n"> + <di:waypoint x="1010" y="290" /> + <di:waypoint x="1090" y="290" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_11gv703_di" bpmnElement="ExclusiveGateway_11gv703" isMarkerVisible="true"> + <dc:Bounds x="1395" y="265" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1393" y="241" width="54" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0hgv9c5_di" bpmnElement="SequenceFlow_0hgv9c5"> + <di:waypoint x="1338" y="290" /> + <di:waypoint x="1395" y="290" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1s7bt3s_di" bpmnElement="ScriptTask_1s7bt3s"> + <dc:Bounds x="1370" y="390" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0y5jr25_di" bpmnElement="SequenceFlow_0y5jr25"> + <di:waypoint x="1420" y="315" /> + <di:waypoint x="1420" y="390" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1401" y="355" width="23" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0gpgxw4_di" bpmnElement="SequenceFlow_0gpgxw4"> + <di:waypoint x="1370" y="430" /> + <di:waypoint x="960" y="430" /> + <di:waypoint x="960" y="330" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_170frn3_di" bpmnElement="SequenceFlow_170frn3"> + <di:waypoint x="1445" y="290" /> + <di:waypoint x="1522" y="290" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1q1vntz_di" bpmnElement="IntermediateThrowEvent_10xe1qh"> + <dc:Bounds x="1522" y="272" width="36" height="36" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn new file mode 100644 index 0000000000..f4886322c2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn @@ -0,0 +1,493 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoAllocateTransportNSSI" name="DoAllocateTransportNSSI" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Allocate TN NSSMF Work Flow"> + <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_0vilb24" name="OOF TN NSSI Selection"> + <bpmn:outgoing>SequenceFlow_1fk37v7</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_197u5pe" name="OofTnNssiSelect" /> + </bpmn:intermediateCatchEvent> + <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03s744c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07e12rt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def css= new TnAllocateNssi() +css.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1jgtb0y" name="Process OOF Selection" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1cv0wop</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_197cm2e</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def css = new TnAllocateNssi() +css.processOofSelection(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0elbczl" name="Use Existing TN NSSI?" default="SequenceFlow_038lb9m"> + <bpmn:incoming>SequenceFlow_197cm2e</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_12t5exy</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_038lb9m</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="ScriptTask_0l3d1ai" name="Process Decomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1t19ips</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0jrclmc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new TnAllocateNssi() +runScript.processDecomposition(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_18eld2o" name="Is Allocation Successful?" default="SequenceFlow_1c6ka9h"> + <bpmn:incoming>SequenceFlow_0mlrlbv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1c6ka9h</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0n4xku8</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_0x406rw"> + <bpmn:incoming>SequenceFlow_1c6ka9h</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0mlneuw" errorRef="Error_03akl5v" /> + </bpmn:endEvent> + <bpmn:subProcess id="SubProcess_1yv9i68" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_1omdx56"> + <bpmn:outgoing>SequenceFlow_1w67v6s</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_06xcioh" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1jx3026"> + <bpmn:incoming>SequenceFlow_08mlzwz</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1swzdpw" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1w67v6s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08mlzwz</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1w67v6s" sourceRef="StartEvent_1omdx56" targetRef="ScriptTask_1swzdpw" /> + <bpmn:sequenceFlow id="SequenceFlow_08mlzwz" sourceRef="ScriptTask_1swzdpw" targetRef="EndEvent_1jx3026" /> + </bpmn:subProcess> + <bpmn:endEvent id="EndEvent_05h01gx" name="End"> + <bpmn:incoming>Flow_06rrcwf</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1xxag1o" name="Prepare Init Service Operation Status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0t094g7</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def rupScript = new TnAllocateNssi() +runScript.prepareUpdateJobStatus(execution,"progress","10","Allocate TN NSSI started")</bpmn:script> + </bpmn:scriptTask> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_1ex8ke9" name="Goto OOF TN NSSI Selection"> + <bpmn:incoming>SequenceFlow_0jrclmc</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0de65en" name="OofTnNssiSelect" /> + </bpmn:intermediateThrowEvent> + <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new TnAllocateNssi() +runScript.prepareUpdateJobStatus(execution,"finished","100","Allocated TN NSSI successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_1bnkmaz" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="sliceServiceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="tnNsstServiceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0q7yc2c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1t19ips</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_0o2r07o" name="Prepare Decompose Service " scriptFormat="groovy"> + <bpmn:incoming>Flow_1k88aak</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0q7yc2c</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new TnAllocateNssi() +runScript.prepareDecomposeService(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_08wim95" name="Prepare OOF TN NSSI Selection" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1fk37v7</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0h2oree</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def css = new TnAllocateNssi() +css.prepareOofSelection(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_0pkvfun" name="Allocate TN NSSI"> + <bpmn:outgoing>SequenceFlow_1bevt3a</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1vlfclx" name="TnAllocateNssi" /> + </bpmn:intermediateCatchEvent> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0ktwpki" name="Goto Allocate TN NSSI"> + <bpmn:incoming>SequenceFlow_12t5exy</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_16f2ri9" name="TnAllocateNssi" /> + </bpmn:intermediateThrowEvent> + <bpmn:endEvent id="EndEvent_1oouvuh" name="End"> + <bpmn:incoming>Flow_0pbq5q0</bpmn:incoming> + </bpmn:endEvent> + <bpmn:callActivity id="CallActivity_0cxst1i" name="Call DoCreateTnNssiInstance " calledElement="DoCreateTnNssiInstance"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="sliceServiceInstanceId" target="sliceServiceInstanceId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="sliceServiceInstanceName" target="sliceServiceInstanceName" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="operationId" target="operationId" /> + <camunda:in source="sliceProfile" target="sliceProfile" /> + <camunda:in source="transportSliceNetworks" target="transportSliceNetworks" /> + <camunda:in source="nsiInfo" target="nsiInfo" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="rollbackData" target="rollbackData" /> + <camunda:out source="rolledBack" target="rolledBack" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1bevt3a</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0mlrlbv</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_03s744c" sourceRef="StartEvent_1nbljfd" targetRef="ScriptTask_1tc44ge" /> + <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="ScriptTask_1xxag1o" /> + <bpmn:sequenceFlow id="SequenceFlow_1cv0wop" sourceRef="Activity_187hs2t" targetRef="ScriptTask_1jgtb0y" /> + <bpmn:sequenceFlow id="SequenceFlow_197cm2e" sourceRef="ScriptTask_1jgtb0y" targetRef="ExclusiveGateway_0elbczl" /> + <bpmn:sequenceFlow id="SequenceFlow_12t5exy" name="No" sourceRef="ExclusiveGateway_0elbczl" targetRef="IntermediateThrowEvent_0ktwpki"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isOofTnNssiSelected") == false)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_038lb9m" name="Yes" sourceRef="ExclusiveGateway_0elbczl" targetRef="Activity_1mh10j4" /> + <bpmn:sequenceFlow id="SequenceFlow_1t19ips" sourceRef="CallActivity_1bnkmaz" targetRef="ScriptTask_0l3d1ai" /> + <bpmn:sequenceFlow id="SequenceFlow_0mlrlbv" sourceRef="CallActivity_0cxst1i" targetRef="ExclusiveGateway_18eld2o" /> + <bpmn:sequenceFlow id="SequenceFlow_1c6ka9h" name="No" sourceRef="ExclusiveGateway_18eld2o" targetRef="EndEvent_0x406rw" /> + <bpmn:sequenceFlow id="SequenceFlow_0n4xku8" name="Yes" sourceRef="ExclusiveGateway_18eld2o" targetRef="ScriptTask_19uxoi8"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("WorkflowException") == null}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0t094g7" sourceRef="ScriptTask_1xxag1o" targetRef="Activity_14an583" /> + <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_1xko5pk" /> + <bpmn:sequenceFlow id="SequenceFlow_0q7yc2c" sourceRef="ScriptTask_0o2r07o" targetRef="CallActivity_1bnkmaz" /> + <bpmn:sequenceFlow id="SequenceFlow_0h2oree" sourceRef="ScriptTask_08wim95" targetRef="Activity_187hs2t" /> + <bpmn:sequenceFlow id="SequenceFlow_1bevt3a" sourceRef="IntermediateCatchEvent_0pkvfun" targetRef="CallActivity_0cxst1i" /> + <bpmn:sequenceFlow id="SequenceFlow_1fk37v7" sourceRef="IntermediateCatchEvent_0vilb24" targetRef="ScriptTask_08wim95" /> + <bpmn:sequenceFlow id="SequenceFlow_0jrclmc" sourceRef="ScriptTask_0l3d1ai" targetRef="IntermediateThrowEvent_1ex8ke9" /> + <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0n4xku8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +execution.setVariable("orchestrationStatus", "allocated") +def runScript = new TnAllocateNssi() +runScript.updateAAIOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ssh2l9" /> + <bpmn:scriptTask id="Activity_1mh10j4" name="Prepare Update Resource Oper Status(finish)" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_038lb9m</bpmn:incoming> + <bpmn:outgoing>Flow_1853sgs</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new TnAllocateNssi() +runScript.prepareUpdateJobStatus(execution,"finished","100","Allocated TN NSSI successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1853sgs" sourceRef="Activity_1mh10j4" targetRef="Activity_124z7q2" /> + <bpmn:callActivity id="Activity_187hs2t" name="Handle TN NSSI Selection OOF request" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nssiSelection_Url" target="apiPath" /> + <camunda:in source="nssiSelection_correlator" target="correlator" /> + <camunda:in source="nssiSelection_messageType" target="messageType" /> + <camunda:in source="nssiSelection_timeout" target="timeout" /> + <camunda:in source="nssiSelection_oofRequest" target="oofRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nssiSelection_asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0h2oree</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1cv0wop</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:serviceTask id="Activity_124z7q2" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1853sgs</bpmn:incoming> + <bpmn:outgoing>Flow_0pbq5q0</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0pbq5q0" sourceRef="Activity_124z7q2" targetRef="EndEvent_1oouvuh" /> + <bpmn:serviceTask id="Activity_14an583" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0t094g7</bpmn:incoming> + <bpmn:outgoing>Flow_1k88aak</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1k88aak" sourceRef="Activity_14an583" targetRef="ScriptTask_0o2r07o" /> + <bpmn:serviceTask id="Activity_1xko5pk" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1qv8qw1</bpmn:incoming> + <bpmn:outgoing>Flow_06rrcwf</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_06rrcwf" sourceRef="Activity_1xko5pk" targetRef="EndEvent_05h01gx" /> + </bpmn:process> + <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> + <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateTransportNSSI"> + <bpmndi:BPMNEdge id="Flow_06rrcwf_di" bpmnElement="Flow_06rrcwf"> + <di:waypoint x="1140" y="680" /> + <di:waypoint x="1252" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1k88aak_di" bpmnElement="Flow_1k88aak"> + <di:waypoint x="750" y="121" /> + <di:waypoint x="850" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0pbq5q0_di" bpmnElement="Flow_0pbq5q0"> + <di:waypoint x="1460" y="500" /> + <di:waypoint x="1562" y="500" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1853sgs_di" bpmnElement="Flow_1853sgs"> + <di:waypoint x="1270" y="500" /> + <di:waypoint x="1360" y="500" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> + <di:waypoint x="770" y="680" /> + <di:waypoint x="860" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0jrclmc_di" bpmnElement="SequenceFlow_0jrclmc"> + <di:waypoint x="1420" y="121" /> + <di:waypoint x="1532" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fk37v7_di" bpmnElement="SequenceFlow_1fk37v7"> + <di:waypoint x="214" y="330" /> + <di:waypoint x="320" y="330" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1bevt3a_di" bpmnElement="SequenceFlow_1bevt3a"> + <di:waypoint x="228" y="680" /> + <di:waypoint x="320" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0h2oree_di" bpmnElement="SequenceFlow_0h2oree"> + <di:waypoint x="420" y="330" /> + <di:waypoint x="540" y="330" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0q7yc2c_di" bpmnElement="SequenceFlow_0q7yc2c"> + <di:waypoint x="950" y="121" /> + <di:waypoint x="1090" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> + <di:waypoint x="960" y="680" /> + <di:waypoint x="1040" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0t094g7_di" bpmnElement="SequenceFlow_0t094g7"> + <di:waypoint x="568" y="121" /> + <di:waypoint x="650" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0n4xku8_di" bpmnElement="SequenceFlow_0n4xku8"> + <di:waypoint x="538" y="680" /> + <di:waypoint x="670" y="680" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="585" y="662" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1c6ka9h_di" bpmnElement="SequenceFlow_1c6ka9h"> + <di:waypoint x="513" y="705" /> + <di:waypoint x="513" y="762" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="522" y="705" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0mlrlbv_di" bpmnElement="SequenceFlow_0mlrlbv"> + <di:waypoint x="420" y="680" /> + <di:waypoint x="488" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1t19ips_di" bpmnElement="SequenceFlow_1t19ips"> + <di:waypoint x="1190" y="121" /> + <di:waypoint x="1320" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_038lb9m_di" bpmnElement="SequenceFlow_038lb9m"> + <di:waypoint x="1090" y="355" /> + <di:waypoint x="1090" y="500" /> + <di:waypoint x="1170" y="500" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1100" y="413" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12t5exy_di" bpmnElement="SequenceFlow_12t5exy"> + <di:waypoint x="1115" y="330" /> + <di:waypoint x="1292" y="330" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1183" y="313" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_197cm2e_di" bpmnElement="SequenceFlow_197cm2e"> + <di:waypoint x="890" y="330" /> + <di:waypoint x="1065" y="330" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1cv0wop_di" bpmnElement="SequenceFlow_1cv0wop"> + <di:waypoint x="640" y="330" /> + <di:waypoint x="790" y="330" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> + <di:waypoint x="385" y="121" /> + <di:waypoint x="468" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> + <di:waypoint x="214" y="121" /> + <di:waypoint x="285" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> + <dc:Bounds x="178" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="146" width="86" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_0vilb24_di" bpmnElement="IntermediateCatchEvent_0vilb24"> + <dc:Bounds x="178" y="312" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="162" y="355" width="71" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="285" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1jgtb0y_di" bpmnElement="ScriptTask_1jgtb0y"> + <dc:Bounds x="790" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0elbczl_di" bpmnElement="ExclusiveGateway_0elbczl" isMarkerVisible="true"> + <dc:Bounds x="1065" y="305" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1050" y="276" width="79" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0l3d1ai_di" bpmnElement="ScriptTask_0l3d1ai"> + <dc:Bounds x="1320" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_18eld2o_di" bpmnElement="ExclusiveGateway_18eld2o" isMarkerVisible="true"> + <dc:Bounds x="488" y="655" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="482.5" y="617.5" width="61" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0x406rw_di" bpmnElement="EndEvent_0x406rw"> + <dc:Bounds x="495" y="762" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> + <dc:Bounds x="685" y="1080" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1079" y="1184" /> + <di:waypoint x="1353" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="751" y="1184" /> + <di:waypoint x="979" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="715" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1353" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="979" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> + <dc:Bounds x="1252" y="662" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1260" y="705" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1xxag1o_di" bpmnElement="ScriptTask_1xxag1o"> + <dc:Bounds x="468" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_1ex8ke9_di" bpmnElement="IntermediateThrowEvent_1ex8ke9"> + <dc:Bounds x="1532" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1522" y="144" width="74" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> + <dc:Bounds x="860" y="640" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1bnkmaz_di" bpmnElement="CallActivity_1bnkmaz"> + <dc:Bounds x="1090" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0o2r07o_di" bpmnElement="ScriptTask_0o2r07o"> + <dc:Bounds x="850" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_08wim95_di" bpmnElement="ScriptTask_08wim95"> + <dc:Bounds x="320" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_0pkvfun_di" bpmnElement="IntermediateCatchEvent_0pkvfun"> + <dc:Bounds x="192" y="662" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="173" y="705" width="86" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0ktwpki_di" bpmnElement="IntermediateThrowEvent_0ktwpki"> + <dc:Bounds x="1292" y="312" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1280" y="353" width="84" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1oouvuh_di" bpmnElement="EndEvent_1oouvuh"> + <dc:Bounds x="1562" y="482" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1570" y="525" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0cxst1i_di" bpmnElement="CallActivity_0cxst1i"> + <dc:Bounds x="320" y="640" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> + <dc:Bounds x="670" y="640" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1mh10j4_di" bpmnElement="Activity_1mh10j4"> + <dc:Bounds x="1170" y="460" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_187hs2t_di" bpmnElement="Activity_187hs2t"> + <dc:Bounds x="540" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_124z7q2_di" bpmnElement="Activity_124z7q2"> + <dc:Bounds x="1360" y="460" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_14an583_di" bpmnElement="Activity_14an583"> + <dc:Bounds x="650" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1xko5pk_di" bpmnElement="Activity_1xko5pk"> + <dc:Bounds x="1040" y="640" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn index ad0732df4d..3ed1999d9a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn @@ -1,17 +1,17 @@ <?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" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> +<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" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> <bpmn:process id="DoCreateSliceServiceOption" name="DoCreateSliceServiceOption" isExecutable="true"> <bpmn:startEvent id="createNS_StartEvent" name="createOption_StartEvent"> <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> </bpmn:startEvent> <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="createNS_StartEvent" targetRef="PreprocessIncomingRequest_task" /> <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="Task_09nzhwk" /> - <bpmn:scriptTask id="Task_09nzhwk" name="send request to OOF for NSI options" scriptFormat="groovy"> + <bpmn:scriptTask id="Task_09nzhwk" name="Prepare OOF Select NSI options request" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1utpplq</bpmn:outgoing> + <bpmn:outgoing>Flow_15c2jcx</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcso = new DoCreateSliceServiceOption() -dcso.getNSIOptionfromOOF(execution)</bpmn:script> +dcso.prepareSelectNSIRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="Preprocess Request" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming> @@ -73,7 +73,6 @@ dcso.prepareNSSTDecompose(execution)</bpmn:script> <bpmn:outgoing>SequenceFlow_0a5f5y6</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_0a5f5y6" sourceRef="CallActivity_1rfnoe2" targetRef="ScriptTask_1mlytov" /> - <bpmn:sequenceFlow id="SequenceFlow_1utpplq" sourceRef="Task_09nzhwk" targetRef="ScriptTask_1umbyel" /> <bpmn:exclusiveGateway id="ExclusiveGateway_1skfk7w" default="SequenceFlow_0wy6oag"> <bpmn:incoming>SequenceFlow_0d774n5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0wy6oag</bpmn:outgoing> @@ -84,7 +83,7 @@ dcso.prepareNSSTDecompose(execution)</bpmn:script> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSISuggested" ) == true)}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:scriptTask id="ScriptTask_1umbyel" name="prepare NST decomposition" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1utpplq</bpmn:incoming> + <bpmn:incoming>Flow_07ustqm</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0piifl1</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcso = new DoCreateSliceServiceOption() @@ -112,124 +111,159 @@ dcso.prepareNSTDecompose(execution)</bpmn:script> def dcso = new DoCreateSliceServiceOption() dcso.processDecomposition(execution)</bpmn:script> </bpmn:scriptTask> + <bpmn:callActivity id="Activity_0dlr4ra" name="Handle NSI Selection OOF request" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nsiSelectionUrl" target="apiPath" /> + <camunda:in source="nsiSelection_correlator" target="correlator" /> + <camunda:in source="nsiSelection_messageType" target="messageType" /> + <camunda:in source="nsiSelection_timeout" target="timeout" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nsiSelection_oofResponse" /> + <camunda:in source="nsiSelection_oofRequest" target="oofRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_15c2jcx</bpmn:incoming> + <bpmn:outgoing>Flow_1mcx2ja</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_049mjag" name="Process OOF response " scriptFormat="groovy"> + <bpmn:incoming>Flow_1mcx2ja</bpmn:incoming> + <bpmn:outgoing>Flow_07ustqm</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processOOFResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1mcx2ja" sourceRef="Activity_0dlr4ra" targetRef="Activity_049mjag" /> + <bpmn:sequenceFlow id="Flow_15c2jcx" sourceRef="Task_09nzhwk" targetRef="Activity_0dlr4ra" /> + <bpmn:sequenceFlow id="Flow_07ustqm" sourceRef="Activity_049mjag" targetRef="ScriptTask_1umbyel" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateSliceServiceOption"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent"> - <dc:Bounds x="175" y="107" width="36" height="36" /> + <bpmndi:BPMNEdge id="SequenceFlow_0d774n5_di" bpmnElement="SequenceFlow_0d774n5"> + <di:waypoint x="1220" y="125" /> + <di:waypoint x="1275" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_086yszq_di" bpmnElement="SequenceFlow_086yszq"> + <di:waypoint x="1060" y="125" /> + <di:waypoint x="1120" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0piifl1_di" bpmnElement="SequenceFlow_0piifl1"> + <di:waypoint x="920" y="125" /> + <di:waypoint x="960" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0hnsycl_di" bpmnElement="SequenceFlow_0hnsycl"> + <di:waypoint x="1325" y="125" /> + <di:waypoint x="1993" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0wy6oag_di" bpmnElement="SequenceFlow_0wy6oag"> + <di:waypoint x="1300" y="150" /> + <di:waypoint x="1300" y="351" /> + <di:waypoint x="1430" y="351" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0a5f5y6_di" bpmnElement="SequenceFlow_0a5f5y6"> + <di:waypoint x="2061" y="351" /> + <di:waypoint x="2148" y="351" /> + <di:waypoint x="2148" y="493" /> + <di:waypoint x="1960" y="493" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_016vi3s_di" bpmnElement="SequenceFlow_016vi3s"> + <di:waypoint x="1872" y="351" /> + <di:waypoint x="1961" y="351" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1r9n9ef_di" bpmnElement="SequenceFlow_1r9n9ef"> + <di:waypoint x="1860" y="493" /> + <di:waypoint x="1666" y="493" /> + <di:waypoint x="1666" y="376" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0m2mr0o_di" bpmnElement="SequenceFlow_0m2mr0o"> + <di:waypoint x="1691" y="351" /> + <di:waypoint x="1772" y="351" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0lt2cdo_di" bpmnElement="SequenceFlow_0lt2cdo"> + <di:waypoint x="1530" y="351" /> + <di:waypoint x="1641" y="351" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ap8kar_di" bpmnElement="SequenceFlow_1ap8kar"> + <di:waypoint x="1666" y="326" /> + <di:waypoint x="1666" y="235" /> + <di:waypoint x="2011" y="235" /> + <di:waypoint x="2011" y="143" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> + <di:waypoint x="350" y="125" /> + <di:waypoint x="390" y="125" /> <bpmndi:BPMNLabel> - <dc:Bounds x="151" y="143" width="86" height="27" /> + <dc:Bounds x="436" y="108" width="0" height="12" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> - <di:waypoint x="211" y="125" /> - <di:waypoint x="251" y="125" /> - <di:waypoint x="251" y="125" /> - <di:waypoint x="293" y="125" /> + <di:waypoint x="218" y="125" /> + <di:waypoint x="250" y="125" /> <bpmndi:BPMNLabel> <dc:Bounds x="266" y="123" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> - <di:waypoint x="393" y="125" /> - <di:waypoint x="460" y="125" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="436" y="108" width="0" height="12" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNEdge id="Flow_1mcx2ja_di" bpmnElement="Flow_1mcx2ja"> + <di:waypoint x="640" y="125" /> + <di:waypoint x="680" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_15c2jcx_di" bpmnElement="Flow_15c2jcx"> + <di:waypoint x="490" y="122" /> + <di:waypoint x="540" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_07ustqm_di" bpmnElement="Flow_07ustqm"> + <di:waypoint x="780" y="125" /> + <di:waypoint x="820" y="125" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_1dw39hg_di" bpmnElement="Task_09nzhwk"> - <dc:Bounds x="460" y="85" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> - <dc:Bounds x="293" y="85" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c"> - <dc:Bounds x="1813" y="107" width="36" height="36" /> + <dc:Bounds x="1993" y="107" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="412" y="617" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0kecvrc_di" bpmnElement="ScriptTask_0kecvrc"> - <dc:Bounds x="1250" y="311" width="100" height="80" /> + <dc:Bounds x="1430" y="311" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1mlytov_di" bpmnElement="ScriptTask_1mlytov"> - <dc:Bounds x="1680" y="453" width="100" height="80" /> + <dc:Bounds x="1860" y="453" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_1y1wzs9_di" bpmnElement="ExclusiveGateway_1y1wzs9" isMarkerVisible="true"> - <dc:Bounds x="1461" y="326" width="50" height="50" /> + <dc:Bounds x="1641" y="326" width="50" height="50" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1ap8kar_di" bpmnElement="SequenceFlow_1ap8kar"> - <di:waypoint x="1486" y="326" /> - <di:waypoint x="1486" y="235" /> - <di:waypoint x="1831" y="235" /> - <di:waypoint x="1831" y="143" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0lt2cdo_di" bpmnElement="SequenceFlow_0lt2cdo"> - <di:waypoint x="1350" y="351" /> - <di:waypoint x="1461" y="351" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0m2mr0o_di" bpmnElement="SequenceFlow_0m2mr0o"> - <di:waypoint x="1511" y="351" /> - <di:waypoint x="1592" y="351" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1r9n9ef_di" bpmnElement="SequenceFlow_1r9n9ef"> - <di:waypoint x="1680" y="493" /> - <di:waypoint x="1486" y="493" /> - <di:waypoint x="1486" y="376" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1e5ysya_di" bpmnElement="ScriptTask_1e5ysya"> - <dc:Bounds x="1592" y="311" width="100" height="80" /> + <dc:Bounds x="1772" y="311" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_016vi3s_di" bpmnElement="SequenceFlow_016vi3s"> - <di:waypoint x="1692" y="351" /> - <di:waypoint x="1781" y="351" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1rfnoe2_di" bpmnElement="CallActivity_1rfnoe2"> - <dc:Bounds x="1781" y="311" width="100" height="80" /> + <dc:Bounds x="1961" y="311" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0a5f5y6_di" bpmnElement="SequenceFlow_0a5f5y6"> - <di:waypoint x="1881" y="351" /> - <di:waypoint x="1968" y="351" /> - <di:waypoint x="1968" y="493" /> - <di:waypoint x="1780" y="493" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1utpplq_di" bpmnElement="SequenceFlow_1utpplq"> - <di:waypoint x="560" y="125" /> - <di:waypoint x="620" y="125" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_1skfk7w_di" bpmnElement="ExclusiveGateway_1skfk7w" isMarkerVisible="true"> - <dc:Bounds x="1095" y="100" width="50" height="50" /> + <dc:Bounds x="1275" y="100" width="50" height="50" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0wy6oag_di" bpmnElement="SequenceFlow_0wy6oag"> - <di:waypoint x="1120" y="150" /> - <di:waypoint x="1120" y="351" /> - <di:waypoint x="1250" y="351" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0hnsycl_di" bpmnElement="SequenceFlow_0hnsycl"> - <di:waypoint x="1145" y="125" /> - <di:waypoint x="1813" y="125" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_1umbyel_di" bpmnElement="ScriptTask_1umbyel"> - <dc:Bounds x="620" y="85" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0piifl1_di" bpmnElement="SequenceFlow_0piifl1"> - <di:waypoint x="720" y="125" /> - <di:waypoint x="780" y="125" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0ly8xiw_di" bpmnElement="CallActivity_0ly8xiw"> - <dc:Bounds x="780" y="85" width="100" height="80" /> + <dc:Bounds x="960" y="85" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_086yszq_di" bpmnElement="SequenceFlow_086yszq"> - <di:waypoint x="880" y="125" /> - <di:waypoint x="940" y="125" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0d774n5_di" bpmnElement="SequenceFlow_0d774n5"> - <di:waypoint x="1040" y="125" /> - <di:waypoint x="1095" y="125" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1895p18_di" bpmnElement="Task_1k2ypj0"> - <dc:Bounds x="940" y="85" width="100" height="80" /> + <dc:Bounds x="1120" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent"> + <dc:Bounds x="182" y="107" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="143" width="86" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> + <dc:Bounds x="250" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1dw39hg_di" bpmnElement="Task_09nzhwk"> + <dc:Bounds x="390" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_049mjag_di" bpmnElement="Activity_049mjag"> + <dc:Bounds x="680" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0dlr4ra_di" bpmnElement="Activity_0dlr4ra"> + <dc:Bounds x="540" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1umbyel_di" bpmnElement="ScriptTask_1umbyel"> + <dc:Bounds x="820" y="85" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions>
\ No newline at end of file +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOptionV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOptionV2.bpmn new file mode 100644 index 0000000000..5d9e53ac18 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOptionV2.bpmn @@ -0,0 +1,563 @@ +<?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" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> + <bpmn:process id="DoCreateSliceServiceOptionV2" name="DoCreateSliceServiceOptionV2" isExecutable="true"> + <bpmn:parallelGateway id="ParallelGateway_0f11kcw"> + <bpmn:incoming>SequenceFlow_17otbuu</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_00t0340</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_06uu0eh</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_09see8v</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_14s7fck</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1c374y2</bpmn:outgoing> + </bpmn:parallelGateway> + <bpmn:parallelGateway id="ParallelGateway_05o7mbp"> + <bpmn:incoming>SequenceFlow_04avf98</bpmn:incoming> + <bpmn:incoming>SequenceFlow_00xa5wa</bpmn:incoming> + <bpmn:incoming>SequenceFlow_064p1n6</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1a699ly</bpmn:outgoing> + </bpmn:parallelGateway> + <bpmn:scriptTask id="ScriptTask_0sznvim" name="Prepare OOF Select NSI options request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_16qt6r2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_175xozh</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.preNSIRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1sik00k" name="Query TN Sub-net capability" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_09see8v</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_04avf98</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.queryTNSubnetCapability(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1sukxzw" name="Query CN Sub-net capability" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_14s7fck</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_00xa5wa</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.queryCNSubnetCapability(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_02u3dmq" name="Query AN Sub-net capability" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1c374y2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_064p1n6</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.queryANSubnetCapability(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_04avf98" sourceRef="ScriptTask_1sik00k" targetRef="ParallelGateway_05o7mbp" /> + <bpmn:sequenceFlow id="SequenceFlow_00xa5wa" sourceRef="ScriptTask_1sukxzw" targetRef="ParallelGateway_05o7mbp" /> + <bpmn:sequenceFlow id="SequenceFlow_064p1n6" sourceRef="ScriptTask_02u3dmq" targetRef="ParallelGateway_05o7mbp" /> + <bpmn:sequenceFlow id="SequenceFlow_1a699ly" sourceRef="ParallelGateway_05o7mbp" targetRef="Task_1kqbsvd" /> + <bpmn:scriptTask id="ScriptTask_11rb2ju" name="prepare NST decomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_00t0340</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1kzy63m</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.prepareDecomposeNST(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_0c567r4" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="nstServiceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="nstServiceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1kzy63m</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1t317y2</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_0z0dwk2" name="Process Decomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1t317y2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1rwl882</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processDecomposition(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0f0rh4w" name="prepare NSST decomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_06uu0eh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1dtfpqp</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.prepareNSTDecompose(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_1tmbgfs" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="nsstServiceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="nsstServiceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1dtfpqp</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0fdqj9b</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_0m6v98c" name="Process Decomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0fdqj9b</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0d2lpv3</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processDecomposition(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1kzy63m" sourceRef="ScriptTask_11rb2ju" targetRef="CallActivity_0c567r4" /> + <bpmn:sequenceFlow id="SequenceFlow_1t317y2" sourceRef="CallActivity_0c567r4" targetRef="ScriptTask_0z0dwk2" /> + <bpmn:sequenceFlow id="SequenceFlow_1dtfpqp" sourceRef="ScriptTask_0f0rh4w" targetRef="CallActivity_1tmbgfs" /> + <bpmn:sequenceFlow id="SequenceFlow_0fdqj9b" sourceRef="CallActivity_1tmbgfs" targetRef="ScriptTask_0m6v98c" /> + <bpmn:sequenceFlow id="SequenceFlow_1rwl882" sourceRef="ScriptTask_0z0dwk2" targetRef="ParallelGateway_1v1unh1" /> + <bpmn:sequenceFlow id="SequenceFlow_0d2lpv3" sourceRef="ScriptTask_0m6v98c" targetRef="ParallelGateway_1v1unh1" /> + <bpmn:callActivity id="CallActivity_15kmmuf" name="Handle NSI Selection OOF request" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nsiSelectionUrl" target="apiPath" /> + <camunda:in source="nsiSelection_correlator" target="correlator" /> + <camunda:in source="nsiSelection_messageType" target="messageType" /> + <camunda:in source="nsiSelection_timeout" target="timeout" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nsiSelection_oofResponse" /> + <camunda:in source="nsiSelection_oofRequest" target="oofRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_175xozh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_188g03z</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_175xozh" sourceRef="ScriptTask_0sznvim" targetRef="CallActivity_15kmmuf" /> + <bpmn:scriptTask id="ScriptTask_0woac2j" name="Process OOF response " scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_188g03z</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17emrud</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processNSIResp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_188g03z" sourceRef="CallActivity_15kmmuf" targetRef="ScriptTask_0woac2j" /> + <bpmn:sequenceFlow id="SequenceFlow_17emrud" sourceRef="ScriptTask_0woac2j" targetRef="EndEvent_15dimzx" /> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_0pstvd4" name=" Select NSSI "> + <bpmn:outgoing>SequenceFlow_1sg6mqd</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1slqdh4" name="SelectNSSI" /> + </bpmn:intermediateCatchEvent> + <bpmn:parallelGateway id="ParallelGateway_05zg916"> + <bpmn:incoming>SequenceFlow_1sg6mqd</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_05250mp</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0euwvgf</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0il5j01</bpmn:outgoing> + </bpmn:parallelGateway> + <bpmn:parallelGateway id="ParallelGateway_06a2n9u"> + <bpmn:incoming>SequenceFlow_14rhmx9</bpmn:incoming> + <bpmn:incoming>SequenceFlow_103oxyw</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0aasemn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1tr3i9d</bpmn:outgoing> + </bpmn:parallelGateway> + <bpmn:callActivity id="CallActivity_0tzazs0" name="Handle NSST Selection OOF request" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nstSelectionUrl" target="apiPath" /> + <camunda:in source="nstSelection_correlator" target="correlator" /> + <camunda:in source="nstSelection_messageType" target="messageType" /> + <camunda:in source="nstSelection_timeout" target="timeout" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nstSelection_oofResponse" /> + <camunda:in source="nstSelection_oofRequest" target="oofRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0abqxa1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1tqg26p</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_1sg6mqd" sourceRef="IntermediateCatchEvent_0pstvd4" targetRef="ParallelGateway_05zg916" /> + <bpmn:sequenceFlow id="SequenceFlow_05250mp" sourceRef="ParallelGateway_05zg916" targetRef="CallActivity_1vzxvna" /> + <bpmn:sequenceFlow id="SequenceFlow_14rhmx9" sourceRef="CallActivity_1vzxvna" targetRef="ParallelGateway_06a2n9u" /> + <bpmn:sequenceFlow id="SequenceFlow_0euwvgf" sourceRef="ParallelGateway_05zg916" targetRef="CallActivity_0melx8d" /> + <bpmn:sequenceFlow id="SequenceFlow_103oxyw" sourceRef="CallActivity_0melx8d" targetRef="ParallelGateway_06a2n9u" /> + <bpmn:sequenceFlow id="SequenceFlow_0il5j01" sourceRef="ParallelGateway_05zg916" targetRef="CallActivity_0otry7e" /> + <bpmn:sequenceFlow id="SequenceFlow_0aasemn" sourceRef="CallActivity_0otry7e" targetRef="ParallelGateway_06a2n9u" /> + <bpmn:sequenceFlow id="SequenceFlow_1tr3i9d" sourceRef="ParallelGateway_06a2n9u" targetRef="Task_1jyj2vs" /> + <bpmn:sequenceFlow id="SequenceFlow_0abqxa1" sourceRef="Task_1m9qoo3" targetRef="CallActivity_0tzazs0" /> + <bpmn:sequenceFlow id="SequenceFlow_1tqg26p" sourceRef="CallActivity_0tzazs0" targetRef="Task_00nfg5x" /> + <bpmn:intermediateThrowEvent id="EndEvent_15dimzx" name="Goto Select NSSI "> + <bpmn:incoming>SequenceFlow_17emrud</bpmn:incoming> + <bpmn:linkEventDefinition name="SelectNSSI" /> + </bpmn:intermediateThrowEvent> + <bpmn:endEvent id="EndEvent_0p0cjhl"> + <bpmn:incoming>SequenceFlow_1nrfy6i</bpmn:incoming> + </bpmn:endEvent> + <bpmn:parallelGateway id="ParallelGateway_1v1unh1"> + <bpmn:incoming>SequenceFlow_1rwl882</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0d2lpv3</bpmn:incoming> + <bpmn:incoming>SequenceFlow_06t1dq5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_16qt6r2</bpmn:outgoing> + </bpmn:parallelGateway> + <bpmn:sequenceFlow id="SequenceFlow_16qt6r2" sourceRef="ParallelGateway_1v1unh1" targetRef="ScriptTask_0sznvim" /> + <bpmn:startEvent id="StartEvent_0mwlirs" name="Start"> + <bpmn:outgoing>SequenceFlow_1fuwy35</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="ScriptTask_0w34e57" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1fuwy35</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17otbuu</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1fuwy35" sourceRef="StartEvent_0mwlirs" targetRef="ScriptTask_0w34e57" /> + <bpmn:sequenceFlow id="SequenceFlow_17otbuu" sourceRef="ScriptTask_0w34e57" targetRef="ParallelGateway_0f11kcw" /> + <bpmn:sequenceFlow id="SequenceFlow_00t0340" sourceRef="ParallelGateway_0f11kcw" targetRef="ScriptTask_11rb2ju" /> + <bpmn:sequenceFlow id="SequenceFlow_06uu0eh" sourceRef="ParallelGateway_0f11kcw" targetRef="ScriptTask_0f0rh4w" /> + <bpmn:sequenceFlow id="SequenceFlow_09see8v" sourceRef="ParallelGateway_0f11kcw" targetRef="ScriptTask_1sik00k" /> + <bpmn:sequenceFlow id="SequenceFlow_14s7fck" sourceRef="ParallelGateway_0f11kcw" targetRef="ScriptTask_1sukxzw" /> + <bpmn:sequenceFlow id="SequenceFlow_1c374y2" sourceRef="ParallelGateway_0f11kcw" targetRef="ScriptTask_02u3dmq" /> + <bpmn:scriptTask id="CallActivity_1vzxvna" name="TN NSSMF supports NSSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_05250mp</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_14rhmx9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.getNSSISelectionCap4TN(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="CallActivity_0melx8d" name="CN NSSMF supports NSSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0euwvgf</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_103oxyw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.getNSSISelectionCap4CN(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="CallActivity_0otry7e" name="AN NSSMF supports NSSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0il5j01</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0aasemn</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.getNSSISelectionCap4AN(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_06t1dq5" sourceRef="Task_1kqbsvd" targetRef="ParallelGateway_1v1unh1" /> + <bpmn:scriptTask id="Task_1kqbsvd" name="handle sub-net capability info" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1a699ly</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_06t1dq5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.handleSubnetCapabilityResp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_1m9qoo3" name="Prepare NSSI Selection" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_126j77n</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0abqxa1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.preNSSIRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_00nfg5x" name="Process NSST Solutions" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1tqg26p</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1i3j8c3</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processNSSIResp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0b52m39" name="need select nssi?" default="SequenceFlow_1nrfy6i"> + <bpmn:incoming>SequenceFlow_1tey3hz</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_126j77n</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1nrfy6i</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_126j77n" name="yes" sourceRef="ExclusiveGateway_0b52m39" targetRef="Task_1m9qoo3"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("nssmfOperation" ) == "update")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1nrfy6i" sourceRef="ExclusiveGateway_0b52m39" targetRef="EndEvent_0p0cjhl" /> + <bpmn:sequenceFlow id="SequenceFlow_1i3j8c3" sourceRef="Task_00nfg5x" targetRef="Task_1jyj2vs" /> + <bpmn:sequenceFlow id="SequenceFlow_1tey3hz" sourceRef="Task_1jyj2vs" targetRef="ExclusiveGateway_0b52m39" /> + <bpmn:scriptTask id="Task_1jyj2vs" name="handle Nssi select " scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1tr3i9d</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1i3j8c3</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1tey3hz</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.handleNssiSelect(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:group id="Group_1k2kt9q" categoryValueRef="CategoryValue_1eh1etw" /> + <bpmn:group id="Group_19fk2vp" categoryValueRef="CategoryValue_1x9qkyq" /> + <bpmn:group id="Group_01yft6a" categoryValueRef="CategoryValue_1nwi9c3" /> + </bpmn:process> + <bpmn:category id="Category_0s5hs8l"> + <bpmn:categoryValue id="CategoryValue_1eh1etw" value="subnetCapabilities" /> + </bpmn:category> + <bpmn:category id="Category_1ahkzyt"> + <bpmn:categoryValue id="CategoryValue_1x9qkyq" value="nst -> NSTInfo" /> + </bpmn:category> + <bpmn:category id="Category_0ne04nd"> + <bpmn:categoryValue id="CategoryValue_1nwi9c3" value="nsst -> NSSTInfo" /> + </bpmn:category> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateSliceServiceOptionV2"> + <bpmndi:BPMNShape id="ParallelGateway_0f11kcw_di" bpmnElement="ParallelGateway_0f11kcw"> + <dc:Bounds x="355" y="525" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ParallelGateway_05o7mbp_di" bpmnElement="ParallelGateway_05o7mbp"> + <dc:Bounds x="697" y="215" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0sznvim_di" bpmnElement="ScriptTask_0sznvim"> + <dc:Bounds x="1110" y="510" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1sik00k_di" bpmnElement="ScriptTask_1sik00k"> + <dc:Bounds x="520" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1sukxzw_di" bpmnElement="ScriptTask_1sukxzw"> + <dc:Bounds x="520" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_02u3dmq_di" bpmnElement="ScriptTask_02u3dmq"> + <dc:Bounds x="520" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_04avf98_di" bpmnElement="SequenceFlow_04avf98"> + <di:waypoint x="620" y="130" /> + <di:waypoint x="722" y="130" /> + <di:waypoint x="722" y="215" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_00xa5wa_di" bpmnElement="SequenceFlow_00xa5wa"> + <di:waypoint x="620" y="240" /> + <di:waypoint x="697" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_064p1n6_di" bpmnElement="SequenceFlow_064p1n6"> + <di:waypoint x="620" y="350" /> + <di:waypoint x="722" y="350" /> + <di:waypoint x="722" y="265" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1a699ly_di" bpmnElement="SequenceFlow_1a699ly"> + <di:waypoint x="747" y="240" /> + <di:waypoint x="820" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Group_1k2kt9q_di" bpmnElement="Group_1k2kt9q"> + <dc:Bounds x="487" y="77" width="485" height="325" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="739" y="78" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_11rb2ju_di" bpmnElement="ScriptTask_11rb2ju"> + <dc:Bounds x="520" y="510" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0c567r4_di" bpmnElement="CallActivity_0c567r4"> + <dc:Bounds x="660" y="510" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0z0dwk2_di" bpmnElement="ScriptTask_0z0dwk2"> + <dc:Bounds x="820" y="510" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0f0rh4w_di" bpmnElement="ScriptTask_0f0rh4w"> + <dc:Bounds x="520" y="740" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1tmbgfs_di" bpmnElement="CallActivity_1tmbgfs"> + <dc:Bounds x="660" y="740" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0m6v98c_di" bpmnElement="ScriptTask_0m6v98c"> + <dc:Bounds x="820" y="740" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1kzy63m_di" bpmnElement="SequenceFlow_1kzy63m"> + <di:waypoint x="620" y="550" /> + <di:waypoint x="660" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1t317y2_di" bpmnElement="SequenceFlow_1t317y2"> + <di:waypoint x="760" y="550" /> + <di:waypoint x="820" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1dtfpqp_di" bpmnElement="SequenceFlow_1dtfpqp"> + <di:waypoint x="620" y="780" /> + <di:waypoint x="660" y="780" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0fdqj9b_di" bpmnElement="SequenceFlow_0fdqj9b"> + <di:waypoint x="760" y="780" /> + <di:waypoint x="820" y="780" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1rwl882_di" bpmnElement="SequenceFlow_1rwl882"> + <di:waypoint x="920" y="550" /> + <di:waypoint x="995" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0d2lpv3_di" bpmnElement="SequenceFlow_0d2lpv3"> + <di:waypoint x="920" y="780" /> + <di:waypoint x="1020" y="780" /> + <di:waypoint x="1020" y="575" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_15kmmuf_di" bpmnElement="CallActivity_15kmmuf"> + <dc:Bounds x="1280" y="510" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_175xozh_di" bpmnElement="SequenceFlow_175xozh"> + <di:waypoint x="1210" y="550" /> + <di:waypoint x="1280" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0woac2j_di" bpmnElement="ScriptTask_0woac2j"> + <dc:Bounds x="1420" y="510" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_188g03z_di" bpmnElement="SequenceFlow_188g03z"> + <di:waypoint x="1380" y="550" /> + <di:waypoint x="1420" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Group_19fk2vp_di" bpmnElement="Group_19fk2vp"> + <dc:Bounds x="495" y="450" width="453" height="180" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="686" y="457" width="72" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_17emrud_di" bpmnElement="SequenceFlow_17emrud"> + <di:waypoint x="1520" y="550" /> + <di:waypoint x="1562" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateCatchEvent_0pstvd4_di" bpmnElement="IntermediateCatchEvent_0pstvd4"> + <dc:Bounds x="198" y="1202" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="191" y="1245" width="60" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ParallelGateway_05zg916_di" bpmnElement="ParallelGateway_05zg916"> + <dc:Bounds x="335" y="1195" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ParallelGateway_06a2n9u_di" bpmnElement="ParallelGateway_06a2n9u"> + <dc:Bounds x="675" y="1195" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0tzazs0_di" bpmnElement="CallActivity_0tzazs0"> + <dc:Bounds x="1200" y="1040" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1sg6mqd_di" bpmnElement="SequenceFlow_1sg6mqd"> + <di:waypoint x="234" y="1220" /> + <di:waypoint x="335" y="1220" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_05250mp_di" bpmnElement="SequenceFlow_05250mp"> + <di:waypoint x="360" y="1195" /> + <di:waypoint x="360" y="1080" /> + <di:waypoint x="500" y="1080" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_14rhmx9_di" bpmnElement="SequenceFlow_14rhmx9"> + <di:waypoint x="600" y="1080" /> + <di:waypoint x="700" y="1080" /> + <di:waypoint x="700" y="1195" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0euwvgf_di" bpmnElement="SequenceFlow_0euwvgf"> + <di:waypoint x="385" y="1220" /> + <di:waypoint x="500" y="1220" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_103oxyw_di" bpmnElement="SequenceFlow_103oxyw"> + <di:waypoint x="600" y="1220" /> + <di:waypoint x="675" y="1220" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0il5j01_di" bpmnElement="SequenceFlow_0il5j01"> + <di:waypoint x="360" y="1245" /> + <di:waypoint x="360" y="1340" /> + <di:waypoint x="500" y="1340" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0aasemn_di" bpmnElement="SequenceFlow_0aasemn"> + <di:waypoint x="600" y="1340" /> + <di:waypoint x="700" y="1340" /> + <di:waypoint x="700" y="1245" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1tr3i9d_di" bpmnElement="SequenceFlow_1tr3i9d"> + <di:waypoint x="725" y="1220" /> + <di:waypoint x="800" y="1220" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0abqxa1_di" bpmnElement="SequenceFlow_0abqxa1"> + <di:waypoint x="1250" y="1180" /> + <di:waypoint x="1250" y="1120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1tqg26p_di" bpmnElement="SequenceFlow_1tqg26p"> + <di:waypoint x="1200" y="1080" /> + <di:waypoint x="900" y="1080" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0ubqlvg_di" bpmnElement="EndEvent_15dimzx"> + <dc:Bounds x="1562" y="532" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1539" y="575" width="87" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0p0cjhl_di" bpmnElement="EndEvent_0p0cjhl"> + <dc:Bounds x="1232" y="1322" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Group_01yft6a_di" bpmnElement="Group_01yft6a"> + <dc:Bounds x="495" y="690" width="453" height="180" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="680" y="697" width="85" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ParallelGateway_1v1unh1_di" bpmnElement="ParallelGateway_1v1unh1"> + <dc:Bounds x="995" y="525" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_16qt6r2_di" bpmnElement="SequenceFlow_16qt6r2"> + <di:waypoint x="1045" y="550" /> + <di:waypoint x="1110" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_0mwlirs_di" bpmnElement="StartEvent_0mwlirs"> + <dc:Bounds x="162" y="532" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="169" y="568" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0w34e57_di" bpmnElement="ScriptTask_0w34e57"> + <dc:Bounds x="230" y="510" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1fuwy35_di" bpmnElement="SequenceFlow_1fuwy35"> + <di:waypoint x="198" y="550" /> + <di:waypoint x="230" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_17otbuu_di" bpmnElement="SequenceFlow_17otbuu"> + <di:waypoint x="330" y="550" /> + <di:waypoint x="355" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_00t0340_di" bpmnElement="SequenceFlow_00t0340"> + <di:waypoint x="405" y="550" /> + <di:waypoint x="520" y="550" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_06uu0eh_di" bpmnElement="SequenceFlow_06uu0eh"> + <di:waypoint x="380" y="575" /> + <di:waypoint x="380" y="780" /> + <di:waypoint x="520" y="780" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_09see8v_di" bpmnElement="SequenceFlow_09see8v"> + <di:waypoint x="380" y="525" /> + <di:waypoint x="380" y="130" /> + <di:waypoint x="520" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_14s7fck_di" bpmnElement="SequenceFlow_14s7fck"> + <di:waypoint x="380" y="525" /> + <di:waypoint x="380" y="240" /> + <di:waypoint x="520" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1c374y2_di" bpmnElement="SequenceFlow_1c374y2"> + <di:waypoint x="380" y="525" /> + <di:waypoint x="380" y="350" /> + <di:waypoint x="520" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1anc3ln_di" bpmnElement="CallActivity_1vzxvna"> + <dc:Bounds x="500" y="1040" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1xgkaqi_di" bpmnElement="CallActivity_0melx8d"> + <dc:Bounds x="500" y="1180" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_11y7ba5_di" bpmnElement="CallActivity_0otry7e"> + <dc:Bounds x="500" y="1300" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_06t1dq5_di" bpmnElement="SequenceFlow_06t1dq5"> + <di:waypoint x="920" y="240" /> + <di:waypoint x="1020" y="240" /> + <di:waypoint x="1020" y="525" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1xkxr0x_di" bpmnElement="Task_1kqbsvd"> + <dc:Bounds x="820" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1icyh1a_di" bpmnElement="Task_1m9qoo3"> + <dc:Bounds x="1200" y="1180" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0aqbm7t_di" bpmnElement="Task_00nfg5x"> + <dc:Bounds x="800" y="1040" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0b52m39_di" bpmnElement="ExclusiveGateway_0b52m39" isMarkerVisible="true"> + <dc:Bounds x="1025" y="1195" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1008" y="1183" width="85" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_126j77n_di" bpmnElement="SequenceFlow_126j77n"> + <di:waypoint x="1075" y="1220" /> + <di:waypoint x="1200" y="1220" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1129" y="1202" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1nrfy6i_di" bpmnElement="SequenceFlow_1nrfy6i"> + <di:waypoint x="1050" y="1245" /> + <di:waypoint x="1050" y="1340" /> + <di:waypoint x="1232" y="1340" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1i3j8c3_di" bpmnElement="SequenceFlow_1i3j8c3"> + <di:waypoint x="850" y="1120" /> + <di:waypoint x="850" y="1180" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1tey3hz_di" bpmnElement="SequenceFlow_1tey3hz"> + <di:waypoint x="900" y="1220" /> + <di:waypoint x="1025" y="1220" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0h3fsja_di" bpmnElement="Task_1jyj2vs"> + <dc:Bounds x="800" y="1180" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateTnNssiInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateTnNssiInstance.bpmn new file mode 100644 index 0000000000..e9cbbb77cc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateTnNssiInstance.bpmn @@ -0,0 +1,179 @@ +<?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" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoCreateTnNssiInstance" name="DoCreateTnNssiInstance" isExecutable="true"> + <bpmn:startEvent id="allocateTnNssi_StartEvent" name="allocateTnNssi_StartEvent"> + <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="allocateTnNssi_StartEvent" targetRef="PreprocessIncomingRequest_task" /> + <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="instantiate_NSTask" /> + <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="Preprocess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0khtova</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCreateTnNssiInstance() +dcsi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="instantiate_NSTask" name="create Service Instance in AAI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0g5bwvl</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCreateTnNssiInstance() +dcsi.createServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1uiz85h" sourceRef="Activity_16luyg1" targetRef="Event_1rsf7yb" /> + <bpmn:sequenceFlow id="SequenceFlow_0g5bwvl" sourceRef="instantiate_NSTask" targetRef="Activity_08tw2di" /> + <bpmn:scriptTask id="ScriptTask_18rzwzb" name="Create Allottedsource in AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_106ei42</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17u69c4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCreateTnNssiInstance() +dcsi.createAllottedResource(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_17u69c4" sourceRef="ScriptTask_18rzwzb" targetRef="Event_1a9swwa" /> + <bpmn:intermediateCatchEvent id="Event_0l9vk9p" name="Start SDNC Operation"> + <bpmn:outgoing>Flow_1c8zr59</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_0uwmpn2" name="SdncOperation" /> + </bpmn:intermediateCatchEvent> + <bpmn:scriptTask id="Activity_0eh82ds" name="PreProcess SDNC Allocate TN NSSI Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1c8zr59</bpmn:incoming> + <bpmn:outgoing>Flow_0pko5tm</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCreateTnNssiInstance() +dcsi.preprocessSdncAllocateTnNssiRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_1fs2182" name="Call SDNC Adapter: Allocate TN NSSI" calledElement="sdncAdapter"> + <bpmn:extensionElements> + <camunda:in source="TNNSSMF_SDNCRequest" target="sdncAdapterWorkflowRequest" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> + <camunda:in source="mso-service-instance-id" target="mso-service-instance-id" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="sdncAdapterResponse" target="TNNSSMF_SDNCAdapterResponse" /> + <camunda:out source="SDNCA_SuccessIndicator" target="SDNCA_SuccessIndicator" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0pko5tm</bpmn:incoming> + <bpmn:outgoing>Flow_11kadz7</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_16luyg1" name="Postprocess SDNC Allocate TN NSSI Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_11kadz7</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1uiz85h</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String response = execution.getVariable("TNNSSMF_SDNCAdapterResponse") + +def dcsi = new DoCreateTnNssiInstance() +dcsi.validateSDNCResponse(execution, response, "allocate")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1c8zr59" name="" sourceRef="Event_0l9vk9p" targetRef="Activity_0eh82ds" /> + <bpmn:sequenceFlow id="Flow_0pko5tm" name="" sourceRef="Activity_0eh82ds" targetRef="Activity_1fs2182" /> + <bpmn:sequenceFlow id="Flow_11kadz7" name="" sourceRef="Activity_1fs2182" targetRef="Activity_16luyg1" /> + <bpmn:endEvent id="Event_1rsf7yb"> + <bpmn:incoming>SequenceFlow_1uiz85h</bpmn:incoming> + </bpmn:endEvent> + <bpmn:intermediateThrowEvent id="Event_1a9swwa" name="Goto SDNC operation"> + <bpmn:incoming>SequenceFlow_17u69c4</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_1skl6p7" name="SdncOperation" /> + </bpmn:intermediateThrowEvent> + <bpmn:scriptTask id="Activity_08tw2di" name="create Slice Profile in AAI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0g5bwvl</bpmn:incoming> + <bpmn:outgoing>Flow_106ei42</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCreateTnNssiInstance() +dcsi.createSliceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_106ei42" sourceRef="Activity_08tw2di" targetRef="ScriptTask_18rzwzb" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateTnNssiInstance"> + <bpmndi:BPMNEdge id="Flow_11kadz7_di" bpmnElement="Flow_11kadz7"> + <di:waypoint x="610" y="375" /> + <di:waypoint x="719" y="375" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0pko5tm_di" bpmnElement="Flow_0pko5tm"> + <di:waypoint x="420" y="375" /> + <di:waypoint x="489" y="375" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1c8zr59_di" bpmnElement="Flow_1c8zr59"> + <di:waypoint x="211" y="375" /> + <di:waypoint x="299" y="375" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_17u69c4_di" bpmnElement="SequenceFlow_17u69c4"> + <di:waypoint x="930" y="129" /> + <di:waypoint x="1102" y="129" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0g5bwvl_di" bpmnElement="SequenceFlow_0g5bwvl"> + <di:waypoint x="574" y="129" /> + <di:waypoint x="650" y="129" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1uiz85h_di" bpmnElement="SequenceFlow_1uiz85h"> + <di:waypoint x="840" y="375" /> + <di:waypoint x="972" y="375" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="631" y="108" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> + <di:waypoint x="393" y="129" /> + <di:waypoint x="474" y="129" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="436" y="108" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> + <di:waypoint x="211" y="129" /> + <di:waypoint x="251" y="129" /> + <di:waypoint x="251" y="129" /> + <di:waypoint x="293" y="129" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="266" y="123" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_106ei42_di" bpmnElement="Flow_106ei42"> + <di:waypoint x="750" y="129" /> + <di:waypoint x="830" y="129" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="allocateTnNssi_StartEvent"> + <dc:Bounds x="175" y="111" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="153" y="147" width="86" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> + <dc:Bounds x="293" y="89" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1qmmew8_di" bpmnElement="instantiate_NSTask"> + <dc:Bounds x="474" y="89" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0l9vk9p_di" bpmnElement="Event_0l9vk9p"> + <dc:Bounds x="175" y="357" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="165" y="400" width="58" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0eh82ds_di" bpmnElement="Activity_0eh82ds"> + <dc:Bounds x="299" y="328" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1fs2182_di" bpmnElement="Activity_1fs2182"> + <dc:Bounds x="489" y="328" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16luyg1_di" bpmnElement="Activity_16luyg1"> + <dc:Bounds x="719" y="328" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1rsf7yb_di" bpmnElement="Event_1rsf7yb"> + <dc:Bounds x="972" y="357" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1a9swwa_di" bpmnElement="Event_1a9swwa"> + <dc:Bounds x="1102" y="111" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1093" y="154" width="59" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_18rzwzb_di" bpmnElement="ScriptTask_18rzwzb"> + <dc:Bounds x="830" y="89" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_08tw2di_di" bpmnElement="Activity_08tw2di"> + <dc:Bounds x="650" y="89" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateAccessNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateAccessNSSI.bpmn new file mode 100644 index 0000000000..5e4b73070d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateAccessNSSI.bpmn @@ -0,0 +1,1226 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_17amn3o" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoDeallocateAccessNSSI" name="DoDeallocateAccessNSSI" isExecutable="true"> + <bpmn:startEvent id="Event_0seox25" name="Start"> + <bpmn:outgoing>Flow_14g5p2j</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="Flow_14g5p2j" sourceRef="Event_0seox25" targetRef="Activity_00sen5i" /> + <bpmn:scriptTask id="Activity_00sen5i" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_14g5p2j</bpmn:incoming> + <bpmn:outgoing>Flow_1hm17vz</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1hm17vz" sourceRef="Activity_00sen5i" targetRef="Activity_1i58rru" /> + <bpmn:sequenceFlow id="Flow_0kt6k2i" sourceRef="Activity_1i58rru" targetRef="Activity_0kpwy97" /> + <bpmn:sequenceFlow id="Flow_08ncj77" sourceRef="Activity_0kpwy97" targetRef="Activity_1v9avqp" /> + <bpmn:exclusiveGateway id="Gateway_05fdvbz" name="Terminate AN NSSi ?" default="Flow_0m12xsi"> + <bpmn:incoming>Flow_150eq0z</bpmn:incoming> + <bpmn:outgoing>Flow_12fyi2n</bpmn:outgoing> + <bpmn:outgoing>Flow_0m12xsi</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_150eq0z" sourceRef="Activity_1v9avqp" targetRef="Gateway_05fdvbz" /> + <bpmn:sequenceFlow id="Flow_12fyi2n" name="Yes" sourceRef="Gateway_05fdvbz" targetRef="Activity_0hpe14n"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("terminateAnNSSI") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0m3x1ra" sourceRef="Activity_0hpe14n" targetRef="Activity_0gzrekf" /> + <bpmn:sequenceFlow id="Flow_1o2mo3u" sourceRef="Activity_0gzrekf" targetRef="Gateway_1ypyzn3" /> + <bpmn:exclusiveGateway id="Gateway_1ypyzn3" default="Flow_16hk034"> + <bpmn:incoming>Flow_1o2mo3u</bpmn:incoming> + <bpmn:outgoing>Flow_02jtaed</bpmn:outgoing> + <bpmn:outgoing>Flow_16hk034</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_02jtaed" name="Yes" sourceRef="Gateway_1ypyzn3" targetRef="Activity_0szls0v"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("terminateAnNfNSSI") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_16hk034" name="No" sourceRef="Gateway_1ypyzn3" targetRef="Activity_0umktii" /> + <bpmn:sequenceFlow id="Flow_1she7i5" sourceRef="Activity_0szls0v" targetRef="Activity_0tbndh6" /> + <bpmn:intermediateThrowEvent id="Event_0vthuwp" name="Goto Terminate TN FH/MH NSSI"> + <bpmn:incoming>Flow_1lfvp5s</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0dpa9td" name="TerminateTnNSSI" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="Event_0opsm2p" name="TN FH/MH Termination"> + <bpmn:outgoing>Flow_0cj22bs</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1gactc9" name="TerminateTnNSSI" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="Flow_0cj22bs" sourceRef="Event_0opsm2p" targetRef="Activity_0uul9fb" /> + <bpmn:sequenceFlow id="Flow_0412ven" sourceRef="Activity_0qho4pw" targetRef="Activity_03zg1pp" /> + <bpmn:sequenceFlow id="Flow_0tlog6y" sourceRef="Activity_03zg1pp" targetRef="Activity_1ri9jrn" /> + <bpmn:sequenceFlow id="Flow_1lfvp5s" sourceRef="Activity_1v1ra2k" targetRef="Event_0vthuwp" /> + <bpmn:scriptTask id="Activity_1i58rru" name="Fetch Related NSSI and Slice profile details" scriptFormat="groovy"> + <bpmn:incoming>Flow_1hm17vz</bpmn:incoming> + <bpmn:outgoing>Flow_0kt6k2i</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.getRelatedInstances(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0kpwy97" name="Prepare AN NSSI Termination request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0kt6k2i</bpmn:incoming> + <bpmn:outgoing>Flow_08ncj77</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareOOFAnNssiTerminationRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1v9avqp" name="Call OOF for AN NSSI Termination" scriptFormat="groovy"> + <bpmn:incoming>Flow_08ncj77</bpmn:incoming> + <bpmn:outgoing>Flow_150eq0z</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.performOofAnNSSITerminationCall(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0hpe14n" name="Prepare OOF Terminate RAN NF NSSI" scriptFormat="groovy"> + <bpmn:incoming>Flow_12fyi2n</bpmn:incoming> + <bpmn:outgoing>Flow_0m3x1ra</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareOOFAnNfNssiTerminationRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0gzrekf" name="Call OOF flow for AN NF termination" scriptFormat="groovy"> + <bpmn:incoming>Flow_0m3x1ra</bpmn:incoming> + <bpmn:outgoing>Flow_1o2mo3u</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.performOofAnNfNSSITerminationCall(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:intermediateThrowEvent id="Event_18fpd51" name="Goto Terminate TN FH/MH NSSI"> + <bpmn:incoming>Flow_1x4e0k3</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_07j10pb" name="TerminateTnNSSI" /> + </bpmn:intermediateThrowEvent> + <bpmn:scriptTask id="Activity_1v1ra2k" name="Delete RAN NF NSSI" scriptFormat="groovy"> + <bpmn:incoming>Flow_0hdpgak</bpmn:incoming> + <bpmn:outgoing>Flow_1lfvp5s</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.deallocateAnNfNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_05frw6w" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1bgguw0</bpmn:incoming> + <bpmn:outgoing>Flow_1x4e0k3</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1bgguw0" sourceRef="Activity_17w3onz" targetRef="Activity_05frw6w" /> + <bpmn:sequenceFlow id="Flow_1x4e0k3" sourceRef="Activity_05frw6w" targetRef="Event_18fpd51" /> + <bpmn:scriptTask id="Activity_17w3onz" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0vcn5tl</bpmn:incoming> + <bpmn:outgoing>Flow_1bgguw0</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareUpdateJobStatus(execution,"processing","40","AN NF NSSI deallocated")</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1irtrgt" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0hlt6jq</bpmn:incoming> + <bpmn:outgoing>Flow_1pm77xu</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareUpdateJobStatus(execution,"processing","40","AN NF NSSI deleted")</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1vyon97" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1pm77xu</bpmn:incoming> + <bpmn:outgoing>Flow_0hdpgak</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1pm77xu" sourceRef="Activity_1irtrgt" targetRef="Activity_1vyon97" /> + <bpmn:sequenceFlow id="Flow_0hdpgak" sourceRef="Activity_1vyon97" targetRef="Activity_1v1ra2k" /> + <bpmn:scriptTask id="Activity_1w9w7a5" name="Validate jobstatus" scriptFormat="groovy"> + <bpmn:incoming>Flow_0azlxam</bpmn:incoming> + <bpmn:outgoing>Flow_1njlj9z</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +String responseDescriptor = execution.getVariable("an_responseDescriptor") + +deallocator.validateJobStatus(execution, responseDescriptor)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1dyluu0" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1nh3x4j</bpmn:incoming> + <bpmn:outgoing>Flow_1g9lfjr</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareUpdateJobStatus(execution,"finished","100","Deallocated successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1x2fc4q" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1g9lfjr</bpmn:incoming> + <bpmn:outgoing>Flow_04bem88</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1g9lfjr" sourceRef="Activity_1dyluu0" targetRef="Activity_1x2fc4q" /> + <bpmn:scriptTask id="Activity_0wlygp0" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0m12xsi</bpmn:incoming> + <bpmn:outgoing>Flow_1xqtf63</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareUpdateJobStatus(execution,"processing","20","callingmodifyNSSI modifyAction-deallocate")</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1e1s439" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1xqtf63</bpmn:incoming> + <bpmn:outgoing>Flow_1s5fdmz</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1xqtf63" sourceRef="Activity_0wlygp0" targetRef="Activity_1e1s439" /> + <bpmn:sequenceFlow id="Flow_0m12xsi" sourceRef="Gateway_05fdvbz" targetRef="Activity_0wlygp0" /> + <bpmn:scriptTask id="Activity_1ih5cjh" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_07m650f</bpmn:incoming> + <bpmn:outgoing>Flow_1ib3uzg</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareUpdateJobStatus(execution,"processing","60","TN-FH terminated")</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1clwk2x" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1ib3uzg</bpmn:incoming> + <bpmn:outgoing>Flow_15bkzm7</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1ib3uzg" sourceRef="Activity_1ih5cjh" targetRef="Activity_1clwk2x" /> + <bpmn:sequenceFlow id="Flow_15bkzm7" sourceRef="Activity_1clwk2x" targetRef="Activity_114fx71" /> + <bpmn:sequenceFlow id="Flow_1nh3x4j" sourceRef="Activity_1ri9jrn" targetRef="Activity_1dyluu0" /> + <bpmn:endEvent id="Event_19tcky7"> + <bpmn:incoming>Flow_04bem88</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_04bem88" sourceRef="Activity_1x2fc4q" targetRef="Event_19tcky7" /> + <bpmn:scriptTask id="Activity_0uul9fb" name="Call NSSMF adapter for TN_FH NSSI Termination" scriptFormat="groovy"> + <bpmn:incoming>Flow_0cj22bs</bpmn:incoming> + <bpmn:outgoing>Flow_0x1wi2t</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.terminateTNFHNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_114fx71" name="Do TN_MH NSSI Termination" scriptFormat="groovy"> + <bpmn:incoming>Flow_15bkzm7</bpmn:incoming> + <bpmn:outgoing>Flow_04coe09</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.terminateTNMHNssi(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:subProcess id="Activity_0qbd3cz" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_13wl9ag"> + <bpmn:outgoing>Flow_1q1450g</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1z0jo5h" errorRef="Error_0i5gql0" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_0ugnt78"> + <bpmn:incoming>Flow_035ivcv</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_1mzoss1" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_0nsc2oc</bpmn:incoming> + <bpmn:outgoing>Flow_035ivcv</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_035ivcv" sourceRef="Activity_1mzoss1" targetRef="Event_0ugnt78" /> + <bpmn:serviceTask id="Activity_055w5hr" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0alqcat</bpmn:incoming> + <bpmn:outgoing>Flow_0nsc2oc</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:scriptTask id="Activity_1nr7xyr" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1q1450g</bpmn:incoming> + <bpmn:outgoing>Flow_0alqcat</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareUpdateJobStatus(execution,"failed","0","Job Failed")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0alqcat" sourceRef="Activity_1nr7xyr" targetRef="Activity_055w5hr" /> + <bpmn:sequenceFlow id="Flow_1q1450g" sourceRef="Event_13wl9ag" targetRef="Activity_1nr7xyr" /> + <bpmn:sequenceFlow id="Flow_0nsc2oc" sourceRef="Activity_055w5hr" targetRef="Activity_1mzoss1" /> + </bpmn:subProcess> + <bpmn:callActivity id="Activity_0jtob0z" name="QueryJobStatus" calledElement="QueryJobStatus"> + <bpmn:extensionElements> + <camunda:in source="an_esrInfo" target="esrInfo" /> + <camunda:in source="an_responseId" target="responseId" /> + <camunda:in source="modificationJobId" target="jobId" /> + <camunda:in source="an_serviceInfo" target="serviceInfo" /> + <camunda:out source="responseDescriptor" target="an_responseDescriptor" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_12cm0xq</bpmn:incoming> + <bpmn:outgoing>Flow_0azlxam</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0azlxam" sourceRef="Activity_0jtob0z" targetRef="Activity_1w9w7a5" /> + <bpmn:scriptTask id="Activity_1l3vkx0" name="Update Job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_01xixn8</bpmn:incoming> + <bpmn:outgoing>Flow_1ai7sri</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareUpdateJobStatus(execution,"finished","100","Deallocated successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_0tuhk79" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1ai7sri</bpmn:incoming> + <bpmn:outgoing>Flow_17mns9c</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1ai7sri" sourceRef="Activity_1l3vkx0" targetRef="Activity_0tuhk79" /> + <bpmn:scriptTask id="Activity_0szls0v" name="Prepare SDNR request" scriptFormat="groovy"> + <bpmn:incoming>Flow_02jtaed</bpmn:incoming> + <bpmn:outgoing>Flow_1she7i5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareSdnrRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_0tbndh6" name="Call SDNR subprocess" calledElement="DoHandleSdnrDmaapRequest"> + <bpmn:extensionElements> + <camunda:in source="sdnrRequest" target="sdnrRequest" /> + <camunda:in source="SDNR_messageType" target="messageType" /> + <camunda:in source="SDNR_timeout" target="timeout" /> + <camunda:in source="msoRequestId" target="correlator" /> + <camunda:out source="asyncCallbackResponse" target="SDNR_Response" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1she7i5</bpmn:incoming> + <bpmn:outgoing>Flow_02pdd51</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:exclusiveGateway id="Gateway_1p35k2g" name="Is Success response" default="Flow_1uz3kjn"> + <bpmn:incoming>Flow_1bpg97k</bpmn:incoming> + <bpmn:outgoing>Flow_0hlt6jq</bpmn:outgoing> + <bpmn:outgoing>Flow_1uz3kjn</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0hlt6jq" name="Yes" sourceRef="Gateway_1p35k2g" targetRef="Activity_1irtrgt"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isAnNfTerminated") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1uz3kjn" name="No" sourceRef="Gateway_1p35k2g" targetRef="Event_1icw8fg" /> + <bpmn:endEvent id="Event_1icw8fg" name="DeallocateWorkflowError"> + <bpmn:incoming>Flow_1uz3kjn</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0kdeuox" errorRef="Error_0i5gql0" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_02pdd51" sourceRef="Activity_0tbndh6" targetRef="Activity_0lszayp" /> + <bpmn:sequenceFlow id="Flow_1bpg97k" sourceRef="Activity_0lszayp" targetRef="Gateway_1p35k2g" /> + <bpmn:scriptTask id="Activity_0lszayp" name="Process sdnr response" scriptFormat="groovy"> + <bpmn:incoming>Flow_02pdd51</bpmn:incoming> + <bpmn:outgoing>Flow_1bpg97k</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.processSdnrResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:subProcess id="Activity_0c0vkj6" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_1bqq1on"> + <bpmn:outgoing>Flow_0bkcs42</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0tgpoyd" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_0qb738v"> + <bpmn:incoming>Flow_1b5mtc4</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_0187ysa" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_0bkcs42</bpmn:incoming> + <bpmn:outgoing>Flow_1b5mtc4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1b5mtc4" sourceRef="Activity_0187ysa" targetRef="Event_0qb738v" /> + <bpmn:sequenceFlow id="Flow_0bkcs42" sourceRef="Event_1bqq1on" targetRef="Activity_0187ysa" /> + </bpmn:subProcess> + <bpmn:callActivity id="Activity_115teb9" name="Call ANModifyNSSI" calledElement="DoModifyAccessNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="modificationJobId" target="jobId" /> + <camunda:in source="modificationsliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1ywvasn</bpmn:incoming> + <bpmn:outgoing>Flow_1udlwb4</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_1s5fdmz" sourceRef="Activity_1e1s439" targetRef="Activity_1wu2d9y" /> + <bpmn:scriptTask id="Activity_1wu2d9y" name="Prepare NSSI modification job" scriptFormat="groovy"> + <bpmn:incoming>Flow_1s5fdmz</bpmn:incoming> + <bpmn:outgoing>Flow_0x71rer</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.preparejobForANNSSIModification(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_0drkoau" name="UpdateModify Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${initResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0x71rer</bpmn:incoming> + <bpmn:outgoing>Flow_1ywvasn</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1ywvasn" sourceRef="Activity_0drkoau" targetRef="Activity_115teb9" /> + <bpmn:endEvent id="Event_14cxrjq"> + <bpmn:incoming>Flow_17mns9c</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_17mns9c" sourceRef="Activity_0tuhk79" targetRef="Event_14cxrjq" /> + <bpmn:sequenceFlow id="Flow_1udlwb4" sourceRef="Activity_115teb9" targetRef="Activity_1x1p1fc" /> + <bpmn:sequenceFlow id="Flow_12cm0xq" sourceRef="Activity_1x1p1fc" targetRef="Activity_0jtob0z" /> + <bpmn:scriptTask id="Activity_1x1p1fc" name="Prepare job status query" scriptFormat="groovy"> + <bpmn:incoming>Flow_1udlwb4</bpmn:incoming> + <bpmn:outgoing>Flow_12cm0xq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String jobId = execution.getVariable("modificationJobId") +String networkType="an" +String nssiid=execution.getVariable("serviceInstanceID") + +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareQueryJobStatus(execution, jobId,networkType, nssiid)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1nm5kq2" name="Is Job complete?" default="Flow_0klaefp"> + <bpmn:incoming>Flow_1njlj9z</bpmn:incoming> + <bpmn:outgoing>Flow_01xixn8</bpmn:outgoing> + <bpmn:outgoing>Flow_0klaefp</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_1njlj9z" sourceRef="Activity_1w9w7a5" targetRef="Gateway_1nm5kq2" /> + <bpmn:sequenceFlow id="Flow_01xixn8" name="Yes" sourceRef="Gateway_1nm5kq2" targetRef="Activity_1l3vkx0"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isSuccess") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="Event_0ayhmk4" name="DeallocateWorkflowError"> + <bpmn:incoming>Flow_0klaefp</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1y9usob" errorRef="Error_0i5gql0" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0klaefp" name="No" sourceRef="Gateway_1nm5kq2" targetRef="Event_0ayhmk4" /> + <bpmn:callActivity id="Activity_0mda4y4" name="QueryJobStatus" calledElement="QueryJobStatus"> + <bpmn:extensionElements> + <camunda:in source="tn_esrInfo" target="esrInfo" /> + <camunda:in source="tn_responseId" target="responseId" /> + <camunda:in source="TN_FH_jobId" target="jobId" /> + <camunda:in source="tn_serviceInfo" target="serviceInfo" /> + <camunda:out source="responseDescriptor" target="tnFh_responseDescriptor" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_11vezy6</bpmn:incoming> + <bpmn:outgoing>Flow_0sg1a2h</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_1e7m0zn" name="Validate jobstatus" scriptFormat="groovy"> + <bpmn:incoming>Flow_0sg1a2h</bpmn:incoming> + <bpmn:outgoing>Flow_1yidpp1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +String responseDescriptor = execution.getVariable("tnFh_responseDescriptor") + +deallocator.validateJobStatus(execution, responseDescriptor)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_18ykcln" name="Is Job complete?" default="Flow_1gr7m1w"> + <bpmn:incoming>Flow_1yidpp1</bpmn:incoming> + <bpmn:outgoing>Flow_1gr7m1w</bpmn:outgoing> + <bpmn:outgoing>Flow_07m650f</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_0r83tv9" name="DeallocateWorkflowError"> + <bpmn:incoming>Flow_1gr7m1w</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_118q048" errorRef="Error_0i5gql0" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0sg1a2h" sourceRef="Activity_0mda4y4" targetRef="Activity_1e7m0zn" /> + <bpmn:sequenceFlow id="Flow_1yidpp1" sourceRef="Activity_1e7m0zn" targetRef="Gateway_18ykcln" /> + <bpmn:sequenceFlow id="Flow_1gr7m1w" name="No" sourceRef="Gateway_18ykcln" targetRef="Event_0r83tv9" /> + <bpmn:callActivity id="Activity_0zlr24k" name="QueryJobStatus" calledElement="QueryJobStatus"> + <bpmn:extensionElements> + <camunda:in source="tn_esrInfo" target="esrInfo" /> + <camunda:in source="tn_responseId" target="responseId" /> + <camunda:in source="TN_MH_jobId" target="jobId" /> + <camunda:in source="tn_serviceInfo" target="serviceInfo" /> + <camunda:out source="responseDescriptor" target="tnMh_responseDescriptor" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_16qo8iw</bpmn:incoming> + <bpmn:outgoing>Flow_0cmkk7f</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_0q7ghdf" name="Validate jobstatus" scriptFormat="groovy"> + <bpmn:incoming>Flow_0cmkk7f</bpmn:incoming> + <bpmn:outgoing>Flow_17caqnb</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +String responseDescriptor = execution.getVariable("tnMh_responseDescriptor") + +deallocator.validateJobStatus(execution, responseDescriptor)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1dylwav" name="Is Job complete?" default="Flow_0jz37j1"> + <bpmn:incoming>Flow_17caqnb</bpmn:incoming> + <bpmn:outgoing>Flow_0jz37j1</bpmn:outgoing> + <bpmn:outgoing>Flow_03fig6p</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_0wlpcd6" name="DeallocateWorkflowError"> + <bpmn:incoming>Flow_0jz37j1</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1w46vnr" errorRef="Error_0i5gql0" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0cmkk7f" sourceRef="Activity_0zlr24k" targetRef="Activity_0q7ghdf" /> + <bpmn:sequenceFlow id="Flow_17caqnb" sourceRef="Activity_0q7ghdf" targetRef="Gateway_1dylwav" /> + <bpmn:sequenceFlow id="Flow_0jz37j1" name="No" sourceRef="Gateway_1dylwav" targetRef="Event_0wlpcd6" /> + <bpmn:scriptTask id="Activity_0506p7p" name="Prepare job status query" scriptFormat="groovy"> + <bpmn:incoming>Flow_04coe09</bpmn:incoming> + <bpmn:outgoing>Flow_16qo8iw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String jobId = execution.getVariable("TN_MH_jobId") +String networkType="tn" +String nssiid=execution.getVariable("tnMHNSSIId") + +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareQueryJobStatus(execution, jobId,networkType, nssiid)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_04coe09" sourceRef="Activity_114fx71" targetRef="Activity_0506p7p" /> + <bpmn:sequenceFlow id="Flow_16qo8iw" sourceRef="Activity_0506p7p" targetRef="Activity_0zlr24k" /> + <bpmn:sequenceFlow id="Flow_07m650f" name="Yes" sourceRef="Gateway_18ykcln" targetRef="Activity_1ih5cjh"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isSuccess") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="Activity_11w4jgm" name="Prepare job status query" scriptFormat="groovy"> + <bpmn:incoming>Flow_0x1wi2t</bpmn:incoming> + <bpmn:outgoing>Flow_11vezy6</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String jobId = execution.getVariable("TN_FH_jobId") +String networkType="tn" +String nssiid=execution.getVariable("tnFHNSSIId") + +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.prepareQueryJobStatus(execution, jobId,networkType, nssiid)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_11vezy6" sourceRef="Activity_11w4jgm" targetRef="Activity_0mda4y4" /> + <bpmn:sequenceFlow id="Flow_0x1wi2t" sourceRef="Activity_0uul9fb" targetRef="Activity_11w4jgm" /> + <bpmn:sequenceFlow id="Flow_03fig6p" name="Yes" sourceRef="Gateway_1dylwav" targetRef="Event_1mf8gxd"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isSuccess") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:intermediateThrowEvent id="Event_1mf8gxd" name="Goto AAI Updates"> + <bpmn:incoming>Flow_03fig6p</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0ocsblp" name="UpdateAAI" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="Event_0dewj8o" name="AAI Updates"> + <bpmn:outgoing>Flow_0omhxaj</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_06yz8px" name="UpdateAAI" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="Flow_0omhxaj" sourceRef="Event_0dewj8o" targetRef="Activity_0qho4pw" /> + <bpmn:scriptTask id="Activity_0qho4pw" name="Delete RAN NF Slice profile in AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_0omhxaj</bpmn:incoming> + <bpmn:outgoing>Flow_0412ven</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.deleteRanNfSliceProfileInAAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_03zg1pp" name="Delete TN Slice profiles" scriptFormat="groovy"> + <bpmn:incoming>Flow_0412ven</bpmn:incoming> + <bpmn:outgoing>Flow_0tlog6y</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.deleteTNSliceProfileInAAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1ri9jrn" name="Delete RAN NSSI" scriptFormat="groovy"> + <bpmn:incoming>Flow_0tlog6y</bpmn:incoming> + <bpmn:outgoing>Flow_1nh3x4j</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def deallocator = new DoDeAllocateAccessNSSI() +deallocator.deleteANNSSI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_0umktii" name="Modify RAN NF NSSI" calledElement="DoModifyRanNfNssi"> + <bpmn:extensionElements> + <camunda:in source="anNfNssiId" target="serviceInstanceID" /> + <camunda:in source="anNfSliceProfileId" target="SliceProfileId" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="sNssaiList" target="snssaiList" /> + <camunda:in source="modifyAction" target="modifyAction" /> + <camunda:out source="ranNfStatus" target="ranNfStatus" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_16hk034</bpmn:incoming> + <bpmn:outgoing>Flow_18y4ab2</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:exclusiveGateway id="Gateway_0g02vzi" name="Is RAN NF deallocated?" default="Flow_0k55zuy"> + <bpmn:incoming>Flow_18y4ab2</bpmn:incoming> + <bpmn:outgoing>Flow_0vcn5tl</bpmn:outgoing> + <bpmn:outgoing>Flow_0k55zuy</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_18y4ab2" sourceRef="Activity_0umktii" targetRef="Gateway_0g02vzi" /> + <bpmn:sequenceFlow id="Flow_0vcn5tl" name="Yes" sourceRef="Gateway_0g02vzi" targetRef="Activity_17w3onz"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ranNfStatus") == "success"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0k55zuy" name="No" sourceRef="Gateway_0g02vzi" targetRef="Event_161u9s2" /> + <bpmn:endEvent id="Event_161u9s2"> + <bpmn:incoming>Flow_0k55zuy</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_031y5kl" errorRef="Error_0i5gql0" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0x71rer" sourceRef="Activity_1wu2d9y" targetRef="Activity_0drkoau" /> + </bpmn:process> + <bpmn:error id="Error_0i5gql0" name="DeallocateWorkflowError" errorCode="2500" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeallocateAccessNSSI"> + <bpmndi:BPMNEdge id="Flow_0omhxaj_di" bpmnElement="Flow_0omhxaj"> + <di:waypoint x="238" y="1110" /> + <di:waypoint x="360" y="1110" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_03fig6p_di" bpmnElement="Flow_03fig6p"> + <di:waypoint x="2085" y="880" /> + <di:waypoint x="2182" y="880" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2125" y="862" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0x1wi2t_di" bpmnElement="Flow_0x1wi2t"> + <di:waypoint x="380" y="880" /> + <di:waypoint x="420" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_11vezy6_di" bpmnElement="Flow_11vezy6"> + <di:waypoint x="520" y="880" /> + <di:waypoint x="570" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_07m650f_di" bpmnElement="Flow_07m650f"> + <di:waypoint x="965" y="880" /> + <di:waypoint x="1030" y="880" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="989" y="862" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16qo8iw_di" bpmnElement="Flow_16qo8iw"> + <di:waypoint x="1590" y="880" /> + <di:waypoint x="1660" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_04coe09_di" bpmnElement="Flow_04coe09"> + <di:waypoint x="1430" y="880" /> + <di:waypoint x="1490" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0jz37j1_di" bpmnElement="Flow_0jz37j1"> + <di:waypoint x="2060" y="905" /> + <di:waypoint x="2060" y="962" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2068" y="931" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_17caqnb_di" bpmnElement="Flow_17caqnb"> + <di:waypoint x="1940" y="880" /> + <di:waypoint x="2035" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cmkk7f_di" bpmnElement="Flow_0cmkk7f"> + <di:waypoint x="1760" y="880" /> + <di:waypoint x="1840" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1gr7m1w_di" bpmnElement="Flow_1gr7m1w"> + <di:waypoint x="940" y="905" /> + <di:waypoint x="940" y="962" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="948" y="931" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1yidpp1_di" bpmnElement="Flow_1yidpp1"> + <di:waypoint x="830" y="880" /> + <di:waypoint x="915" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0sg1a2h_di" bpmnElement="Flow_0sg1a2h"> + <di:waypoint x="670" y="880" /> + <di:waypoint x="730" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0klaefp_di" bpmnElement="Flow_0klaefp"> + <di:waypoint x="2140" y="675" /> + <di:waypoint x="2140" y="732" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2148" y="701" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_01xixn8_di" bpmnElement="Flow_01xixn8"> + <di:waypoint x="2165" y="650" /> + <di:waypoint x="2220" y="650" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2184" y="632" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1njlj9z_di" bpmnElement="Flow_1njlj9z"> + <di:waypoint x="2050" y="650" /> + <di:waypoint x="2115" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_12cm0xq_di" bpmnElement="Flow_12cm0xq"> + <di:waypoint x="1720" y="650" /> + <di:waypoint x="1780" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1udlwb4_di" bpmnElement="Flow_1udlwb4"> + <di:waypoint x="1560" y="650" /> + <di:waypoint x="1620" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_17mns9c_di" bpmnElement="Flow_17mns9c"> + <di:waypoint x="2490" y="650" /> + <di:waypoint x="2552" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ywvasn_di" bpmnElement="Flow_1ywvasn"> + <di:waypoint x="1420" y="650" /> + <di:waypoint x="1460" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0x71rer_di" bpmnElement="Flow_0x71rer"> + <di:waypoint x="1275" y="650" /> + <di:waypoint x="1320" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1s5fdmz_di" bpmnElement="Flow_1s5fdmz"> + <di:waypoint x="1130" y="650" /> + <di:waypoint x="1175" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1bpg97k_di" bpmnElement="Flow_1bpg97k"> + <di:waypoint x="1820" y="410" /> + <di:waypoint x="1875" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_02pdd51_di" bpmnElement="Flow_02pdd51"> + <di:waypoint x="1680" y="410" /> + <di:waypoint x="1720" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1uz3kjn_di" bpmnElement="Flow_1uz3kjn"> + <di:waypoint x="1900" y="435" /> + <di:waypoint x="1900" y="482" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1908" y="456" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0hlt6jq_di" bpmnElement="Flow_0hlt6jq"> + <di:waypoint x="1925" y="410" /> + <di:waypoint x="1970" y="410" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1939" y="392" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ai7sri_di" bpmnElement="Flow_1ai7sri"> + <di:waypoint x="2320" y="650" /> + <di:waypoint x="2390" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0azlxam_di" bpmnElement="Flow_0azlxam"> + <di:waypoint x="1880" y="650" /> + <di:waypoint x="1950" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_04bem88_di" bpmnElement="Flow_04bem88"> + <di:waypoint x="1130" y="1110" /> + <di:waypoint x="1207" y="1110" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1nh3x4j_di" bpmnElement="Flow_1nh3x4j"> + <di:waypoint x="810" y="1110" /> + <di:waypoint x="880" y="1110" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_15bkzm7_di" bpmnElement="Flow_15bkzm7"> + <di:waypoint x="1280" y="880" /> + <di:waypoint x="1330" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ib3uzg_di" bpmnElement="Flow_1ib3uzg"> + <di:waypoint x="1130" y="880" /> + <di:waypoint x="1180" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0m12xsi_di" bpmnElement="Flow_0m12xsi"> + <di:waypoint x="880" y="435" /> + <di:waypoint x="880" y="650" /> + <di:waypoint x="900" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1xqtf63_di" bpmnElement="Flow_1xqtf63"> + <di:waypoint x="1000" y="650" /> + <di:waypoint x="1030" y="650" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1g9lfjr_di" bpmnElement="Flow_1g9lfjr"> + <di:waypoint x="980" y="1110" /> + <di:waypoint x="1030" y="1110" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0hdpgak_di" bpmnElement="Flow_0hdpgak"> + <di:waypoint x="2220" y="410" /> + <di:waypoint x="2280" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1pm77xu_di" bpmnElement="Flow_1pm77xu"> + <di:waypoint x="2070" y="410" /> + <di:waypoint x="2120" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1x4e0k3_di" bpmnElement="Flow_1x4e0k3"> + <di:waypoint x="2130" y="240" /> + <di:waypoint x="2232" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1bgguw0_di" bpmnElement="Flow_1bgguw0"> + <di:waypoint x="1920" y="240" /> + <di:waypoint x="2030" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1lfvp5s_di" bpmnElement="Flow_1lfvp5s"> + <di:waypoint x="2380" y="410" /> + <di:waypoint x="2422" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0tlog6y_di" bpmnElement="Flow_0tlog6y"> + <di:waypoint x="630" y="1110" /> + <di:waypoint x="710" y="1110" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0412ven_di" bpmnElement="Flow_0412ven"> + <di:waypoint x="460" y="1110" /> + <di:waypoint x="530" y="1110" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cj22bs_di" bpmnElement="Flow_0cj22bs"> + <di:waypoint x="238" y="880" /> + <di:waypoint x="280" y="880" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1she7i5_di" bpmnElement="Flow_1she7i5"> + <di:waypoint x="1500" y="410" /> + <di:waypoint x="1580" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16hk034_di" bpmnElement="Flow_16hk034"> + <di:waypoint x="1290" y="385" /> + <di:waypoint x="1290" y="240" /> + <di:waypoint x="1400" y="240" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1298" y="312" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_02jtaed_di" bpmnElement="Flow_02jtaed"> + <di:waypoint x="1315" y="410" /> + <di:waypoint x="1400" y="410" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1349" y="392" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1o2mo3u_di" bpmnElement="Flow_1o2mo3u"> + <di:waypoint x="1200" y="410" /> + <di:waypoint x="1265" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0m3x1ra_di" bpmnElement="Flow_0m3x1ra"> + <di:waypoint x="1050" y="410" /> + <di:waypoint x="1100" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_12fyi2n_di" bpmnElement="Flow_12fyi2n"> + <di:waypoint x="905" y="410" /> + <di:waypoint x="950" y="410" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="919" y="392" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_150eq0z_di" bpmnElement="Flow_150eq0z"> + <di:waypoint x="810" y="410" /> + <di:waypoint x="855" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_08ncj77_di" bpmnElement="Flow_08ncj77"> + <di:waypoint x="670" y="410" /> + <di:waypoint x="710" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0kt6k2i_di" bpmnElement="Flow_0kt6k2i"> + <di:waypoint x="530" y="410" /> + <di:waypoint x="570" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1hm17vz_di" bpmnElement="Flow_1hm17vz"> + <di:waypoint x="390" y="410" /> + <di:waypoint x="430" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_14g5p2j_di" bpmnElement="Flow_14g5p2j"> + <di:waypoint x="238" y="410" /> + <di:waypoint x="290" y="410" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_18y4ab2_di" bpmnElement="Flow_18y4ab2"> + <di:waypoint x="1500" y="240" /> + <di:waypoint x="1625" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0vcn5tl_di" bpmnElement="Flow_0vcn5tl"> + <di:waypoint x="1675" y="240" /> + <di:waypoint x="1820" y="240" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1739" y="222" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0k55zuy_di" bpmnElement="Flow_0k55zuy"> + <di:waypoint x="1650" y="215" /> + <di:waypoint x="1650" y="100" /> + <di:waypoint x="1822" y="100" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1658" y="155" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_0seox25_di" bpmnElement="Event_0seox25"> + <dc:Bounds x="202" y="392" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="208" y="435" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ahytqr_di" bpmnElement="Activity_00sen5i"> + <dc:Bounds x="290" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_05fdvbz_di" bpmnElement="Gateway_05fdvbz" isMarkerVisible="true"> + <dc:Bounds x="855" y="385" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="847" y="355" width="67" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1ypyzn3_di" bpmnElement="Gateway_1ypyzn3" isMarkerVisible="true"> + <dc:Bounds x="1265" y="385" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1dvx4n9_di" bpmnElement="Event_0vthuwp"> + <dc:Bounds x="2422" y="392" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2399" y="438" width="82" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1ekryu8_di" bpmnElement="Event_0opsm2p"> + <dc:Bounds x="202" y="862" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="192" y="905" width="57" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_18i5si0_di" bpmnElement="Activity_1i58rru"> + <dc:Bounds x="430" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0u528ge_di" bpmnElement="Activity_0kpwy97"> + <dc:Bounds x="570" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0tgprdn_di" bpmnElement="Activity_1v9avqp"> + <dc:Bounds x="710" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_11wbmk9_di" bpmnElement="Activity_0hpe14n"> + <dc:Bounds x="950" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1h4jup8_di" bpmnElement="Activity_0gzrekf"> + <dc:Bounds x="1100" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_18fpd51_di" bpmnElement="Event_18fpd51"> + <dc:Bounds x="2232" y="222" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2209" y="268" width="82" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0m43umg_di" bpmnElement="Activity_1v1ra2k"> + <dc:Bounds x="2280" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1i1fknn_di" bpmnElement="Activity_1irtrgt"> + <dc:Bounds x="1970" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1vyon97_di" bpmnElement="Activity_1vyon97"> + <dc:Bounds x="2120" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1w9w7a5_di" bpmnElement="Activity_1w9w7a5"> + <dc:Bounds x="1950" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1dyluu0_di" bpmnElement="Activity_1dyluu0"> + <dc:Bounds x="880" y="1070" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1x2fc4q_di" bpmnElement="Activity_1x2fc4q"> + <dc:Bounds x="1030" y="1070" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0wlygp0_di" bpmnElement="Activity_0wlygp0"> + <dc:Bounds x="900" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1e1s439_di" bpmnElement="Activity_1e1s439"> + <dc:Bounds x="1030" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ih5cjh_di" bpmnElement="Activity_1ih5cjh"> + <dc:Bounds x="1030" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1clwk2x_di" bpmnElement="Activity_1clwk2x"> + <dc:Bounds x="1180" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_19tcky7_di" bpmnElement="Event_19tcky7"> + <dc:Bounds x="1207" y="1092" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0pm19vk_di" bpmnElement="Activity_0uul9fb"> + <dc:Bounds x="280" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1i9b3oi_di" bpmnElement="Activity_114fx71"> + <dc:Bounds x="1330" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_01s2lve_di" bpmnElement="Activity_0umktii"> + <dc:Bounds x="1400" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_05frw6w_di" bpmnElement="Activity_05frw6w"> + <dc:Bounds x="2030" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0njdei2_di" bpmnElement="Activity_17w3onz"> + <dc:Bounds x="1820" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0g02vzi_di" bpmnElement="Gateway_0g02vzi" isMarkerVisible="true"> + <dc:Bounds x="1625" y="215" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1619" y="272" width="63" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0jtob0z_di" bpmnElement="Activity_0jtob0z"> + <dc:Bounds x="1780" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1l3vkx0_di" bpmnElement="Activity_1l3vkx0"> + <dc:Bounds x="2220" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0tuhk79_di" bpmnElement="Activity_0tuhk79"> + <dc:Bounds x="2390" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0mddd28_di" bpmnElement="Activity_0szls0v"> + <dc:Bounds x="1400" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0zhag3x_di" bpmnElement="Activity_0tbndh6"> + <dc:Bounds x="1580" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1p35k2g_di" bpmnElement="Gateway_1p35k2g" isMarkerVisible="true"> + <dc:Bounds x="1875" y="385" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1874" y="355" width="54" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1us3hum_di" bpmnElement="Event_1icw8fg"> + <dc:Bounds x="1882" y="482" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1918" y="466" width="83" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_10vgzv9_di" bpmnElement="Activity_0lszayp"> + <dc:Bounds x="1720" y="370" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_115teb9_di" bpmnElement="Activity_115teb9"> + <dc:Bounds x="1460" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1kzmrir_di" bpmnElement="Activity_1wu2d9y"> + <dc:Bounds x="1175" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0drkoau_di" bpmnElement="Activity_0drkoau"> + <dc:Bounds x="1320" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_14cxrjq_di" bpmnElement="Event_14cxrjq"> + <dc:Bounds x="2552" y="632" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1i80irm_di" bpmnElement="Activity_1x1p1fc"> + <dc:Bounds x="1620" y="610" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1nm5kq2_di" bpmnElement="Gateway_1nm5kq2" isMarkerVisible="true"> + <dc:Bounds x="2115" y="625" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2099" y="595" width="84" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0ayhmk4_di" bpmnElement="Event_0ayhmk4"> + <dc:Bounds x="2122" y="732" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2158" y="716" width="83" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0mda4y4_di" bpmnElement="Activity_0mda4y4"> + <dc:Bounds x="570" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1e7m0zn_di" bpmnElement="Activity_1e7m0zn"> + <dc:Bounds x="730" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_18ykcln_di" bpmnElement="Gateway_18ykcln" isMarkerVisible="true"> + <dc:Bounds x="915" y="855" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="899" y="825" width="84" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0r83tv9_di" bpmnElement="Event_0r83tv9"> + <dc:Bounds x="922" y="962" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="998" y="948" width="83" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0zlr24k_di" bpmnElement="Activity_0zlr24k"> + <dc:Bounds x="1660" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0q7ghdf_di" bpmnElement="Activity_0q7ghdf"> + <dc:Bounds x="1840" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1dylwav_di" bpmnElement="Gateway_1dylwav" isMarkerVisible="true"> + <dc:Bounds x="2035" y="855" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2019" y="825" width="84" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0wlpcd6_di" bpmnElement="Event_0wlpcd6"> + <dc:Bounds x="2042" y="962" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2078" y="946" width="83" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0506p7p_di" bpmnElement="Activity_0506p7p"> + <dc:Bounds x="1490" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_11w4jgm_di" bpmnElement="Activity_11w4jgm"> + <dc:Bounds x="420" y="840" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0y0f7aq_di" bpmnElement="Event_1mf8gxd"> + <dc:Bounds x="2182" y="862" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="2156" y="905" width="89" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_066h3ef_di" bpmnElement="Event_0dewj8o"> + <dc:Bounds x="202" y="1092" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="189" y="1135" width="62" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0r4899a_di" bpmnElement="Activity_0qho4pw"> + <dc:Bounds x="360" y="1070" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0b0pl0x_di" bpmnElement="Activity_03zg1pp"> + <dc:Bounds x="530" y="1070" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0dreslj_di" bpmnElement="Activity_1ri9jrn"> + <dc:Bounds x="710" y="1070" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1m6hsxq_di" bpmnElement="Event_161u9s2"> + <dc:Bounds x="1822" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0qbd3cz_di" bpmnElement="Activity_0qbd3cz" isExpanded="true"> + <dc:Bounds x="820" y="1310" width="770" height="170" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0nsc2oc_di" bpmnElement="Flow_0nsc2oc"> + <di:waypoint x="1240" y="1414" /> + <di:waypoint x="1320" y="1414" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1q1450g_di" bpmnElement="Flow_1q1450g"> + <di:waypoint x="888" y="1414" /> + <di:waypoint x="990" y="1414" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0alqcat_di" bpmnElement="Flow_0alqcat"> + <di:waypoint x="1090" y="1414" /> + <di:waypoint x="1140" y="1414" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_035ivcv_di" bpmnElement="Flow_035ivcv"> + <di:waypoint x="1420" y="1414" /> + <di:waypoint x="1502" y="1414" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_13wl9ag_di" bpmnElement="Event_13wl9ag"> + <dc:Bounds x="852" y="1396" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0ugnt78_di" bpmnElement="Event_0ugnt78"> + <dc:Bounds x="1502" y="1396" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1mzoss1_di" bpmnElement="Activity_1mzoss1"> + <dc:Bounds x="1320" y="1374" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_055w5hr_di" bpmnElement="Activity_055w5hr"> + <dc:Bounds x="1140" y="1374" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1nr7xyr_di" bpmnElement="Activity_1nr7xyr"> + <dc:Bounds x="990" y="1374" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0c0vkj6_di" bpmnElement="Activity_0c0vkj6" isExpanded="true"> + <dc:Bounds x="930" y="1600" width="440" height="140" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0bkcs42_di" bpmnElement="Flow_0bkcs42"> + <di:waypoint x="1018" y="1661" /> + <di:waypoint x="1083" y="1661" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b5mtc4_di" bpmnElement="Flow_1b5mtc4"> + <di:waypoint x="1183" y="1661" /> + <di:waypoint x="1282" y="1661" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_1bqq1on_di" bpmnElement="Event_1bqq1on"> + <dc:Bounds x="982" y="1643" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0qb738v_di" bpmnElement="Event_0qb738v"> + <dc:Bounds x="1282" y="1643" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0187ysa_di" bpmnElement="Activity_0187ysa"> + <dc:Bounds x="1083" y="1621" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateCoreNSSI.bpmn new file mode 100644 index 0000000000..81ed921a5f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateCoreNSSI.bpmn @@ -0,0 +1,340 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1v4vnwb" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="Process_02hqnsq" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Deallocate Core NSSI Flow"> + <bpmn:outgoing>Flow_0xxq2h8</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0u06qij" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0xxq2h8</bpmn:incoming> + <bpmn:outgoing>Flow_0g84uy5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0xxq2h8" sourceRef="StartEvent_1" targetRef="Activity_0u06qij" /> + <bpmn:scriptTask id="Activity_0wswwhj" name="Get Network Service Instance" scriptFormat="groovy"> + <bpmn:incoming>Flow_189j30m</bpmn:incoming> + <bpmn:outgoing>Flow_16192dm</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.getNetworkServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1dqw1bg" name="Is terminateNSSI=true?" default="Flow_0e3yvck"> + <bpmn:incoming>Flow_16192dm</bpmn:incoming> + <bpmn:outgoing>Flow_15ew9rs</bpmn:outgoing> + <bpmn:outgoing>Flow_0e3yvck</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_16192dm" sourceRef="Activity_0wswwhj" targetRef="Gateway_1dqw1bg" /> + <bpmn:scriptTask id="Activity_1kne6ot" name="Invoke DeleteServiceOrder API" scriptFormat="groovy"> + <bpmn:incoming>Flow_15ew9rs</bpmn:incoming> + <bpmn:outgoing>Flow_1b14can</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.deleteServiceOrder(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1anr9ry" name="Get constitute VNF from Network Service Instance" scriptFormat="groovy"> + <bpmn:incoming>Flow_1v68jns</bpmn:incoming> + <bpmn:outgoing>Flow_1eev81t</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.getConstituteVNFFromNetworkServiceInst(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_16wfqhu" name="Get NSSI associated profiles" scriptFormat="groovy"> + <bpmn:incoming>Flow_1eev81t</bpmn:incoming> + <bpmn:outgoing>Flow_0xrq94a</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.getNSSIAssociatedProfiles(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0es9or8" name="Calculate remaining S-NSSAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_0xrq94a</bpmn:incoming> + <bpmn:outgoing>Flow_1qwi2ka</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.calculateSNSSAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0mnkgd6" name="Invoke PUT Service Instance API" scriptFormat="groovy"> + <bpmn:incoming>Flow_1qwi2ka</bpmn:incoming> + <bpmn:outgoing>Flow_178myd8</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.invokePUTServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_19z90sm" name="Remove the NSSI association with NSI" scriptFormat="groovy"> + <bpmn:incoming>Flow_16j7pjk</bpmn:incoming> + <bpmn:outgoing>Flow_0nvtepd</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.removeNSSIAssociationWithNSI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1mbtpe6" name="Remove association of slice profile instance with the NSSI " scriptFormat="groovy"> + <bpmn:incoming>Flow_0nvtepd</bpmn:incoming> + <bpmn:outgoing>Flow_0j8gu83</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.removeSPAssociationWithNSSI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0tanqh5" name="Delete the slice profile instance
" scriptFormat="groovy"> + <bpmn:incoming>Flow_0j8gu83</bpmn:incoming> + <bpmn:outgoing>Flow_009x8vn</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.deleteSliceProfileInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_07ygtxz" name="Is terminateNSSI=true?" default="Flow_12nxpx6"> + <bpmn:incoming>Flow_009x8vn</bpmn:incoming> + <bpmn:outgoing>Flow_1r39237</bpmn:outgoing> + <bpmn:outgoing>Flow_12nxpx6</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="Event_1vgebg2" name="End"> + <bpmn:incoming>Flow_15rk73d</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_1gcmlps" name=" Delete the NSSI service instance
" scriptFormat="groovy"> + <bpmn:incoming>Flow_1r39237</bpmn:incoming> + <bpmn:outgoing>Flow_04hswb4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.deleteNSSIServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1r39237" name="yes" sourceRef="Gateway_07ygtxz" targetRef="Activity_1gcmlps"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isTerminateNSSI" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="Activity_0gs71qq" name="Update Service Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_12nxpx6</bpmn:incoming> + <bpmn:incoming>Flow_04hswb4</bpmn:incoming> + <bpmn:outgoing>Flow_15rk73d</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.updateServiceOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:intermediateThrowEvent id="Event_016dxue" name="Goto no terminate NSSI Subflow"> + <bpmn:incoming>Flow_0e3yvck</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0l191e1" name="NoTerminateNSSISubflow" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="Event_1mk9pgp" name="No terminate NSSI Subflow"> + <bpmn:outgoing>Flow_1v68jns</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1ynsson" name="NoTerminateNSSISubflow" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="Flow_0nvtepd" sourceRef="Activity_19z90sm" targetRef="Activity_1mbtpe6" /> + <bpmn:sequenceFlow id="Flow_15ew9rs" name="yes" sourceRef="Gateway_1dqw1bg" targetRef="Activity_1kne6ot"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isTerminateNSSI" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1v68jns" sourceRef="Event_1mk9pgp" targetRef="Activity_1anr9ry" /> + <bpmn:sequenceFlow id="Flow_1eev81t" sourceRef="Activity_1anr9ry" targetRef="Activity_16wfqhu" /> + <bpmn:sequenceFlow id="Flow_0xrq94a" sourceRef="Activity_16wfqhu" targetRef="Activity_0es9or8" /> + <bpmn:sequenceFlow id="Flow_1qwi2ka" sourceRef="Activity_0es9or8" targetRef="Activity_0mnkgd6" /> + <bpmn:sequenceFlow id="Flow_0e3yvck" name="no" sourceRef="Gateway_1dqw1bg" targetRef="Event_016dxue" /> + <bpmn:intermediateThrowEvent id="Event_062ulql" name="Goto Common Subflow"> + <bpmn:incoming>Flow_178myd8</bpmn:incoming> + <bpmn:incoming>Flow_1b14can</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_017h179" name="CommonSubflow" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_178myd8" sourceRef="Activity_0mnkgd6" targetRef="Event_062ulql" /> + <bpmn:sequenceFlow id="Flow_1b14can" sourceRef="Activity_1kne6ot" targetRef="Event_062ulql" /> + <bpmn:intermediateCatchEvent id="Event_027jirg" name="Common Subflow"> + <bpmn:outgoing>Flow_16j7pjk</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1fn4t8h" name="CommonSubflow" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="Flow_16j7pjk" sourceRef="Event_027jirg" targetRef="Activity_19z90sm" /> + <bpmn:sequenceFlow id="Flow_0j8gu83" sourceRef="Activity_1mbtpe6" targetRef="Activity_0tanqh5" /> + <bpmn:sequenceFlow id="Flow_009x8vn" sourceRef="Activity_0tanqh5" targetRef="Gateway_07ygtxz" /> + <bpmn:sequenceFlow id="Flow_12nxpx6" name="no" sourceRef="Gateway_07ygtxz" targetRef="Activity_0gs71qq" /> + <bpmn:sequenceFlow id="Flow_04hswb4" sourceRef="Activity_1gcmlps" targetRef="Activity_0gs71qq" /> + <bpmn:sequenceFlow id="Flow_15rk73d" sourceRef="Activity_0gs71qq" targetRef="Event_1vgebg2" /> + <bpmn:scriptTask id="Activity_13qnpcn" name="Execute terminate NSSI query" scriptFormat="groovy"> + <bpmn:incoming>Flow_0g84uy5</bpmn:incoming> + <bpmn:outgoing>Flow_189j30m</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi= new DoDeallocateCoreNSSI() + dcnssi.executeTerminateNSSIQuery(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0g84uy5" sourceRef="Activity_0u06qij" targetRef="Activity_13qnpcn" /> + <bpmn:sequenceFlow id="Flow_189j30m" sourceRef="Activity_13qnpcn" targetRef="Activity_0wswwhj" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_02hqnsq"> + <bpmndi:BPMNEdge id="Flow_15rk73d_di" bpmnElement="Flow_15rk73d"> + <di:waypoint x="1220" y="600" /> + <di:waypoint x="1282" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_04hswb4_di" bpmnElement="Flow_04hswb4"> + <di:waypoint x="980" y="600" /> + <di:waypoint x="1120" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_12nxpx6_di" bpmnElement="Flow_12nxpx6"> + <di:waypoint x="790" y="625" /> + <di:waypoint x="790" y="680" /> + <di:waypoint x="1170" y="680" /> + <di:waypoint x="1170" y="640" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="814" y="663" width="13" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_009x8vn_di" bpmnElement="Flow_009x8vn"> + <di:waypoint x="680" y="600" /> + <di:waypoint x="765" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0j8gu83_di" bpmnElement="Flow_0j8gu83"> + <di:waypoint x="510" y="600" /> + <di:waypoint x="580" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16j7pjk_di" bpmnElement="Flow_16j7pjk"> + <di:waypoint x="208" y="600" /> + <di:waypoint x="260" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b14can_di" bpmnElement="Flow_1b14can"> + <di:waypoint x="800" y="240" /> + <di:waypoint x="975" y="240" /> + <di:waypoint x="975" y="382" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_178myd8_di" bpmnElement="Flow_178myd8"> + <di:waypoint x="840" y="400" /> + <di:waypoint x="957" y="400" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0e3yvck_di" bpmnElement="Flow_0e3yvck"> + <di:waypoint x="775" y="117" /> + <di:waypoint x="832" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="787" y="95" width="13" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1qwi2ka_di" bpmnElement="Flow_1qwi2ka"> + <di:waypoint x="680" y="400" /> + <di:waypoint x="740" y="400" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0xrq94a_di" bpmnElement="Flow_0xrq94a"> + <di:waypoint x="510" y="400" /> + <di:waypoint x="580" y="400" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1eev81t_di" bpmnElement="Flow_1eev81t"> + <di:waypoint x="360" y="400" /> + <di:waypoint x="410" y="400" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1v68jns_di" bpmnElement="Flow_1v68jns"> + <di:waypoint x="208" y="400" /> + <di:waypoint x="260" y="400" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_15ew9rs_di" bpmnElement="Flow_15ew9rs"> + <di:waypoint x="750" y="142" /> + <di:waypoint x="750" y="200" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="731" y="150" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0nvtepd_di" bpmnElement="Flow_0nvtepd"> + <di:waypoint x="360" y="600" /> + <di:waypoint x="410" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1r39237_di" bpmnElement="Flow_1r39237"> + <di:waypoint x="815" y="600" /> + <di:waypoint x="880" y="600" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="823" y="582" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16192dm_di" bpmnElement="Flow_16192dm"> + <di:waypoint x="680" y="117" /> + <di:waypoint x="725" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0xxq2h8_di" bpmnElement="Flow_0xxq2h8"> + <di:waypoint x="215" y="117" /> + <di:waypoint x="260" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0g84uy5_di" bpmnElement="Flow_0g84uy5"> + <di:waypoint x="360" y="117" /> + <di:waypoint x="410" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_189j30m_di" bpmnElement="Flow_189j30m"> + <di:waypoint x="510" y="117" /> + <di:waypoint x="580" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="179" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="160" y="142" width="79" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0u06qij_di" bpmnElement="Activity_0u06qij"> + <dc:Bounds x="260" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1kne6ot_di" bpmnElement="Activity_1kne6ot"> + <dc:Bounds x="700" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1anr9ry_di" bpmnElement="Activity_1anr9ry"> + <dc:Bounds x="260" y="360" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16wfqhu_di" bpmnElement="Activity_16wfqhu"> + <dc:Bounds x="410" y="360" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0es9or8_di" bpmnElement="Activity_0es9or8"> + <dc:Bounds x="580" y="360" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0mnkgd6_di" bpmnElement="Activity_0mnkgd6"> + <dc:Bounds x="740" y="360" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_19z90sm_di" bpmnElement="Activity_19z90sm"> + <dc:Bounds x="260" y="560" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1mbtpe6_di" bpmnElement="Activity_1mbtpe6"> + <dc:Bounds x="410" y="560" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0tanqh5_di" bpmnElement="Activity_0tanqh5"> + <dc:Bounds x="580" y="560" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_07ygtxz_di" bpmnElement="Gateway_07ygtxz" isMarkerVisible="true"> + <dc:Bounds x="765" y="575" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="737" y="529" width="86" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1vgebg2_di" bpmnElement="Event_1vgebg2"> + <dc:Bounds x="1282" y="582" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1290" y="558" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1gcmlps_di" bpmnElement="Activity_1gcmlps"> + <dc:Bounds x="880" y="560" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0gs71qq_di" bpmnElement="Activity_0gs71qq"> + <dc:Bounds x="1120" y="560" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1mk9pgp_di" bpmnElement="Event_1mk9pgp"> + <dc:Bounds x="172" y="382" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="162" y="425" width="69" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_062ulql_di" bpmnElement="Event_062ulql"> + <dc:Bounds x="957" y="382" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="947" y="423" width="72" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_027jirg_di" bpmnElement="Event_027jirg"> + <dc:Bounds x="172" y="582" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="153" y="625" width="88" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_13qnpcn_di" bpmnElement="Activity_13qnpcn"> + <dc:Bounds x="410" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0wswwhj_di" bpmnElement="Activity_0wswwhj"> + <dc:Bounds x="580" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1dqw1bg_di" bpmnElement="Gateway_1dqw1bg" isMarkerVisible="true"> + <dc:Bounds x="725" y="92" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="708" y="53" width="85" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_016dxue_di" bpmnElement="Event_016dxue"> + <dc:Bounds x="832" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="820" y="140" width="74" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn index db805ecb92..c107cfb53a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn @@ -1,5 +1,5 @@ <?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0884541" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> +<bpmn:definitions xmlns:bpmn="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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0884541" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.2"> <bpmn:process id="DoDeallocateNSSIV1" name="DoDeallocateNSSIV1" isExecutable="true"> <bpmn:startEvent id="StartEvent_1" name="start"> <bpmn:outgoing>SequenceFlow_05jfhy6</bpmn:outgoing> @@ -35,25 +35,15 @@ dnssi.processDecomposition(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_1e7o57n" sourceRef="Task_15ut397" targetRef="Task_0vi4ijv" /> <bpmn:scriptTask id="Task_0vi4ijv" name="Send deallocate request to NSSMF" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_1e7o57n</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_03b0822</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1wj89r5</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dnssi= new DoDeallocateNSSI() dnssi.sendRequestToNSSMF(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_03b0822" sourceRef="Task_0vi4ijv" targetRef="Task_0kl6lcq" /> - <bpmn:scriptTask id="Task_0kl6lcq" name="Query Job Status" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_03b0822</bpmn:incoming> - <bpmn:incoming>SequenceFlow_1anlirk</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1jj0p5q</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dnssi= new DoDeallocateNSSI() -dnssi.getJobStatus(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_1jj0p5q" sourceRef="Task_0kl6lcq" targetRef="ExclusiveGateway_0nhfsui" /> - <bpmn:exclusiveGateway id="ExclusiveGateway_0nhfsui" name="Is deallocate finish?" default="SequenceFlow_0sfh52b"> - <bpmn:incoming>SequenceFlow_1jj0p5q</bpmn:incoming> + <bpmn:exclusiveGateway id="ExclusiveGateway_0nhfsui" name="Is deallocate finish?"> + <bpmn:incoming>SequenceFlow_02327ff</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0xq380j</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_0sfh52b</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1wpbkt9</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:scriptTask id="Task_13vaezk" name="Delete Slice Profile From AAI" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0xq380j</bpmn:incoming> @@ -77,15 +67,6 @@ dnssi.delSliceProfileFromAAI(execution)</bpmn:script> def dnssi= new DoDeallocateNSSI() dnssi.preProcessRequest(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_1anlirk" sourceRef="Task_0fxuz4i" targetRef="Task_0kl6lcq" /> - <bpmn:scriptTask id="Task_0fxuz4i" name="TimeDelay" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1ugva41</bpmn:incoming> - <bpmn:incoming>SequenceFlow_1u66wjs</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1anlirk</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dnssi= new DoDeallocateNSSI() -dnssi.timeDelay(execution)</bpmn:script> - </bpmn:scriptTask> <bpmn:serviceTask id="Task_0amt4hu" name="Update Service Operation Status"> <bpmn:extensionElements> <camunda:connector> @@ -105,149 +86,171 @@ dnssi.timeDelay(execution)</bpmn:script> <camunda:connectorId>http-connector</camunda:connectorId> </camunda:connector> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_04vg0c2</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1ugva41</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_19cdxhv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_02327ff</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:exclusiveGateway id="ExclusiveGateway_0y0w592" name="IsNeedUpdateDB?" default="SequenceFlow_1u66wjs"> - <bpmn:incoming>SequenceFlow_0sfh52b</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0r95j9m</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_1u66wjs</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_0sfh52b" sourceRef="ExclusiveGateway_0nhfsui" targetRef="ExclusiveGateway_0y0w592" /> - <bpmn:sequenceFlow id="SequenceFlow_0r95j9m" sourceRef="ExclusiveGateway_0y0w592" targetRef="Task_1renmzf"> - <bpmn:documentation>#{(execution.getVariable("isNeedUpdateDB" ) == true)}</bpmn:documentation> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNeedUpdateDB" ) == true)}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_04vg0c2" sourceRef="Task_1renmzf" targetRef="Task_0amt4hu" /> - <bpmn:sequenceFlow id="SequenceFlow_1ugva41" sourceRef="Task_0amt4hu" targetRef="Task_0fxuz4i" /> - <bpmn:sequenceFlow id="SequenceFlow_1u66wjs" sourceRef="ExclusiveGateway_0y0w592" targetRef="Task_0fxuz4i" /> <bpmn:scriptTask id="Task_1renmzf" name="Prepare Update Operation Status" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0r95j9m</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_04vg0c2</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_0o7qjoo</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_19cdxhv</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dnssi= new DoDeallocateNSSI() +dnssi.prepareUpdateOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Task_1x3et9h" name="Query Job Status" calledElement="QueryJobStatus"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="serviceDecompositionString" target="serviceDecompositionString" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0w01l14</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_10nogqz</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_10nogqz" sourceRef="Task_1x3et9h" targetRef="Task_1v3sdzq" /> + <bpmn:sequenceFlow id="SequenceFlow_1wj89r5" sourceRef="Task_0vi4ijv" targetRef="Task_1vt5xaa" /> + <bpmn:scriptTask id="Task_1v3sdzq" name="Handle Job Status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_10nogqz</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0o7qjoo</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dnssi= new DoDeallocateNSSI() dnssi.handleJobStatus(execution)</bpmn:script> </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0o7qjoo" sourceRef="Task_1v3sdzq" targetRef="Task_1renmzf" /> + <bpmn:scriptTask id="Task_1vt5xaa" name="prepare QueryJobStatus Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1wj89r5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0w01l14</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dnssi= new DoDeallocateNSSI() +dnssi.prepareJobStatusRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0w01l14" sourceRef="Task_1vt5xaa" targetRef="Task_1x3et9h" /> + <bpmn:sequenceFlow id="SequenceFlow_19cdxhv" sourceRef="Task_1renmzf" targetRef="Task_0amt4hu" /> + <bpmn:sequenceFlow id="SequenceFlow_02327ff" sourceRef="Task_0amt4hu" targetRef="ExclusiveGateway_0nhfsui" /> + <bpmn:endEvent id="Event_11u9vp2"> + <bpmn:incoming>SequenceFlow_1wpbkt9</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_11pdh1q" errorRef="Error_1o5kb95" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1wpbkt9" name="no" sourceRef="ExclusiveGateway_0nhfsui" targetRef="Event_11u9vp2" /> </bpmn:process> + <bpmn:error id="Error_1o5kb95" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeallocateNSSIV1"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> - <dc:Bounds x="192" y="112" width="36" height="36" /> + <bpmndi:BPMNEdge id="Flow_1wpbkt9_di" bpmnElement="SequenceFlow_1wpbkt9"> + <di:waypoint x="1860" y="155" /> + <di:waypoint x="1860" y="212" /> <bpmndi:BPMNLabel> - <dc:Bounds x="199" y="155" width="22" height="14" /> + <dc:Bounds x="1869" y="165" width="13" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_02327ff_di" bpmnElement="SequenceFlow_02327ff"> + <di:waypoint x="1770" y="130" /> + <di:waypoint x="1835" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_19cdxhv_di" bpmnElement="SequenceFlow_19cdxhv"> + <di:waypoint x="1610" y="130" /> + <di:waypoint x="1670" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0w01l14_di" bpmnElement="SequenceFlow_0w01l14"> + <di:waypoint x="1120" y="130" /> + <di:waypoint x="1190" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0o7qjoo_di" bpmnElement="SequenceFlow_0o7qjoo"> + <di:waypoint x="1450" y="130" /> + <di:waypoint x="1510" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1wj89r5_di" bpmnElement="SequenceFlow_1wj89r5"> + <di:waypoint x="970" y="130" /> + <di:waypoint x="1020" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_10nogqz_di" bpmnElement="SequenceFlow_10nogqz"> + <di:waypoint x="1290" y="130" /> + <di:waypoint x="1350" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0eug5nv_di" bpmnElement="SequenceFlow_0eug5nv"> + <di:waypoint x="340" y="130" /> + <di:waypoint x="390" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0xq380j_di" bpmnElement="SequenceFlow_0xq380j"> + <di:waypoint x="1885" y="130" /> + <di:waypoint x="1940" y="130" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1904" y="112" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ii5002_di" bpmnElement="SequenceFlow_1ii5002"> + <di:waypoint x="2040" y="130" /> + <di:waypoint x="2102" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1e7o57n_di" bpmnElement="SequenceFlow_1e7o57n"> + <di:waypoint x="800" y="130" /> + <di:waypoint x="870" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1e451y9_di" bpmnElement="SequenceFlow_1e451y9"> + <di:waypoint x="650" y="130" /> + <di:waypoint x="700" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0wlyy5i_di" bpmnElement="SequenceFlow_0wlyy5i"> + <di:waypoint x="490" y="130" /> + <di:waypoint x="550" y="130" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_05jfhy6_di" bpmnElement="SequenceFlow_05jfhy6"> - <di:waypoint x="228" y="130" /> - <di:waypoint x="310" y="130" /> + <di:waypoint x="188" y="130" /> + <di:waypoint x="240" y="130" /> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="152" y="112" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="159" y="155" width="23" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_159g5ey_di" bpmnElement="Task_1m8upus"> - <dc:Bounds x="490" y="90" width="100" height="80" /> + <dc:Bounds x="390" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0wlyy5i_di" bpmnElement="SequenceFlow_0wlyy5i"> - <di:waypoint x="590" y="130" /> - <di:waypoint x="660" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1ep4ama_di" bpmnElement="Task_1giechg"> - <dc:Bounds x="660" y="90" width="100" height="80" /> + <dc:Bounds x="550" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1e451y9_di" bpmnElement="SequenceFlow_1e451y9"> - <di:waypoint x="760" y="130" /> - <di:waypoint x="820" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1yt5s46_di" bpmnElement="Task_15ut397"> - <dc:Bounds x="820" y="90" width="100" height="80" /> + <dc:Bounds x="700" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1e7o57n_di" bpmnElement="SequenceFlow_1e7o57n"> - <di:waypoint x="920" y="130" /> - <di:waypoint x="970" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_16dxpvz_di" bpmnElement="Task_0vi4ijv"> - <dc:Bounds x="970" y="90" width="100" height="80" /> + <dc:Bounds x="870" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_03b0822_di" bpmnElement="SequenceFlow_03b0822"> - <di:waypoint x="1070" y="130" /> - <di:waypoint x="1120" y="130" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0arl3j9_di" bpmnElement="Task_0kl6lcq"> - <dc:Bounds x="1120" y="90" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1jj0p5q_di" bpmnElement="SequenceFlow_1jj0p5q"> - <di:waypoint x="1220" y="130" /> - <di:waypoint x="1505" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0nhfsui_di" bpmnElement="ExclusiveGateway_0nhfsui" isMarkerVisible="true"> - <dc:Bounds x="1505" y="105" width="50" height="50" /> + <dc:Bounds x="1835" y="105" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1501" y="75" width="63" height="27" /> + <dc:Bounds x="1831" y="75" width="63" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1rfdrw3_di" bpmnElement="Task_13vaezk"> - <dc:Bounds x="1690" y="90" width="100" height="80" /> + <dc:Bounds x="1940" y="90" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1f579t4_di" bpmnElement="EndEvent_1f579t4"> - <dc:Bounds x="1862" y="112" width="36" height="36" /> + <dc:Bounds x="2102" y="112" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1871" y="155" width="19" height="14" /> + <dc:Bounds x="2111" y="155" width="19" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1ii5002_di" bpmnElement="SequenceFlow_1ii5002"> - <di:waypoint x="1790" y="130" /> - <di:waypoint x="1862" y="130" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0xq380j_di" bpmnElement="SequenceFlow_0xq380j"> - <di:waypoint x="1555" y="130" /> - <di:waypoint x="1690" y="130" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1614" y="112" width="17" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0eug5nv_di" bpmnElement="SequenceFlow_0eug5nv"> - <di:waypoint x="410" y="130" /> - <di:waypoint x="490" y="130" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1dytya8_di" bpmnElement="Task_1vste9s"> - <dc:Bounds x="310" y="90" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1anlirk_di" bpmnElement="SequenceFlow_1anlirk"> - <di:waypoint x="1170" y="190" /> - <di:waypoint x="1170" y="170" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0a4zalz_di" bpmnElement="Task_0fxuz4i"> - <dc:Bounds x="1120" y="190" width="100" height="80" /> + <dc:Bounds x="240" y="90" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0vegqix_di" bpmnElement="Task_0amt4hu"> - <dc:Bounds x="1280" y="300" width="100" height="80" /> + <dc:Bounds x="1670" y="90" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_0y0w592_di" bpmnElement="ExclusiveGateway_0y0w592" isMarkerVisible="true"> - <dc:Bounds x="1505" y="205" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1567" y="216" width="86" height="27" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0sfh52b_di" bpmnElement="SequenceFlow_0sfh52b"> - <di:waypoint x="1530" y="155" /> - <di:waypoint x="1530" y="205" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0r95j9m_di" bpmnElement="SequenceFlow_0r95j9m"> - <di:waypoint x="1530" y="255" /> - <di:waypoint x="1530" y="300" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_04vg0c2_di" bpmnElement="SequenceFlow_04vg0c2"> - <di:waypoint x="1480" y="340" /> - <di:waypoint x="1380" y="340" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1ugva41_di" bpmnElement="SequenceFlow_1ugva41"> - <di:waypoint x="1280" y="340" /> - <di:waypoint x="1170" y="340" /> - <di:waypoint x="1170" y="270" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1u66wjs_di" bpmnElement="SequenceFlow_1u66wjs"> - <di:waypoint x="1505" y="230" /> - <di:waypoint x="1220" y="230" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_10pw6ot_di" bpmnElement="Task_1renmzf"> - <dc:Bounds x="1480" y="300" width="100" height="80" /> + <dc:Bounds x="1510" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1x3et9h_di" bpmnElement="Task_1x3et9h"> + <dc:Bounds x="1190" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1v3sdzq_di" bpmnElement="Task_1v3sdzq"> + <dc:Bounds x="1350" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1vt5xaa_di" bpmnElement="Task_1vt5xaa"> + <dc:Bounds x="1020" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_11u9vp2_di" bpmnElement="Event_11u9vp2"> + <dc:Bounds x="1842" y="212" width="36" height="36" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn new file mode 100644 index 0000000000..a800289aaa --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateTransportNSSI.bpmn @@ -0,0 +1,221 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoDeallocateTransportNSSI" name="DoDeallocateTransportNSSI" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Deallocate TN NSSMF Work Flow"> + <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:subProcess id="SubProcess_1yv9i68" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_1omdx56"> + <bpmn:outgoing>SequenceFlow_1w67v6s</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_06xcioh" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1jx3026"> + <bpmn:incoming>SequenceFlow_08mlzwz</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1swzdpw" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1w67v6s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08mlzwz</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1w67v6s" sourceRef="StartEvent_1omdx56" targetRef="ScriptTask_1swzdpw" /> + <bpmn:sequenceFlow id="SequenceFlow_08mlzwz" sourceRef="ScriptTask_1swzdpw" targetRef="EndEvent_1jx3026" /> + </bpmn:subProcess> + <bpmn:endEvent id="EndEvent_05h01gx" name="End"> + <bpmn:incoming>Flow_0ca4l8d</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new TnAllocateNssi() +runScript.prepareUpdateJobStatus(execution,"finished","100","Deallocated TN NSSI successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_03s744c" sourceRef="StartEvent_1nbljfd" targetRef="ScriptTask_1tc44ge" /> + <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_0rgeefb" /> + <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1jygjln</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +execution.setVariable("orchestrationStatus", "deallocated") +def runScript = new DoDeallocateTnNssi() +runScript.updateAAIOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ssh2l9" /> + <bpmn:scriptTask id="Activity_1tw8eyy" name="PreProcess SDNC Deallocate TN NSSI Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> + <bpmn:outgoing>Flow_0cpctye</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoDeallocateTnNssi() +runScript.preprocessSdncDeallocateTnNssiRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0cpctye" sourceRef="Activity_1tw8eyy" targetRef="Activity_0p20esb" /> + <bpmn:callActivity id="Activity_0p20esb" name="Call SDNC Adapter: Deallocate TN NSSI" calledElement="sdncAdapter"> + <bpmn:extensionElements> + <camunda:in source="TNNSSMF_SDNCRequest" target="sdncAdapterWorkflowRequest" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> + <camunda:in source="mso-service-instance-id" target="mso-service-instance-id" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="sdncAdapterResponse" target="TNNSSMF_SDNCAdapterResponse" /> + <camunda:out source="SDNCA_SuccessIndicator" target="SDNCA_SuccessIndicator" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0cpctye</bpmn:incoming> + <bpmn:outgoing>Flow_0fuabjs</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0fuabjs" sourceRef="Activity_0p20esb" targetRef="Activity_0phv8e5" /> + <bpmn:scriptTask id="Activity_0phv8e5" name="Postprocess SDNC Deallocate TN NSSI Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0fuabjs</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1jdb2oq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String response = execution.getVariable("TNNSSMF_SDNCAdapterResponse") + +def runScript = new DoDeallocateTnNssi() +runScript.validateSDNCResponse(execution, response, "deallocate")</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_013rjwc" name="Delete Service Instance (TN NSSI) in AAI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1jygjln</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoDeallocateTnNssi() +runScript.deleteServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1jdb2oq" sourceRef="Activity_0phv8e5" targetRef="Activity_013rjwc" /> + <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03s744c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07e12rt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoDeallocateTnNssi() +runScript.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Activity_1tw8eyy" /> + <bpmn:sequenceFlow id="SequenceFlow_1jygjln" sourceRef="Activity_013rjwc" targetRef="ScriptTask_19uxoi8" /> + <bpmn:serviceTask id="Activity_0rgeefb" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1qv8qw1</bpmn:incoming> + <bpmn:outgoing>Flow_0ca4l8d</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0ca4l8d" sourceRef="Activity_0rgeefb" targetRef="EndEvent_05h01gx" /> + </bpmn:process> + <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> + <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeallocateTransportNSSI"> + <bpmndi:BPMNEdge id="Flow_1jygjln_di" bpmnElement="SequenceFlow_1jygjln"> + <di:waypoint x="360" y="350" /> + <di:waypoint x="520" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> + <di:waypoint x="385" y="121" /> + <di:waypoint x="509" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq"> + <di:waypoint x="1080" y="121" /> + <di:waypoint x="1220" y="121" /> + <di:waypoint x="1220" y="210" /> + <di:waypoint x="310" y="210" /> + <di:waypoint x="310" y="310" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fuabjs_di" bpmnElement="Flow_0fuabjs"> + <di:waypoint x="850" y="121" /> + <di:waypoint x="959" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cpctye_di" bpmnElement="Flow_0cpctye"> + <di:waypoint x="630" y="121" /> + <di:waypoint x="729" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> + <di:waypoint x="620" y="350" /> + <di:waypoint x="740" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> + <di:waypoint x="840" y="350" /> + <di:waypoint x="990" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> + <di:waypoint x="214" y="121" /> + <di:waypoint x="285" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ca4l8d_di" bpmnElement="Flow_0ca4l8d"> + <di:waypoint x="1090" y="350" /> + <di:waypoint x="1202" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> + <dc:Bounds x="178" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="166" y="146" width="70" height="53" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0rgeefb_di" bpmnElement="Activity_0rgeefb"> + <dc:Bounds x="990" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> + <dc:Bounds x="685" y="1080" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1079" y="1184" /> + <di:waypoint x="1353" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="751" y="1184" /> + <di:waypoint x="979" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="715" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1353" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="979" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> + <dc:Bounds x="1202" y="332" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1210" y="375" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> + <dc:Bounds x="740" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> + <dc:Bounds x="520" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1tw8eyy_di" bpmnElement="Activity_1tw8eyy"> + <dc:Bounds x="509" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0p20esb_di" bpmnElement="Activity_0p20esb"> + <dc:Bounds x="729" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5"> + <dc:Bounds x="959" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_013rjwc_di" bpmnElement="Activity_013rjwc"> + <dc:Bounds x="260" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="285" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn index 5f4816e78f..5510dcde38 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn @@ -1,5 +1,5 @@ <?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1p1suc9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> +<bpmn:definitions xmlns:bpmn="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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1p1suc9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.2"> <bpmn:process id="DoDeleteSliceServiceV1" name="DoDeleteSliceServiceV1" isExecutable="true"> <bpmn:startEvent id="StartEvent_1" name="start"> <bpmn:outgoing>SequenceFlow_0ep5het</bpmn:outgoing> @@ -23,12 +23,11 @@ ddss.getNSIFromAAI(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:scriptTask id="Task_1u755sr" name="Query NSSI List From AAI" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_1rgfzzy</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_05si1me</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1aa2ek0</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddss= new DoDeleteSliceService() ddss.getNSSIListFromAAI(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_05si1me" sourceRef="Task_1u755sr" targetRef="Task_1iomfas" /> <bpmn:exclusiveGateway id="ExclusiveGateway_1ogbunu" name="Is all NSSI finished?"> <bpmn:incoming>SequenceFlow_15z9iio</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1c4fjbv</bpmn:outgoing> @@ -40,7 +39,6 @@ ddss.getNSSIListFromAAI(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_1c4fjbv" name="yes" sourceRef="ExclusiveGateway_1ogbunu" targetRef="EndEvent_0jaitqv"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isAllNSSIFinished" ) == true)}</bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_01o2qpv" sourceRef="Task_1iomfas" targetRef="Task_1qqljvu" /> <bpmn:sequenceFlow id="SequenceFlow_0c58sw3" sourceRef="Task_1rc7mcw" targetRef="ScriptTask_159855t" /> <bpmn:sequenceFlow id="SequenceFlow_0926ghe" name="no" sourceRef="ExclusiveGateway_1ogbunu" targetRef="Task_1iomfas"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isAllNSSIFinished" ) == false)}</bpmn:conditionExpression> @@ -55,8 +53,8 @@ ddss.preProcessRequest(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_0npmman" sourceRef="Task_0etki1p" targetRef="Task_13k9usx" /> <bpmn:scriptTask id="Task_1iomfas" name="Get Current NSSI" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0926ghe</bpmn:incoming> - <bpmn:incoming>SequenceFlow_05si1me</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_01o2qpv</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_1252rbf</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17tvomo</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddss= new DoDeleteSliceService() ddss.getCurrentNSSI(execution)</bpmn:script> @@ -69,14 +67,6 @@ def ddss= new DoDeleteSliceService() ddss.parseNextNSSI(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_15z9iio" sourceRef="ScriptTask_159855t" targetRef="ExclusiveGateway_1ogbunu" /> - <bpmn:sequenceFlow id="SequenceFlow_0q83qg3" sourceRef="Task_1qqljvu" targetRef="Task_1rc7mcw" /> - <bpmn:scriptTask id="Task_1qqljvu" name="Query Slice Profile From AAI" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_01o2qpv</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0q83qg3</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def ddss= new DoDeleteSliceService() -ddss.querySliceProfileFromAAI(execution)</bpmn:script> - </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_029u1wr" sourceRef="Task_13k9usx" targetRef="Task_1ujnqtj" /> <bpmn:scriptTask id="Task_13k9usx" name="Query E2ESlice Serive From AAI" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0npmman</bpmn:incoming> @@ -93,30 +83,84 @@ ddss.queryE2ESliceSeriveFromAAI(execution)</bpmn:script> <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> <camunda:out source="WorkflowException" target="WorkflowException" /> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_0q83qg3</bpmn:incoming> + <bpmn:incoming>SequenceFlow_17tvomo</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0c58sw3</bpmn:outgoing> </bpmn:callActivity> + <bpmn:scriptTask id="Task_1iuls9p" name="Terminate NSI Query" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1aa2ek0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1252rbf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dss= new DeleteSliceService() +dss.terminateNSIQuery(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_17tvomo" sourceRef="Task_1iomfas" targetRef="Task_1rc7mcw" /> + <bpmn:sequenceFlow id="SequenceFlow_1aa2ek0" sourceRef="Task_1u755sr" targetRef="Task_1iuls9p" /> + <bpmn:sequenceFlow id="SequenceFlow_1252rbf" sourceRef="Task_1iuls9p" targetRef="Task_1iomfas" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeleteSliceServiceV1"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> - <dc:Bounds x="152" y="122" width="36" height="36" /> + <bpmndi:BPMNEdge id="Flow_1252rbf_di" bpmnElement="SequenceFlow_1252rbf"> + <di:waypoint x="1150" y="140" /> + <di:waypoint x="1200" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1aa2ek0_di" bpmnElement="SequenceFlow_1aa2ek0"> + <di:waypoint x="1000" y="140" /> + <di:waypoint x="1050" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_17tvomo_di" bpmnElement="SequenceFlow_17tvomo"> + <di:waypoint x="1300" y="140" /> + <di:waypoint x="1370" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_029u1wr_di" bpmnElement="SequenceFlow_029u1wr"> + <di:waypoint x="530" y="140" /> + <di:waypoint x="600" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_15z9iio_di" bpmnElement="SequenceFlow_15z9iio"> + <di:waypoint x="1640" y="140" /> + <di:waypoint x="1715" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0npmman_di" bpmnElement="SequenceFlow_0npmman"> + <di:waypoint x="370" y="140" /> + <di:waypoint x="430" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0926ghe_di" bpmnElement="SequenceFlow_0926ghe"> + <di:waypoint x="1740" y="165" /> + <di:waypoint x="1740" y="260" /> + <di:waypoint x="1250" y="260" /> + <di:waypoint x="1250" y="180" /> <bpmndi:BPMNLabel> - <dc:Bounds x="159" y="165" width="22" height="14" /> + <dc:Bounds x="1489" y="242" width="13" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0ep5het_di" bpmnElement="SequenceFlow_0ep5het"> - <di:waypoint x="188" y="140" /> - <di:waypoint x="270" y="140" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1qkgvvu_di" bpmnElement="SequenceFlow_1qkgvvu"> - <di:waypoint x="700" y="140" /> - <di:waypoint x="750" y="140" /> + <bpmndi:BPMNEdge id="SequenceFlow_0c58sw3_di" bpmnElement="SequenceFlow_0c58sw3"> + <di:waypoint x="1470" y="140" /> + <di:waypoint x="1540" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1c4fjbv_di" bpmnElement="SequenceFlow_1c4fjbv"> + <di:waypoint x="1765" y="140" /> + <di:waypoint x="1802" y="140" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1771" y="118" width="17" height="14" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1rgfzzy_di" bpmnElement="SequenceFlow_1rgfzzy"> <di:waypoint x="850" y="140" /> <di:waypoint x="900" y="140" /> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qkgvvu_di" bpmnElement="SequenceFlow_1qkgvvu"> + <di:waypoint x="700" y="140" /> + <di:waypoint x="750" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0ep5het_di" bpmnElement="SequenceFlow_0ep5het"> + <di:waypoint x="188" y="140" /> + <di:waypoint x="270" y="140" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="152" y="122" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="159" y="165" width="22" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1bj6tw4_di" bpmnElement="Task_1ujnqtj"> <dc:Bounds x="600" y="100" width="100" height="80" /> </bpmndi:BPMNShape> @@ -126,79 +170,35 @@ ddss.queryE2ESliceSeriveFromAAI(execution)</bpmn:script> <bpmndi:BPMNShape id="ScriptTask_01fp1vt_di" bpmnElement="Task_1u755sr"> <dc:Bounds x="900" y="100" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_05si1me_di" bpmnElement="SequenceFlow_05si1me"> - <di:waypoint x="1000" y="140" /> - <di:waypoint x="1040" y="140" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_1ogbunu_di" bpmnElement="ExclusiveGateway_1ogbunu" isMarkerVisible="true"> - <dc:Bounds x="1555" y="115" width="50" height="50" /> + <dc:Bounds x="1715" y="115" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1560" y="85" width="52" height="27" /> + <dc:Bounds x="1720" y="85" width="52" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0jaitqv_di" bpmnElement="EndEvent_0jaitqv"> - <dc:Bounds x="1692" y="122" width="36" height="36" /> + <dc:Bounds x="1802" y="122" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1700" y="168" width="20" height="14" /> + <dc:Bounds x="1810" y="168" width="20" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1c4fjbv_di" bpmnElement="SequenceFlow_1c4fjbv"> - <di:waypoint x="1605" y="140" /> - <di:waypoint x="1692" y="140" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1630" y="118" width="17" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_01o2qpv_di" bpmnElement="SequenceFlow_01o2qpv"> - <di:waypoint x="1140" y="140" /> - <di:waypoint x="1170" y="140" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0c58sw3_di" bpmnElement="SequenceFlow_0c58sw3"> - <di:waypoint x="1400" y="140" /> - <di:waypoint x="1420" y="140" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0926ghe_di" bpmnElement="SequenceFlow_0926ghe"> - <di:waypoint x="1580" y="165" /> - <di:waypoint x="1580" y="260" /> - <di:waypoint x="1090" y="260" /> - <di:waypoint x="1090" y="180" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1329" y="242" width="13" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0icszw6_di" bpmnElement="Task_0etki1p"> <dc:Bounds x="270" y="100" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0npmman_di" bpmnElement="SequenceFlow_0npmman"> - <di:waypoint x="370" y="140" /> - <di:waypoint x="430" y="140" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1obnwrr_di" bpmnElement="Task_1iomfas"> - <dc:Bounds x="1040" y="100" width="100" height="80" /> + <dc:Bounds x="1200" y="100" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_159855t_di" bpmnElement="ScriptTask_159855t"> - <dc:Bounds x="1420" y="100" width="100" height="80" /> + <dc:Bounds x="1540" y="100" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_15z9iio_di" bpmnElement="SequenceFlow_15z9iio"> - <di:waypoint x="1520" y="140" /> - <di:waypoint x="1555" y="140" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0q83qg3_di" bpmnElement="SequenceFlow_0q83qg3"> - <di:waypoint x="1270" y="140" /> - <di:waypoint x="1300" y="140" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0y9ppnc_di" bpmnElement="Task_1qqljvu"> - <dc:Bounds x="1170" y="100" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_029u1wr_di" bpmnElement="SequenceFlow_029u1wr"> - <di:waypoint x="530" y="140" /> - <di:waypoint x="600" y="140" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0f9rjq4_di" bpmnElement="Task_13k9usx"> <dc:Bounds x="430" y="100" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_18qkiat_di" bpmnElement="Task_1rc7mcw"> - <dc:Bounds x="1300" y="100" width="100" height="80" /> + <dc:Bounds x="1370" y="100" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1iuls9p_di" bpmnElement="Task_1iuls9p"> + <dc:Bounds x="1050" y="100" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleOofRequest.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleOofRequest.bpmn new file mode 100644 index 0000000000..d6b251649f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleOofRequest.bpmn @@ -0,0 +1,120 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0nlt5gi" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> + <bpmn:process id="DoHandleOofRequest" name="DoHandleOofRequest" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_1jorico</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="Flow_1fbzzqg" sourceRef="Activity_0tki17o" targetRef="Activity_08ozlfa" /> + <bpmn:scriptTask id="Activity_08ozlfa" name="Call Oof Adapter" scriptFormat="groovy"> + <bpmn:incoming>Flow_1fbzzqg</bpmn:incoming> + <bpmn:outgoing>Flow_013jfci</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +def oofHandler = new DoHandleOofRequest() +oofHandler.callOofAdapter(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1jorico" sourceRef="StartEvent_1" targetRef="Activity_0tki17o" /> + <bpmn:scriptTask id="Activity_0tki17o" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1jorico</bpmn:incoming> + <bpmn:outgoing>Flow_1fbzzqg</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +def oofHandler = new DoHandleOofRequest() +oofHandler .preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:subProcess id="Activity_02ru8n9" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_1r00tca"> + <bpmn:outgoing>Flow_072knve</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1sy4yh2" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1rwmekw"> + <bpmn:incoming>Flow_0ykpxpc</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_11rvko0" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_072knve</bpmn:incoming> + <bpmn:outgoing>Flow_0ykpxpc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0ykpxpc" sourceRef="Activity_11rvko0" targetRef="Event_1rwmekw" /> + <bpmn:sequenceFlow id="Flow_072knve" sourceRef="Event_1r00tca" targetRef="Activity_11rvko0" /> + </bpmn:subProcess> + <bpmn:callActivity id="Activity_1yq993l" name="Receive Async Callback" camunda:modelerTemplate="receiveWorkflowMessage" calledElement="ReceiveWorkflowMessage"> + <bpmn:extensionElements> + <camunda:in source="true" target="isDebugLogEnabled" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="messageType" target="RCVWFMSG_messageType" /> + <camunda:in source="correlator" target="RCVWFMSG_correlator" /> + <camunda:in source="timeout" target="RCVWFMSG_timeout" /> + <camunda:out source="WorkflowResponse" target="asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_013jfci</bpmn:incoming> + <bpmn:outgoing>Flow_1nmoiqi</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_013jfci" sourceRef="Activity_08ozlfa" targetRef="Activity_1yq993l" /> + <bpmn:endEvent id="Event_179tp7r" name="End event"> + <bpmn:incoming>Flow_1nmoiqi</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_1nmoiqi" sourceRef="Activity_1yq993l" targetRef="Event_179tp7r" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoHandleOofRequest"> + <bpmndi:BPMNEdge id="Flow_1jorico_di" bpmnElement="Flow_1jorico"> + <di:waypoint x="218" y="130" /> + <di:waypoint x="270" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1fbzzqg_di" bpmnElement="Flow_1fbzzqg"> + <di:waypoint x="370" y="130" /> + <di:waypoint x="450" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_013jfci_di" bpmnElement="Flow_013jfci"> + <di:waypoint x="550" y="130" /> + <di:waypoint x="641" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1nmoiqi_di" bpmnElement="Flow_1nmoiqi"> + <di:waypoint x="741" y="127" /> + <di:waypoint x="832" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="182" y="112" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="154" y="142" width="87" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1nfzvjq_di" bpmnElement="Activity_0tki17o"> + <dc:Bounds x="270" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0wi75kt_di" bpmnElement="Activity_08ozlfa"> + <dc:Bounds x="450" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1yq993l_di" bpmnElement="Activity_1yq993l"> + <dc:Bounds x="641" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_179tp7r_di" bpmnElement="Event_179tp7r"> + <dc:Bounds x="832" y="109" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="826" y="152" width="50" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_02ru8n9_di" bpmnElement="Activity_02ru8n9" isExpanded="true"> + <dc:Bounds x="160" y="420" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0ykpxpc_di" bpmnElement="Flow_0ykpxpc"> + <di:waypoint x="554" y="524" /> + <di:waypoint x="828" y="524" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_072knve_di" bpmnElement="Flow_072knve"> + <di:waypoint x="226" y="524" /> + <di:waypoint x="454" y="524" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_1r00tca_di" bpmnElement="Event_1r00tca"> + <dc:Bounds x="190" y="506" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1rwmekw_di" bpmnElement="Event_1rwmekw"> + <dc:Bounds x="828" y="506" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_11rvko0_di" bpmnElement="Activity_11rvko0"> + <dc:Bounds x="454" y="484" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleSdnrDmaapRequest.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleSdnrDmaapRequest.bpmn new file mode 100644 index 0000000000..d4e50c4d44 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleSdnrDmaapRequest.bpmn @@ -0,0 +1,98 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1347ugu" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.1"> + <bpmn:process id="DoHandleSdnrDmaapRequest" name="CallSdnrForSliceSubnetActions" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_05aj74g</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:callActivity id="Activity_1930vdf" name="Receive Async Callback" camunda:modelerTemplate="receiveWorkflowMessage" calledElement="ReceiveWorkflowMessage"> + <bpmn:extensionElements> + <camunda:in source="true" target="isDebugLogEnabled" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="messageType" target="RCVWFMSG_messageType" /> + <camunda:in source="correlator" target="RCVWFMSG_correlator" /> + <camunda:in source="timeout" target="RCVWFMSG_timeout" /> + <camunda:out source="WorkflowResponse" target="asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1ujhb0b</bpmn:incoming> + <bpmn:outgoing>Flow_0ygvrm7</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0ygvrm7" sourceRef="Activity_1930vdf" targetRef="Event_0axmcg1" /> + <bpmn:endEvent id="Event_0axmcg1"> + <bpmn:incoming>Flow_0ygvrm7</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_05aj74g" sourceRef="StartEvent_1" targetRef="Activity_0se24pv" /> + <bpmn:subProcess id="Activity_1br4yea" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_06b1eun"> + <bpmn:outgoing>Flow_1if0x9d</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0y90o3x" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1q3xxjf"> + <bpmn:incoming>Flow_04gv65b</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_0k6o70p" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_1if0x9d</bpmn:incoming> + <bpmn:outgoing>Flow_04gv65b</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1if0x9d" sourceRef="Event_06b1eun" targetRef="Activity_0k6o70p" /> + <bpmn:sequenceFlow id="Flow_04gv65b" sourceRef="Activity_0k6o70p" targetRef="Event_1q3xxjf" /> + </bpmn:subProcess> + <bpmn:sequenceFlow id="Flow_1ujhb0b" sourceRef="Activity_0se24pv" targetRef="Activity_1930vdf" /> + <bpmn:serviceTask id="Activity_0se24pv" name="send request to SDNR" camunda:class="org.onap.so.client.sdnc.common.SendRequestToSdnr"> + <bpmn:incoming>Flow_05aj74g</bpmn:incoming> + <bpmn:outgoing>Flow_1ujhb0b</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoHandleSdnrDmaapRequest"> + <bpmndi:BPMNEdge id="Flow_05aj74g_di" bpmnElement="Flow_05aj74g"> + <di:waypoint x="308" y="120" /> + <di:waypoint x="350" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ygvrm7_di" bpmnElement="Flow_0ygvrm7"> + <di:waypoint x="581" y="118" /> + <di:waypoint x="622" y="118" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ujhb0b_di" bpmnElement="Flow_1ujhb0b"> + <di:waypoint x="450" y="120" /> + <di:waypoint x="481" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="272" y="102" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1930vdf_di" bpmnElement="Activity_1930vdf"> + <dc:Bounds x="481" y="78" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0axmcg1_di" bpmnElement="Event_0axmcg1"> + <dc:Bounds x="622" y="100" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1f7ncbf_di" bpmnElement="Activity_0se24pv"> + <dc:Bounds x="350" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1br4yea_di" bpmnElement="Activity_1br4yea" isExpanded="true"> + <dc:Bounds x="140" y="310" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_04gv65b_di" bpmnElement="Flow_04gv65b"> + <di:waypoint x="534" y="414" /> + <di:waypoint x="808" y="414" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1if0x9d_di" bpmnElement="Flow_1if0x9d"> + <di:waypoint x="206" y="414" /> + <di:waypoint x="434" y="414" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_06b1eun_di" bpmnElement="Event_06b1eun"> + <dc:Bounds x="170" y="396" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1q3xxjf_di" bpmnElement="Event_1q3xxjf"> + <dc:Bounds x="808" y="396" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0k6o70p_di" bpmnElement="Activity_0k6o70p"> + <dc:Bounds x="434" y="374" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyAccessNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyAccessNSSI.bpmn new file mode 100644 index 0000000000..c62b143932 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyAccessNSSI.bpmn @@ -0,0 +1,886 @@ +<?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: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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1igy8ns" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.1"> + <bpmn:process id="DoModifyAccessNSSI" name="DoModifyAccessNSSI" isExecutable="true"> + <bpmn:startEvent id="Event_1sy6p6u" name="Start"> + <bpmn:outgoing>Flow_1yfvjui</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_1eiktpg" name="preprocess request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1yfvjui</bpmn:incoming> + <bpmn:outgoing>Flow_09sxq6k</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_00u5sgf" name="prepare OOF request for RAN NSS slice profiles" scriptFormat="groovy"> + <bpmn:incoming>Flow_0hzibw4</bpmn:incoming> + <bpmn:outgoing>Flow_0714cfa</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.prepareOofRequestForRanNSS(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_1qswyrk" name="Call DoCreateSubnetOption" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nssiSelection_Url" target="apiPath" /> + <camunda:in source="nssiSelection_correlator" target="correlator" /> + <camunda:in source="nssiSelection_messageType" target="messageType" /> + <camunda:in source="nssiSelection_timeout" target="timeout" /> + <camunda:in source="nssiSelection_oofRequest" target="oofRequest" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nssiSelection_asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0714cfa</bpmn:incoming> + <bpmn:outgoing>Flow_0ei9866</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_1w537ie" name="Process OOF response" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ei9866</bpmn:incoming> + <bpmn:outgoing>Flow_14xj79h</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.processOofResponseForRanNSS(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1yfvjui" sourceRef="Event_1sy6p6u" targetRef="Activity_1eiktpg" /> + <bpmn:sequenceFlow id="Flow_0714cfa" sourceRef="Activity_00u5sgf" targetRef="Activity_1qswyrk" /> + <bpmn:sequenceFlow id="Flow_0ei9866" sourceRef="Activity_1qswyrk" targetRef="Activity_1w537ie" /> + <bpmn:exclusiveGateway id="Gateway_0gi40v8" name="check modify action"> + <bpmn:incoming>Flow_09sxq6k</bpmn:incoming> + <bpmn:outgoing>Flow_1ycw1zo</bpmn:outgoing> + <bpmn:outgoing>Flow_1orjrjp</bpmn:outgoing> + <bpmn:outgoing>Flow_1p5ruyv</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_1ycw1zo" name="allocate" sourceRef="Gateway_0gi40v8" targetRef="Activity_0vki9dw"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isModifyallocate" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1orjrjp" name="deallocate" sourceRef="Gateway_0gi40v8" targetRef="Activity_10zcvcv"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isModifydeallocate" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="Activity_0vki9dw" name="query AAI for slice profile" scriptFormat="groovy"> + <bpmn:incoming>Flow_1ycw1zo</bpmn:incoming> + <bpmn:outgoing>Flow_1ym755g</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.getSliceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_14xj79h" sourceRef="Activity_1w537ie" targetRef="Activity_0c8tzf1" /> + <bpmn:sequenceFlow id="Flow_1p5ruyv" name="reconfigure" sourceRef="Gateway_0gi40v8" targetRef="Activity_0kcrid0"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isModifyreconfigure" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="Activity_0c8tzf1" name="get NSSIs from AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_14xj79h</bpmn:incoming> + <bpmn:outgoing>Flow_1fpw4gf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.getNssisFromAai(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1fpw4gf" sourceRef="Activity_0c8tzf1" targetRef="Activity_1so8vif" /> + <bpmn:sequenceFlow id="Flow_05cl21h" sourceRef="Activity_1so8vif" targetRef="Activity_0uxxkp1" /> + <bpmn:scriptTask id="Activity_0uxxkp1" name="update AAI relationships"> + <bpmn:incoming>Flow_05cl21h</bpmn:incoming> + <bpmn:outgoing>Flow_1jwk3jy</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.updateRelationshipInAai(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1so8vif" name="create slice profiles in AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_1fpw4gf</bpmn:incoming> + <bpmn:outgoing>Flow_05cl21h</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.createSliceProfiles(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1jwk3jy" sourceRef="Activity_0uxxkp1" targetRef="Event_1wm97cy" /> + <bpmn:intermediateThrowEvent id="Event_1wm97cy" name="Go to modify allocate"> + <bpmn:incoming>Flow_1jwk3jy</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_02uw07i" name="modifyAllocate" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="Event_058xrlc" name="Modify allocate"> + <bpmn:outgoing>Flow_06hymr5</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_0j8kv6s" name="modifyAllocate" /> + </bpmn:intermediateCatchEvent> + <bpmn:callActivity id="Activity_1nexxhu" name="DoModifyRanNfNssi" calledElement="DoModifyRanNfNssi"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="ANNF_NSSI" target="serviceInstanceID" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="ANNF_sliceProfileInstanceId" target="sliceProfileId" /> + <camunda:in source="snssaiList" target="snssaiList" /> + <camunda:out source="ranNfStatus" target="ranNfStatus" /> + <camunda:in source="modifyAction" target="modifyAction" /> + <camunda:in source="ranNfSliceProfile" target="additionalProperties" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_06hymr5</bpmn:incoming> + <bpmn:outgoing>Flow_19p3d5t</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_1rweifb" name="post process RAN NF NSSI modify" scriptFormat="groovy"> + <bpmn:incoming>Flow_19p3d5t</bpmn:incoming> + <bpmn:outgoing>Flow_0t8y3x5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.processRanNfModifyRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_19p3d5t" sourceRef="Activity_1nexxhu" targetRef="Activity_1rweifb" /> + <bpmn:sequenceFlow id="Flow_06hymr5" sourceRef="Event_058xrlc" targetRef="Activity_1nexxhu" /> + <bpmn:scriptTask id="Activity_0dr4umy" name="send modify allocate FH NSSI request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0t8y3x5</bpmn:incoming> + <bpmn:outgoing>Flow_0cd38vb</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.prepareTnFhRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0e0ldfk" name="prepare query job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0cd38vb</bpmn:incoming> + <bpmn:outgoing>Flow_1yfkps3</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.createFhAllocateNssiJobQuery(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_07kzsym" name="Query Job status" calledElement="QueryJobStatus "> + <bpmn:extensionElements> + <camunda:in source="esrInfo" target="esrInfo" /> + <camunda:in source="serviceInfo" target="serviceInfo" /> + <camunda:in source="TNFH_jobId" target="jobId" /> + <camunda:out source="jobResponse" target="TNFH_jobResponse" /> + <camunda:in source="responseId" target="responseId" /> + <camunda:in source="job_timeout" target="timeout" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1yfkps3</bpmn:incoming> + <bpmn:outgoing>Flow_0tkrh8z</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_06pgtv8" name="process Job status response" scriptFormat="groovy"> + <bpmn:incoming>Flow_0tkrh8z</bpmn:incoming> + <bpmn:outgoing>Flow_0ygfojp</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.processFhAllocateNssiJobStatusRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0cd38vb" sourceRef="Activity_0dr4umy" targetRef="Activity_0e0ldfk" /> + <bpmn:sequenceFlow id="Flow_1yfkps3" sourceRef="Activity_0e0ldfk" targetRef="Activity_07kzsym" /> + <bpmn:sequenceFlow id="Flow_0tkrh8z" sourceRef="Activity_07kzsym" targetRef="Activity_06pgtv8" /> + <bpmn:sequenceFlow id="Flow_0t8y3x5" sourceRef="Activity_1rweifb" targetRef="Activity_0dr4umy" /> + <bpmn:scriptTask id="Activity_11ohmvk" name="send modify allocate MH NSSI request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ygfojp</bpmn:incoming> + <bpmn:outgoing>Flow_1702ljm</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.prepareTnMhRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_11kv5jk" name="prepare query job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1702ljm</bpmn:incoming> + <bpmn:outgoing>Flow_1hzswil</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.createMhAllocateNssiJobQuery(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_031x96n" name="Query Job status" calledElement="QueryJobStatus "> + <bpmn:extensionElements> + <camunda:in source="esrInfo" target="esrInfo" /> + <camunda:in source="serviceInfo" target="serviceInfo" /> + <camunda:in source="TNMH_jobId" target="jobId" /> + <camunda:out source="jobResponse" target="TNMH_jobResponse" /> + <camunda:in source="responseId" target="responseId" /> + <camunda:in source="job_timeout" target="timeout" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1hzswil</bpmn:incoming> + <bpmn:outgoing>Flow_0zh5p33</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_1x48i50" name="process Job status response" scriptFormat="groovy"> + <bpmn:incoming>Flow_0zh5p33</bpmn:incoming> + <bpmn:outgoing>Flow_0wgumc4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.processMhAllocateNssiJobStatusRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1702ljm" sourceRef="Activity_11ohmvk" targetRef="Activity_11kv5jk" /> + <bpmn:sequenceFlow id="Flow_1hzswil" sourceRef="Activity_11kv5jk" targetRef="Activity_031x96n" /> + <bpmn:sequenceFlow id="Flow_0zh5p33" sourceRef="Activity_031x96n" targetRef="Activity_1x48i50" /> + <bpmn:sequenceFlow id="Flow_0ygfojp" sourceRef="Activity_06pgtv8" targetRef="Activity_11ohmvk" /> + <bpmn:callActivity id="Activity_1pqb2g0" name="DoModifyRanNfNssi" calledElement="DoModifyRanNfNssi"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="ANNF_NSSI" target="serviceInstanceID" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="ANNF_sliceProfileInstanceId" target="sliceProfileId" /> + <camunda:in source="snssaiList" target="snssaiList" /> + <camunda:out source="ranNfStatus" target="ranNfStatus" /> + <camunda:in source="modifyAction" target="modifyAction" /> + <camunda:in source="additionalProperties" target="additionalProperties" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_09p79e6</bpmn:incoming> + <bpmn:outgoing>Flow_0ks2ut4</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_0mleulg" name="post process RAN NF NSSI modify" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ks2ut4</bpmn:incoming> + <bpmn:outgoing>Flow_1mu3zgb</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.processRanNfModifyRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0ks2ut4" sourceRef="Activity_1pqb2g0" targetRef="Activity_0mleulg" /> + <bpmn:scriptTask id="Activity_1xdke18" name="send modify deallocate FH NSSI request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1mu3zgb</bpmn:incoming> + <bpmn:outgoing>Flow_01vilkh</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.prepareTnFhDeallocateRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_06meubi" name="prepare query job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_01vilkh</bpmn:incoming> + <bpmn:outgoing>Flow_0r7bejs</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.createFhAllocateNssiJobQuery(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_0sjyngn" name="Query Job status" calledElement="QueryJobStatus "> + <bpmn:extensionElements> + <camunda:in source="esrInfo" target="esrInfo" /> + <camunda:in source="serviceInfo" target="serviceInfo" /> + <camunda:in source="TN_FH_jobId" target="jobId" /> + <camunda:out source="jobResponse" target="TNFH_jobResponse" /> + <camunda:in source="responseId" target="responseId" /> + <camunda:in source="job_timeout" target="timeout" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0r7bejs</bpmn:incoming> + <bpmn:outgoing>Flow_06lgxk9</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_0j3bxt8" name="process Job status response" scriptFormat="groovy"> + <bpmn:incoming>Flow_06lgxk9</bpmn:incoming> + <bpmn:outgoing>Flow_120fe2z</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.processFhAllocateNssiJobStatusRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_01vilkh" sourceRef="Activity_1xdke18" targetRef="Activity_06meubi" /> + <bpmn:sequenceFlow id="Flow_0r7bejs" sourceRef="Activity_06meubi" targetRef="Activity_0sjyngn" /> + <bpmn:sequenceFlow id="Flow_06lgxk9" sourceRef="Activity_0sjyngn" targetRef="Activity_0j3bxt8" /> + <bpmn:sequenceFlow id="Flow_1mu3zgb" sourceRef="Activity_0mleulg" targetRef="Activity_1xdke18" /> + <bpmn:scriptTask id="Activity_10zcvcv" name="get NSSIs from AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_1orjrjp</bpmn:incoming> + <bpmn:outgoing>Flow_1atfnov</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.getNssisFromAai(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_0m97fsi" name="send modify deallocate MH NSSI request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1489mpe</bpmn:incoming> + <bpmn:outgoing>Flow_1ueq9wo</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.prepareTnMhDeallocateRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1wwt0yj" name="prepare query job status" scriptFormat="groovy"> + <bpmn:incoming>Flow_1ueq9wo</bpmn:incoming> + <bpmn:outgoing>Flow_05junp8</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.createMhAllocateNssiJobQuery(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_18gqpmg" name="Query Job status" calledElement="QueryJobStatus "> + <bpmn:extensionElements> + <camunda:in source="esrInfo" target="esrInfo" /> + <camunda:in source="serviceInfo" target="serviceInfo" /> + <camunda:in source="TN_MH_jobId" target="jobId" /> + <camunda:out source="jobResponse" target="TNMH_jobResponse" /> + <camunda:in source="responseId" target="responseId" /> + <camunda:in source="job_timeout" target="timeout" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_05junp8</bpmn:incoming> + <bpmn:outgoing>Flow_1xchogr</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_1j4c00v" name="process Job status response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1xchogr</bpmn:incoming> + <bpmn:outgoing>Flow_11aacst</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.processMhAllocateNssiJobStatusRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1ueq9wo" sourceRef="Activity_0m97fsi" targetRef="Activity_1wwt0yj" /> + <bpmn:sequenceFlow id="Flow_05junp8" sourceRef="Activity_1wwt0yj" targetRef="Activity_18gqpmg" /> + <bpmn:sequenceFlow id="Flow_1xchogr" sourceRef="Activity_18gqpmg" targetRef="Activity_1j4c00v" /> + <bpmn:sequenceFlow id="Flow_120fe2z" sourceRef="Activity_0j3bxt8" targetRef="Event_1x3sb7x" /> + <bpmn:intermediateThrowEvent id="Event_1x3sb7x" name="Go to modify deallocate"> + <bpmn:incoming>Flow_120fe2z</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_1wixp6w" name="modifydeAllocate" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_16lc641" sourceRef="Event_1vdrrdl" targetRef="Activity_0w9oree" /> + <bpmn:intermediateCatchEvent id="Event_1vdrrdl" name="Modify deallocate"> + <bpmn:outgoing>Flow_16lc641</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1aw5yul" name="modifydeAllocate" /> + </bpmn:intermediateCatchEvent> + <bpmn:scriptTask id="Activity_09ku290" name="remove TN MH slice profile" scriptFormat="groovy"> + <bpmn:incoming>Flow_11aacst</bpmn:incoming> + <bpmn:outgoing>Flow_05gp3p7</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.deleteMhSliceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1489mpe" sourceRef="Activity_0w9oree" targetRef="Activity_0m97fsi" /> + <bpmn:scriptTask id="Activity_0w9oree" name="remove TN FH slice profile" scriptFormat="groovy"> + <bpmn:incoming>Flow_16lc641</bpmn:incoming> + <bpmn:outgoing>Flow_1489mpe</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.deleteFhSliceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_11aacst" sourceRef="Activity_1j4c00v" targetRef="Activity_09ku290" /> + <bpmn:scriptTask id="Activity_121aiqf" name="remove RAN slice profile" scriptFormat="groovy"> + <bpmn:incoming>Flow_05gp3p7</bpmn:incoming> + <bpmn:outgoing>Flow_1nyp1l1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.deleteAnSliceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_05gp3p7" sourceRef="Activity_09ku290" targetRef="Activity_121aiqf" /> + <bpmn:subProcess id="Activity_0sp6bx7" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_0gr296x"> + <bpmn:outgoing>Flow_0yj2tlu</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1do1xse" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1hq0k3q"> + <bpmn:incoming>Flow_07c6g27</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_1awhkox" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_0dafrg8</bpmn:incoming> + <bpmn:outgoing>Flow_07c6g27</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_16up0r1" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_0yj2tlu</bpmn:incoming> + <bpmn:outgoing>Flow_0jar916</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.prepareFailedOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1h1crsr" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0jar916</bpmn:incoming> + <bpmn:outgoing>Flow_0dafrg8</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_07c6g27" sourceRef="Activity_1awhkox" targetRef="Event_1hq0k3q" /> + <bpmn:sequenceFlow id="Flow_0yj2tlu" sourceRef="Event_0gr296x" targetRef="Activity_16up0r1" /> + <bpmn:sequenceFlow id="Flow_0jar916" sourceRef="Activity_16up0r1" targetRef="Activity_1h1crsr" /> + <bpmn:sequenceFlow id="Flow_0dafrg8" sourceRef="Activity_1h1crsr" targetRef="Activity_1awhkox" /> + </bpmn:subProcess> + <bpmn:callActivity id="Activity_0kcrid0" name="DoModifyRanNfNssi" calledElement="DoModifyRanNfNssi"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="serviceInstanceID" target="serviceInstanceID" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="sliceProfileId" target="sliceProfileId" /> + <camunda:in source="snssaiList" target="snssaiList" /> + <camunda:out source="ranNfStatus" target="ranNfStatus" /> + <camunda:in source="modifyAction" target="modifyAction" /> + <camunda:in source="additionalProperties" target="additionalProperties" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1p5ruyv</bpmn:incoming> + <bpmn:outgoing>Flow_0fkl1gv</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_05m354s" name="post process RAN NF NSSI modify" scriptFormat="groovy"> + <bpmn:incoming>Flow_0fkl1gv</bpmn:incoming> + <bpmn:outgoing>Flow_17dxvu5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.processRanNfModifyRsp(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0fkl1gv" sourceRef="Activity_0kcrid0" targetRef="Activity_05m354s" /> + <bpmn:sequenceFlow id="Flow_09sxq6k" sourceRef="Activity_1eiktpg" targetRef="Gateway_0gi40v8" /> + <bpmn:scriptTask id="Activity_1w8iqt0" name="Get Subnet capabilities" scriptFormat="groovy"> + <bpmn:incoming>Flow_1ym755g</bpmn:incoming> + <bpmn:outgoing>Flow_0hzibw4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.getSubnetCapabilities(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1ym755g" sourceRef="Activity_0vki9dw" targetRef="Activity_1w8iqt0" /> + <bpmn:sequenceFlow id="Flow_0hzibw4" sourceRef="Activity_1w8iqt0" targetRef="Activity_00u5sgf" /> + <bpmn:scriptTask id="Activity_137i4pg" name="get sice profiles from AAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_1atfnov</bpmn:incoming> + <bpmn:outgoing>Flow_09p79e6</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.getSliceProfilesFromAai(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1atfnov" sourceRef="Activity_10zcvcv" targetRef="Activity_137i4pg" /> + <bpmn:sequenceFlow id="Flow_09p79e6" sourceRef="Activity_137i4pg" targetRef="Activity_1pqb2g0" /> + <bpmn:intermediateCatchEvent id="Event_00zdcuh" name="Start operation status update"> + <bpmn:outgoing>Flow_0ei2q6r</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1ohe6f7" name="OperationStatusUpdate" /> + </bpmn:intermediateCatchEvent> + <bpmn:scriptTask id="Activity_0mr7bh2" name="Prepare Resource Operation Status Update" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ei2q6r</bpmn:incoming> + <bpmn:outgoing>Flow_1giua78</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyAccessNSSI() +nss.prepareOperationStatusUpdate(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_125mjhq" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1giua78</bpmn:incoming> + <bpmn:outgoing>Flow_1oubjfe</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:endEvent id="Event_159m6y8"> + <bpmn:incoming>Flow_1oubjfe</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_1giua78" sourceRef="Activity_0mr7bh2" targetRef="Activity_125mjhq" /> + <bpmn:sequenceFlow id="Flow_1oubjfe" sourceRef="Activity_125mjhq" targetRef="Event_159m6y8" /> + <bpmn:intermediateThrowEvent id="Event_1gy8um0" name="Go to start operation status update"> + <bpmn:incoming>Flow_0wgumc4</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0kburcf" name="OperationStatusUpdate" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_0wgumc4" sourceRef="Activity_1x48i50" targetRef="Event_1gy8um0" /> + <bpmn:sequenceFlow id="Flow_0ei2q6r" sourceRef="Event_00zdcuh" targetRef="Activity_0mr7bh2" /> + <bpmn:intermediateThrowEvent id="Event_1304mrw" name="Go to start operation status update"> + <bpmn:incoming>Flow_1nyp1l1</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_1rrc1x9" name="OperationStatusUpdate" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_1nyp1l1" sourceRef="Activity_121aiqf" targetRef="Event_1304mrw" /> + <bpmn:intermediateThrowEvent id="Event_00vqmnl" name="Go to start operation status update"> + <bpmn:incoming>Flow_17dxvu5</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_158e1rq" name="OperationStatusUpdate" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_17dxvu5" sourceRef="Activity_05m354s" targetRef="Event_00vqmnl" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoModifyAccessNSSI"> + <bpmndi:BPMNEdge id="Flow_09sxq6k_di" bpmnElement="Flow_09sxq6k"> + <di:waypoint x="330" y="240" /> + <di:waypoint x="395" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0fkl1gv_di" bpmnElement="Flow_0fkl1gv"> + <di:waypoint x="620" y="120" /> + <di:waypoint x="680" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_05gp3p7_di" bpmnElement="Flow_05gp3p7"> + <di:waypoint x="1080" y="760" /> + <di:waypoint x="1130" y="760" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_11aacst_di" bpmnElement="Flow_11aacst"> + <di:waypoint x="940" y="760" /> + <di:waypoint x="980" y="760" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1489mpe_di" bpmnElement="Flow_1489mpe"> + <di:waypoint x="360" y="760" /> + <di:waypoint x="400" y="760" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16lc641_di" bpmnElement="Flow_16lc641"> + <di:waypoint x="188" y="760" /> + <di:waypoint x="260" y="760" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_120fe2z_di" bpmnElement="Flow_120fe2z"> + <di:waypoint x="1610" y="380" /> + <di:waypoint x="1652" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1xchogr_di" bpmnElement="Flow_1xchogr"> + <di:waypoint x="780" y="760" /> + <di:waypoint x="840" y="760" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_05junp8_di" bpmnElement="Flow_05junp8"> + <di:waypoint x="640" y="760" /> + <di:waypoint x="680" y="760" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ueq9wo_di" bpmnElement="Flow_1ueq9wo"> + <di:waypoint x="500" y="760" /> + <di:waypoint x="540" y="760" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1mu3zgb_di" bpmnElement="Flow_1mu3zgb"> + <di:waypoint x="1060" y="380" /> + <di:waypoint x="1100" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_06lgxk9_di" bpmnElement="Flow_06lgxk9"> + <di:waypoint x="1470" y="380" /> + <di:waypoint x="1510" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0r7bejs_di" bpmnElement="Flow_0r7bejs"> + <di:waypoint x="1330" y="380" /> + <di:waypoint x="1370" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_01vilkh_di" bpmnElement="Flow_01vilkh"> + <di:waypoint x="1200" y="380" /> + <di:waypoint x="1230" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ks2ut4_di" bpmnElement="Flow_0ks2ut4"> + <di:waypoint x="920" y="380" /> + <di:waypoint x="960" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ygfojp_di" bpmnElement="Flow_0ygfojp"> + <di:waypoint x="940" y="570" /> + <di:waypoint x="960" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0zh5p33_di" bpmnElement="Flow_0zh5p33"> + <di:waypoint x="1300" y="570" /> + <di:waypoint x="1330" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1hzswil_di" bpmnElement="Flow_1hzswil"> + <di:waypoint x="1180" y="570" /> + <di:waypoint x="1200" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1702ljm_di" bpmnElement="Flow_1702ljm"> + <di:waypoint x="1060" y="570" /> + <di:waypoint x="1080" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0t8y3x5_di" bpmnElement="Flow_0t8y3x5"> + <di:waypoint x="450" y="570" /> + <di:waypoint x="480" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0tkrh8z_di" bpmnElement="Flow_0tkrh8z"> + <di:waypoint x="820" y="570" /> + <di:waypoint x="840" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1yfkps3_di" bpmnElement="Flow_1yfkps3"> + <di:waypoint x="700" y="570" /> + <di:waypoint x="720" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0cd38vb_di" bpmnElement="Flow_0cd38vb"> + <di:waypoint x="580" y="570" /> + <di:waypoint x="600" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_06hymr5_di" bpmnElement="Flow_06hymr5"> + <di:waypoint x="188" y="570" /> + <di:waypoint x="220" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_19p3d5t_di" bpmnElement="Flow_19p3d5t"> + <di:waypoint x="320" y="570" /> + <di:waypoint x="350" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jwk3jy_di" bpmnElement="Flow_1jwk3jy"> + <di:waypoint x="1620" y="240" /> + <di:waypoint x="1652" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_05cl21h_di" bpmnElement="Flow_05cl21h"> + <di:waypoint x="1480" y="240" /> + <di:waypoint x="1520" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1fpw4gf_di" bpmnElement="Flow_1fpw4gf"> + <di:waypoint x="1340" y="240" /> + <di:waypoint x="1380" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1p5ruyv_di" bpmnElement="Flow_1p5ruyv"> + <di:waypoint x="420" y="215" /> + <di:waypoint x="420" y="120" /> + <di:waypoint x="520" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="409" y="103" width="56" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_14xj79h_di" bpmnElement="Flow_14xj79h"> + <di:waypoint x="1200" y="240" /> + <di:waypoint x="1240" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1orjrjp_di" bpmnElement="Flow_1orjrjp"> + <di:waypoint x="420" y="265" /> + <di:waypoint x="420" y="380" /> + <di:waypoint x="520" y="380" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="437" y="363" width="51" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ycw1zo_di" bpmnElement="Flow_1ycw1zo"> + <di:waypoint x="445" y="240" /> + <di:waypoint x="520" y="240" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="463" y="222" width="39" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ei9866_di" bpmnElement="Flow_0ei9866"> + <di:waypoint x="1050" y="240" /> + <di:waypoint x="1100" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0714cfa_di" bpmnElement="Flow_0714cfa"> + <di:waypoint x="890" y="240" /> + <di:waypoint x="950" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1yfvjui_di" bpmnElement="Flow_1yfvjui"> + <di:waypoint x="188" y="240" /> + <di:waypoint x="230" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ym755g_di" bpmnElement="Flow_1ym755g"> + <di:waypoint x="620" y="240" /> + <di:waypoint x="660" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0hzibw4_di" bpmnElement="Flow_0hzibw4"> + <di:waypoint x="760" y="240" /> + <di:waypoint x="790" y="240" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1atfnov_di" bpmnElement="Flow_1atfnov"> + <di:waypoint x="620" y="380" /> + <di:waypoint x="670" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_09p79e6_di" bpmnElement="Flow_09p79e6"> + <di:waypoint x="770" y="380" /> + <di:waypoint x="820" y="380" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1giua78_di" bpmnElement="Flow_1giua78"> + <di:waypoint x="340" y="920" /> + <di:waypoint x="380" y="920" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1oubjfe_di" bpmnElement="Flow_1oubjfe"> + <di:waypoint x="480" y="920" /> + <di:waypoint x="512" y="920" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0wgumc4_di" bpmnElement="Flow_0wgumc4"> + <di:waypoint x="1430" y="570" /> + <di:waypoint x="1482" y="570" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ei2q6r_di" bpmnElement="Flow_0ei2q6r"> + <di:waypoint x="198" y="920" /> + <di:waypoint x="240" y="920" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1nyp1l1_di" bpmnElement="Flow_1nyp1l1"> + <di:waypoint x="1230" y="760" /> + <di:waypoint x="1282" y="760" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_17dxvu5_di" bpmnElement="Flow_17dxvu5"> + <di:waypoint x="780" y="120" /> + <di:waypoint x="832" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_1sy6p6u_di" bpmnElement="Event_1sy6p6u"> + <dc:Bounds x="152" y="222" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="265" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_01kasfm_di" bpmnElement="Activity_1eiktpg"> + <dc:Bounds x="230" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0gi40v8_di" bpmnElement="Gateway_0gi40v8" isMarkerVisible="true"> + <dc:Bounds x="395" y="215" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="347" y="265.5" width="65" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1djbf1x_di" bpmnElement="Activity_0vki9dw"> + <dc:Bounds x="520" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_09vilc7_di" bpmnElement="Event_058xrlc"> + <dc:Bounds x="152" y="552" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="133" y="595" width="74" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1nexxhu_di" bpmnElement="Activity_1nexxhu"> + <dc:Bounds x="220" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1rweifb_di" bpmnElement="Activity_1rweifb"> + <dc:Bounds x="350" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0dr4umy_di" bpmnElement="Activity_0dr4umy"> + <dc:Bounds x="480" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0e0ldfk_di" bpmnElement="Activity_0e0ldfk"> + <dc:Bounds x="600" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_07kzsym_di" bpmnElement="Activity_07kzsym"> + <dc:Bounds x="720" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_06pgtv8_di" bpmnElement="Activity_06pgtv8"> + <dc:Bounds x="840" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_11ohmvk_di" bpmnElement="Activity_11ohmvk"> + <dc:Bounds x="960" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_11kv5jk_di" bpmnElement="Activity_11kv5jk"> + <dc:Bounds x="1080" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_031x96n_di" bpmnElement="Activity_031x96n"> + <dc:Bounds x="1200" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1x48i50_di" bpmnElement="Activity_1x48i50"> + <dc:Bounds x="1330" y="530" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_10zcvcv_di" bpmnElement="Activity_10zcvcv"> + <dc:Bounds x="520" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0m97fsi_di" bpmnElement="Activity_0m97fsi"> + <dc:Bounds x="400" y="720" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1wwt0yj_di" bpmnElement="Activity_1wwt0yj"> + <dc:Bounds x="540" y="720" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_18gqpmg_di" bpmnElement="Activity_18gqpmg"> + <dc:Bounds x="680" y="720" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1j4c00v_di" bpmnElement="Activity_1j4c00v"> + <dc:Bounds x="840" y="720" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1uqka61_di" bpmnElement="Event_1vdrrdl"> + <dc:Bounds x="152" y="742" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="127" y="785" width="86" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_09ku290_di" bpmnElement="Activity_09ku290"> + <dc:Bounds x="980" y="720" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1de2pwc_di" bpmnElement="Activity_0w9oree"> + <dc:Bounds x="260" y="720" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_06x7003_di" bpmnElement="Activity_121aiqf"> + <dc:Bounds x="1130" y="720" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1w8iqt0_di" bpmnElement="Activity_1w8iqt0"> + <dc:Bounds x="660" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_00u5sgf_di" bpmnElement="Activity_00u5sgf"> + <dc:Bounds x="790" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1qswyrk_di" bpmnElement="Activity_1qswyrk"> + <dc:Bounds x="950" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1w537ie_di" bpmnElement="Activity_1w537ie"> + <dc:Bounds x="1100" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1yl3g1d_di" bpmnElement="Activity_0c8tzf1"> + <dc:Bounds x="1240" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_12zdzs0_di" bpmnElement="Activity_1so8vif"> + <dc:Bounds x="1380" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1j6uaol_di" bpmnElement="Event_1wm97cy"> + <dc:Bounds x="1652" y="222" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1639" y="265" width="63" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_07pdl82_di" bpmnElement="Activity_0uxxkp1"> + <dc:Bounds x="1520" y="200" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0p57tcv_di" bpmnElement="Event_1x3sb7x"> + <dc:Bounds x="1652" y="362" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1642" y="405" width="63" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0j3bxt8_di" bpmnElement="Activity_0j3bxt8"> + <dc:Bounds x="1510" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0sjyngn_di" bpmnElement="Activity_0sjyngn"> + <dc:Bounds x="1370" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_06meubi_di" bpmnElement="Activity_06meubi"> + <dc:Bounds x="1230" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1xdke18_di" bpmnElement="Activity_1xdke18"> + <dc:Bounds x="1100" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0mleulg_di" bpmnElement="Activity_0mleulg"> + <dc:Bounds x="960" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1pqb2g0_di" bpmnElement="Activity_1pqb2g0"> + <dc:Bounds x="820" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_171ya99_di" bpmnElement="Activity_137i4pg"> + <dc:Bounds x="670" y="340" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_00zdcuh_di" bpmnElement="Event_00zdcuh"> + <dc:Bounds x="162" y="902" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="144" y="945" width="73" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0mr7bh2_di" bpmnElement="Activity_0mr7bh2"> + <dc:Bounds x="240" y="880" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_125mjhq_di" bpmnElement="Activity_125mjhq"> + <dc:Bounds x="380" y="880" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_159m6y8_di" bpmnElement="Event_159m6y8"> + <dc:Bounds x="512" y="902" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1gy8um0_di" bpmnElement="Event_1gy8um0"> + <dc:Bounds x="1482" y="552" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1460" y="587" width="79" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1304mrw_di" bpmnElement="Event_1304mrw"> + <dc:Bounds x="1282" y="742" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1260" y="777" width="79" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0kcrid0_di" bpmnElement="Activity_0kcrid0"> + <dc:Bounds x="520" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_05m354s_di" bpmnElement="Activity_05m354s"> + <dc:Bounds x="680" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_00vqmnl_di" bpmnElement="Event_00vqmnl"> + <dc:Bounds x="832" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="810" y="137" width="79" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0sp6bx7_di" bpmnElement="Activity_0sp6bx7" isExpanded="true"> + <dc:Bounds x="430" y="1070" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0dafrg8_di" bpmnElement="Flow_0dafrg8"> + <di:waypoint x="820" y="1174" /> + <di:waypoint x="890" y="1174" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0jar916_di" bpmnElement="Flow_0jar916"> + <di:waypoint x="660" y="1174" /> + <di:waypoint x="720" y="1174" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0yj2tlu_di" bpmnElement="Flow_0yj2tlu"> + <di:waypoint x="496" y="1174" /> + <di:waypoint x="560" y="1174" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_07c6g27_di" bpmnElement="Flow_07c6g27"> + <di:waypoint x="990" y="1174" /> + <di:waypoint x="1098" y="1174" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_0gr296x_di" bpmnElement="Event_0gr296x"> + <dc:Bounds x="460" y="1156" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1hq0k3q_di" bpmnElement="Event_1hq0k3q"> + <dc:Bounds x="1098" y="1156" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1awhkox_di" bpmnElement="Activity_1awhkox"> + <dc:Bounds x="890" y="1134" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16up0r1_di" bpmnElement="Activity_16up0r1"> + <dc:Bounds x="560" y="1134" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1h1crsr_di" bpmnElement="Activity_1h1crsr"> + <dc:Bounds x="720" y="1134" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyCoreNSSI.bpmn new file mode 100644 index 0000000000..fa167d4515 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyCoreNSSI.bpmn @@ -0,0 +1,311 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1ejx57e" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="Process_1nmtzzp" isExecutable="true"> + <bpmn:startEvent id="Event_0fbqt56" name="Modify Core NSSI Flow"> + <bpmn:outgoing>Flow_0e007rx</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0tf735w" name="Get Network Service Instance" scriptFormat="groovy"> + <bpmn:incoming>Flow_06j2avj</bpmn:incoming> + <bpmn:outgoing>Flow_1mqjtfk</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoModifyCoreNSSI() + mcnssi.getNetworkServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Activity_1ce41n6" name="Get constitute VNF from Network Service Instance" scriptFormat="groovy"> + <bpmn:incoming>Flow_1mqjtfk</bpmn:incoming> + <bpmn:outgoing>Flow_184tfp7</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoModifyCoreNSSI() + mcnssi.getConstituteVNFFromNetworkServiceInst(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1mqjtfk" sourceRef="Activity_0tf735w" targetRef="Activity_1ce41n6" /> + <bpmn:scriptTask id="Activity_02skgkj" name="Get NSSI associated profiles" scriptFormat="groovy"> + <bpmn:incoming>Flow_184tfp7</bpmn:incoming> + <bpmn:outgoing>Flow_0s31teg</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoModifyCoreNSSI() + mcnssi.getNSSIAssociatedProfiles(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_184tfp7" sourceRef="Activity_1ce41n6" targetRef="Activity_02skgkj" /> + <bpmn:exclusiveGateway id="Gateway_1hadnun" name="Is Slice Profile Instance has to be created" default="Flow_03gf14v"> + <bpmn:incoming>Flow_0s31teg</bpmn:incoming> + <bpmn:outgoing>Flow_1pls2hu</bpmn:outgoing> + <bpmn:outgoing>Flow_03gf14v</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0s31teg" sourceRef="Activity_02skgkj" targetRef="Gateway_1hadnun" /> + <bpmn:intermediateThrowEvent id="Event_1243wg1" name="Goto Slice Profile Instance has to be created"> + <bpmn:incoming>Flow_1pls2hu</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_14qnw6y" name="SliceProfileInstanceHasToBeCreated" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_1pls2hu" name="yes" sourceRef="Gateway_1hadnun" targetRef="Event_1243wg1"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isCreateSliceProfileInstance" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:intermediateThrowEvent id="Event_1gjhrcq" name="Goto Slice profile instance has to be deleted"> + <bpmn:incoming>Flow_03gf14v</bpmn:incoming> + <bpmn:linkEventDefinition id="LinkEventDefinition_0ecwvhj" name="SliceProfileInstanceHasToBeDeleted" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="Flow_03gf14v" name="no" sourceRef="Gateway_1hadnun" targetRef="Event_1gjhrcq" /> + <bpmn:scriptTask id="Activity_0oph5am" name="Update Service Operation Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0l7hcnf</bpmn:incoming> + <bpmn:incoming>Flow_0lrenyo</bpmn:incoming> + <bpmn:outgoing>Flow_0yq24um</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoDeallocateCoreNSSI() + mcnssi.updateServiceOperationStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:endEvent id="Event_1p0mogo" name="End"> + <bpmn:incoming>Flow_0yq24um</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0yq24um" sourceRef="Activity_0oph5am" targetRef="Event_1p0mogo" /> + <bpmn:intermediateCatchEvent id="Event_0z9mer1" name="Slice Profile Instance has to be created"> + <bpmn:outgoing>Flow_1xysykm</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_0fbskyk" name="SliceProfileInstanceHasToBeCreated" /> + </bpmn:intermediateCatchEvent> + <bpmn:intermediateCatchEvent id="Event_0m2jn7c" name="Slice profile instance has to be deleted"> + <bpmn:outgoing>Flow_11vf6ik</bpmn:outgoing> + <bpmn:linkEventDefinition id="LinkEventDefinition_1lptuqv" name="SliceProfileInstanceHasToBeDeleted" /> + </bpmn:intermediateCatchEvent> + <bpmn:scriptTask id="Activity_0ouov98" name="Calculate S-NSSAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_1xysykm</bpmn:incoming> + <bpmn:outgoing>Flow_1nxaeez</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoModifyCoreNSSI() + mcnssi.calculateSNSSAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1xysykm" sourceRef="Event_0z9mer1" targetRef="Activity_0ouov98" /> + <bpmn:scriptTask id="Activity_00t4mmi" name="Invoke PUT Service Instance API" scriptFormat="groovy"> + <bpmn:incoming>Flow_1nxaeez</bpmn:incoming> + <bpmn:outgoing>Flow_0ccqmju</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new ModifyCoreNSSI() + mcnssi.invokePUTServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1nxaeez" sourceRef="Activity_0ouov98" targetRef="Activity_00t4mmi" /> + <bpmn:scriptTask id="Activity_1q02wiz" name="Create a slice profile instance
" scriptFormat="groovy"> + <bpmn:incoming>Flow_0ccqmju</bpmn:incoming> + <bpmn:outgoing>Flow_1fdpbsx</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new ModifyCoreNSSI() + mcnssi.createSliceProfileInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0ccqmju" sourceRef="Activity_00t4mmi" targetRef="Activity_1q02wiz" /> + <bpmn:scriptTask id="Activity_1josmor" name="Associate slice profile instance the same with the NSSI
" scriptFormat="groovy"> + <bpmn:incoming>Flow_1fdpbsx</bpmn:incoming> + <bpmn:outgoing>Flow_0l7hcnf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new ModifyCoreNSSI() + mcnssi.associateSliceProfileInstanceWithNSSI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1fdpbsx" sourceRef="Activity_1q02wiz" targetRef="Activity_1josmor" /> + <bpmn:scriptTask id="Activity_0j4c22q" name="Calculate S-NSSAI" scriptFormat="groovy"> + <bpmn:incoming>Flow_11vf6ik</bpmn:incoming> + <bpmn:outgoing>Flow_1oeokwy</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new DoModifyCoreNSSI() + mcnssi.calculateSNSSAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_11vf6ik" sourceRef="Event_0m2jn7c" targetRef="Activity_0j4c22q" /> + <bpmn:scriptTask id="Activity_0c4wmiz" name="Invoke PUT Service Instance API" scriptFormat="groovy"> + <bpmn:incoming>Flow_1oeokwy</bpmn:incoming> + <bpmn:outgoing>Flow_15fi92t</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new ModifyCoreNSSI() + mcnssi.invokePUTServiceInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1oeokwy" sourceRef="Activity_0j4c22q" targetRef="Activity_0c4wmiz" /> + <bpmn:scriptTask id="Activity_1iegufd" name="Remove the NSSI to slice instance association
" scriptFormat="groovy"> + <bpmn:incoming>Flow_15fi92t</bpmn:incoming> + <bpmn:outgoing>Flow_1wtv1zj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new ModifyCoreNSSI() + mcnssi.removeNSSIToSliceInstanceAssociation(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_15fi92t" sourceRef="Activity_0c4wmiz" targetRef="Activity_1iegufd" /> + <bpmn:scriptTask id="Activity_010nkjp" name="Delete the slice profile instance
" scriptFormat="groovy"> + <bpmn:incoming>Flow_1wtv1zj</bpmn:incoming> + <bpmn:outgoing>Flow_0lrenyo</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def mcnssi= new ModifyCoreNSSI() + mcnssi.deleteSliceProfileInstance(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1wtv1zj" sourceRef="Activity_1iegufd" targetRef="Activity_010nkjp" /> + <bpmn:sequenceFlow id="Flow_0l7hcnf" sourceRef="Activity_1josmor" targetRef="Activity_0oph5am" /> + <bpmn:sequenceFlow id="Flow_0lrenyo" sourceRef="Activity_010nkjp" targetRef="Activity_0oph5am" /> + <bpmn:scriptTask id="Activity_0klj7y1" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0e007rx</bpmn:incoming> + <bpmn:outgoing>Flow_06j2avj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + def mcnssi= new DoModifyCoreNSSI() + mcnssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0e007rx" sourceRef="Event_0fbqt56" targetRef="Activity_0klj7y1" /> + <bpmn:sequenceFlow id="Flow_06j2avj" sourceRef="Activity_0klj7y1" targetRef="Activity_0tf735w" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1nmtzzp"> + <bpmndi:BPMNEdge id="Flow_0lrenyo_di" bpmnElement="Flow_0lrenyo"> + <di:waypoint x="890" y="600" /> + <di:waypoint x="930" y="600" /> + <di:waypoint x="930" y="540" /> + <di:waypoint x="970" y="540" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0l7hcnf_di" bpmnElement="Flow_0l7hcnf"> + <di:waypoint x="890" y="430" /> + <di:waypoint x="930" y="430" /> + <di:waypoint x="930" y="500" /> + <di:waypoint x="970" y="500" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1wtv1zj_di" bpmnElement="Flow_1wtv1zj"> + <di:waypoint x="730" y="600" /> + <di:waypoint x="790" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_15fi92t_di" bpmnElement="Flow_15fi92t"> + <di:waypoint x="560" y="600" /> + <di:waypoint x="630" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1oeokwy_di" bpmnElement="Flow_1oeokwy"> + <di:waypoint x="380" y="600" /> + <di:waypoint x="460" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_11vf6ik_di" bpmnElement="Flow_11vf6ik"> + <di:waypoint x="218" y="600" /> + <di:waypoint x="280" y="600" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1fdpbsx_di" bpmnElement="Flow_1fdpbsx"> + <di:waypoint x="730" y="430" /> + <di:waypoint x="790" y="430" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ccqmju_di" bpmnElement="Flow_0ccqmju"> + <di:waypoint x="560" y="430" /> + <di:waypoint x="630" y="430" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1nxaeez_di" bpmnElement="Flow_1nxaeez"> + <di:waypoint x="390" y="430" /> + <di:waypoint x="460" y="430" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1xysykm_di" bpmnElement="Flow_1xysykm"> + <di:waypoint x="218" y="430" /> + <di:waypoint x="290" y="430" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0yq24um_di" bpmnElement="Flow_0yq24um"> + <di:waypoint x="1070" y="520" /> + <di:waypoint x="1132" y="520" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_03gf14v_di" bpmnElement="Flow_03gf14v"> + <di:waypoint x="1010" y="175" /> + <di:waypoint x="1010" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1019" y="190" width="13" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1pls2hu_di" bpmnElement="Flow_1pls2hu"> + <di:waypoint x="1035" y="150" /> + <di:waypoint x="1132" y="150" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1049" y="132" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0s31teg_di" bpmnElement="Flow_0s31teg"> + <di:waypoint x="910" y="150" /> + <di:waypoint x="985" y="150" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_184tfp7_di" bpmnElement="Flow_184tfp7"> + <di:waypoint x="720" y="150" /> + <di:waypoint x="810" y="150" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1mqjtfk_di" bpmnElement="Flow_1mqjtfk"> + <di:waypoint x="540" y="150" /> + <di:waypoint x="620" y="150" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0e007rx_di" bpmnElement="Flow_0e007rx"> + <di:waypoint x="218" y="150" /> + <di:waypoint x="280" y="150" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_06j2avj_di" bpmnElement="Flow_06j2avj"> + <di:waypoint x="380" y="150" /> + <di:waypoint x="440" y="150" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_0fbqt56_di" bpmnElement="Event_0fbqt56"> + <dc:Bounds x="182" y="132" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="175" width="89" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0oph5am_di" bpmnElement="Activity_0oph5am"> + <dc:Bounds x="970" y="480" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1p0mogo_di" bpmnElement="Event_1p0mogo"> + <dc:Bounds x="1132" y="502" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1140" y="478" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0z9mer1_di" bpmnElement="Event_0z9mer1"> + <dc:Bounds x="182" y="412" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="162" y="455" width="90" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0m2jn7c_di" bpmnElement="Event_0m2jn7c"> + <dc:Bounds x="182" y="582" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="155" y="625" width="90" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ouov98_di" bpmnElement="Activity_0ouov98"> + <dc:Bounds x="290" y="390" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_00t4mmi_di" bpmnElement="Activity_00t4mmi"> + <dc:Bounds x="460" y="390" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1q02wiz_di" bpmnElement="Activity_1q02wiz"> + <dc:Bounds x="630" y="390" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1josmor_di" bpmnElement="Activity_1josmor"> + <dc:Bounds x="790" y="390" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0j4c22q_di" bpmnElement="Activity_0j4c22q"> + <dc:Bounds x="280" y="560" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0c4wmiz_di" bpmnElement="Activity_0c4wmiz"> + <dc:Bounds x="460" y="560" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1iegufd_di" bpmnElement="Activity_1iegufd"> + <dc:Bounds x="630" y="560" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_010nkjp_di" bpmnElement="Activity_010nkjp"> + <dc:Bounds x="790" y="560" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1243wg1_di" bpmnElement="Event_1243wg1"> + <dc:Bounds x="1132" y="132" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1113" y="173" width="90" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1hadnun_di" bpmnElement="Gateway_1hadnun" isMarkerVisible="true"> + <dc:Bounds x="985" y="125" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="974" y="86" width="75" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1gjhrcq_di" bpmnElement="Event_1gjhrcq"> + <dc:Bounds x="992" y="252" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="973" y="293" width="90" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_02skgkj_di" bpmnElement="Activity_02skgkj"> + <dc:Bounds x="810" y="110" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ce41n6_di" bpmnElement="Activity_1ce41n6"> + <dc:Bounds x="620" y="110" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0tf735w_di" bpmnElement="Activity_0tf735w"> + <dc:Bounds x="440" y="110" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0klj7y1_di" bpmnElement="Activity_0klj7y1"> + <dc:Bounds x="280" y="110" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyRanNfNssi.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyRanNfNssi.bpmn new file mode 100644 index 0000000000..1af4ff9be1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyRanNfNssi.bpmn @@ -0,0 +1,91 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0misy4e" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.1"> + <bpmn:process id="DoModifyRanNfNssi" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_0f9s9j7</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0bbh5uy" name="preprocess request" scriptFormat="groovy"> + <bpmn:incoming>Flow_0f9s9j7</bpmn:incoming> + <bpmn:outgoing>Flow_1kdh0gl</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyRanNfNssi() +nss.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0f9s9j7" sourceRef="StartEvent_1" targetRef="Activity_0bbh5uy" /> + <bpmn:sequenceFlow id="Flow_1kdh0gl" sourceRef="Activity_0bbh5uy" targetRef="Activity_1rs1l5c" /> + <bpmn:scriptTask id="Activity_1rs1l5c" name="prepare SDNR request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1kdh0gl</bpmn:incoming> + <bpmn:outgoing>Flow_0n0zzp4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyRanNfNssi() +nss.createSdnrRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="Activity_1jpoqws" name="call sdnr for RAN NF NSSI creation" calledElement="DoHandleSdnrDmaapRequest"> + <bpmn:extensionElements> + <camunda:in source="createNSSI_sdnrRequest" target="sdnrRequest" /> + <camunda:out source="asyncCallbackResponse" target="SDNR_asyncCallbackResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="createNSSI_correlator" target="correlator" /> + <camunda:in source="createNSSI_messageType" target="messageType" /> + <camunda:in source="createNSSI_timeout" target="timeout" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0n0zzp4</bpmn:incoming> + <bpmn:outgoing>Flow_1b0cez1</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_03xcmka" name="process SDNR response" scriptFormat="groovy"> + <bpmn:incoming>Flow_1b0cez1</bpmn:incoming> + <bpmn:outgoing>Flow_1ngijid</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def nss = new DoModifyRanNfNssi() +nss.processSdnrResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0n0zzp4" sourceRef="Activity_1rs1l5c" targetRef="Activity_1jpoqws" /> + <bpmn:sequenceFlow id="Flow_1b0cez1" sourceRef="Activity_1jpoqws" targetRef="Activity_03xcmka" /> + <bpmn:sequenceFlow id="Flow_1ngijid" sourceRef="Activity_03xcmka" targetRef="Event_086qr2t" /> + <bpmn:endEvent id="Event_086qr2t"> + <bpmn:incoming>Flow_1ngijid</bpmn:incoming> + </bpmn:endEvent> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoModifyRanNfNssi"> + <bpmndi:BPMNEdge id="Flow_1ngijid_di" bpmnElement="Flow_1ngijid"> + <di:waypoint x="730" y="100" /> + <di:waypoint x="772" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1b0cez1_di" bpmnElement="Flow_1b0cez1"> + <di:waypoint x="590" y="100" /> + <di:waypoint x="630" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0n0zzp4_di" bpmnElement="Flow_0n0zzp4"> + <di:waypoint x="460" y="100" /> + <di:waypoint x="490" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1kdh0gl_di" bpmnElement="Flow_1kdh0gl"> + <di:waypoint x="320" y="100" /> + <di:waypoint x="360" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0f9s9j7_di" bpmnElement="Flow_0f9s9j7"> + <di:waypoint x="188" y="100" /> + <di:waypoint x="220" y="100" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="152" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0bbh5uy_di" bpmnElement="Activity_0bbh5uy"> + <dc:Bounds x="220" y="60" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1rs1l5c_di" bpmnElement="Activity_1rs1l5c"> + <dc:Bounds x="360" y="60" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1jpoqws_di" bpmnElement="Activity_1jpoqws"> + <dc:Bounds x="490" y="60" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_03xcmka_di" bpmnElement="Activity_03xcmka"> + <dc:Bounds x="630" y="60" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_086qr2t_di" bpmnElement="Event_086qr2t"> + <dc:Bounds x="772" y="82" width="36" height="36" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyTransportNSSI.bpmn new file mode 100644 index 0000000000..d70bed68cb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyTransportNSSI.bpmn @@ -0,0 +1,222 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoModifyTransportNSSI" name="DoModifyTransportNSSI" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Modify TN NSSMF Work Flow"> + <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:subProcess id="SubProcess_1yv9i68" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_1omdx56"> + <bpmn:outgoing>SequenceFlow_1w67v6s</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_06xcioh" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1jx3026"> + <bpmn:incoming>SequenceFlow_08mlzwz</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1swzdpw" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1w67v6s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08mlzwz</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1w67v6s" sourceRef="StartEvent_1omdx56" targetRef="ScriptTask_1swzdpw" /> + <bpmn:sequenceFlow id="SequenceFlow_08mlzwz" sourceRef="ScriptTask_1swzdpw" targetRef="EndEvent_1jx3026" /> + </bpmn:subProcess> + <bpmn:endEvent id="EndEvent_05h01gx" name="End"> + <bpmn:incoming>Flow_1akxvak</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qv8qw1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoActivateTnNssi() +runScript.prepareUpdateJobStatus(execution,"finished","100","Modified TN NSSI successfully")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_03s744c" sourceRef="StartEvent_1nbljfd" targetRef="ScriptTask_1tc44ge" /> + <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_0ziz3ti" /> + <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_0h5rwlh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +execution.setVariable("orchestrationStatus", "modified") +def runScript = new DoModifyTnNssi() +runScript.updateAAIOrchStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ssh2l9" /> + <bpmn:scriptTask id="Activity_0phv8e5" name="Modify TN NSSI in AAI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1jdb2oq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +def runScript = new DoModifyTnNssi() +runScript.updateTnNssiInAAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1jdb2oq" sourceRef="Activity_0phv8e5" targetRef="Activity_0h1vr2l" /> + <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03s744c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07e12rt</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoModifyTnNssi() +runScript.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Activity_0phv8e5" /> + <bpmn:scriptTask id="Activity_0h1vr2l" name="PreProcess SDNC Modify TN NSSI Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming> + <bpmn:outgoing>Flow_1dvo5ih</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def runScript = new DoModifyTnNssi() +runScript.preprocessSdncModifyTnNssiRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1dvo5ih" sourceRef="Activity_0h1vr2l" targetRef="Activity_14ab476" /> + <bpmn:callActivity id="Activity_14ab476" name="Call SDNC Adapter: Modify TN NSSI" calledElement="sdncAdapter"> + <bpmn:extensionElements> + <camunda:in source="TNNSSMF_SDNCRequest" target="sdncAdapterWorkflowRequest" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> + <camunda:in source="mso-service-instance-id" target="mso-service-instance-id" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="sdncAdapterResponse" target="TNNSSMF_SDNCAdapterResponse" /> + <camunda:out source="SDNCA_SuccessIndicator" target="SDNCA_SuccessIndicator" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1dvo5ih</bpmn:incoming> + <bpmn:outgoing>Flow_139j3yd</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_139j3yd" sourceRef="Activity_14ab476" targetRef="Activity_1vtz33q" /> + <bpmn:scriptTask id="Activity_1vtz33q" name="Postprocess SDNC Modify TN NSSI Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_139j3yd</bpmn:incoming> + <bpmn:outgoing>Flow_0h5rwlh</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* + +String response = execution.getVariable("TNNSSMF_SDNCAdapterResponse") + +def runScript = new DoModifyTnNssi() +runScript.validateSDNCResponse(execution, response, "modify")</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0h5rwlh" sourceRef="Activity_1vtz33q" targetRef="ScriptTask_19uxoi8" /> + <bpmn:serviceTask id="Activity_0ziz3ti" name="Update Resource Operation Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1qv8qw1</bpmn:incoming> + <bpmn:outgoing>Flow_1akxvak</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1akxvak" sourceRef="Activity_0ziz3ti" targetRef="EndEvent_05h01gx" /> + </bpmn:process> + <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> + <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoModifyTransportNSSI"> + <bpmndi:BPMNEdge id="Flow_0h5rwlh_di" bpmnElement="Flow_0h5rwlh"> + <di:waypoint x="1240" y="121" /> + <di:waypoint x="1380" y="121" /> + <di:waypoint x="1380" y="210" /> + <di:waypoint x="335" y="210" /> + <di:waypoint x="335" y="310" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_139j3yd_di" bpmnElement="Flow_139j3yd"> + <di:waypoint x="1010" y="121" /> + <di:waypoint x="1119" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1dvo5ih_di" bpmnElement="Flow_1dvo5ih"> + <di:waypoint x="806" y="121" /> + <di:waypoint x="889" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> + <di:waypoint x="385" y="121" /> + <di:waypoint x="479" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq"> + <di:waypoint x="600" y="121" /> + <di:waypoint x="685" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> + <di:waypoint x="385" y="350" /> + <di:waypoint x="530" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> + <di:waypoint x="630" y="350" /> + <di:waypoint x="740" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> + <di:waypoint x="214" y="121" /> + <di:waypoint x="285" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1akxvak_di" bpmnElement="Flow_1akxvak"> + <di:waypoint x="840" y="350" /> + <di:waypoint x="1002" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> + <dc:Bounds x="178" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="161" y="146" width="86" height="40" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ziz3ti_di" bpmnElement="Activity_0ziz3ti"> + <dc:Bounds x="740" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> + <dc:Bounds x="685" y="1080" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1079" y="1184" /> + <di:waypoint x="1353" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="751" y="1184" /> + <di:waypoint x="979" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="715" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1353" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="979" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> + <dc:Bounds x="1002" y="332" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1010" y="375" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> + <dc:Bounds x="530" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> + <dc:Bounds x="285" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5"> + <dc:Bounds x="479" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="285" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0h1vr2l_di" bpmnElement="Activity_0h1vr2l"> + <dc:Bounds x="685" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_14ab476_di" bpmnElement="Activity_14ab476"> + <dc:Bounds x="889" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1vtz33q_di" bpmnElement="Activity_1vtz33q"> + <dc:Bounds x="1119" y="74" width="121" height="94" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn new file mode 100644 index 0000000000..b2b6c031f9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn @@ -0,0 +1,141 @@ +<?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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0le3oyh" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.2"> + <bpmn:process id="QueryJobStatus" name="QueryJobStatus" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>Flow_16nxw2f</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Activity_0cd23fy" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_16nxw2f</bpmn:incoming> + <bpmn:outgoing>Flow_0qhl0m8</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def qjs= new QueryJobStatus() +qjs.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="Activity_1aivult" name="Query Job Status"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${NSSMF_AdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/json</camunda:entry> + <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${NSSMF_AdapterRequest}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="NSSMF_ResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="NSSMF_Response">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0qhl0m8</bpmn:incoming> + <bpmn:incoming>Flow_1qqqckj</bpmn:incoming> + <bpmn:outgoing>Flow_18di8yy</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_16nxw2f" sourceRef="StartEvent_1" targetRef="Activity_0cd23fy" /> + <bpmn:sequenceFlow id="Flow_0qhl0m8" sourceRef="Activity_0cd23fy" targetRef="Activity_1aivult" /> + <bpmn:scriptTask id="Activity_16hyg49" name="Check Job Status" scriptFormat="groovy"> + <bpmn:incoming>Flow_18di8yy</bpmn:incoming> + <bpmn:outgoing>Flow_0ct1kfw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def qjs= new QueryJobStatus() +qjs.checkJobStatus(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_1ruy0j9" name="Is Completed?"> + <bpmn:incoming>Flow_0ct1kfw</bpmn:incoming> + <bpmn:outgoing>Flow_1x9fug6</bpmn:outgoing> + <bpmn:outgoing>Flow_1qqqckj</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_18di8yy" sourceRef="Activity_1aivult" targetRef="Activity_16hyg49" /> + <bpmn:sequenceFlow id="Flow_0ct1kfw" sourceRef="Activity_16hyg49" targetRef="Gateway_1ruy0j9" /> + <bpmn:scriptTask id="Activity_0rtwx97" name="Update JobStatus details" scriptFormat="groovy"> + <bpmn:incoming>Flow_1x9fug6</bpmn:incoming> + <bpmn:outgoing>Flow_0qqltc9</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def qjs= new QueryJobStatus() +qjs.updateJobStatusDetails(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1x9fug6" name="yes" sourceRef="Gateway_1ruy0j9" targetRef="Activity_0rtwx97"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("JobStatusCompleted") == "TRUE"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="Event_0p00z2s" name="End"> + <bpmn:incoming>Flow_0qqltc9</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0qqltc9" sourceRef="Activity_0rtwx97" targetRef="Event_0p00z2s" /> + <bpmn:sequenceFlow id="Flow_1qqqckj" name="No" sourceRef="Gateway_1ruy0j9" targetRef="Activity_1aivult"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("JobStatusCompleted") == "FALSE"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="QueryJobStatus"> + <bpmndi:BPMNEdge id="Flow_1qqqckj_di" bpmnElement="Flow_1qqqckj"> + <di:waypoint x="880" y="152" /> + <di:waypoint x="880" y="280" /> + <di:waypoint x="550" y="280" /> + <di:waypoint x="550" y="167" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="892" y="163" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0qqltc9_di" bpmnElement="Flow_0qqltc9"> + <di:waypoint x="1100" y="127" /> + <di:waypoint x="1152" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1x9fug6_di" bpmnElement="Flow_1x9fug6"> + <di:waypoint x="905" y="127" /> + <di:waypoint x="1000" y="127" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="944" y="109" width="17" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0ct1kfw_di" bpmnElement="Flow_0ct1kfw"> + <di:waypoint x="780" y="127" /> + <di:waypoint x="855" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_18di8yy_di" bpmnElement="Flow_18di8yy"> + <di:waypoint x="600" y="127" /> + <di:waypoint x="680" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0qhl0m8_di" bpmnElement="Flow_0qhl0m8"> + <di:waypoint x="410" y="127" /> + <di:waypoint x="500" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16nxw2f_di" bpmnElement="Flow_16nxw2f"> + <di:waypoint x="215" y="127" /> + <di:waypoint x="310" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="179" y="109" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="186" y="152" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0cd23fy_di" bpmnElement="Activity_0cd23fy"> + <dc:Bounds x="310" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1aivult_di" bpmnElement="Activity_1aivult"> + <dc:Bounds x="500" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16hyg49_di" bpmnElement="Activity_16hyg49"> + <dc:Bounds x="680" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_1ruy0j9_di" bpmnElement="Gateway_1ruy0j9" isMarkerVisible="true"> + <dc:Bounds x="855" y="102" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="844" y="83" width="72" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0rtwx97_di" bpmnElement="Activity_0rtwx97"> + <dc:Bounds x="1000" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0p00z2s_di" bpmnElement="Event_0p00z2s"> + <dc:Bounds x="1152" y="109" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1160" y="152" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSWUPDownloadTest.java index a0ef90d7b8..b9c5fdf145 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSWUPDownloadTest.java @@ -49,15 +49,15 @@ import static org.assertj.core.api.Assertions.fail; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; /** - * Basic Integration test for PNFSWUPDownloadTest.bpmn workflow. + * Basic Integration test for GenericPnfSWUPDownloadTest.bpmn workflow. */ -public class PNFSWUPDownloadTest extends BaseBPMNTest { +public class GenericPnfSWUPDownloadTest extends BaseBPMNTest { private final Logger logger = LoggerFactory.getLogger(getClass()); private static final long WORKFLOW_WAIT_TIME = 1000L; - private static final String TEST_PROCESSINSTANCE_KEY = "PNFSWUPDownload"; + private static final String TEST_PROCESSINSTANCE_KEY = "GenericPnfSWUPDownload"; private static final AAIVersion VERSION = AAIVersion.LATEST; private static final Map<String, Object> executionVariables = new HashMap(); private final String[] actionNames = new String[3]; @@ -76,8 +76,8 @@ public class PNFSWUPDownloadTest extends BaseBPMNTest { executionVariables.clear(); - requestObject = FileUtil.readResourceFile("request/PNFSoftwareUpgradeTest.json"); - responseObject = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest.json"); + requestObject = FileUtil.readResourceFile("request/GenericPnfSoftwareUpgradeTest.json"); + responseObject = FileUtil.readResourceFile("response/GenericPnfSoftwareUpgradeTest.json"); executionVariables.put("bpmnRequest", requestObject); @@ -136,7 +136,7 @@ public class PNFSWUPDownloadTest extends BaseBPMNTest { } } catch (Exception e) { e.printStackTrace(); - fail("PNFSWUPDownload request exception", e); + fail("GenericPnfSWUPDownload request exception", e); } assertThat(count == actionNames.length); } @@ -152,7 +152,8 @@ public class PNFSWUPDownloadTest extends BaseBPMNTest { ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); /** - * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + * the fields of actionIdentifiers should match the one in the + * response/GenericPnfSoftwareUpgradeTest_catalogdb.json. */ Assertions.assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); Assertions.assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); @@ -202,7 +203,8 @@ public class PNFSWUPDownloadTest extends BaseBPMNTest { */ private void mockCatalogDb() { - String catalogdbClientResponse = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest_catalogdb.json"); + String catalogdbClientResponse = + FileUtil.readResourceFile("response/GenericPnfSoftwareUpgradeTest_catalogdb.json"); /** diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSoftwareUpgradeTest.java index 0bf14d7443..de81f91e66 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSoftwareUpgradeTest.java @@ -49,15 +49,15 @@ import static org.assertj.core.api.Assertions.fail; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; /** - * Basic Integration test for PNFSoftwareUpgrade.bpmn workflow. + * Basic Integration test for GenericPnfSoftwareUpgrade.bpmn workflow. */ -public class PNFSoftwareUpgradeTest extends BaseBPMNTest { +public class GenericPnfSoftwareUpgradeTest extends BaseBPMNTest { private final Logger logger = LoggerFactory.getLogger(getClass()); private static final long WORKFLOW_WAIT_TIME = 1000L; - private static final String TEST_PROCESSINSTANCE_KEY = "PNFSoftwareUpgrade"; + private static final String TEST_PROCESSINSTANCE_KEY = "GenericPnfSoftwareUpgrade"; private static final AAIVersion VERSION = AAIVersion.LATEST; private static final Map<String, Object> executionVariables = new HashMap(); private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5"; @@ -140,7 +140,7 @@ public class PNFSoftwareUpgradeTest extends BaseBPMNTest { } } catch (Exception e) { e.printStackTrace(); - fail("PNFSoftwareUpgrade request exception", e); + fail("GenericPnfSoftwareUpgrade request exception", e); } assertThat(count == actionNames.length); } @@ -156,7 +156,8 @@ public class PNFSoftwareUpgradeTest extends BaseBPMNTest { ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); /** - * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + * the fields of actionIdentifiers should match the one in the + * response/GenericPnfSoftwareUpgrade_catalogdb.json. */ assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java index 805597cd12..4322ff5bdf 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java @@ -20,7 +20,19 @@ package org.onap.so.bpmn.infrastructure.process; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; import org.junit.Test; @@ -35,14 +47,6 @@ import org.onap.so.bpmn.mock.FileUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static org.assertj.core.api.Assertions.fail; -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; /** * Basic Integration test for ServiceLevelUpgrade.bpmn workflow. @@ -58,7 +62,8 @@ public class ServiceLevelUpgradeTest extends BaseBPMNTest { private static final Map<String, Object> executionVariables = new HashMap(); private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5"; private static final String SERVICE_INSTANCE_ID = "5df8b6de-2083-11e7-93ae-92361f002676"; - private final String[] actionNames = new String[5]; + private final String[] actionNames = new String[10]; + private final String[] pnfNames = new String[10]; private final String CLASSNAME = getClass().getSimpleName(); private String requestObject; private String responseObject; @@ -69,10 +74,26 @@ public class ServiceLevelUpgradeTest extends BaseBPMNTest { @Before public void setUp() throws IOException { actionNames[0] = "healthCheck"; - actionNames[1] = "preCheck"; - actionNames[2] = "downloadNESw"; - actionNames[3] = "activateNESw"; - actionNames[4] = "postCheck"; + actionNames[1] = "healthCheck"; + actionNames[2] = "preCheck"; + actionNames[3] = "downloadNESw"; + actionNames[4] = "activateNESw"; + actionNames[5] = "postCheck"; + actionNames[6] = "preCheck"; + actionNames[7] = "downloadNESw"; + actionNames[8] = "activateNESw"; + actionNames[9] = "postCheck"; + + pnfNames[0] = "PNFDemo"; + pnfNames[1] = "PNFDemo1"; + pnfNames[2] = "PNFDemo"; + pnfNames[3] = "PNFDemo"; + pnfNames[4] = "PNFDemo"; + pnfNames[5] = "PNFDemo"; + pnfNames[6] = "PNFDemo1"; + pnfNames[7] = "PNFDemo1"; + pnfNames[8] = "PNFDemo1"; + pnfNames[9] = "PNFDemo1"; executionVariables.clear(); @@ -121,27 +142,27 @@ public class ServiceLevelUpgradeTest extends BaseBPMNTest { } // Layout is to reflect the bpmn visual layout - assertThat(pi).isEnded().hasPassedInOrder("Event_02mc8tr", "Activity_18vue7u", "Activity_0qgmx7a", - "Activity_09bqns0", "Activity_0n17xou", "Gateway_1nr51kr", "Activity_0snmatn", "Activity_1q4o9fx", - "Gateway_02fectw", "Activity_1hp67qz", "Gateway_18ch73t", "Activity_0ft7fa2", "Gateway_1vq11i7", - "Activity_1n4rk7m", "Activity_1lz38px", "Event_12983th"); + assertThat(pi).isEnded().hasPassedInOrder("Event_02mc8tr", "Activity_18vue7u", "Activity_09bqns0", + "Activity_02vp5np", "Activity_0n17xou", "Gateway_1nr51kr", "Activity_0snmatn", "Activity_0e6w886", + "Activity_1q4o9fx", "Gateway_02fectw", "Activity_1hp67qz", "Gateway_18ch73t", "Activity_0ft7fa2", + "Gateway_1vq11i7", "Activity_1n4rk7m", "Activity_1lz38px", "Event_12983th"); List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); assertThat(detailedMessages.size() == 5); int count = 0; + String action = ""; try { for (ExecutionServiceInput eSI : detailedMessages) { - for (String action : actionNames) { - if (action.equals(eSI.getActionIdentifiers().getActionName()) - && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { - checkWithActionName(eSI, action); - count++; - } + action = actionNames[count]; + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action, pnfNames[count]); + count++; } } } catch (Exception e) { e.printStackTrace(); - fail("PNFSoftwareUpgrade request exception", e); + fail("GenericPnfSoftwareUpgrade request exception", e); } assertThat(count == actionNames.length); } @@ -151,7 +172,8 @@ public class ServiceLevelUpgradeTest extends BaseBPMNTest { .singleResult() == null; } - private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) { + private void checkWithActionName(final ExecutionServiceInput executionServiceInput, final String action, + final String pnfName) { logger.info("Checking the " + action + " request"); ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); @@ -170,10 +192,10 @@ public class ServiceLevelUpgradeTest extends BaseBPMNTest { Struct payload = executionServiceInput.getPayload(); Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); - assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo(pnfName); Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); - assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo(pnfName); assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) .isEqualTo("d88da85c-d9e8-4f73-b837-3a72a431622b"); assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) @@ -184,26 +206,43 @@ public class ServiceLevelUpgradeTest extends BaseBPMNTest { final String sIUrl = "/business/customers/customer/5df8b6de-2083-11e7-93ae-92361f002676/service-subscriptions/service-subscription/pNF/service-instances/service-instance/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce"; - final String aaiPnfEntry = FileUtil.readResourceFile("response/Pnf_aai.json"); + final String aaiPnfDemoEntry = FileUtil.readResourceFile("response/PnfDemo_aai.json"); + final String aaiPnfDemo1Entry = FileUtil.readResourceFile("response/PnfDemo1_aai.json"); final String aaiServiceInstanceEntry = FileUtil.readResourceFile("response/Service_instance_aai.json"); /** - * PUT the PNF correlation ID to AAI. + * PUT the PNF correlation ID PnfDemo to AAI. */ wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); /** - * Get the PNF entry from AAI. + * PUT the PNF correlation ID PnfDemo1 to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo1"))); + + /** + * Get the PNF entry PnfDemo from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfDemoEntry))); + + /** + * Get the PNF entry PnfDemo1 from AAI. */ wireMockServer.stubFor( - get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo1")).willReturn(okJson(aaiPnfDemo1Entry))); /** - * Post the pnf to AAI + * Post the pnf PnfDemo to AAI */ wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); /** + * Post the pnf PnfDemo1 to AAI + */ + wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo1"))); + + /** * Get the Service Instance to AAI. */ wireMockServer.stubFor(get(urlEqualTo("/aai/" + VERSION + sIUrl)).willReturn(okJson(aaiServiceInstanceEntry))); diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/GenericPnfSoftwareUpgradeTest.json index a101118623..a101118623 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/GenericPnfSoftwareUpgradeTest.json diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest.json index 32539844ba..32539844ba 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest.json diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest_catalogdb.json index faec947fec..faec947fec 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest_catalogdb.json diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfDemo1_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfDemo1_aai.json new file mode 100644 index 0000000000..189d2c5a9b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfDemo1_aai.json @@ -0,0 +1,42 @@ +{ + "pnf-name": "PNFDemo1", + "pnf-id": "37c6e19d-6d9f-4085-98a9-d3fcbaf3a616", + "equip-type": "val8", + "equip-vendor": "Ericsson", + "equip-model": "val6", + "ipaddress-v4-oam": "10.10.10.44", + "sw-version": "5gDUv18.05.201", + "in-maint": false, + "serial-number": "7061ZW3", + "ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab", + "resource-version": "1595010038094", + "nf-role": "gNB", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "related-link": "/aai/v11/business/customers/customer/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce/service-subscriptions/service-subscription/pNF/service-instances/service-instance/5df8b6de-2083-11e7-93ae-92361f002676", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "pNF" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5df8b6de-2083-11e7-93ae-92361f002676" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269" + } + ] + } + ] + } +},
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfDemo_aai.json index 865600c800..865600c800 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PnfDemo_aai.json diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json index 53fb210478..8ea4263bbe 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json @@ -29,6 +29,16 @@ "relationship-value": "PNFDemo" } ] + }, + { + "related-to": "pnf", + "related-link": "/aai/v11/network/pnfs/pnf/PNFDemo1", + "relationship-data": [ + { + "relationship-key": "pnf.pnf-name", + "relationship-value": "PNFDemo1" + } + ] } ] } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapter.java new file mode 100644 index 0000000000..c21b467a95 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapter.java @@ -0,0 +1,36 @@ +package org.onap.so.bpmn.infrastructure.adapter.cnf.tasks; + +import java.io.IOException; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowAction; +import org.onap.so.client.adapter.cnf.CnfAdapterClient; +import org.onap.so.client.adapter.cnf.CnfAdapterClientException; +import org.onap.so.client.adapter.cnf.entities.InstanceRequest; +import org.onap.so.client.adapter.cnf.entities.InstanceResponse; +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.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class CnfAdapter { + + @Autowired + private CnfAdapterClient cnfAdapterClient; + + private static final Logger logger = LoggerFactory.getLogger(CnfAdapter.class); + + public void callCnfAdapter(DelegateExecution execution) throws Exception { + try { + final String instanceRequest = (String) execution.getVariable("instanceRequest"); + InstanceRequest request = new ObjectMapper().readValue(instanceRequest, InstanceRequest.class); + InstanceResponse response = cnfAdapterClient.createVfModule(request); + } catch (Exception ex) { + logger.error("Exception in callCnfAdapter", ex); + throw ex; + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java new file mode 100644 index 0000000000..93d30512b6 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java @@ -0,0 +1,121 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.adapter.cnf.tasks; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.cnf.CnfAdapterClient; +import org.onap.so.client.adapter.cnf.entities.InstanceRequest; +import org.onap.so.client.adapter.cnf.entities.InstanceResponse; +import org.onap.so.client.adapter.vnf.mapper.AttributeNameValue; +import org.onap.so.client.adapter.vnf.mapper.Attributes; +import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.openstack.utils.MsoMulticloudUtils; +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.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class CnfAdapterCreateTasks { + private static final Logger logger = LoggerFactory.getLogger(CnfAdapterCreateTasks.class); + public static final String SDNCQUERY_RESPONSE = "SDNCQueryResponse_"; + + @Autowired + private ExtractPojosForBB extractPojosForBB; + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private CnfAdapterClient cnfAdapterClient; + @Autowired + private VnfAdapterVfModuleObjectMapper vfModuleMapper; + + private ObjectMapper mapper = new ObjectMapper(); + + /** + * This method is used for creating the request for an Instance in Multicloud K8s Plugin. + * + * @param execution + * @return + */ + public void createInstance(BuildingBlockExecution execution) { + try { + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + ServiceInstance serviceInstance = + gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0); + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + RequestContext requestContext = gBBInput.getRequestContext(); + CloudRegion cloudRegion = gBBInput.getCloudRegion(); + String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId()); + String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId()); + Map<String, Object> paramsMap = vfModuleMapper.buildVfModuleParamsMap(requestContext, serviceInstance, + genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse); + Map<String, String> sdncDirectives = getSdncDirectives(paramsMap); + InstanceRequest createInstanceRequest = createInstanceRequest(vfModule, cloudRegion, sdncDirectives); + InstanceResponse response = cnfAdapterClient.createVfModule(createInstanceRequest); + execution.setVariable("heatStackId", response.getId()); + } catch (Exception ex) { + logger.error("Exception occurred", ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + protected Map<String, String> getSdncDirectives(Map<String, Object> paramsMap) + throws JsonParseException, JsonMappingException, IOException { + Map<String, String> sdncDirectivesMap = new HashMap<>(); + String sdncDirectivesString = (String) paramsMap.get(MsoMulticloudUtils.SDNC_DIRECTIVES); + Attributes sdncDirectives = mapper.readValue(sdncDirectivesString, Attributes.class); + for (AttributeNameValue nameVal : sdncDirectives.getAttributes()) { + sdncDirectivesMap.put(nameVal.getAttributeName(), (String) nameVal.getAttributeValue()); + } + return sdncDirectivesMap; + } + + protected InstanceRequest createInstanceRequest(VfModule vfModule, CloudRegion cloudRegion, + Map<String, String> sdncDirectives) { + InstanceRequest request = new InstanceRequest(); + request.setRbName(vfModule.getModelInfoVfModule().getModelInvariantUUID()); + request.setRbVersion(vfModule.getModelInfoVfModule().getModelUUID()); + request.setCloudRegion(cloudRegion.getLcpCloudRegionId()); + request.setReleaseName(vfModule.getVfModuleId()); + request.setProfileName(sdncDirectives.get("k8s-rb-profile-name")); + request.setOverrideValues(sdncDirectives); + return request; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevel.java index 0671354bd6..b8f5ec9674 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevel.java @@ -20,32 +20,63 @@ package org.onap.so.bpmn.infrastructure.service.level; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import jline.internal.Log; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.Workflow; +import org.onap.so.db.catalog.client.CatalogDbClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; -import java.util.List; /** - * Abstract class for Service level upgrade Execution, it should be extended for service level upgrade tasks. + * Parent class for Service level upgrade Execution, it should be extended for service level upgrade tasks. */ -public abstract class AbstractServiceLevelPreparable { +public class ServiceLevel { - protected static final Logger LOG = LoggerFactory.getLogger(AbstractServiceLevelPreparable.class); + protected static final Logger LOG = LoggerFactory.getLogger(ServiceLevel.class); @Autowired protected ExceptionBuilder exceptionBuilder; + @Autowired + protected CatalogDbClient catalogDbClient; + + private static final String PNF_NAME_LIST = "pnfNameList"; + + private static final String PNF_COUNTER = "pnfCounter"; + /** - * This method fetches workflow names to be invoked based on the controller scope . + * Fetches workflow names based on the controller scope and operation name. * * @param scope Controller scope + * @param operationName healthcheck/softwareUpgrade * @return String value of Workflow name */ - protected abstract String fetchWorkflowUsingScope(DelegateExecution execution, final String scope); + protected String fetchWorkflowUsingScope(final String scope, String operationName) { + Optional<String> wflName = Optional.empty(); + try { + List<Workflow> workflows = catalogDbClient.findWorkflowByOperationName(operationName); + if (!workflows.isEmpty()) { + wflName = Optional.ofNullable( + workflows.stream().filter(workflow -> workflow.getResourceTarget().equalsIgnoreCase(scope)) + .findFirst().get().getName()); + } + } catch (Exception e) { + // do nothing and assign the default workflow in finally + LOG.error("Error occurred while fetching workflow name from CatalogDb {}", e); + } finally { + if (wflName.isEmpty()) { + wflName = Optional.of(ServiceLevelConstants.WORKFLOW_OPERATIONS_MAP.get(operationName).get(scope)); + } + } + return wflName.get(); + + } /** * This method validates the execution parameters to be passed for health check workflow. @@ -69,4 +100,20 @@ public abstract class AbstractServiceLevelPreparable { } + /** + * This method set correct value of pnf name for health check and software upgrade workflow. + * + * @param delegateExecution Delegate execution obj + */ + public void pnfCounterExecution(DelegateExecution delegateExecution) { + LOG.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(), + delegateExecution.getCurrentActivityName()); + + final List<String> pnfNameList = (List<String>) delegateExecution.getVariable(PNF_NAME_LIST); + final int pnfCounter = (int) delegateExecution.getVariable(PNF_COUNTER); + + delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME, pnfNameList.get(pnfCounter)); + delegateExecution.setVariable(PNF_COUNTER, pnfCounter + 1); + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java index 34ebb308c3..b0b12b5276 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java @@ -1,5 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.service.level.impl; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + public class ServiceLevelConstants { public static final String BPMN_REQUEST = "bpmnRequest"; public static final String RESOURCE_TYPE = "resourceType"; @@ -8,13 +32,31 @@ public class ServiceLevelConstants { public static final String PNF = "pnf"; public static final String VNF = "vnf"; public static final String EMPTY_STRING = ""; - public static final String WORKFLOW_TO_INVOKE = "healthCheckWorkflow"; + public static final String HEALTH_CHECK_WORKFLOW_TO_INVOKE = "healthCheckWorkflow"; public static final String SOFTWARE_WORKFLOW_TO_INVOKE = "softwareUpgradeWorkflow"; - public static final String GENERIC_PNF_HEALTH_CHECK_WORKFLOW = "GenericPnfHealthCheck"; - public static final String PNF_SOFTWARE_UPGRADE_WORKFLOW = "PNFSoftwareUpgrade"; + public static final String HEALTH_CHECK_OPERATION = "ResourceHealthCheck"; + public static final String SW_UP_OPERATION = "ResourceSoftwareUpgrade"; public static final String CONTROLLER_STATUS = "ControllerStatus"; public static final int ERROR_CODE = 601; - // TODO This value needs to be updated once vnf health check workflow is available - protected static final String GENERIC_VNF_HEALTH_CHECK_WORKFLOW = "GenericVNFHealthCheck"; + public static final String PNF_COUNTER = "pnfCounter"; + public static final int COUNT_ZERO = 0; + public static final String PNF_NAME_LIST = "pnfNameList"; + public static final String PNF_SIZE = "pnfSize"; + + // TODO GenericVNFHealthCheck and GenericVnfSoftwareUpgrade workflow names should be updated once the workflow is + // implemented. + public static final Map<String, String> DEFAULT_HEALTH_CHECK_WORKFLOWS = + Map.of(PNF, "GenericPnfHealthCheck", VNF, "GenericVNFHealthCheck"); + + public static final Map<String, String> DEFAULT_SOFTWARE_UP_WORKFLOWS = + Map.of(PNF, "GenericPnfSoftwareUpgrade", VNF, "GenericVnfSoftwareUpgrade"); + + // Maps operation name with workflows + public static final Map<String, Map<String, String>> WORKFLOW_OPERATIONS_MAP = Map.of(HEALTH_CHECK_OPERATION, + DEFAULT_HEALTH_CHECK_WORKFLOWS, SW_UP_OPERATION, DEFAULT_SOFTWARE_UP_WORKFLOWS); + + public static final List<String> VALID_CONTROLLER_SCOPE = Arrays.asList(PNF, VNF); + + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java index fad28e315e..8e720c3e53 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java @@ -8,6 +8,6 @@ import org.springframework.stereotype.Component; public class ServiceLevelPostcheck implements JavaDelegate { @Override public void execute(DelegateExecution delegateExecution) throws Exception { - // TODO : Set serviceInstance to aai + // Write your postcheck operations here, if any } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java index 5b772760f0..6cb3461001 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java @@ -20,59 +20,58 @@ package org.onap.so.bpmn.infrastructure.service.level.impl; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable; +import org.onap.so.bpmn.infrastructure.service.level.ServiceLevel; import org.springframework.stereotype.Component; -import java.util.Arrays; -import java.util.List; + /** * Fetches health check workflow based on the controller_scope. Invoke the corresponding health check workflow after * validation. */ @Component("ServiceLevelPreparation") -public class ServiceLevelPreparation extends AbstractServiceLevelPreparable implements JavaDelegate { +public class ServiceLevelPreparation extends ServiceLevel implements JavaDelegate { + + private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, + ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST); - private static final List<String> PNF_HC_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, - ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME); + // TODO Update the list with vnf health check parameters if any validation needed + private static final List<String> VNF_HEALTH_CHECK_PARAMS = Collections.emptyList(); + + private static final Map<String, List<String>> HEALTH_CHECK_PARAMS_MAP = Map.of(ServiceLevelConstants.PNF, + PNF_HEALTH_CHECK_PARAMS, ServiceLevelConstants.VNF, VNF_HEALTH_CHECK_PARAMS); @Override public void execute(DelegateExecution execution) throws Exception { + LOG.debug("Running execute block for activity id: {}, name: {}", execution.getCurrentActivityId(), + execution.getCurrentActivityName()); + if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE) && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) { final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE); LOG.debug("Scope retrieved from delegate execution: " + controllerScope); - final String wflName = fetchWorkflowUsingScope(execution, controllerScope); - LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName); - - if (ServiceLevelConstants.PNF.equalsIgnoreCase(controllerScope)) { - validateParamsWithScope(execution, controllerScope, PNF_HC_PARAMS); + if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) { + final String wflName = + fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.HEALTH_CHECK_OPERATION); + LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName); + validateParamsWithScope(execution, controllerScope, HEALTH_CHECK_PARAMS_MAP.get(controllerScope)); LOG.info("Parameters validated successfully for {}", wflName); + execution.setVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE, wflName); + execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING); + execution.setVariable(ServiceLevelConstants.PNF_COUNTER, ServiceLevelConstants.COUNT_ZERO); + } else { + exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, + "Invalid Controller scope to prepare resource level health check"); } - execution.setVariable(ServiceLevelConstants.WORKFLOW_TO_INVOKE, wflName); - execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING); } else { exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, - "Controller scope not found to invoke resource level health check"); - } - } - - @Override - public String fetchWorkflowUsingScope(DelegateExecution execution, final String scope) { - String wflName = null; - switch (scope.toLowerCase()) { - case ServiceLevelConstants.PNF: - wflName = ServiceLevelConstants.GENERIC_PNF_HEALTH_CHECK_WORKFLOW; - break; - case ServiceLevelConstants.VNF: - wflName = ServiceLevelConstants.GENERIC_VNF_HEALTH_CHECK_WORKFLOW; - break; - default: - exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, - "No valid health check work flow retrieved for the scope: " + scope); + "Resource type not found in the execution to invoke resource level health check"); } - return wflName; } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java index 5b20a86cb7..5d9295dc95 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java @@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.service.level.impl; import com.fasterxml.jackson.databind.ObjectMapper; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aaiclient.client.aai.AAIRestClientI; import org.onap.aaiclient.client.aai.AAIRestClientImpl; @@ -34,7 +35,11 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.Optional; +import java.util.stream.Collector; +import java.util.stream.Collectors; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; /** @@ -83,21 +88,18 @@ public class ServiceLevelRequestDispatcher implements JavaDelegate { Optional<ServiceInstance> optionalSi = restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId); - if (!optionalSi.isPresent()) { - - } - optionalSi.ifPresentOrElse(serviceInstance -> { - final String pnfName = serviceInstance.getRelationshipList().getRelationship().stream() - .filter(x -> x.getRelatedTo().contains("pnf")).findFirst().get().getRelationshipData().stream() - .filter(data -> data.getRelationshipKey().contains("pnf.pnf-name")).findFirst().get() - .getRelationshipValue(); - if (pnfName == null || pnfName.isEmpty()) { + final List<String> pnfNameList = serviceInstance.getRelationshipList().getRelationship().stream() + .filter(x -> x.getRelatedTo().contains("pnf")).flatMap(x -> x.getRelationshipData().stream()) + .filter(data -> data.getRelationshipKey().contains("pnf.pnf-name")) + .map(x -> x.getRelationshipValue()).collect(Collectors.toList()); + if (pnfNameList == null || pnfNameList.size() == 0) { logger.warn( "Unable to find the PNF for service instance id: " + serviceInstance.getServiceInstanceId()); return; } - delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME, pnfName); + delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME_LIST, pnfNameList); + delegateExecution.setVariable(ServiceLevelConstants.PNF_SIZE, pnfNameList.size()); delegateExecution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.PNF); }, () -> { throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java index dfc77d6f0c..a3a8f6e714 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java @@ -1,54 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.service.level.impl; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable; +import org.onap.so.bpmn.infrastructure.service.level.ServiceLevel; import org.springframework.stereotype.Component; -import java.util.Arrays; -import java.util.List; @Component -public class ServiceLevelUpgrade extends AbstractServiceLevelPreparable implements JavaDelegate { +public class ServiceLevelUpgrade extends ServiceLevel implements JavaDelegate { - private static final List<String> PNF_SWU_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, - ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME); + private static final List<String> PNF_SOFTWARE_UP_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, + ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST); + + // TODO Update the list with vnf software upgrade parameters if any validation needed + private static final List<String> VNF_SOFTWARE_UP_PARAMS = Collections.emptyList(); + + private static final Map<String, List<String>> SOFTWARE_UP_PARAMS_MAP = Map.of(ServiceLevelConstants.PNF, + PNF_SOFTWARE_UP_PARAMS, ServiceLevelConstants.VNF, VNF_SOFTWARE_UP_PARAMS); - @Override - protected String fetchWorkflowUsingScope(DelegateExecution execution, String scope) { - String wflName = null; - switch (scope.toLowerCase()) { - case ServiceLevelConstants.PNF: - wflName = ServiceLevelConstants.PNF_SOFTWARE_UPGRADE_WORKFLOW; - break; - case ServiceLevelConstants.VNF: - wflName = ServiceLevelConstants.GENERIC_VNF_HEALTH_CHECK_WORKFLOW; - break; - default: - exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, - "No valid health check work flow retrieved for the scope: " + scope); - } - return wflName; - } @Override public void execute(DelegateExecution execution) throws Exception { + LOG.debug("Running execute block for activity id: {}, name: {}", execution.getCurrentActivityId(), + execution.getCurrentActivityName()); + if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE) && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) { final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE); LOG.debug("Scope retrieved from delegate execution: " + controllerScope); - final String wflName = fetchWorkflowUsingScope(execution, controllerScope); - LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName); - - if ("pnf".equalsIgnoreCase(controllerScope)) { - validateParamsWithScope(execution, controllerScope, PNF_SWU_PARAMS); + if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) { + final String wflName = fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.SW_UP_OPERATION); + LOG.debug("Software Upgrade workflow fetched for the scope: {} is: {}", controllerScope, wflName); + validateParamsWithScope(execution, controllerScope, SOFTWARE_UP_PARAMS_MAP.get(controllerScope)); LOG.info("Parameters validated successfully for {}", wflName); execution.setVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE, wflName); - execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ""); + execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING); + execution.setVariable(ServiceLevelConstants.PNF_COUNTER, ServiceLevelConstants.COUNT_ZERO); + } else { + exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, + "Invalid Controller scope for resource level software upgrade"); } - } else { exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, - "Controller scope not found to invoke resource level health check"); + "Resource type not found in the execution to invoke resource level software upgrade"); } } } 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 75d3ddf2e6..9b9433afdb 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 @@ -300,6 +300,9 @@ public class WorkflowAction { || ("recreateInstance".equalsIgnoreCase(requestAction)))) { traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds); + } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) { + customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), + workflowResourceIds.getVnfId(), aaiResourceIds); } else { buildAndThrowException(execution, "Current Macro Request is not supported"); } @@ -568,6 +571,10 @@ public class WorkflowAction { WorkflowResourceIds workflowIdsCopy = SerializationUtils.clone(dataObj.getWorkflowResourceIds()); org.onap.aai.domain.yang.Configuration configuration = getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION); + if (configuration == null) { + logger.warn(String.format("No configuration found for VNFC %s in AAI", vnfc.getVnfcName())); + continue; + } workflowIdsCopy.setConfigurationId(configuration.getConfigurationId()); for (OrchestrationFlow orchFlow : result) { dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID); @@ -584,7 +591,6 @@ public class WorkflowAction { dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), workflowIdsCopy, dataObj.getRequestDetails(), false, null, vnfcName, true, null); flowsToExecuteConfigs.add(ebb); - } } return flowsToExecuteConfigs; @@ -1108,6 +1114,51 @@ public class WorkflowAction { } } + private void customTraverseAAIVnf(DelegateExecution execution, List<Resource> resourceList, String serviceId, + String vnfId, List<Pair<WorkflowType, String>> aaiResourceIds) { + try { + ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId); + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = + bbInputSetup.getExistingServiceInstance(serviceInstanceAAI); + resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false)); + if (serviceInstanceMSO.getVnfs() != null) { + for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) { + if (vnf.getVnfId().equals(vnfId)) { + aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); + + String vnfCustomizationUUID = + bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(); + resourceList.add(new Resource(WorkflowType.VNF, vnfCustomizationUUID, false)); + + if (vnf.getVfModules() != null) { + for (VfModule vfModule : vnf.getVfModules()) { + aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); + resourceList.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false)); + findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(), + resourceList, aaiResourceIds); + } + } + if (vnf.getVolumeGroups() != null) { + for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf + .getVolumeGroups()) { + aaiResourceIds + .add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId())); + resourceList.add( + new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false)); + } + } + break; + } + } + } + } catch (Exception ex) { + logger.error("Exception in customTraverseAAIVnf", ex); + buildAndThrowException(execution, + "Could not find existing Vnf or related Instances to execute the request on."); + } + + } + private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId, List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds) { try { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java new file mode 100644 index 0000000000..f44c15ac54 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java @@ -0,0 +1,97 @@ +/*- + * ============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.client.adapter.cnf; + +import java.util.ArrayList; +import java.util.List; +import javax.persistence.EntityNotFoundException; +import javax.ws.rs.core.UriBuilder; +import org.apache.http.HttpStatus; +import org.onap.so.client.adapter.cnf.entities.InstanceRequest; +import org.onap.so.client.adapter.cnf.entities.InstanceResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.retry.annotation.Backoff; +import org.springframework.retry.annotation.Retryable; +import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpServerErrorException; +import org.springframework.web.client.RestTemplate; + +@Component +public class CnfAdapterClient { + + private static final Logger logger = LoggerFactory.getLogger(CnfAdapterClient.class); + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private Environment env; + + private static final String INSTANCE_CREATE_PATH = "/api/multicloud-k8s/v1/v1/instance"; + + @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000)) + public InstanceResponse createVfModule(InstanceRequest request) throws CnfAdapterClientException { + try { + // String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well + // for configuration + String uri = "https://localhost:32780"; // TODO: What is the correct uri? + String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString(); + HttpEntity<?> entity = getHttpEntity(request); + ResponseEntity<InstanceResponse> result = + restTemplate.exchange(endpoint, HttpMethod.POST, entity, InstanceResponse.class); + return result.getBody(); + } catch (HttpClientErrorException e) { + logger.error("Error Calling CNF Adapter, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } + } + + protected HttpHeaders getHttpHeaders() { + HttpHeaders headers = new HttpHeaders(); + List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>(); + acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON); + headers.setAccept(acceptableMediaTypes); + /* + * try { String userCredentials = CryptoUtils.decrypt(env.getRequiredProperty("mso.cnf.adapter.auth"), + * env.getRequiredProperty("mso.msoKey")); if (userCredentials != null) { headers.add(HttpHeaders.AUTHORIZATION, + * "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes())); } } catch + * (GeneralSecurityException e) { logger.error("Security exception", e); } + */ + return headers; + } + + protected HttpEntity<?> getHttpEntity(InstanceRequest request) { + HttpHeaders headers = getHttpHeaders(); + return new HttpEntity<>(request, headers); + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentStatus.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClientException.java index f7d6a9d214..d716070ffa 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentStatus.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClientException.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -18,14 +18,17 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.beans; +package org.onap.so.client.adapter.cnf; +public class CnfAdapterClientException extends Exception { -/* - * Enum status values to capture the state of a deployment, based on last known workflow (assume only INSTALL and - * UNINSTALL at this point). - */ -public enum DeploymentStatus { - NOTFOUND, CREATED, INSTALLED, FAILED, INSTALLING, UNINSTALLING, UNKNOWN -} + /** + * + */ + private static final long serialVersionUID = -7154784472485852602L; + public CnfAdapterClientException(String message) { + super(message); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/GVK.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/GVK.java new file mode 100644 index 0000000000..3ed6894fcf --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/GVK.java @@ -0,0 +1,49 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"Group", "Version", "Kind"}) +public class GVK { + + @JsonProperty("Group") + private String group; + @JsonProperty("Version") + private String version; + @JsonProperty("Kind") + private String kind; + + @JsonProperty("Group") + public String getGroup() { + return group; + } + + @JsonProperty("Group") + public void setGroup(String group) { + this.group = group; + } + + @JsonProperty("Version") + public String getVersion() { + return version; + } + + @JsonProperty("Version") + public void setVersion(String version) { + this.version = version; + } + + @JsonProperty("Kind") + public String getKind() { + return kind; + } + + @JsonProperty("Kind") + public void setKind(String kind) { + this.kind = kind; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java new file mode 100644 index 0000000000..e4058097ab --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java @@ -0,0 +1,95 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"rb-name", "rb-version", "profile-name", "release-name", "cloud-region", "labels", + "override-values"}) +public class InstanceRequest { + + @JsonProperty("rb-name") + private String rbName; + @JsonProperty("rb-version") + private String rbVersion; + @JsonProperty("profile-name") + private String profileName; + @JsonProperty("release-name") + private String releaseName; + @JsonProperty("cloud-region") + private String cloudRegion; + @JsonProperty("labels") + private Labels labels; + @JsonProperty(value = "override-values") + private Map<String, String> overrideValues; + + @JsonProperty("rb-name") + public String getRbName() { + return rbName; + } + + @JsonProperty("rb-name") + public void setRbName(String rbName) { + this.rbName = rbName; + } + + @JsonProperty("rb-version") + public String getRbVersion() { + return rbVersion; + } + + @JsonProperty("rb-version") + public void setRbVersion(String rbVersion) { + this.rbVersion = rbVersion; + } + + @JsonProperty("profile-name") + public String getProfileName() { + return profileName; + } + + @JsonProperty("profile-name") + public void setProfileName(String profileName) { + this.profileName = profileName; + } + + @JsonProperty("cloud-region") + public String getCloudRegion() { + return cloudRegion; + } + + @JsonProperty("cloud-region") + public void setCloudRegion(String cloudRegion) { + this.cloudRegion = cloudRegion; + } + + @JsonProperty("labels") + public Labels getLabels() { + return labels; + } + + @JsonProperty("labels") + public void setLabels(Labels labels) { + this.labels = labels; + } + + public String getReleaseName() { + return releaseName; + } + + public void setReleaseName(String releaseName) { + this.releaseName = releaseName; + } + + public Map<String, String> getOverrideValues() { + return overrideValues; + } + + public void setOverrideValues(Map<String, String> overrideValues) { + this.overrideValues = overrideValues; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java new file mode 100644 index 0000000000..e38bcc2664 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java @@ -0,0 +1,62 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"id", "request", "namespace", "resources"}) +public class InstanceResponse { + + @JsonProperty("id") + private String id; + @JsonProperty("request") + private InstanceRequest request; + @JsonProperty("namespace") + private String namespace; + @JsonProperty("resources") + private List<Resource> resources = null; + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("id") + public void setId(String id) { + this.id = id; + } + + @JsonProperty("request") + public InstanceRequest getRequest() { + return request; + } + + @JsonProperty("request") + public void setRequest(InstanceRequest request) { + this.request = request; + } + + @JsonProperty("namespace") + public String getNamespace() { + return namespace; + } + + @JsonProperty("namespace") + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + @JsonProperty("resources") + public List<Resource> getResources() { + return resources; + } + + @JsonProperty("resources") + public void setResources(List<Resource> resources) { + this.resources = resources; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Labels.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Labels.java new file mode 100644 index 0000000000..1df2e59459 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Labels.java @@ -0,0 +1,25 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"testCaseName"}) +public class Labels { + + @JsonProperty("testCaseName") + private String testCaseName; + + @JsonProperty("testCaseName") + public String getTestCaseName() { + return testCaseName; + } + + @JsonProperty("testCaseName") + public void setTestCaseName(String testCaseName) { + this.testCaseName = testCaseName; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Resource.java new file mode 100644 index 0000000000..bde495aaa2 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Resource.java @@ -0,0 +1,37 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"GVK", "Name"}) +public class Resource { + + @JsonProperty("GVK") + private GVK gVK; + @JsonProperty("Name") + private String name; + + @JsonProperty("GVK") + public GVK getGVK() { + return gVK; + } + + @JsonProperty("GVK") + public void setGVK(GVK gVK) { + this.gVK = gVK; + } + + @JsonProperty("Name") + public String getName() { + return name; + } + + @JsonProperty("Name") + public void setName(String name) { + this.name = name; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/Attributes.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/Attributes.java new file mode 100644 index 0000000000..6d79c20616 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/Attributes.java @@ -0,0 +1,23 @@ +package org.onap.so.client.adapter.vnf.mapper; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Attributes implements Serializable { + + private static final long serialVersionUID = -5782985934617532582L; + + @JsonProperty("attributes") + private List<AttributeNameValue> attributes = new ArrayList<>(); + + public List<AttributeNameValue> getAttributes() { + return attributes; + } + + public void setAttributes(List<AttributeNameValue> attributes) { + this.attributes = attributes; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index bc618e17de..59da22f8e1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -178,7 +178,7 @@ public class VnfAdapterVfModuleObjectMapper { return msoRequest; } - private Map<String, Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, + public Map<String, Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws IOException, MissingValueTagException { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java index 340b2776a4..0b1c5b0f5e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java @@ -20,6 +20,13 @@ package org.onap.so.bpmn.infrastructure.service.level; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; @@ -27,23 +34,16 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants; import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelPreparation; import org.onap.so.client.exception.ExceptionBuilder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import static org.assertj.core.api.Assertions.assertThat; +import org.onap.so.db.catalog.beans.Workflow; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {ServiceLevelPreparation.class, ExceptionBuilder.class}) -public class ServiceLevelPreparationTest { +public class ServiceLevelPreparationTest extends BaseTaskTest { private static final String TEST_PNF_SCOPE = "pnf"; private static final String TEST_PROCESS_KEY = "testProcessKey"; @@ -52,42 +52,29 @@ public class ServiceLevelPreparationTest { private static final String RESOURCE_TYPE = "resourceType"; private static final String SERVICE_INSTANCE_ID = "serviceInstanceId"; private static final String PNF_NAME = "pnfName"; - private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, - ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME); + private static final String HEALTH_CHECK_OPERATION = "ResourceHealthCheck"; + private static final String PNF_HEALTH_CHECK_WORKFLOW = "PNFHealthCheck"; + private static final Map<String, List<String>> HEALTH_CHECK_PARAMS_MAP = Map.of(TEST_PNF_SCOPE, + Arrays.asList(SERVICE_INSTANCE_ID, RESOURCE_TYPE, BPMN_REQUEST, PNF_NAME), "vnf", Collections.emptyList()); + + private List<Workflow> workflowList = new ArrayList<>(); - private Map<String, String> pnfHealthCheckTestParams = new HashMap<>(); + @Rule + public ExpectedException thrown = ExpectedException.none(); - @Autowired + @InjectMocks private ServiceLevelPreparation serviceLevelPrepare; - @Autowired + @InjectMocks + @Spy private ExceptionBuilder exceptionBuilder; - @Rule - public ExpectedException thrown = ExpectedException.none(); - private DelegateExecution execution = new DelegateExecutionFake(); private DelegateExecution invalidExecution = new DelegateExecutionFake(); @Before public void setUpPnfUpgradeTest() { - pnfHealthCheckTestParams.put("TEST_SERVICE_MODEL_INFO", "d4c6855e-3be2-5dtu-9390-c999a38829bc"); - pnfHealthCheckTestParams.put("TEST_SERVICE_INSTANCE_NAME", "test_service_id"); - pnfHealthCheckTestParams.put("TEST_PNF_CORRELATION_ID", "pnfCorrelationId"); - pnfHealthCheckTestParams.put("TEST_MODEL_UUID", "6bc0b04d-1873-4721-b53d-6615225b2a28"); - pnfHealthCheckTestParams.put("TEST_PNF_UUID", "c93g70d9-8de3-57f1-7de1-f5690ac2b005"); - pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_NAME", "serviceUpgrade"); - pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_VERSION", "1.0.2"); - pnfHealthCheckTestParams.put("TEST_PRC_CUSTOMIZATION_UUID", "PRC_customizationUuid"); - pnfHealthCheckTestParams.put("TEST_RESOURCE_CUSTOMIZATION_UUID_PARAM", "9acb3a83-8a52-412c-9a45-901764938144"); - pnfHealthCheckTestParams.put("TEST_PRC_INSTANCE_NAME", "Demo_pnf"); - pnfHealthCheckTestParams.put("TEST_PRC_CONTROLLER_ACTOR", "cds"); - pnfHealthCheckTestParams.put("TEST_REQUEST_PAYLOAD", "test_payload"); - - for (String param : PNF_HEALTH_CHECK_PARAMS) { - execution.setVariable(param, pnfHealthCheckTestParams.get("TEST_" + param)); - } execution.setVariable(RESOURCE_TYPE, TEST_PNF_SCOPE); execution.setVariable(TEST_PROCESS_KEY, PROCESS_KEY_VALUE); execution.setVariable(BPMN_REQUEST, "bpmnRequestValue"); @@ -95,14 +82,22 @@ public class ServiceLevelPreparationTest { execution.setVariable(PNF_NAME, "PnfDemo"); invalidExecution.setVariables(execution.getVariables()); + + Workflow pnfWorkflow = new Workflow(); + pnfWorkflow.setName(PNF_HEALTH_CHECK_WORKFLOW); + pnfWorkflow.setOperationName(HEALTH_CHECK_OPERATION); + pnfWorkflow.setResourceTarget(TEST_PNF_SCOPE); + workflowList.add(pnfWorkflow); + + when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(workflowList); } @Test public void executePnfUpgradeSuccessTest() throws Exception { serviceLevelPrepare.execute(execution); // Expect the pnf health check workflow to be set in to execution if validation is successful - assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.WORKFLOW_TO_INVOKE))) - .isEqualTo("GenericPnfHealthCheck"); + assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE))) + .isEqualTo("PNFHealthCheck"); } @Test @@ -110,7 +105,8 @@ public class ServiceLevelPreparationTest { invalidExecution.removeVariable(BPMN_REQUEST); // BPMN exception is thrown in case of validation failure or invalid execution thrown.expect(BpmnError.class); - serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE, PNF_HEALTH_CHECK_PARAMS); + serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE, + HEALTH_CHECK_PARAMS_MAP.get(TEST_PNF_SCOPE)); } @Test @@ -129,6 +125,32 @@ public class ServiceLevelPreparationTest { } + @Test + public void validateDefaultWorkflowIsSetWithoutDBData() throws Exception { + // Mock empty workflow list in db response + when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(new ArrayList<Workflow>()); + serviceLevelPrepare.execute(execution); + // Expect default workflow gets assigned when workflow name not found in db. + assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE))) + .isEqualTo(ServiceLevelConstants.DEFAULT_HEALTH_CHECK_WORKFLOWS.get(TEST_PNF_SCOPE)); + } + + @Test + public void validateWorkflowSetFromDb() throws Exception { + Workflow vnfWorkflow = new Workflow(); + vnfWorkflow.setName("VNFHealthCheck"); + vnfWorkflow.setOperationName(HEALTH_CHECK_OPERATION); + vnfWorkflow.setResourceTarget("vnf"); + workflowList.add(vnfWorkflow); + // Mock db response with multiple worklfows mapped with same operation name + when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(workflowList); + serviceLevelPrepare.execute(execution); + + // Expect right workflow gets assigned from db based on the controller scope. + assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE))) + .isEqualTo(PNF_HEALTH_CHECK_WORKFLOW); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 407a844c4e..c1970ec32c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -1601,6 +1601,79 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void getConfigBuildingBlocksNullConfigurationTest() throws Exception { + String gAction = "deleteInstance"; + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES); + + WorkflowType resourceType = WorkflowType.VFMODULE; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("vnfId", "1234"); + execution.setVariable("vfModuleId", "vfModuleId1234"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); + ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); + RequestDetails requestDetails = sIRequest.getRequestDetails(); + String requestAction = "deleteInstance"; + String requestId = "9c944122-d161-4280-8594-48c06a9d96d5"; + boolean aLaCarte = true; + String apiVersion = "7"; + String vnfType = "vnfType"; + String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0"; + String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e"; + Resource resourceKey = new Resource(resourceType, key, aLaCarte); + WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution); + + List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", + "UnassignVfModuleBB", "DeleteFabricConfigurationBB"); + + ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest) + .setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution); + + org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); + vnf.setVnfId("vnf0"); + vnf.setModelCustomizationId("modelCustomizationId"); + when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf); + + org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); + vfModule.setModelCustomizationId("modelCustomizationId"); + + /* this is a test case where configuration for vnfc is null */ + org.onap.aai.domain.yang.Configuration config1 = null; + org.onap.aai.domain.yang.Configuration config2 = new org.onap.aai.domain.yang.Configuration(); + config2.setConfigurationId("config2"); + + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc1 = new org.onap.aai.domain.yang.Vnfc(); + vnfc1.setVnfcName("zauk53avetd02svm001"); + org.onap.aai.domain.yang.Vnfc vnfc2 = new org.onap.aai.domain.yang.Vnfc(); + vnfc2.setVnfcName("zauk53avetd02tvm001"); + vnfcs.add(vnfc1); + vnfcs.add(vnfc2); + + when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule); + doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), + eq(org.onap.aai.domain.yang.Vnfc.class), eq(AAIObjectType.VNFC)); + doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1), + eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2), + eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + + List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj); + + assertFalse(results.isEmpty()); + assertEquals(1, results.size()); + assertEquals("config2", results.get(0).getWorkflowResourceIds().getConfigurationId()); + assertEquals("zauk53avetd02tvm001", results.get(0).getConfigurationResourceKeys().getVnfcName()); + } + + @Test public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "VfModule"; diff --git a/cloudify-client/.gitignore b/cloudify-client/.gitignore deleted file mode 100644 index ae3c172604..0000000000 --- a/cloudify-client/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/cloudify-client/pom.xml b/cloudify-client/pom.xml deleted file mode 100644 index ccf2c4270e..0000000000 --- a/cloudify-client/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.so</groupId> - <artifactId>so</artifactId> - <version>1.7.1-SNAPSHOT</version> - </parent> - - <groupId>org.onap.so</groupId> - <artifactId>cloudify-client</artifactId> - <packaging>jar</packaging> - <name>Cloudify Rest Client</name> - <description>Java client for Cloudify REST interface</description> - - <build> - <finalName>${project.artifactId}-${project.version}</finalName> - <plugins> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <!--<version>2.6</version>--> - <version>3.0.2</version> - <configuration> - <classesDirectory>target/classes</classesDirectory> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.onap.so</groupId> - <artifactId>common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpcore</artifactId> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.6</version> - </dependency> - </dependencies> -</project> diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClient.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClient.java deleted file mode 100644 index d15fbf9322..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClient.java +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * ============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.cloudify.base.client; - -import java.util.Properties; -import org.onap.so.cloudify.connector.http.HttpClientConnector; - -public class CloudifyClient { - - protected String managerEndpoint; - protected String tenant = "default_tenant"; // Note - only default_tenant supported in community edition - - protected CloudifyTokenProvider tokenProvider; - - protected static int AUTHENTICATION_RETRIES = 1; - - protected CloudifyClientConnector connector; - - protected Properties properties = new Properties(); - - public CloudifyClient(String managerEndpoint) { - this.managerEndpoint = managerEndpoint; - this.connector = new HttpClientConnector(); - } - - public CloudifyClient(String managerEndpoint, String tenant) { - this.managerEndpoint = managerEndpoint; - this.tenant = tenant; - this.connector = new HttpClientConnector(); - } - - public CloudifyClient(String managerEndpoint, CloudifyClientConnector connector) { - this.managerEndpoint = managerEndpoint; - this.connector = connector; - } - - /** - * Execute a Cloudify request by making the REST API call. Return the complete CloudifyResponse structure, which - * includes the complete HTTP response. - * - * @param request a CloudifyRequest object - * @return a CloudifyResponse object - */ - public <T> CloudifyResponse request(CloudifyRequest<T> request) { - CloudifyResponseException authException = null; - - for (int i = 0; i <= AUTHENTICATION_RETRIES; i++) { - request.endpoint(managerEndpoint); - request.header("Tenant", tenant); - if (tokenProvider != null) - request.header("Authentication-Token", tokenProvider.getToken()); - - try { - return connector.request(request); - } catch (CloudifyResponseException e) { - if (e.getStatus() != CloudifyResponseStatus.NOT_AUTHORIZED || tokenProvider == null) { - throw e; - } - authException = e; - tokenProvider.expireToken(); - } - } - - if (authException != null) { - throw authException; - } - - return null; - } - - /** - * Execute a CloudifyRequest by sending the REST API call to the Cloudify Manager endpoint. The return type is a - * JSON POJO object containing the response body entity. - * - * @param request - * @return a JSON POJO object specific to the request type - */ - public <T> T execute(CloudifyRequest<T> request) { - CloudifyResponse response = request(request); - - if (null == response) { - return null; - } - - return (request.returnType() != null && request.returnType() != Void.class) - ? response.getEntity(request.returnType()) - : null; - } - - public void property(String property, String value) { - properties.put(property, value); - } - - /** - * Set a Token Provider. This class should be able to produce an authentication token on-demand. - * - * @param tokenProvider - */ - public void setTokenProvider(CloudifyTokenProvider tokenProvider) { - this.tokenProvider = tokenProvider; - } - - /** - * Manually set the authentication token to use for this client. - * - * @param token - */ - public void setToken(String token) { - setTokenProvider(new CloudifySimpleTokenProvider(token)); - } - - /** - * Perform a simple GET request with no request message body - * - * @param path - * @param returnType - * @return An object of Class <R> - */ - public <R> CloudifyRequest<R> get(String path, Class<R> returnType) { - return new CloudifyRequest<>(this, HttpMethod.GET, path, null, returnType); - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProvider.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProvider.java deleted file mode 100644 index c4dcc89d0b..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProvider.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============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.cloudify.base.client; - -import java.util.Date; -import org.apache.commons.lang.time.DateUtils; -import org.onap.so.cloudify.v3.client.Cloudify; -import org.onap.so.cloudify.v3.client.TokensResource.GetToken; -import org.onap.so.cloudify.v3.model.Token; - -/** - * Cloudify Token Provider that uses the Cloudify client API itself to obtain a token - * - * @author JC1348 - * - */ -public class CloudifyClientTokenProvider implements CloudifyTokenProvider { - - String user; - String password; - String token; - Date expiration; - Cloudify cloudify = null; - - public CloudifyClientTokenProvider(String cloudifyEndpoint, String user, String password) { - this.user = user; - this.password = password; - - cloudify = new Cloudify(cloudifyEndpoint); - } - - @Override - public String getToken() { - Date now = new Date(); - if (token != null && expiration != null && expiration.after(now)) { - return token; - } - - // Create a "Get Token" request. Force basic authentication to acquire the token itself. - GetToken tokenRequest = cloudify.tokens().token(); - tokenRequest.setBasicAuthentication(user, password); - Token newToken = tokenRequest.execute(); - - if (newToken != null) { - token = newToken.getValue(); - } - - if (expiration == null) { - expiration = new Date(); - } - // TODO: Make this property driven (or see if it comes back somehow in response) - expiration = DateUtils.addMinutes(expiration, 10); - - return token; - } - - @Override - /** - * This doesn't actually expire the token in Cloudify. It just prevents this token provider from using it. - */ - public void expireToken() { - expiration = null; - token = null; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyRequest.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyRequest.java deleted file mode 100644 index 006768f2f1..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyRequest.java +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * ============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.cloudify.base.client; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; - -public class CloudifyRequest<R> { - - private CloudifyClient client; - - private String endpoint; - - private HttpMethod method; - - private StringBuilder path = new StringBuilder(); - - private Map<String, List<Object>> headers = new HashMap<>(); - - private Entity<?> entity; - - private Class<R> returnType; - - private boolean basicAuth = false; - private String user = null; - private String password = null; - - public CloudifyRequest() { - - } - - public CloudifyRequest(CloudifyClient client, HttpMethod method, CharSequence path, Entity<?> entity, - Class<R> returnType) { - this.client = client; - this.method = method; - this.path = new StringBuilder(path); - this.entity = entity; - this.returnType = returnType; - header("Accept", "application/json"); - } - - public CloudifyRequest<R> endpoint(String endpoint) { - this.endpoint = endpoint; - return this; - } - - public String endpoint() { - return endpoint; - } - - public CloudifyRequest<R> method(HttpMethod method) { - this.method = method; - return this; - } - - public HttpMethod method() { - return method; - } - - public CloudifyRequest<R> path(String path) { - this.path.append(path); - return this; - } - - public String path() { - return path.toString(); - } - - public CloudifyRequest<R> header(String name, Object value) { - if (value != null) { - headers.put(name, Arrays.asList(value)); - } - return this; - } - - public Map<String, List<Object>> headers() { - return headers; - } - - public <T> Entity<T> entity(T entity, String contentType) { - return new Entity<>(entity, contentType); - } - - public Entity<?> entity() { - return entity; - } - - public <T> Entity<T> json(T entity) { - return entity(entity, "application/json"); - } - - public void returnType(Class<R> returnType) { - this.returnType = returnType; - } - - public Class<R> returnType() { - return returnType; - } - - /* - * Use Basic Authentication for this request. If not set, the client will use Token authentication if a token - * provider is defined. Otherwise, no authentication will be applied. - */ - public void setBasicAuthentication(String user, String password) { - this.basicAuth = true; - this.user = user; - this.password = password; - } - - public boolean isBasicAuth() { - return this.basicAuth; - } - - public String getUser() { - return user; - } - - public String getPassword() { - return password; - } - - public R execute() { - return client.execute(this); - } - - public CloudifyResponse request() { - return client.request(this); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CloudifyRequest [endpoint=" + endpoint + ", method=" + method + ", path=" + path + ", headers=" - + headers + ", entity=" + entity + ", returnType=" + returnType + "]"; - } - - private Map<String, List<Object>> queryParams = new LinkedHashMap<>(); - - public Map<String, List<Object>> queryParams() { - return queryParams; - } - - public CloudifyRequest<R> queryParam(String key, Object value) { - if (queryParams.containsKey(key)) { - List<Object> values = queryParams.get(key); - values.add(value); - } else { - List<Object> values = new ArrayList<>(); - values.add(value); - queryParams.put(key, values); - } - - return this; - } - - protected static String buildPath(String... elements) { - StringBuilder stringBuilder = new StringBuilder(); - for (String element : elements) { - stringBuilder.append(element); - } - - return stringBuilder.toString(); - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java deleted file mode 100644 index 0ca3212238..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============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.cloudify.base.client; - -import org.onap.so.cloudify.v3.model.CloudifyError; - -public class CloudifyResponseException extends CloudifyBaseException { - - private static final long serialVersionUID = 7294957362769575271L; - - private final String message; - private final int status; - - // Make the response available for exception handling (includes body) - private final CloudifyResponse response; - - public CloudifyResponseException(String message, int status) { - this.message = message; - this.status = status; - this.response = null; - } - - // Include the response message itself. The body is a CloudifyError JSON structure. - public CloudifyResponseException(String message, int status, CloudifyResponse response) { - CloudifyError error = response.getErrorEntity(CloudifyError.class); - this.message = message + ": " + error.getErrorCode(); - this.status = status; - this.response = response; - } - - public String getMessage() { - return message; - } - - public int getStatus() { - return status; - } - - public CloudifyResponse getResponse() { - return response; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/Entity.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/Entity.java deleted file mode 100644 index 095582fa51..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/Entity.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============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.cloudify.base.client; - -public class Entity<T> { - - private T entity; - - private String contentType; - - public static <T> Entity<T> json(T entity) { - return new Entity<T>(entity, "application/json"); - } - - public static <T> Entity<T> stream(T entity) { - return new Entity<T>(entity, "application/octet-stream"); - } - - public Entity(T entity, String contentType) { - super(); - this.entity = entity; - this.contentType = contentType; - } - - /** - * @return the entity - */ - public T getEntity() { - return entity; - } - - /** - * @param entity the entity to set - */ - public void setEntity(T entity) { - this.entity = entity; - } - - /** - * @return the contentType - */ - public String getContentType() { - return contentType; - } - - /** - * @param contentType the contentType to set - */ - public void setContentType(String contentType) { - this.contentType = contentType; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java deleted file mode 100644 index 54519bac72..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java +++ /dev/null @@ -1,246 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.connector.http; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.UnknownHostException; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.http.HttpEntity; -import org.apache.http.HttpStatus; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.HttpResponseException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.InputStreamEntity; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.BasicCredentialsProvider; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.onap.so.cloudify.base.client.CloudifyClientConnector; -import org.onap.so.cloudify.base.client.CloudifyConnectException; -import org.onap.so.cloudify.base.client.CloudifyRequest; -import org.onap.so.cloudify.base.client.CloudifyResponse; -import org.onap.so.cloudify.base.client.CloudifyResponseException; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonRootName; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class HttpClientConnector implements CloudifyClientConnector { - - private static ObjectMapper DEFAULT_MAPPER; - private static ObjectMapper WRAPPED_MAPPER; - - private static Logger logger = LoggerFactory.getLogger(HttpClientConnector.class); - - static { - DEFAULT_MAPPER = new ObjectMapper(); - - DEFAULT_MAPPER.setSerializationInclusion(Include.NON_NULL); - DEFAULT_MAPPER.disable(SerializationFeature.INDENT_OUTPUT); - DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); - DEFAULT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - - WRAPPED_MAPPER = new ObjectMapper(); - - WRAPPED_MAPPER.setSerializationInclusion(Include.NON_NULL); - WRAPPED_MAPPER.disable(SerializationFeature.INDENT_OUTPUT); - WRAPPED_MAPPER.enable(SerializationFeature.WRAP_ROOT_VALUE); - WRAPPED_MAPPER.enable(DeserializationFeature.UNWRAP_ROOT_VALUE); - WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); - WRAPPED_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - } - - protected static <T> ObjectMapper getObjectMapper(Class<T> type) { - return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER; - } - - public <T> CloudifyResponse request(CloudifyRequest<T> request) { - - CloseableHttpClient httpClient = null; - - if (request.isBasicAuth()) { - // Use Basic Auth for this request. - CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); - credentialsProvider.setCredentials(AuthScope.ANY, - new UsernamePasswordCredentials(request.getUser(), request.getPassword())); - - httpClient = HttpClients.custom().setRedirectStrategy(new HttpClientRedirectStrategy()) - .setDefaultCredentialsProvider(credentialsProvider).build(); - } else { - // Don't use basic authentication. The Client will attempt Token-based authentication - httpClient = HttpClients.custom().setRedirectStrategy(new HttpClientRedirectStrategy()).build(); - } - - URI uri = null; - - // Build the URI with query params - try { - URIBuilder uriBuilder = new URIBuilder(request.endpoint() + request.path()); - - for (Map.Entry<String, List<Object>> entry : request.queryParams().entrySet()) { - for (Object o : entry.getValue()) { - uriBuilder.setParameter(entry.getKey(), String.valueOf(o)); - } - } - - uri = uriBuilder.build(); - } catch (URISyntaxException e) { - throw new HttpClientException(e); - } - - HttpEntity entity = null; - if (request.entity() != null) { - // Special handling for streaming input - if (request.entity().getEntity() instanceof InputStream) { - // Entity is an InputStream - entity = new InputStreamEntity((InputStream) request.entity().getEntity()); - } else { - // Assume to be JSON. Flatten the entity to a Json string - try { - // Get appropriate mapper, based on existence of a root element in Entity class - ObjectMapper mapper = getObjectMapper(request.entity().getEntity().getClass()); - - String entityJson = mapper.writeValueAsString(request.entity().getEntity()); - entity = new StringEntity(entityJson, ContentType.create(request.entity().getContentType())); - - logger.debug("Request JSON Body: {}", - entityJson.replaceAll("\"password\":\"[^\"]*\"", "\"password\":\"***\"")); - - } catch (JsonProcessingException e) { - throw new HttpClientException("Json processing error on request entity", e); - } catch (IOException e) { - throw new HttpClientException("Json IO error on request entity", e); - } - } - } - - // Determine the HttpRequest class based on the method - HttpUriRequest httpRequest; - - switch (request.method()) { - case POST: - HttpPost post = new HttpPost(uri); - post.setEntity(entity); - httpRequest = post; - break; - - case GET: - httpRequest = new HttpGet(uri); - break; - - case PUT: - HttpPut put = new HttpPut(uri); - put.setEntity(entity); - httpRequest = put; - break; - - case DELETE: - httpRequest = new HttpDelete(uri); - break; - - default: - throw new HttpClientException("Unrecognized HTTP Method: " + request.method()); - } - - for (Entry<String, List<Object>> h : request.headers().entrySet()) { - StringBuilder sb = new StringBuilder(); - for (Object v : h.getValue()) { - sb.append(String.valueOf(v)); - } - httpRequest.addHeader(h.getKey(), sb.toString()); - } - - // Get the Response. But don't get the body entity yet, as this response - // will be wrapped in an HttpClientResponse. The HttpClientResponse - // buffers the body in constructor, so can close the response here. - HttpClientResponse httpClientResponse = null; - CloseableHttpResponse httpResponse = null; - - // Catch known HttpClient exceptions, and wrap them in OpenStack Client Exceptions - // so calling functions can distinguish. Only RuntimeExceptions are allowed. - try { - httpResponse = httpClient.execute(httpRequest); - - logger.debug("Response status: {}", httpResponse.getStatusLine().getStatusCode()); - - httpClientResponse = new HttpClientResponse(httpResponse); - - int status = httpResponse.getStatusLine().getStatusCode(); - if (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED || status == HttpStatus.SC_NO_CONTENT - || status == HttpStatus.SC_ACCEPTED) { - return httpClientResponse; - } - } catch (HttpResponseException e) { - // What exactly does this mean? It does not appear to get thrown for - // non-2XX responses as documented. - logger.error("Client HttpResponseException", e); - throw new CloudifyResponseException(e.getMessage(), e.getStatusCode()); - } catch (UnknownHostException e) { - logger.error("Client UnknownHostException", e); - throw new CloudifyConnectException("Unknown Host: " + e.getMessage()); - } catch (IOException e) { - // Catch all other IOExceptions and throw as OpenStackConnectException - logger.error("Client IOException", e); - throw new CloudifyConnectException(e.getMessage()); - } catch (Exception e) { - // Catchall for anything else, must throw as a RuntimeException - logger.error("Client exception", e); - throw new RuntimeException("Unexpected client exception", e); - } finally { - // Have the body. Close the stream - if (httpResponse != null) - try { - httpResponse.close(); - } catch (IOException e) { - logger.debug("Unable to close HTTP Response: ", e); - } - } - - // Get here on an error response (4XX-5XX) - if (httpResponse != null) { - throw new CloudifyResponseException(httpResponse.getStatusLine().getReasonPhrase(), - httpResponse.getStatusLine().getStatusCode(), httpClientResponse); - } else { - throw new CloudifyResponseException("Null httpResponse", 0, httpClientResponse); - } - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientException.java b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientException.java deleted file mode 100644 index 6f170baef5..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientException.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============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.cloudify.connector.http; - -/* - * Declare a RuntimeException since the Interface does not declare any throwables. Any caught exception will be wrapped - * in HttpClientException - */ -public class HttpClientException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public HttpClientException(String s) { - super(s); - } - - public HttpClientException(Exception e) { - super("Caught nested exception in HttpClient", e); - } - - public HttpClientException(String s, Exception e) { - super(s, e); - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategy.java b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategy.java deleted file mode 100644 index b8b4a5b018..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategy.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============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.cloudify.connector.http; - -import java.net.URI; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.methods.RequestBuilder; -import org.apache.http.impl.client.DefaultRedirectStrategy; -import org.apache.http.protocol.HttpContext; - -/** - * Custom {@link org.apache.http.client.RedirectStrategy} implementation that automatically redirects all HEAD, GET and - * DELETE requests. The {@link org.apache.http.client.DefaultRedirectStrategy} only redirects GET and HEAD - * automatically, per the HTTP specification (POST and PUT typically have bodies and thus cannot be redirected). - * - * A custom strategy is needed for the Openstack API, which can also send 302 on a DELETE (by name) request, expecting - * the client to follow the redirect to perform the actual deletion. - */ -@Immutable -public class HttpClientRedirectStrategy extends DefaultRedirectStrategy { - - /** - * Redirectable methods. - */ - private static final String[] REDIRECT_METHODS = - new String[] {HttpGet.METHOD_NAME, HttpDelete.METHOD_NAME, HttpHead.METHOD_NAME}; - - /** - * Determine if the request should be redirected. This may not actually be needed, since the REDIRECT_METHODS array - * has been updated with the DELETE. - */ - @Override - protected boolean isRedirectable(final String method) { - for (final String m : REDIRECT_METHODS) { - if (m.equalsIgnoreCase(method)) { - return true; - } - } - return false; - } - - /** - * Override the default redirect handling method. As implemented in HttpClient, it does not preserve the method on - * 301 or 302 responses, always redirecting to a GET. - */ - @Override - public HttpUriRequest getRedirect(final HttpRequest request, final HttpResponse response, final HttpContext context) - throws ProtocolException { - - final URI uri = getLocationURI(request, response, context); - final String method = request.getRequestLine().getMethod(); - if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) { - return new HttpHead(uri); - } else if (method.equalsIgnoreCase(HttpGet.METHOD_NAME)) { - return new HttpGet(uri); - } else { - - final int status = response.getStatusLine().getStatusCode(); - - HttpUriRequest newRequest = null; - if (status == HttpStatus.SC_TEMPORARY_REDIRECT || status == HttpStatus.SC_MOVED_TEMPORARILY) { - newRequest = RequestBuilder.copy(request).setUri(uri).build(); - } else { - newRequest = new HttpGet(uri); - } - return newRequest; - } - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java deleted file mode 100644 index f1aa06cb39..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.connector.http; - -import org.apache.http.Header; -import org.apache.http.HttpResponse; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.onap.so.cloudify.base.client.CloudifyResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -public class HttpClientResponse implements CloudifyResponse { - - private static Logger logger = LoggerFactory.getLogger(HttpClientResponse.class); - - private transient HttpResponse response = null; - private String entityBody = null; - - public HttpClientResponse(HttpResponse response) { - this.response = response; - - // Read the body so InputStream can be closed - if (response.getEntity() == null) { - // No body - logger.debug("No Response Body"); - return; - } - - ByteArrayOutputStream responseBody = new ByteArrayOutputStream(); - try { - response.getEntity().writeTo(responseBody); - } catch (IOException e) { - throw new HttpClientException("Error Reading Response Body", e); - } - entityBody = responseBody.toString(); - logger.debug(entityBody); - } - - - @Override - public <T> T getEntity(Class<T> returnType) { - // Get appropriate mapper, based on existence of a root element - ObjectMapper mapper = HttpClientConnector.getObjectMapper(returnType); - - T resp = null; - try { - resp = mapper.readValue(entityBody, returnType); - } catch (Exception e) { - throw new HttpClientException("Caught exception in getEntity", e); - } - return resp; - } - - @Override - public <T> T getErrorEntity(Class<T> returnType) { - return getEntity(returnType); - } - - @Override - public InputStream getInputStream() { - return new ByteArrayInputStream(entityBody.getBytes()); - } - - @Override - public String getHeader(String name) { - return response.getFirstHeader(name).getValue(); - } - - @Override - public Map<String, String> headers() { - Map<String, String> headers = new HashMap<>(); - - Header responseHeaders[] = response.getAllHeaders(); - for (Header h : responseHeaders) { - headers.put(h.getName(), h.getValue()); - } - - return headers; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/BlueprintsResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/BlueprintsResource.java deleted file mode 100644 index 9877eb9f43..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/BlueprintsResource.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============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.cloudify.v3.client; - -import java.io.InputStream; -import org.onap.so.cloudify.v3.model.Blueprint; -import org.onap.so.cloudify.v3.model.Blueprints; -import org.onap.so.cloudify.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class BlueprintsResource { - - private final CloudifyClient client; - private static final String BLUEPRINTS_PATH = "/api/v3/blueprints/"; - - public BlueprintsResource(CloudifyClient client) { - this.client = client; - } - - /* - * Upload a blueprint package directly. The blueprint must be a ZIP archive. However, this method will not validate - * this. - */ - public UploadBlueprint uploadFromStream(String blueprintId, String mainFileName, InputStream blueprint) { - return new UploadBlueprint(blueprintId, mainFileName, blueprint, null); - } - - public UploadBlueprint uploadFromUrl(String blueprintId, String mainFileName, String blueprintUrl) { - return new UploadBlueprint(blueprintId, mainFileName, null, blueprintUrl); - } - - public ListBlueprints list() { - return new ListBlueprints(); - } - - public GetBlueprint getById(String id) { - return new GetBlueprint(id, ""); - } - - // Return all of the metadata, but not the plan - public GetBlueprint getMetadataById(String id) { - return new GetBlueprint(id, "?_include=id,main_file_name,description,tenant_name,created_at,updated_at"); - } - - public DeleteBlueprint deleteById(String id) { - return new DeleteBlueprint(id); - } - - public class UploadBlueprint extends CloudifyRequest<Blueprint> { - public UploadBlueprint(String blueprintId, String mainFileName, InputStream blueprint, String blueprintUrl) { - // Initialize the request elements dynamically. - // Either a blueprint input stream or a URL will be provided. - // If a URL is provided, add it to the query string - // If a Stream is provided, set it as the Entity body - super(client, HttpMethod.PUT, - BLUEPRINTS_PATH + blueprintId + "?application_file_name=" + mainFileName - + ((blueprintUrl != null) ? "&blueprint_archive=" + blueprintUrl : ""), - ((blueprint != null) ? Entity.stream(blueprint) : null), Blueprint.class); - } - } - - public class DeleteBlueprint extends CloudifyRequest<Blueprint> { - public DeleteBlueprint(String blueprintId) { - super(client, HttpMethod.DELETE, BLUEPRINTS_PATH + blueprintId, null, Blueprint.class); - } - } - - public class GetBlueprint extends CloudifyRequest<Blueprint> { - public GetBlueprint(String id, String queryArgs) { - super(client, HttpMethod.GET, BLUEPRINTS_PATH + id + queryArgs, null, Blueprint.class); - } - } - - public class ListBlueprints extends CloudifyRequest<Blueprints> { - public ListBlueprints() { - super(client, HttpMethod.GET, "/api/v3/blueprints", null, Blueprints.class); - } - } - - // TODO: DownloadBlueprint is not supported, as it needs to return an input stream - // containing the full blueprint ZIP. - // For a full client library, this will require returning an open stream as the entity... -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/Cloudify.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/Cloudify.java deleted file mode 100644 index 2fdd61ce48..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/Cloudify.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============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.cloudify.v3.client; - -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyClientConnector; - -/** - * Reference: http://docs.getcloudify.org/api/v3/ - */ -public class Cloudify extends CloudifyClient { - - private final DeploymentsResource deployments; - private final BlueprintsResource blueprints; - private final TokensResource tokens; - private final NodeInstancesResource nodeInstances; - private final ExecutionsResource executions; - - /* - * Not supporting dynamic connectors public Cloudify(String endpoint, CloudifyClientConnector connector) { - * super(endpoint, connector); deployments = new DeploymentsResource(this); blueprints = new - * BlueprintsResource(this); nodeInstances = new NodeInstancesResource(this); tokens = new TokensResource(this); } - */ - public Cloudify(String endpoint, String tenant) { - super(endpoint, tenant); - deployments = new DeploymentsResource(this); - blueprints = new BlueprintsResource(this); - nodeInstances = new NodeInstancesResource(this); - executions = new ExecutionsResource(this); - tokens = new TokensResource(this); - } - - public Cloudify(String endpoint) { - super(endpoint); - deployments = new DeploymentsResource(this); - blueprints = new BlueprintsResource(this); - nodeInstances = new NodeInstancesResource(this); - executions = new ExecutionsResource(this); - tokens = new TokensResource(this); - } - - public DeploymentsResource deployments() { - return this.deployments; - } - - public BlueprintsResource blueprints() { - return this.blueprints; - } - - public NodeInstancesResource nodeInstances() { - return this.nodeInstances; - } - - public ExecutionsResource executions() { - return this.executions; - } - - public TokensResource tokens() { - return this.tokens; - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/DeploymentsResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/DeploymentsResource.java deleted file mode 100644 index 335f6b1697..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/DeploymentsResource.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============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.cloudify.v3.client; - -import org.onap.so.cloudify.v3.model.CreateDeploymentParams; -import org.onap.so.cloudify.v3.model.Deployment; -import org.onap.so.cloudify.v3.model.DeploymentOutputs; -import org.onap.so.cloudify.v3.model.Deployments; -import org.onap.so.cloudify.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class DeploymentsResource { - - private final CloudifyClient client; - private static final String DEPLOYMENT_PATH = "/api/v3/deployments/"; - - public DeploymentsResource(CloudifyClient client) { - this.client = client; - } - - public CreateDeployment create(String deploymentId, CreateDeploymentParams body) { - return new CreateDeployment(deploymentId, body); - } - - public ListDeployments list() { - return new ListDeployments(); - } - - public GetDeployment byId(String id) { - return new GetDeployment(id); - } - - public GetDeploymentOutputs outputsById(String id) { - return new GetDeploymentOutputs(id); - } - - public DeleteDeployment deleteByName(String name) { - return new DeleteDeployment(name); - } - - public class CreateDeployment extends CloudifyRequest<Deployment> { - public CreateDeployment(String deploymentId, CreateDeploymentParams body) { - super(client, HttpMethod.PUT, DEPLOYMENT_PATH + deploymentId, Entity.json(body), Deployment.class); - } - } - - public class DeleteDeployment extends CloudifyRequest<Deployment> { - public DeleteDeployment(String deploymentId) { - super(client, HttpMethod.DELETE, DEPLOYMENT_PATH + deploymentId, null, Deployment.class); - } - } - - public class GetDeployment extends CloudifyRequest<Deployment> { - public GetDeployment(String id) { - super(client, HttpMethod.GET, DEPLOYMENT_PATH + id, null, Deployment.class); - } - } - - public class GetDeploymentOutputs extends CloudifyRequest<DeploymentOutputs> { - public GetDeploymentOutputs(String id) { - super(client, HttpMethod.GET, DEPLOYMENT_PATH + id + "/outputs", null, DeploymentOutputs.class); - } - } - - public class ListDeployments extends CloudifyRequest<Deployments> { - public ListDeployments() { - super(client, HttpMethod.GET, "/api/v3/deployments", null, Deployments.class); - } - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/ExecutionsResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/ExecutionsResource.java deleted file mode 100644 index 34251bfe52..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/ExecutionsResource.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============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.cloudify.v3.client; - -import org.onap.so.cloudify.v3.model.CancelExecutionParams; -import org.onap.so.cloudify.v3.model.Execution; -import org.onap.so.cloudify.v3.model.Executions; -import org.onap.so.cloudify.v3.model.StartExecutionParams; -import org.onap.so.cloudify.v3.model.UpdateExecutionParams; -import org.onap.so.cloudify.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class ExecutionsResource { - - private final CloudifyClient client; - private static final String EXECUTIONS_PATH = "/api/v3/executions/"; - - public ExecutionsResource(CloudifyClient client) { - this.client = client; - } - - public ListExecutions list() { - return new ListExecutions(null); - } - - public ListExecutions listSorted(String sortBy) { - return new ListExecutions("?_sort=" + sortBy); - } - - // Return a filtered list. - // The filter parameter should be a query string of filter criteria (without leading "?") - public ListExecutions listFiltered(String filter, String sortBy) { - String listParams = "?" + filter; - if (sortBy != null) - listParams += "&_sort=" + sortBy; - return new ListExecutions(listParams); - } - - public GetExecution byId(String id) { - return new GetExecution(id); - } - - public StartExecution start(StartExecutionParams params) { - return new StartExecution(params); - } - - public UpdateExecution updateStatus(String id, String status) { - UpdateExecutionParams params = new UpdateExecutionParams(); - params.setStatus(status); - return new UpdateExecution(id, params); - } - - public CancelExecution cancel(String executionId, CancelExecutionParams params) { - return new CancelExecution(executionId, params); - } - - - public class GetExecution extends CloudifyRequest<Execution> { - public GetExecution(String id) { - super(client, HttpMethod.GET, EXECUTIONS_PATH + id, null, Execution.class); - } - } - - public class ListExecutions extends CloudifyRequest<Executions> { - public ListExecutions(String listParams) { - super(client, HttpMethod.GET, "/api/v3/executions" + ((listParams != null) ? listParams : ""), null, - Executions.class); - } - } - - public class StartExecution extends CloudifyRequest<Execution> { - public StartExecution(StartExecutionParams body) { - super(client, HttpMethod.POST, "/api/v3/executions", Entity.json(body), Execution.class); - } - } - - public class UpdateExecution extends CloudifyRequest<Execution> { - public UpdateExecution(String executionId, UpdateExecutionParams body) { - super(client, HttpMethod.PATCH, EXECUTIONS_PATH + executionId, Entity.json(body), Execution.class); - } - } - - public class CancelExecution extends CloudifyRequest<Execution> { - public CancelExecution(String executionId, CancelExecutionParams body) { - super(client, HttpMethod.POST, EXECUTIONS_PATH + executionId, Entity.json(body), Execution.class); - } - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/NodeInstancesResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/NodeInstancesResource.java deleted file mode 100644 index bc82c77026..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/NodeInstancesResource.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============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.cloudify.v3.client; - -import org.onap.so.cloudify.v3.model.UpdateNodeInstanceParams; -import org.onap.so.cloudify.v3.model.NodeInstance; -import org.onap.so.cloudify.v3.model.NodeInstances; -import org.onap.so.cloudify.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class NodeInstancesResource { - - private final CloudifyClient client; - - public NodeInstancesResource(CloudifyClient client) { - this.client = client; - } - - public ListNodeInstances list() { - return new ListNodeInstances(); - } - - public GetNodeInstance byId(String id) { - return new GetNodeInstance(id); - } - - public UpdateNodeInstance update(String id, UpdateNodeInstanceParams params) { - return new UpdateNodeInstance(id, params); - } - - - public class GetNodeInstance extends CloudifyRequest<NodeInstance> { - public GetNodeInstance(String id) { - super(client, HttpMethod.GET, "/api/v3/node-instances/" + id, null, NodeInstance.class); - } - } - - public class ListNodeInstances extends CloudifyRequest<NodeInstances> { - public ListNodeInstances() { - super(client, HttpMethod.GET, "/api/v3/node-instances", null, NodeInstances.class); - } - } - - public class UpdateNodeInstance extends CloudifyRequest<NodeInstance> { - public UpdateNodeInstance(String nodeInstanceId, UpdateNodeInstanceParams body) { - super(client, HttpMethod.PATCH, "/api/v3/node-instances/" + nodeInstanceId, Entity.json(body), - NodeInstance.class); - } - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/TokensResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/TokensResource.java deleted file mode 100644 index 417d7c6eda..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/TokensResource.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============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.cloudify.v3.client; - -import org.onap.so.cloudify.v3.model.Token; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class TokensResource { - - private final CloudifyClient client; - - public TokensResource(CloudifyClient client) { - this.client = client; - } - - /* - * Get a new token for a user TODO: User ID/Password logic need to be in the Client. Results of a token query should - * also be able to add to the Client - */ - public GetToken token() { - return new GetToken(); - } - - public class GetToken extends CloudifyRequest<Token> { - public GetToken() { - super(client, HttpMethod.GET, "/api/v3/tokens", null, Token.class); - } - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/AzureConfig.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/AzureConfig.java deleted file mode 100644 index 8fd6b7c9c0..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/AzureConfig.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class AzureConfig implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("subscription_id") - String subscriptionId; - - @JsonProperty("tenant_id") - String tenantId; - - @JsonProperty("client_id") - String clientId; - - @JsonProperty("client_secret") - String clientSecret; - - public String getSubscriptionId() { - return subscriptionId; - } - - public void setSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - } - - public String getTenantId() { - return tenantId; - } - - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprint.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprint.java deleted file mode 100644 index 873816d121..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprint.java +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Date; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("blueprint") -public class Blueprint implements Serializable { - - - /** - * - */ - private static final long serialVersionUID = 938604986548763151L; - - @JsonProperty("created_at") - private Date createdAt; - - @JsonProperty("description") - private String description; - - @JsonProperty("id") - private String id; - - @JsonProperty("main_file_name") - private String mainFileName; - - @JsonProperty("plan") - private Map<String, Object> plan = null; - - @JsonProperty("tenant_name") - private String tenantName; - - @JsonProperty("updated_at") - private Date updatedAt; - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getMainFileName() { - return mainFileName; - } - - public void setMainFileName(String mainFileName) { - this.mainFileName = mainFileName; - } - - public Map<String, Object> getPlan() { - return this.plan; - } - - public void setPlan(Map<String, Object> plan) { - this.plan = plan; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - } - - - /* - * Return an output as a Json-mapped Object of the provided type. This is useful for json-object outputs. - */ - public <T> T getMapValue(Map<String, Object> map, String key, Class<T> type) { - - ObjectMapper mapper = new ObjectMapper(); - - if (map.containsKey(key)) { - try { - String s = mapper.writeValueAsString(map.get(key)); - return (mapper.readValue(s, type)); - } catch (IOException e) { - return null; - } - } - return null; - } - - @Override - public String toString() { - return "Deployment{" + "id='" + id + '\'' + ", description='" + description + '\'' + ", createdAt=" + createdAt - + ", updatedAt=" + updatedAt + ", mainFileName='" + mainFileName + '\'' + ", tenantName='" + tenantName - + '\'' + '}'; - } - - /* - * Add a definition of the Cloudify "plan" attribute once we know what it is. - * - * @JsonIgnoreProperties(ignoreUnknown=true) public static final class Plan { } - * - */ - - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CloudifyError.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CloudifyError.java deleted file mode 100644 index 1638199ce9..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CloudifyError.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * This class represents a generic Cloudify error response body. These responses have a common format: { "message": - * "<error message>", "error_code": "<cloudify error id string>". "server_traceback": "<Python traceback>" } - * - * @author jc1348 - */ -public class CloudifyError implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("message") - private String message; - - @JsonProperty("error_code") - private String errorCode; - - @JsonProperty("server_traceback") - private String serverTraceback; - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getServerTraceback() { - return serverTraceback; - } - - public void setServerTraceback(String serverTraceback) { - this.serverTraceback = serverTraceback; - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CreateDeploymentParams.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CreateDeploymentParams.java deleted file mode 100644 index 66e9b61d27..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CreateDeploymentParams.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.Map; - -public class CreateDeploymentParams implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("blueprint_id") - private String blueprintId; - - @JsonProperty("inputs") - private Map<String, Object> inputs; - - public String getBlueprintId() { - return blueprintId; - } - - public void setBlueprintId(String blueprintId) { - this.blueprintId = blueprintId; - } - - public Map<String, Object> getInputs() { - return inputs; - } - - public void setInputs(Map<String, Object> inputs) { - this.inputs = inputs; - } - - @Override - public String toString() { - return "CreateDeploymentBody{" + "blueprintId='" + blueprintId + '\'' + ", inputs=" + inputs + '}'; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployment.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployment.java deleted file mode 100644 index 86a2b5f1bb..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployment.java +++ /dev/null @@ -1,358 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("deployment") -public class Deployment implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("blueprint_id") - private String blueprintId; - - @JsonProperty("created_at") - private Date createdAt; - - @JsonProperty("created_by") - private String createdBy; - - @JsonProperty("description") - private String description; - - @JsonProperty("groups") - private Map<String, Group> groups = null; - - @JsonProperty("id") - private String id; - - @JsonProperty("inputs") - private Map<String, Object> inputs = null; - - // TODO: Expand the definition of a PolicyTrigger - @JsonProperty("policy_triggers") - private List<Object> policyTriggers; - - // TODO: Expand the definition of a PolicyType - @JsonProperty("policy_types") - private List<Object> policyTypes; - - @JsonProperty("scaling_groups") - private Map<String, ScalingGroup> scalingGroups = null; - - @JsonProperty("tenant_name") - private String tenantName; - - @JsonProperty("updated_at") - private Date updatedAt; - - @JsonProperty("workflows") - private List<Workflow> workflows; - - public List<Object> getPolicyTriggers() { - return policyTriggers; - } - - public void setPolicyTriggers(List<Object> policyTriggers) { - this.policyTriggers = policyTriggers; - } - - public List<Object> getPolicyTypes() { - return policyTypes; - } - - public void setPolicyTypes(List<Object> policyTypes) { - this.policyTypes = policyTypes; - } - - public String getBlueprintId() { - return blueprintId; - } - - public void setBlueprintId(String blueprintId) { - this.blueprintId = blueprintId; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, Group> getGroups() { - return this.groups; - } - - public void setGroups(Map<String, Group> groups) { - this.groups = groups; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Map<String, Object> getInputs() { - return this.inputs; - } - - public void setInputs(Map<String, Object> inputs) { - this.inputs = inputs; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public Map<String, ScalingGroup> getScalingGroups() { - return scalingGroups; - } - - public void setScalingGroups(Map<String, ScalingGroup> scalingGroups) { - this.scalingGroups = scalingGroups; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - } - - public List<Workflow> getWorkflows() { - return workflows; - } - - public void setWorkflows(List<Workflow> workflows) { - this.workflows = workflows; - } - - /* - * Nested subclasses for Group definitions - */ - public static final class Group { - @JsonProperty("policies") - Object policies; - - @JsonProperty("members") - List<String> members; - - public Object getPolicies() { - return policies; - } - - public void setPolicies(Object policies) { - this.policies = policies; - } - - public List<String> getMembers() { - return members; - } - - public void setMembers(List<String> members) { - this.members = members; - } - } - - /* - * Nested subclasses for Scaling Group definitions - */ - public static final class ScalingGroup { - @JsonProperty("properties") - ScalingGroupProperties properties; - - @JsonProperty("members") - List<String> members; - - public ScalingGroupProperties getProperties() { - return properties; - } - - public void setProperties(ScalingGroupProperties properties) { - this.properties = properties; - } - - public List<String> getMembers() { - return members; - } - - public void setMembers(List<String> members) { - this.members = members; - } - } - - public static final class ScalingGroupProperties { - @JsonProperty("current_instances") - int currentInstances; - - @JsonProperty("default_instances") - int defaultInstances; - - @JsonProperty("max_instances") - int maxInstances; - - @JsonProperty("min_instances") - int minInstances; - - @JsonProperty("planned_instances") - int plannedInstances; - - public int getCurrentInstances() { - return currentInstances; - } - - public void setCurrentInstances(int currentInstances) { - this.currentInstances = currentInstances; - } - - public int getDefaultInstances() { - return defaultInstances; - } - - public void setDefaultInstances(int defaultInstances) { - this.defaultInstances = defaultInstances; - } - - public int getMaxInstances() { - return maxInstances; - } - - public void setMaxInstances(int maxInstances) { - this.maxInstances = maxInstances; - } - - public int getMinInstances() { - return minInstances; - } - - public void setMinInstances(int minInstances) { - this.minInstances = minInstances; - } - - public int getPlannedInstances() { - return plannedInstances; - } - - public void setPlannedInstances(int plannedInstances) { - this.plannedInstances = plannedInstances; - } - } - - /* - * Nested subclass for Deployment Workflow entities. Note that Blueprint class also contains a slightly different - * Workflow structure. - */ - public static final class Workflow { - @JsonProperty("name") - private String name; - @JsonProperty("created_at") - private Date createdAt; - @JsonProperty("parameters") - private Map<String, ParameterDefinition> parameters; - - public Workflow() {} - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public Map<String, ParameterDefinition> getParameters() { - return parameters; - } - - public void setParameters(Map<String, ParameterDefinition> parameters) { - this.parameters = parameters; - } - } - - /* - * Return an output as a Json-mapped Object of the provided type. This is useful for json-object outputs. - */ - public <T> T getMapValue(Map<String, Object> map, String key, Class<T> type) { - - ObjectMapper mapper = new ObjectMapper(); - if (map.containsKey(key)) { - try { - String s = mapper.writeValueAsString(map.get(key)); - return (mapper.readValue(s, type)); - } catch (IOException e) { - return null; - } - } - return null; - } - - @Override - public String toString() { - return "Deployment{" + "id='" + id + '\'' + ", description='" + description + '\'' + ", blueprintId='" - + blueprintId + '\'' + ", createdBy='" + createdBy + '\'' + ", tenantName='" + tenantName + '\'' - + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + ", inputs='" + inputs + '\'' - + ", workflows=" + workflows + ", groups=" + groups + '}'; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/DeploymentOutputs.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/DeploymentOutputs.java deleted file mode 100644 index 1f34534a15..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/DeploymentOutputs.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("outputs") -public class DeploymentOutputs implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("deployment_id") - private String deploymentId; - - @JsonProperty("outputs") - private Map<String, Object> outputs = null; - - public Map<String, Object> getOutputs() { - return this.outputs; - } - - public void setOutputs(Map<String, Object> outputs) { - this.outputs = outputs; - } - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - /* - * Return an output as a Json-mapped Object of the provided type. This is useful for json-object outputs. - */ - public <T> T getMapValue(Map<String, Object> map, String key, Class<T> type) { - - ObjectMapper mapper = new ObjectMapper(); - - if (map.containsKey(key)) { - try { - String s = mapper.writeValueAsString(map.get(key)); - return (mapper.readValue(s, type)); - } catch (IOException e) { - return null; - } - } - return null; - } - - @Override - public String toString() { - return "DeploymentOutputs{" + "deploymentId='" + deploymentId + '\'' + ", outputs='" + outputs + '\'' + '}'; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployments.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployments.java deleted file mode 100644 index b97164f528..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployments.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.List; - -public class Deployments implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("items") - private List<Deployment> items; - - @JsonProperty("metadata") - private Metadata metadata; - - public List<Deployment> getItems() { - return items; - } - - public void setItems(List<Deployment> items) { - this.items = items; - } - - public Metadata getMetadata() { - return metadata; - } - - public void setMetadata(Metadata metadata) { - this.metadata = metadata; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Execution.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Execution.java deleted file mode 100644 index 258d8e525a..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Execution.java +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.Serializable; -import java.util.Date; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("execution") -public class Execution implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("blueprint_id") - private String blueprintId; - - @JsonProperty("created_at") - private Date createdAt; - - @JsonProperty("created_by") - private String createdBy; - - @JsonProperty("deployment_id") - private String deploymentId; - - @JsonProperty("error") - private String error; - - @JsonProperty("id") - private String id; - - @JsonProperty("is_system_workflow") - private boolean isSystemWorkflow; - - @JsonProperty("parameters") - private Map<String, Object> parameters; - - @JsonProperty("status") - private String status; - - @JsonProperty("tenant_name") - private String tenantName; - - @JsonProperty("workflow_id") - private String workflowId; - - public String getBlueprintId() { - return blueprintId; - } - - public void setBlueprintId(String blueprintId) { - this.blueprintId = blueprintId; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public boolean isSystemWorkflow() { - return isSystemWorkflow; - } - - public void setSystemWorkflow(boolean isSystemWorkflow) { - this.isSystemWorkflow = isSystemWorkflow; - } - - public Map<String, Object> getParameters() { - return parameters; - } - - public void setParameters(Map<String, Object> parameters) { - this.parameters = parameters; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public String getWorkflowId() { - return workflowId; - } - - public void setWorkflowId(String workflowId) { - this.workflowId = workflowId; - } - - @Override - public String toString() { - return "Execution{" + "id='" + id + '\'' + ", blueprintId='" + blueprintId + '\'' + ", createdBy='" + createdBy - + '\'' + ", createdAt=" + createdAt + ", deploymentId='" + deploymentId + '\'' + ", error=" + error - + ", isSystemWorkflow=" + isSystemWorkflow + ", status=" + status + ", tenantName='" + tenantName + '\'' - + ", parameters=" + parameters + '}'; - } - - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Executions.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Executions.java deleted file mode 100644 index e238bc7fee..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Executions.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.List; - -public class Executions implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("items") - private List<Execution> items; - - @JsonProperty("metadata") - private Metadata metadata; - - public List<Execution> getItems() { - return items; - } - - public void setItems(List<Execution> items) { - this.items = items; - } - - public Metadata getMetadata() { - return metadata; - } - - public void setMetadata(Metadata metadata) { - this.metadata = metadata; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Metadata.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Metadata.java deleted file mode 100644 index 269ed9db8a..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Metadata.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; - -/** - * This class represents a generic Cloudify response to a GET command. These responses have a common format: { "items": - * [ List of objects of the requested type ], "metadata": { } } - * - * @author jc1348 - * - */ -public class Metadata implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("pagination") - private Pagination pagination; - - - public Pagination getPagination() { - return pagination; - } - - public void setPagination(Pagination pagination) { - this.pagination = pagination; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstance.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstance.java deleted file mode 100644 index 4d7f8fb749..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstance.java +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonRootName("node_instance") -public class NodeInstance implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("created_by") - private String createdBy; - - @JsonProperty("deployment_id") - private String deploymentId; - - @JsonProperty("host_id") - private String hostId; - - @JsonProperty("id") - private String id; - - @JsonProperty("node_id") - private String nodeId; - - @JsonProperty("relationships") - private List<Object> relationships = null; - - @JsonProperty("runtime_properties") - private Map<String, Object> runtimeProperties = null; - - @JsonProperty("scaling_groups") - private List<ScalingGroupIdentifier> scalingGroups; - - @JsonProperty("state") - private String state; - - @JsonProperty("tenant_name") - private String tenantName; - - @JsonProperty("version") - private String version; - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - public String getHostId() { - return hostId; - } - - public void setHostId(String hostId) { - this.hostId = hostId; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getNodeId() { - return nodeId; - } - - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } - - public List<Object> getRelationships() { - return relationships; - } - - public void setRelationships(List<Object> relationships) { - this.relationships = relationships; - } - - public Map<String, Object> getRuntimeProperties() { - return runtimeProperties; - } - - public void setRuntimeProperties(Map<String, Object> runtimeProperties) { - this.runtimeProperties = runtimeProperties; - } - - public List<ScalingGroupIdentifier> getScalingGroups() { - return scalingGroups; - } - - public void setScalingGroups(List<ScalingGroupIdentifier> scalingGroups) { - this.scalingGroups = scalingGroups; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - /* - * Nested structure representing scaling groups in which this node is a member - */ - public static final class ScalingGroupIdentifier { - @JsonProperty("name") - private String name; - - @JsonProperty("id") - private String id; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String toString() { - return "Scaling Group{ name=" + name + ", id=" + id + "}"; - } - } - - @Override - public String toString() { - return "Deployment{" + "id='" + id + '\'' + "nodeId='" + nodeId + '\'' + ", createdBy='" + createdBy + '\'' - + ", tenantName='" + tenantName + '\'' + ", state=" + state + ", deploymentId=" + deploymentId - + ", hostId='" + hostId + '\'' + ", version='" + version + '\'' + ", relationships=" + relationships - + ", runtimeProperties=" + runtimeProperties + ", scalingGroups=" + scalingGroups + '}'; - } - - // TODO: Need an object structure for Relationships -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstances.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstances.java deleted file mode 100644 index 8dd30d9696..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstances.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.List; - -public class NodeInstances implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("items") - private List<NodeInstance> items; - - @JsonProperty("metadata") - private Metadata metadata; - - public List<NodeInstance> getItems() { - return items; - } - - public void setItems(List<NodeInstance> items) { - this.items = items; - } - - public Metadata getMetadata() { - return metadata; - } - - public void setMetadata(Metadata metadata) { - this.metadata = metadata; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/OpenstackConfig.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/OpenstackConfig.java deleted file mode 100644 index 8914a83a55..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/OpenstackConfig.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class OpenstackConfig implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("username") - String username; - - @JsonProperty("password") - String password; - - @JsonProperty("tenant_name") - String tenantName; - - @JsonProperty("auth_url") - String authUrl; - - @JsonProperty("region") - String region; - - // NOTE: Not supporting "custom_configuration" - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public String getAuthUrl() { - return authUrl; - } - - public void setAuthUrl(String authUrl) { - this.authUrl = authUrl; - } - - public String getRegion() { - return region; - } - - public void setRegion(String region) { - this.region = region; - } - - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Pagination.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Pagination.java deleted file mode 100644 index a292b13881..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Pagination.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Pagination { - @JsonProperty("total") - private int total; - @JsonProperty("offset") - private int offset; - @JsonProperty("size") - private int size; - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public int getOffset() { - return offset; - } - - public void setOffset(int offset) { - this.offset = offset; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/ParameterDefinition.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/ParameterDefinition.java deleted file mode 100644 index 1ff70b68d6..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/ParameterDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class ParameterDefinition implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("type") - private String type; - @JsonProperty("description") - private String description; - @JsonProperty("default") - private Object defaultValue; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Object getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(Object defaultValue) { - this.defaultValue = defaultValue; - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/StartExecutionParams.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/StartExecutionParams.java deleted file mode 100644 index e12b7d094c..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/StartExecutionParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.Serializable; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class StartExecutionParams implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("workflow_id") - private String workflowId; - - @JsonProperty("deployment_id") - private String deploymentId; - - @JsonProperty("allow_custom_parameters") - private boolean allowCustomParameters; - - @JsonProperty("force") - private boolean force; - - @JsonProperty("parameters") - private Map<String, Object> parameters; - - public String getWorkflowId() { - return workflowId; - } - - public void setWorkflowId(String workflowId) { - this.workflowId = workflowId; - } - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - public boolean isAllowCustomParameters() { - return allowCustomParameters; - } - - public void setAllowCustomParameters(boolean allowCustomParameters) { - this.allowCustomParameters = allowCustomParameters; - } - - public boolean isForce() { - return force; - } - - public void setForce(boolean force) { - this.force = force; - } - - public Map<String, Object> getParameters() { - return parameters; - } - - public void setParameters(Map<String, Object> parameters) { - this.parameters = parameters; - } - - @Override - public String toString() { - return "UpdateExecutionParams{" + "workflowId='" + workflowId + '\'' + "deploymentId='" + deploymentId + '\'' - + "allowCustomParameters='" + allowCustomParameters + '\'' + "force='" + force + '\'' + "parameters='" - + parameters + '\'' + '}'; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Token.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Token.java deleted file mode 100644 index c5809d4a32..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Token.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============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.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("token") -// The Token object is returned without a root element -public class Token implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("role") - private String role; - - @JsonProperty("value") - private String value; - - // Any expiration? Maybe something in the Headers? - - public String getRole() { - return role; - } - - public void setRole(String role) { - this.role = role; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - - @Override - public String toString() { - return "Token{" + "role='" + role + '\'' + ", value='" + value + '\'' + '}'; - } -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java deleted file mode 100644 index 4028b71109..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============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.cloudify; - -import org.junit.Before; -import org.junit.Test; -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class BeanMultiTest { - - Validator validator; - PojoClassFilter enumFilter; - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Before - public void setup() { - enumFilter = new FilterEnum(); - validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule()) - .with(new SetterTester(), new GetterTester()).build(); - } - - @Test - public void validateBeansMsoApihandlerBeans() { - - validator.validate("org.onap.so.cloudify.v3.model", enumFilter); - } - - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/src/test/java"); - } - } -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java deleted file mode 100644 index 88974acb11..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.cloudify.base.client; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.v3.model.Execution; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class CloudifyClientTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void clientCreate() { - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - CloudifyClient cc = new CloudifyClient("http://localhost:" + port); - cc.setToken("token"); - CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class); - Execution x = crx.execute(); - assertEquals("123", x.getId()); - } - - @Test - public void clientCreateWithBadConnector() { - thrown.expect(CloudifyResponseException.class); - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - CloudifyClientConnector ccc = new CloudifyClientConnector() { - @Override - public <T> CloudifyResponse request(CloudifyRequest<T> request) { - throw new CloudifyResponseException("test case", 401); - } - }; - CloudifyClient cc = new CloudifyClient("http://localhost:" + port, ccc); - // cc.setToken("token"); - CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class); - Execution x = crx.execute(); - } - - @Test - public void clientCreateWithBadConnectorAndToken() { - thrown.expect(CloudifyResponseException.class); - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - CloudifyClientConnector ccc = new CloudifyClientConnector() { - @Override - public <T> CloudifyResponse request(CloudifyRequest<T> request) { - throw new CloudifyResponseException("test case", 401); - } - }; - CloudifyClient cc = new CloudifyClient("http://localhost:" + port, ccc); - cc.setToken("token"); - CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class); - Execution x = crx.execute(); - } - - @Test - public void clientCreateWithTenant() { - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - CloudifyClient cc = new CloudifyClient("http://localhost:" + port, "other_tenant"); - cc.setToken("token"); - cc.property("property", "value"); - CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class); - Execution x = crx.execute(); - assertEquals("123", x.getId()); - } - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java deleted file mode 100644 index 77152a2dd0..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.cloudify.base.client; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class CloudifyClientTokenProviderTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void createTokenProvider() { - wireMockRule.stubFor(get(urlPathEqualTo("/testUrl/api/v3/tokens")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"role\": \"user\", \"value\": \"tokenVal\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - - CloudifyClientTokenProvider cctp = - new CloudifyClientTokenProvider("http://localhost:" + port + "/testUrl", "user", "pswd"); - String token = cctp.getToken(); - assertEquals("tokenVal", token); - token = cctp.getToken(); - assertEquals("tokenVal", token); - cctp.expireToken(); - } -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java deleted file mode 100644 index c85b88f7f3..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * ============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.cloudify.connector.http; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import com.github.tomakehurst.wiremock.http.Fault; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; -import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertEquals; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import org.onap.so.cloudify.base.client.CloudifyConnectException; -import org.onap.so.cloudify.base.client.CloudifyRequest; -import org.onap.so.cloudify.base.client.CloudifyResponseException; -import org.onap.so.cloudify.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.v3.model.Deployment; - -public class HttpClientConnectorTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void sunnyDay_POST() { - wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - Deployment deployment = new Deployment(); - deployment.setId("id"); - request.entity(deployment, "application/json"); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.header("Content-Type", "application/json"); - request.method(HttpMethod.POST); - conector.request(request); - verify(postRequestedFor(urlEqualTo("/testUrl"))); - } - - - @Test - public void sunnyDay_GET() { - wireMockRule.stubFor(get(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.GET); - conector.request(request); - verify(getRequestedFor(urlEqualTo("/testUrl"))); - } - - @Test - public void sunnyDay_PUT() { - wireMockRule.stubFor(put(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.PUT); - conector.request(request); - verify(putRequestedFor(urlEqualTo("/testUrl"))); - } - - - @Test - public void sunnyDay_DELETE() { - wireMockRule.stubFor(delete(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.DELETE); - conector.request(request); - verify(deleteRequestedFor(urlEqualTo("/testUrl"))); - } - - - @Test - public void rainyDay_PATCH() { - thrown.expect(HttpClientException.class); - thrown.expectMessage("Unrecognized HTTP Method: PATCH"); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:123123/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.PATCH); - conector.request(request); - - } - - @Test - public void rainyDayRunTimeException() { - wireMockRule.stubFor(post(urlEqualTo("/503")) - .willReturn(aResponse().withStatus(503).withHeader("Content-Type", "text/plain").withBody("failure"))); - thrown.expect(RuntimeException.class); - thrown.expectMessage("Unexpected client exception"); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:123123/503"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.POST); - conector.request(request); - - } - - @Test - public void rainyDayBadUri() { - wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - thrown.expect(HttpClientException.class); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - Deployment deployment = new Deployment(); - deployment.setId("id"); - request.entity(deployment, "application/json"); - request.endpoint("(@#$@(#*$&asfasdf"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.header("Content-Type", "application/json"); - request.method(HttpMethod.POST); - conector.request(request); - } - - @Test - public void sunnyDayWithJsonEntity_POST() { - wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - - Deployment deployment = new Deployment(); - deployment.setId("id"); - - CloudifyRequest<Deployment> request = - new CloudifyRequest<Deployment>(null, HttpMethod.POST, "/", Entity.json(deployment), null); - - request.endpoint("http://localhost:" + port); - request.path("testUrl"); - request.header("Content-Type", "application/json"); - request.header("Content-Type", null); - - request.returnType(Deployment.class); - assertEquals(Deployment.class, request.returnType()); - - Entity<Deployment> t = request.json(deployment); - assertEquals(t.getEntity().getId(), "id"); - - request.queryParam("test", "one").queryParam("test", "two"); - - conector.request(request); - - verify(postRequestedFor(urlEqualTo("/testUrl?test=two"))); - } - - @Test - public void sunnyDayWithStreamEntity_POST() { - wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - - InputStream is = new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8)); - - CloudifyRequest<Deployment> request = - new CloudifyRequest<Deployment>(null, HttpMethod.POST, "/testUrl", Entity.stream(is), null); - - request.endpoint("http://localhost:" + port); - request.setBasicAuthentication("USER", "PASSWORD"); - request.header("Content-Type", "application/json"); - - conector.request(request); - verify(postRequestedFor(urlEqualTo("/testUrl"))); - } - - @Test - public void rainyDayGarbageData() { - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withFault(Fault.RANDOM_DATA_THEN_CLOSE))); - thrown.expect(CloudifyConnectException.class); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.GET); - conector.request(request); - } - - @Test - public void rainyDayEmptyResponse() { - wireMockRule.stubFor(get(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_NOT_FOUND))); - - thrown.expect(HttpClientException.class); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.GET); - conector.request(request); // gets down to "Get here on an error response (4XX-5XX)", then tries to throw a - // CloudifyResponseException, which calls getEntity, which tries to parse an HTML - // error page as a JSON, which causes the HttpClientException. - } - - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java deleted file mode 100644 index 6010726669..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 Nokia. - * ============================================================================= 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.cloudify.connector.http; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.RETURNS_DEEP_STUBS; -import static org.mockito.Mockito.mock; -import java.net.URI; -import java.net.URISyntaxException; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolException; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpOptions; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpTrace; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.protocol.HttpContext; -import org.junit.Test; - -public class HttpClientRedirectStrategyTest { - - private HttpClientRedirectStrategy httpClientRedirectStrategy = new HttpClientRedirectStrategy(); - - @Test - public void isRedirectable_shouldReturnFalse_forNonRedirectableHttpMethods() { - assertThat(httpClientRedirectStrategy.isRedirectable(HttpPost.METHOD_NAME)).isFalse(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpPatch.METHOD_NAME)).isFalse(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpPut.METHOD_NAME)).isFalse(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpOptions.METHOD_NAME)).isFalse(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpTrace.METHOD_NAME)).isFalse(); - } - - @Test - public void isRedirectable_shouldReturnTrue_forRedirectableHttpMethods() { - assertThat(httpClientRedirectStrategy.isRedirectable(HttpGet.METHOD_NAME)).isTrue(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpDelete.METHOD_NAME)).isTrue(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpHead.METHOD_NAME)).isTrue(); - } - - @Test - public void getRedirect_shouldReturnHttpHeadUriRequest() throws URISyntaxException, ProtocolException { - assertHttpUriRequestFor(HttpHead.METHOD_NAME, HttpHead.class); - } - - @Test - public void getRedirect_shouldReturnHttpGetUriRequest() throws URISyntaxException, ProtocolException { - assertHttpUriRequestFor(HttpGet.METHOD_NAME, HttpGet.class); - } - - private void assertHttpUriRequestFor(String methodName, Class<? extends HttpUriRequest> expectedHttpMethodClass) - throws URISyntaxException, ProtocolException { - // GIVEN - HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS); - given(request.getRequestLine().getMethod()).willReturn(methodName); - HttpResponse response = null; - HttpContext context = null; - URI expectedUri = new URI("http://localhost/host"); - // WHEN - HttpUriRequest httpUriRequest = - new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context); - // THEN - assertThat(httpUriRequest).isInstanceOf(expectedHttpMethodClass); - assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri); - } - - @Test - public void getRedirect_shouldReturnHttpGetUri_byDefault() throws URISyntaxException, ProtocolException { - // GIVEN - HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS); - given(request.getRequestLine().getMethod()).willReturn(HttpPost.METHOD_NAME); - HttpResponse response = mock(HttpResponse.class, RETURNS_DEEP_STUBS); - given(response.getStatusLine().getStatusCode()).willReturn(HttpStatus.SC_ACCEPTED); - URI expectedUri = new URI("http://localhost/host"); - HttpContext context = null; - // WHEN - HttpUriRequest httpUriRequest = - new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context); - // THEN - assertThat(httpUriRequest).isInstanceOf(HttpGet.class); - assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri); - } - - @Test - public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forMovedTemporarilyStatus() - throws URISyntaxException, ProtocolException { - assertHttpRequestIsCopied(HttpStatus.SC_MOVED_TEMPORARILY); - } - - @Test - public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forTemporaryRedirectStatus() - throws URISyntaxException, ProtocolException { - assertHttpRequestIsCopied(HttpStatus.SC_TEMPORARY_REDIRECT); - } - - private void assertHttpRequestIsCopied(int expectedHttpStatus) throws URISyntaxException, ProtocolException { - // GIVEN - HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS); - given(request.getRequestLine().getMethod()).willReturn(HttpGet.METHOD_NAME); - given(request.getRequestLine().getUri()).willReturn("http://hostname"); - HttpResponse response = mock(HttpResponse.class, RETURNS_DEEP_STUBS); - given(response.getStatusLine().getStatusCode()).willReturn(expectedHttpStatus); - URI expectedUri = new URI("http://localhost/host"); - HttpContext context = null; - // WHEN - HttpUriRequest httpUriRequest = - new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context); - // THEN - assertThat(httpUriRequest).isInstanceOf(HttpGet.class); - assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri); - } - - private static class TestableHttpClientRedirectStrategy extends HttpClientRedirectStrategy { - - private final URI expectedUri; - - public TestableHttpClientRedirectStrategy(URI expectedUri) { - this.expectedUri = expectedUri; - } - - @Override - public URI getLocationURI(HttpRequest request, HttpResponse response, HttpContext context) { - return expectedUri; - } - } -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java deleted file mode 100644 index cba3bf8fdc..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.cloudify.v3.client; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.v3.client.BlueprintsResource.DeleteBlueprint; -import org.onap.so.cloudify.v3.client.BlueprintsResource.GetBlueprint; -import org.onap.so.cloudify.v3.client.BlueprintsResource.ListBlueprints; -import org.onap.so.cloudify.v3.client.BlueprintsResource.UploadBlueprint; -import org.onap.so.cloudify.v3.model.Blueprint; -import org.onap.so.cloudify.v3.model.Blueprints; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class BlueprintsResourceTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void cloudifyClientBlueprintFromStream() { - wireMockRule.stubFor(put(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - InputStream is = new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8)); - UploadBlueprint ub = br.uploadFromStream("123", "blueprint.json", is); - Blueprint b = ub.execute(); - assertEquals("123", b.getId()); - } - - @Test - public void cloudifyClientBlueprintFromUrl() { - wireMockRule.stubFor(put(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - UploadBlueprint ub = br.uploadFromUrl("123", "blueprint.json", "http://localhost:" + port + "/blueprint"); - Blueprint b = ub.execute(); - assertEquals("123", b.getId()); - } - - @Test - public void cloudifyClientBlueprintDelete() { - wireMockRule.stubFor(delete(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - DeleteBlueprint db = br.deleteById("123"); - Blueprint b = db.execute(); - assertEquals("123", b.getId()); - } - - @Test - public void cloudifyClientBlueprintList() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/blueprints")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"items\": [{\"id\": \"123\"}]}").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - ListBlueprints lb = br.list(); - Blueprints b = lb.execute(); - assertEquals("123", b.getItems().get(0).getId()); - } - - @Test - public void cloudifyClientBlueprintGetById() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - GetBlueprint gb = br.getById("123"); - Blueprint b = gb.execute(); - assertEquals("123", b.getId()); - } - - @Test - public void cloudifyClientBlueprintGetMetadataById() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - GetBlueprint gb = br.getMetadataById("123"); - Blueprint b = gb.execute(); - assertEquals("123", b.getId()); - } - - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java deleted file mode 100644 index 2acd4ba5a3..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.cloudify.v3.client; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import java.util.HashMap; -import java.util.Map; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.v3.client.DeploymentsResource.CreateDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.DeleteDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeploymentOutputs; -import org.onap.so.cloudify.v3.client.DeploymentsResource.ListDeployments; -import org.onap.so.cloudify.v3.model.CreateDeploymentParams; -import org.onap.so.cloudify.v3.model.Deployment; -import org.onap.so.cloudify.v3.model.Deployments; -import org.onap.so.cloudify.v3.model.DeploymentOutputs; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class DeploymentsResourceTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void cloudifyDeploymentsCreate() { - wireMockRule.stubFor(put(urlPathEqualTo("/api/v3/deployments/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - - CreateDeploymentParams cdp = new CreateDeploymentParams(); - cdp.setBlueprintId("123"); - Map<String, Object> inputs = new HashMap<String, Object>(); - cdp.setInputs(inputs); - CreateDeployment cd = br.create("123", cdp); - Deployment d = cd.execute(); - assertEquals("123", d.getId()); - } - - @Test - public void cloudifyDeploymentsList() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/deployments")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{ \"items\": {\"id\": \"123\" } } ").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - ListDeployments ld = br.list(); - Deployments d = ld.execute(); - assertEquals("123", d.getItems().get(0).getId()); - } - - @Test - public void cloudifyDeploymentsGet() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/deployments/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - GetDeployment gd = br.byId("123"); - Deployment d = gd.execute(); - assertEquals("123", d.getId()); - } - - @Test - public void cloudifyDeploymentsGetOutputs() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/deployments/123/outputs")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{ \"deployment_id\": \"123\" }").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - GetDeploymentOutputs gdo = br.outputsById("123"); - DeploymentOutputs d = gdo.execute(); - assertEquals("123", d.getDeploymentId()); - - Map<String, Object> map = new HashMap<String, Object>(); - map.put("test", "answer"); - assertEquals("answer", d.getMapValue(map, "test", String.class)); - - Integer i = d.getMapValue(map, "nil", Integer.class); - assertNull(i); - - i = d.getMapValue(map, "test", Integer.class); - assertNull(i); - } - - @Test - public void cloudifyDeploymentsDelete() { - wireMockRule.stubFor(delete(urlPathEqualTo("/api/v3/deployments/name")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - DeleteDeployment cd = br.deleteByName("name"); - Deployment d = cd.execute(); - assertEquals("123", d.getId()); - } - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java deleted file mode 100644 index 7b63c6eecb..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.cloudify.v3.client; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.connector.http.HttpClientException; -import org.onap.so.cloudify.v3.client.ExecutionsResource.CancelExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.GetExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.ListExecutions; -import org.onap.so.cloudify.v3.client.ExecutionsResource.StartExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.UpdateExecution; -import org.onap.so.cloudify.v3.model.CancelExecutionParams; -import org.onap.so.cloudify.v3.model.Execution; -import org.onap.so.cloudify.v3.model.Executions; -import org.onap.so.cloudify.v3.model.StartExecutionParams; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class ExecutionsResourceTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void cloudifyClientExecutions() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions")).willReturn(aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - "{\"items\": [{ \"id\": \"345\" }, { \"id\": \"123\" }], \"metadata\": {\"pagination\": {\"total\": 100, \"offset\": 0, \"size\": 25}}}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - ListExecutions lx = xr.list(); - Executions x = lx.execute(); - assertEquals("123", x.getItems().get(1).getId()); - } - - @Test - public void cloudifyClientExecutionsSorted() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions")).willReturn(aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - "{\"items\": [{ \"id\": \"123\" }, { \"id\": \"345\" }], \"metadata\": {\"pagination\": {\"total\": 100, \"offset\": 0, \"size\": 25}}}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - ListExecutions lx = xr.listSorted("id"); - Executions x = lx.execute(); - assertEquals("345", x.getItems().get(1).getId()); - } - - @Test - public void cloudifyClientExecutionsFilter() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions")).willReturn(aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - "{\"items\": [{ \"id\": \"121\" }, { \"id\": \"123\" }], \"metadata\": {\"pagination\": {\"total\": 100, \"offset\": 0, \"size\": 25}}}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - ListExecutions lx = xr.listFiltered("a=b", "id"); - Executions x = lx.execute(); - assertEquals("123", x.getItems().get(1).getId()); - } - - @Test - public void cloudifyClientExecutionById() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - GetExecution gx = xr.byId("123"); - Execution x = gx.execute(); - assertEquals("123", x.getId()); - } - - @Test - public void cloudifyClientStartExecution() { - wireMockRule.stubFor(post(urlPathEqualTo("/api/v3/executions")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - - StartExecutionParams params = new StartExecutionParams(); - StartExecution sx = xr.start(params); - Execution x = sx.execute(); - assertEquals("123", x.getId()); - } - - @Test - public void cloudifyClientUpdateExecution() { - thrown.expect(HttpClientException.class); - thrown.expectMessage("Unrecognized HTTP Method: PATCH"); - - wireMockRule.stubFor(patch(urlPathEqualTo("/api/v3/executions")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - - UpdateExecution ux = xr.updateStatus("123", "good"); - Execution x = ux.execute(); - assertEquals("123", x.getId()); - } - - @Test - public void cloudifyClientCancelExecution() { - wireMockRule.stubFor(post(urlPathEqualTo("/api/v3/executions/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - - CancelExecutionParams params = new CancelExecutionParams(); - CancelExecution cx = xr.cancel("123", params); - Execution x = cx.execute(); - assertEquals("123", x.getId()); - } - - - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java deleted file mode 100644 index d38d0401c3..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.cloudify.v3.client; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.connector.http.HttpClientException; -import org.onap.so.cloudify.v3.client.NodeInstancesResource.GetNodeInstance; -import org.onap.so.cloudify.v3.client.NodeInstancesResource.ListNodeInstances; -import org.onap.so.cloudify.v3.client.NodeInstancesResource.UpdateNodeInstance; -import org.onap.so.cloudify.v3.model.NodeInstance; -import org.onap.so.cloudify.v3.model.NodeInstances; -import org.onap.so.cloudify.v3.model.UpdateNodeInstanceParams; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class NodeInstancesResourceTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void nodeInstanceGet() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/node-instances/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{ \"node_instance\": { \"id\": \"123\" } }").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - NodeInstancesResource nir = c.nodeInstances(); - GetNodeInstance gni = nir.byId("123"); - NodeInstance ni = gni.execute(); - assertEquals("123", ni.getId()); - } - - @Test - public void nodeInstanceList() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/node-instances")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - // .withBody(" { \"items\": [ { \"node_instance\": { \"id\": \"123\" } } ] } ") - .withBody(" { \"items\": [ { \"id\": \"123\" } ] } ").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - NodeInstancesResource nir = c.nodeInstances(); - ListNodeInstances lni = nir.list(); - NodeInstances ni = lni.execute(); - assertEquals("123", ni.getItems().get(0).getId()); - } - - @Test - public void nodeInstanceUpdate() { - wireMockRule.stubFor(patch(urlPathEqualTo("/api/v3/node-instances/")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{ \"node_instance\": { \"id\": \"123\" } }").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - NodeInstancesResource nir = c.nodeInstances(); - UpdateNodeInstanceParams params = new UpdateNodeInstanceParams(); - - UpdateNodeInstance uni = nir.update("123", params); - thrown.expect(HttpClientException.class); /// ??????? - NodeInstance ni = uni.execute(); - } -} diff --git a/common/pom.xml b/common/pom.xml index 08554480c3..ff13da4ee6 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -271,6 +271,15 @@ </exclusions> </dependency> <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.validation</groupId> + <artifactId>validation-api</artifactId> + </dependency> + <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ActDeActNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/ActDeActNssi.java index 8d45048ee4..ed82500210 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ActDeActNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ActDeActNssi.java @@ -20,6 +20,7 @@ package org.onap.so.beans.nsmf; +import java.util.List; import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) @@ -33,6 +34,10 @@ public class ActDeActNssi { private String nssiId; + private String sliceProfileId; + + private List<String> snssaiList; + public String getNsiId() { return nsiId; } @@ -48,4 +53,20 @@ public class ActDeActNssi { public void setNssiId(String nssiId) { this.nssiId = nssiId; } + + public String getSliceProfileId() { + return sliceProfileId; + } + + public void setSliceProfileId(String sliceProfileId) { + this.sliceProfileId = sliceProfileId; + } + + public List<String> getSnssaiList() { + return snssaiList; + } + + public void setSnssaiList(List<String> snssaiList) { + this.snssaiList = snssaiList; + } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java new file mode 100644 index 0000000000..5b070bb00f --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class AdditionalProperties implements Serializable { + + private static final long serialVersionUID = -4020397418955518175L; + + private SliceProfile sliceProfile; + + private List<EndPoint> endPoints; + + private NsiInfo nsiInfo; + + private String scriptName; + + private ModifyAction modifyAction; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java index 484f5b42b1..156f999773 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java @@ -25,12 +25,11 @@ import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) public class AllocateAnNssi { + @Deprecated public final static String URL = "/api/rest/provMns/v1/an/NSS" + "/SliceProfiles"; private String nsstId; - private String flavorId; - private String nssiId; private String nssiName; @@ -51,14 +50,6 @@ public class AllocateAnNssi { this.nsstId = nsstId; } - public String getFlavorId() { - return flavorId; - } - - public void setFlavorId(String flavorId) { - this.flavorId = flavorId; - } - public String getNssiId() { return nssiId; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java index d03673368c..bdc2c608e2 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java @@ -26,7 +26,9 @@ import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) public class AllocateCnNssi implements Serializable { + @Deprecated public final static String URL = "/api/rest/provMns/v1/NSS/SliceProfiles"; + private static final long serialVersionUID = 4909074863148869163L; private String nsstId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java index b66fb133d2..f85cb0cd85 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java @@ -20,90 +20,17 @@ package org.onap.so.beans.nsmf; -import com.fasterxml.jackson.annotation.JsonInclude; -@JsonInclude(JsonInclude.Include.NON_NULL) -public class AllocateTnNssi { +import lombok.Data; +import java.io.Serializable; +import java.util.List; - public final static String URL = "/api/rest/provMns/v1/tn/NSS" + "/SliceProfiles"; +@Data +public class AllocateTnNssi implements Serializable { - private String nsstId; + private static final long serialVersionUID = -7069801712339914746L; - private String flavorId; + private List<NetworkSliceInfo> networkSliceInfos; - private String nssiId; - - private String nssiName; - - private TnSliceProfile sliceProfile; - - private String scriptName; - - private Object extension; - - private NsiInfo nsiInfo; - - public String getNsstId() { - return nsstId; - } - - public void setNsstId(String nsstId) { - this.nsstId = nsstId; - } - - public String getFlavorId() { - return flavorId; - } - - public void setFlavorId(String flavorId) { - this.flavorId = flavorId; - } - - public String getNssiId() { - return nssiId; - } - - public void setNssiId(String nssiId) { - this.nssiId = nssiId; - } - - public String getNssiName() { - return nssiName; - } - - public void setNssiName(String nssiName) { - this.nssiName = nssiName; - } - - public TnSliceProfile getSliceProfile() { - return sliceProfile; - } - - public void setSliceProfile(TnSliceProfile sliceProfile) { - this.sliceProfile = sliceProfile; - } - - public String getScriptName() { - return scriptName; - } - - public void setScriptName(String scriptName) { - this.scriptName = scriptName; - } - - public Object getExtension() { - return extension; - } - - public void setExtension(Object extension) { - this.extension = extension; - } - - public NsiInfo getNsiInfo() { - return nsiInfo; - } - - public void setNsiInfo(NsiInfo nsiInfo) { - this.nsiInfo = nsiInfo; - } + private List<TransportSliceNetwork> transportSliceNetworks; } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java index 3590c683e6..418f8a5065 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenRequest.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java @@ -18,37 +18,30 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.nssmf.model; +package org.onap.so.beans.nsmf; -public class TokenRequest { +import com.fasterxml.jackson.annotation.JsonInclude; - private String grantType; +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AnPerfReq { - private String userName; + private PerfReqEmbb perfReqEmbb; - private String value; + private PerfReqUrllc perfReqUrllc; - public String getGrantType() { - return grantType; + public PerfReqEmbb getPerfReqEmbb() { + return perfReqEmbb; } - public void setGrantType(String grantType) { - this.grantType = grantType; + public void setPerfReqEmbb(PerfReqEmbb perfReqEmbb) { + this.perfReqEmbb = perfReqEmbb; } - public String getUserName() { - return userName; + public PerfReqUrllc getPerfReqUrllc() { + return perfReqUrllc; } - public void setUserName(String userName) { - this.userName = userName; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; + public void setPerfReqUrllc(PerfReqUrllc perfReqUrllc) { + this.perfReqUrllc = perfReqUrllc; } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java index 3d60949385..83675da5f0 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java @@ -22,40 +22,40 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) +@Data public class AnSliceProfile { - @JsonProperty("5QI") - private String qi; + @JsonProperty(value = "sliceProfileId", required = true) + private String sliceProfileId; - private List<String> coverageAreaTAList; + @JsonProperty(value = "sNSSAIList", required = true) + private List<String> sNSSAIList; - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int latency; + @JsonProperty(value = "pLMNIdList", required = true) + private List<String> pLMNIdList; + + @JsonProperty(value = "perfReq", required = true) + private AnPerfReq perfReq; - public String getQi() { - return qi; - } + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + @JsonProperty(value = "maxNumberofUEs") + private long maxNumberofUEs; - public void setQi(String qi) { - this.qi = qi; - } + @JsonProperty(value = "coverageAreaTAList") + private List<Integer> coverageAreaTAList; - public List<String> getCoverageAreaTAList() { - return coverageAreaTAList; - } + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + @JsonProperty(value = "latency") + private int latency; - public void setCoverageAreaTAList(List<String> coverageAreaTAList) { - this.coverageAreaTAList = coverageAreaTAList; - } + @JsonProperty(value = "uEMobilityLevel") + private UeMobilityLevel uEMobilityLevel; - public int getLatency() { - return latency; - } + @JsonProperty(value = "resourceSharingLevel") + private ResourceSharingLevel resourceSharingLevel; - public void setLatency(int latency) { - this.latency = latency; - } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java new file mode 100644 index 0000000000..99a8525974 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + + +import java.io.Serializable; + + +public class ConnectionLink implements Serializable { + private static final long serialVersionUID = -1834584960407180427L; + + private String transportEndpointA; + + private String transportEndpointB; + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getTransportEndpointA() { + return transportEndpointA; + } + + public void setTransportEndpointA(String transportEndpointA) { + this.transportEndpointA = transportEndpointA; + } + + public String getTransportEndpointB() { + return transportEndpointB; + } + + public void setTransportEndpointB(String transportEndpointB) { + this.transportEndpointB = transportEndpointB; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java index 648fd4985f..399d51e894 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java @@ -25,7 +25,7 @@ import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) public class DeAllocateNssi { - + @Deprecated public final static String URL = "/api/rest/provMns/v1/NSS" + "/SliceProfiles/%s"; private String nsiId; @@ -41,6 +41,16 @@ public class DeAllocateNssi { private String extension; + private String sliceProfileId; + + public String getSliceProfileId() { + return sliceProfileId; + } + + public void setSliceProfileId(String sliceProfileId) { + this.sliceProfileId = sliceProfileId; + } + public String getNsiId() { return nsiId; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java new file mode 100644 index 0000000000..dab9b3a990 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class EndPoint implements Serializable { + + private static final long serialVersionUID = 2479795890807020491L; + + private String nodeId; + + private Map<String, Object> additionalInfo; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java index d720399293..f8ff5be70e 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java @@ -26,6 +26,7 @@ import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) public class EsrInfo implements Serializable { + private static final long serialVersionUID = -7696600990607396263L; private String vendor; private NetworkType networkType; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ModifyAction.java b/common/src/main/java/org/onap/so/beans/nsmf/ModifyAction.java new file mode 100644 index 0000000000..57cb2b02aa --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ModifyAction.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + +public enum ModifyAction { + allocate, deallocate +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NetworkSliceInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NetworkSliceInfo.java new file mode 100644 index 0000000000..a190a82646 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NetworkSliceInfo.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + + +import lombok.Data; +import java.io.Serializable; + +@Data +public class NetworkSliceInfo implements Serializable { + private static final long serialVersionUID = 4401921718259398587L; + + private String snssai; + + private String customer; + + private String serviceType; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java index 0ff554d10d..d1679c6dfa 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java @@ -37,11 +37,11 @@ public class NsiInfo { this.nsiName = nsiName; } - public void setNsiId(String nsiId) { - this.nsiId = nsiId; - } - public String getNsiId() { return nsiId; } + + public void setNsiId(String nsiId) { + this.nsiId = nsiId; + } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java index f72a74a063..9a25d6fea3 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java @@ -21,10 +21,15 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import javax.validation.constraints.NotNull; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class NssiAllocateRequest { +public class NssiAllocateRequest implements Serializable { + private static final long serialVersionUID = -454145891489457960L; + + @NotNull private EsrInfo esrInfo; private AllocateCnNssi allocateCnNssi; @@ -33,6 +38,8 @@ public class NssiAllocateRequest { private AllocateAnNssi allocateAnNssi; + private ServiceInfo serviceInfo; + public EsrInfo getEsrInfo() { return esrInfo; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java new file mode 100644 index 0000000000..a44dbd636f --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; + + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class NssmfAdapterNBIRequest implements Serializable { + + private static final long serialVersionUID = -454145891489457960L; + + private EsrInfo esrInfo; + + private ServiceInfo serviceInfo; + + private AllocateCnNssi allocateCnNssi; + + private AllocateTnNssi allocateTnNssi; + + private AllocateAnNssi allocateAnNssi; + + private ActDeActNssi actDeActNssi; + + private DeAllocateNssi deAllocateNssi; + + private String subnetCapabilityQuery; + + private String responseId; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java new file mode 100644 index 0000000000..3292730f29 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class NssmfRequest implements Serializable { + + private static final long serialVersionUID = 3313218757241310655L; + + private String name; + + private String modelInvariantUuid; + + private String modelUuid; + + private String globalSubscriberId; + + private String serviceInstanceId; + + private String subscriptionServiceType; + + private NetworkType networkType; + + private Object additionalProperties; + + public NssmfRequest() {} + + public NssmfRequest(ServiceInfo serviceInfo, NetworkType networkType, Object additionalProperties) { + this.modelInvariantUuid = serviceInfo.getServiceInvariantUuid(); + this.modelUuid = serviceInfo.getServiceUuid(); + this.globalSubscriberId = serviceInfo.getGlobalSubscriberId(); + this.subscriptionServiceType = serviceInfo.getSubscriptionServiceType(); + this.networkType = networkType; + this.additionalProperties = additionalProperties; + this.serviceInstanceId = serviceInfo.getNssiId(); + this.name = serviceInfo.getNssiName(); + } + +} + + +/** + * { "name": "eMBB-001", "modelInvariantUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX", "modelUuid": + * "NSST-C-001-HDBNJ-NSSMF-01-A-ZX-UUID", "globalSubscriberId": "5GCustomer", "subscriptionServiceType": "5G", + * "networkType": "AN/CN/TN", "additionalProperties": { "sliceProfile": { "snssaiList": [ "001-100001" ], + * "sliceProfileId": "ab9af40f13f721b5f13539d87484098", "plmnIdList": [ "460-00", "460-01" ], "perfReq": { + * "perfReqEmbbList ": [ { "activityFactor": 50 } ] }, "maxNumberofUEs": 200, "coverageAreaTAList": [ "1", "2", "3", "4" + * ], "latency": 2, "resourceSharingLevel": "non-shared" }, "endPoints": [ { "nodeId": "", "additionalInfo": { "xxx": + * "xxx" } }, { "nodeId": "", "additionalInfo": { "xxx": "xxx" } } ], "nsiInfo": { "nsiId": + * "NSI-M-001-HDBNJ-NSMF-01-A-ZX", "nsiName": "eMBB-001" }, "scriptName": "AN1" } } + */ diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java index 4aabc3f26f..c67f193a02 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java @@ -26,23 +26,23 @@ import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) public class PerfReq { - private List<PerfReqEmbbList> perfReqEmbbList; + private List<PerfReqEmbb> perfReqEmbbList; - private List<PerfReqUrllcList> perfReqUrllcList; + private List<PerfReqUrllc> perfReqUrllcList; - public List<PerfReqEmbbList> getPerfReqEmbbList() { + public List<PerfReqEmbb> getPerfReqEmbbList() { return perfReqEmbbList; } - public void setPerfReqEmbbList(List<PerfReqEmbbList> perfReqEmbbList) { + public void setPerfReqEmbbList(List<PerfReqEmbb> perfReqEmbbList) { this.perfReqEmbbList = perfReqEmbbList; } - public List<PerfReqUrllcList> getPerfReqUrllcList() { + public List<PerfReqUrllc> getPerfReqUrllcList() { return perfReqUrllcList; } - public void setPerfReqUrllcList(List<PerfReqUrllcList> perfReqUrllcList) { + public void setPerfReqUrllcList(List<PerfReqUrllc> perfReqUrllcList) { this.perfReqUrllcList = perfReqUrllcList; } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbbList.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java index 9e9fcaa19e..bce0d56f9a 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbbList.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java @@ -23,7 +23,7 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) -public class PerfReqEmbbList { +public class PerfReqEmbb { @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int expDataRateDL; @@ -38,6 +38,9 @@ public class PerfReqEmbbList { private int areaTrafficCapUL; @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int overallUserDensity; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int activityFactor; public int getExpDataRateDL() { @@ -72,6 +75,14 @@ public class PerfReqEmbbList { this.areaTrafficCapUL = areaTrafficCapUL; } + public int getOverallUserDensity() { + return overallUserDensity; + } + + public void setOverallUserDensity(int overallUserDensity) { + this.overallUserDensity = overallUserDensity; + } + public int getActivityFactor() { return activityFactor; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllcList.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java index 00f0a917aa..0b05d39bab 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllcList.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java @@ -23,7 +23,7 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) -public class PerfReqUrllcList { +public class PerfReqUrllc { @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int e2eLatency; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java new file mode 100644 index 0000000000..7a52cc85cb --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@Data +public class ServiceInfo implements Serializable { + + private static final long serialVersionUID = 7895110339097615695L; + + private String serviceInvariantUuid; + + private String serviceUuid; + + private String globalSubscriberId; + + private String subscriptionServiceType; + + private String serviceType; + + private String nsiId; + + private String nssiId; + + private String sST; + + private String nssiName; + + private String pLMNIdList; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java index 6c5d9c6909..cc6c9bbb82 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java @@ -21,7 +21,11 @@ package org.onap.so.beans.nsmf; import java.io.Serializable; +import java.util.HashMap; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfile.java new file mode 100644 index 0000000000..919a5d8114 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfile.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class SliceProfile implements Serializable { + + private static final long serialVersionUID = 7924389625656716814L; + + private List<String> snssaiList; + + private String sliceProfileId; + + private List<String> plmnIdList; + + private PerfReq perfReq; + + private Integer maxNumberofUEs; + + private List<String> coverageAreaTAList; + + private Integer latency; + + private String resourceSharingLevel; + +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java new file mode 100644 index 0000000000..dd1292e7e5 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java @@ -0,0 +1,33 @@ +package org.onap.so.beans.nsmf; + +import lombok.Data; +import org.onap.so.beans.nsmf.oof.TemplateInfo; +import java.io.Serializable; + +@Data +public class SliceTaskInfo<T> implements Serializable { + private static final long serialVersionUID = 7580056468353975320L; + + private String suggestNssiId; + + private String suggestNssiName; + + private String progress; + + private String status; + + private String statusDescription; + + private T sliceProfile; + + private TemplateInfo NSSTInfo; + + private String serviceInstanceId; + + private String scriptName; + + private String vendor; + + private NetworkType networkType; + +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java new file mode 100644 index 0000000000..cab209ebd1 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java @@ -0,0 +1,36 @@ +package org.onap.so.beans.nsmf; + +import lombok.Data; +import org.onap.so.beans.nsmf.oof.TemplateInfo; + + +@Data +public class SliceTaskParamsAdapter { + private static final long serialVersionUID = -7785578865170503301L; + + private String serviceId; + + private String serviceName; + + private String nstId; + + private String nstName; + + private ServiceProfile serviceProfile; + + private String suggestNsiId; + + private String suggestNsiName; + + private TemplateInfo NSTInfo; + + private SliceTaskInfo<TnSliceProfile> tnBHSliceTaskInfo; + + private SliceTaskInfo<TnSliceProfile> tnMHSliceTaskInfo; + + private SliceTaskInfo<TnSliceProfile> tnFHSliceTaskInfo; + + private SliceTaskInfo<CnSliceProfile> cnSliceTaskInfo; + + private SliceTaskInfo<AnSliceProfile> anSliceTaskInfo; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java index c3548f15af..be530bfb9c 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java @@ -25,11 +25,21 @@ import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) public class TnSliceProfile { + private String sliceProfileId; + private String bandwidth; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int latency; + public String getSliceProfileId() { + return sliceProfileId; + } + + public void setSliceProfileId(String sliceProfileId) { + this.sliceProfileId = sliceProfileId; + } + public String getBandwidth() { return bandwidth; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java new file mode 100644 index 0000000000..aa2579edf8 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # 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.beans.nsmf; + +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@Data +public class TransportSliceNetwork implements Serializable { + private static final long serialVersionUID = 809947462399806990L; + + private List<ConnectionLink> connectionLinks; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/DomainType.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/DomainType.java new file mode 100644 index 0000000000..4af60cf492 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/DomainType.java @@ -0,0 +1,27 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Getter; +import org.onap.so.beans.nsmf.NetworkType; + +@Getter +public enum DomainType { + + AN_NF("AN-NF", NetworkType.ACCESS), + + CN("CN", NetworkType.CORE), + + TN_FH("TN-FH", NetworkType.TRANSPORT), + + TN_MH("TN-MH", NetworkType.TRANSPORT), + + TN_BH("TN-BH", NetworkType.TRANSPORT),; + + private NetworkType networkType; + + private String domainType; + + DomainType(String domainType, NetworkType networkType) { + this.domainType = domainType; + this.networkType = networkType; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java new file mode 100644 index 0000000000..e1829eb2c3 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java @@ -0,0 +1,23 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import org.onap.so.beans.nsmf.ServiceProfile; +import java.io.Serializable; +import java.util.List; + +@Data +public class NsiReqBody implements Serializable { + private static final long serialVersionUID = -1383112063216226985L; + + private ServiceProfile serviceProfile; + + private RequestInfo requestInfo; + + private TemplateInfo NSTInfo; + + private List<TemplateInfo> NSSTInfo; + + private Boolean preferReuse; + + private List<SubnetCapability> subnetCapabilities; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/NssiReqBody.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/NssiReqBody.java new file mode 100644 index 0000000000..0632ab78e9 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/NssiReqBody.java @@ -0,0 +1,17 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import org.onap.so.beans.nsmf.ServiceProfile; +import java.io.Serializable; + +@Data +public class NssiReqBody implements Serializable { + + private static final long serialVersionUID = -76327522074333341L; + + private ServiceProfile serviceProfile; + + private RequestInfo requestInfo; + + private TemplateInfo NSSTInfo; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/RequestInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/RequestInfo.java new file mode 100644 index 0000000000..f900c3599d --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/RequestInfo.java @@ -0,0 +1,27 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import java.io.Serializable; +import java.util.Map; + +@Data +public class RequestInfo implements Serializable { + + private static final long serialVersionUID = -875589918188540922L; + + private String transactionId; + + private String requestId; + + private String callbackUrl; + + private Map<?, ?> callbackHeader; + + private String sourceId; + + private Integer numSolutions; + + private Integer timeout; + + private Map<?, ?> addtnlArgs; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/SubnetCapability.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/SubnetCapability.java new file mode 100644 index 0000000000..f21c1c379e --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/SubnetCapability.java @@ -0,0 +1,15 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import java.io.Serializable; +import java.util.Map; + +@Data +public class SubnetCapability implements Serializable { + + private static final long serialVersionUID = -7671021271451538821L; + + private String domainType; + + private Map<?, ?> capabilityDetails; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/TemplateInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/TemplateInfo.java new file mode 100644 index 0000000000..3713bc7186 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/TemplateInfo.java @@ -0,0 +1,17 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import java.io.Serializable; + + +@Data +public class TemplateInfo implements Serializable { + + private static final long serialVersionUID = 4237411651259839093L; + + private String UUID; + + private String invariantUUID; + + private String name; +} diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java index fff82ea5bc..33958a7850 100644 --- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java +++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java @@ -1,8 +1,10 @@ package org.onap.so.utils; import java.security.GeneralSecurityException; +import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; import org.camunda.bpm.client.ExternalTaskClient; import org.camunda.bpm.client.interceptor.ClientRequestInterceptor; import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider; @@ -75,7 +77,20 @@ public class ExternalTaskServiceUtils { @ScheduledLogging @Scheduled(fixedDelay = 30000) public void checkAllClientsActive() { - getClients().stream().filter(client -> !client.isActive()).forEach(ExternalTaskClient::start); + try { + logger.debug("Executing scheduled task to check and restart external task clients"); // TODO remove + // eventually + List<ExternalTaskClient> inactiveClients = + getClients().stream().filter(client -> !client.isActive()).collect(Collectors.toList()); + + inactiveClients.forEach(c -> { + logger.debug("External Task Client found to be inactive. Restarting Client."); + c.start(); + }); + } catch (Exception e) { + logger.error("Exception occured in checkAllClientsActive", e); + } + } protected Set<ExternalTaskClient> getClients() { diff --git a/docs/api/swagger/swagger.html b/docs/api/swagger/swagger.html index 5d7c963a8a..514c2bdda2 100644 --- a/docs/api/swagger/swagger.html +++ b/docs/api/swagger/swagger.html @@ -843,11 +843,191 @@ margin-bottom: 20px; }, "description" : "This describes the subnet capabilities that can be queried" }; + defs["RetrievingWorkflowResponse"] = { + "type" : "object", + "properties" : { + "workflowSpecificationList" : { + "type" : "array", + "description" : "List of Workflow specification data", + "items" : { + "$ref" : "#/definitions/WorkflowSpecification" + } + } + }, + "description" : "Response body of fetching workflows using resource target" +}; + defs["ServiceLevelWorkflowExecution"] = { + "type" : "object", + "properties" : { + "requestInfo" : { + "$ref" : "#/definitions/ServiceLevelWorkflowExecution_requestInfo" + }, + "modelInfo" : { + "$ref" : "#/definitions/ServiceLevelWorkflowExecution_modelInfo" + }, + "requestParameters" : { + "$ref" : "#/definitions/ServiceLevelWorkflowExecution_requestParameters" + }, + "subscriberInfo" : { + "$ref" : "#/definitions/ServiceLevelWorkflowExecution_subscriberInfo" + }, + "project" : { + "$ref" : "#/definitions/ServiceLevelWorkflowExecution_project" + }, + "owningEntity" : { + "$ref" : "#/definitions/ServiceLevelWorkflowExecution_owningEntity" + } + }, + "description" : "This describes the request body of service level custom workflow execution" +}; + defs["ServiceLevelWorkflowExecution_modelInfo"] = { + "type" : "object", + "properties" : { + "modelType" : { + "type" : "string", + "description" : "Type of the model to be executed" + }, + "modelInvariantUuid" : { + "type" : "string", + "description" : "Model invariant id corresponding to the service" + }, + "modelUuid" : { + "type" : "string", + "description" : "Model uuid corresponding to the service" + }, + "modelVersionId" : { + "type" : "string", + "description" : "Model version of the service instance" + }, + "modelName" : { + "type" : "string", + "description" : "Name of the service" + }, + "modelVersion" : { + "type" : "string", + "description" : "Version of the service instance" + } + }, + "description" : "Parameters related to the service model" +}; + defs["ServiceLevelWorkflowExecution_owningEntity"] = { + "type" : "object", + "properties" : { + "owningEntityId" : { + "type" : "string", + "description" : "Id of the owning Entity" + }, + "owningEntityName" : { + "type" : "string", + "description" : "Name of the owning Entity" + } + }, + "description" : "Object describes the entity details" +}; + defs["ServiceLevelWorkflowExecution_project"] = { + "type" : "object", + "properties" : { + "projectName" : { + "type" : "string", + "description" : "Name of the target project" + } + }, + "description" : "Information about the target project name" +}; + defs["ServiceLevelWorkflowExecution_requestInfo"] = { + "type" : "object", + "properties" : { + "source" : { + "type" : "string", + "description" : "Name of the sender" + }, + "suppressRollback" : { + "type" : "boolean", + "description" : "Enable/disable rollback suppression" + }, + "requestorId" : { + "type" : "string", + "description" : "Id of the sender" + } + }, + "description" : "Request object contains source information" +}; + defs["ServiceLevelWorkflowExecution_requestParameters"] = { + "type" : "object", + "properties" : { + "subscriptionServiceType" : { + "type" : "string", + "description" : "Type of service subscription" + } + }, + "description" : "User parameter object" +}; + defs["ServiceLevelWorkflowExecution_subscriberInfo"] = { + "type" : "object", + "properties" : { + "globalSubscriberId" : { + "type" : "string", + "description" : "Id of the subscriber sending the request" + } + }, + "description" : "Subscriber id information" +}; defs["SubnetTypes"] = { "type" : "string", "description" : "This describes allowed subnet types", "enum" : [ "AN", "AN_NF", "CN", "TN_FH", "TN_MH", "TN_BH" ] }; + defs["WorkflowSpecification"] = { + "type" : "object", + "properties" : { + "artifactInfo" : { + "$ref" : "#/definitions/WorkflowSpecification_artifactInfo" + } + }, + "description" : "This describes workflow specification object" +}; + defs["WorkflowSpecification_artifactInfo"] = { + "type" : "object", + "properties" : { + "artifactType" : { + "type" : "string", + "description" : "Type of the artifact to be queried" + }, + "artifactUuid" : { + "type" : "string", + "description" : "UUID of the artifact" + }, + "artifactName" : { + "type" : "string", + "description" : "Name of the artifact" + }, + "artifactVersion" : { + "type" : "string", + "description" : "Artifact's Version" + }, + "artifactDescription" : { + "type" : "string", + "description" : "" + }, + "workflowName" : { + "type" : "string", + "description" : "Name of the workflow fetched for the resource type" + }, + "operationName" : { + "type" : "string", + "description" : "Mapped operation name of the corresponding workflow" + }, + "workflowSource" : { + "type" : "string", + "description" : "" + }, + "workflowResourceTarget" : { + "type" : "string", + "description" : "Type of Resource mapped against the workflow" + } + }, + "description" : "Attributes related to artifact information " +}; </script> <div class="container-fluid"> @@ -930,6 +1110,10 @@ margin-bottom: 20px; <li data-group="OnapsoinfracloudResourcesRequests" data-name="unlockOrchestrationRequestForReqId" class=""> <a href="#api-OnapsoinfracloudResourcesRequests-unlockOrchestrationRequestForReqId">unlockOrchestrationRequestForReqId</a> </li> + <li class="nav-header" data-group="OnapsoinfrainstanceManagement"><a href="#api-OnapsoinfrainstanceManagement">API Methods - OnapsoinfrainstanceManagement</a></li> + <li data-group="OnapsoinfrainstanceManagement" data-name="executeServiceLevelCustomWorkflow" class=""> + <a href="#api-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow">executeServiceLevelCustomWorkflow</a> + </li> <li class="nav-header" data-group="OnapsoinframodelDistributions"><a href="#api-OnapsoinframodelDistributions">API Methods - OnapsoinframodelDistributions</a></li> <li data-group="OnapsoinframodelDistributions" data-name="updateModelDistributionStatus" class=""> <a href="#api-OnapsoinframodelDistributions-updateModelDistributionStatus">updateModelDistributionStatus</a> @@ -1067,6 +1251,10 @@ margin-bottom: 20px; <li data-group="Onapsoinfratasks" data-name="queryFilters" class=""> <a href="#api-Onapsoinfratasks-queryFilters">queryFilters</a> </li> + <li class="nav-header" data-group="OnapsoinfraworkflowSpecifications"><a href="#api-OnapsoinfraworkflowSpecifications">API Methods - OnapsoinfraworkflowSpecifications</a></li> + <li data-group="OnapsoinfraworkflowSpecifications" data-name="queryWorkflowSpecifications" class=""> + <a href="#api-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications">queryWorkflowSpecifications</a> + </li> </ul> </nav> </div> @@ -1449,7 +1637,7 @@ $(document).ready(function() { <article id="api-E2eServiceInstances-compareModelwithTargetVersion-0" data-group="User" data-name="compareModelwithTargetVersion" data-version="0"> <div class="pull-left"> <h1>compareModelwithTargetVersion</h1> - <p>Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId </p> + <p>Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId</p> </div> <div class="pull-right"></div> <div class="clearfix"></div> @@ -1536,7 +1724,7 @@ String *body = body_example; // (optional) E2eServiceInstancesApi *apiInstance = [[E2eServiceInstancesApi alloc] init]; -// Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId +// Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId [apiInstance compareModelwithTargetVersionWith:serviceId version:version body:body @@ -1596,7 +1784,7 @@ namespace Example try { - // Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId + // Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId apiInstance.compareModelwithTargetVersion(serviceId, version, body); } catch (Exception e) @@ -1658,7 +1846,7 @@ version = version_example # String | body = body_example # String | (optional) try: - # Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId + # Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId api_instance.compare_modelwith_target_version(serviceId, version, body=body) except ApiException as e: print("Exception when calling E2eServiceInstancesApi->compareModelwithTargetVersion: %s\n" % e)</code></pre> @@ -7385,6 +7573,366 @@ $(document).ready(function() { </div> <hr> </section> + <section id="api-OnapsoinfrainstanceManagement"> + <h1>OnapsoinfrainstanceManagement</h1> + <div id="api-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow"> + <article id="api-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0" data-group="User" data-name="executeServiceLevelCustomWorkflow" data-version="0"> + <div class="pull-left"> + <h1>executeServiceLevelCustomWorkflow</h1> + <p>Executing service level custom workflow</p> + </div> + <div class="pull-right"></div> + <div class="clearfix"></div> + <p></p> + <p class="marked"></p> + <p></p> + <br /> + <pre class="prettyprint language-html prettyprinted" data-type="post"><code><span class="pln">/onap/so/infra/instanceManagement/{version}/serviceInstances/{serviceInstanceId}/workflows/{workflow_UUID}</span></code></pre> + <p> + <h3>Usage and SDK Samples</h3> + </p> + <ul class="nav nav-tabs nav-tabs-examples"> + <li class="active"><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-curl">Curl</a></li> + <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-java">Java</a></li> + <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-android">Android</a></li> + <!--<li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-groovy">Groovy</a></li>--> + <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-objc">Obj-C</a></li> + <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-javascript">JavaScript</a></li> + <!--<li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-angular">Angular</a></li>--> + <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-csharp">C#</a></li> + <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-php">PHP</a></li> + <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-perl">Perl</a></li> + <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-python">Python</a></li> + </ul> + + <div class="tab-content"> + <div class="tab-pane active" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-curl"> + <pre class="prettyprint"><code class="language-bsh">curl -X POST "http://localhost/onap/so/infra/instanceManagement/{version}/serviceInstances/{serviceInstanceId}/workflows/{workflow_UUID}"</code></pre> + </div> + <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-java"> + <pre class="prettyprint"><code class="language-java">import io.swagger.client.*; +import io.swagger.client.auth.*; +import io.swagger.client.model.*; +import io.swagger.client.api.OnapsoinfrainstanceManagementApi; + +import java.io.File; +import java.util.*; + +public class OnapsoinfrainstanceManagementApiExample { + + public static void main(String[] args) { + + OnapsoinfrainstanceManagementApi apiInstance = new OnapsoinfrainstanceManagementApi(); + String version = version_example; // String | + String serviceInstanceId = serviceInstanceId_example; // String | + String workflowUUID = workflowUUID_example; // String | + ServiceLevelWorkflowExecution body = ; // ServiceLevelWorkflowExecution | + try { + apiInstance.executeServiceLevelCustomWorkflow(version, serviceInstanceId, workflowUUID, body); + } catch (ApiException e) { + System.err.println("Exception when calling OnapsoinfrainstanceManagementApi#executeServiceLevelCustomWorkflow"); + e.printStackTrace(); + } + } +}</code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-android"> + <pre class="prettyprint"><code class="language-java">import io.swagger.client.api.OnapsoinfrainstanceManagementApi; + +public class OnapsoinfrainstanceManagementApiExample { + + public static void main(String[] args) { + OnapsoinfrainstanceManagementApi apiInstance = new OnapsoinfrainstanceManagementApi(); + String version = version_example; // String | + String serviceInstanceId = serviceInstanceId_example; // String | + String workflowUUID = workflowUUID_example; // String | + ServiceLevelWorkflowExecution body = ; // ServiceLevelWorkflowExecution | + try { + apiInstance.executeServiceLevelCustomWorkflow(version, serviceInstanceId, workflowUUID, body); + } catch (ApiException e) { + System.err.println("Exception when calling OnapsoinfrainstanceManagementApi#executeServiceLevelCustomWorkflow"); + e.printStackTrace(); + } + } +}</code></pre> + </div> + <!-- + <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-groovy"> + <pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre> + </div> --> + <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-objc"> + <pre class="prettyprint"><code class="language-cpp">String *version = version_example; // +String *serviceInstanceId = serviceInstanceId_example; // +String *workflowUUID = workflowUUID_example; // +ServiceLevelWorkflowExecution *body = ; // (optional) + +OnapsoinfrainstanceManagementApi *apiInstance = [[OnapsoinfrainstanceManagementApi alloc] init]; + +// Executing service level custom workflow +[apiInstance executeServiceLevelCustomWorkflowWith:version + serviceInstanceId:serviceInstanceId + workflowUUID:workflowUUID + body:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +</code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-javascript"> + <pre class="prettyprint"><code class="language-js">var SoGuilinApIs = require('so_guilin_ap_is'); + +var api = new SoGuilinApIs.OnapsoinfrainstanceManagementApi() + +var version = version_example; // {String} + +var serviceInstanceId = serviceInstanceId_example; // {String} + +var workflowUUID = workflowUUID_example; // {String} + +var opts = { + 'body': // {ServiceLevelWorkflowExecution} +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.executeServiceLevelCustomWorkflow(version, serviceInstanceId, workflowUUID, opts, callback); +</code></pre> + </div> + + <!--<div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-angular"> + <pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre> + </div>--> + <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-csharp"> + <pre class="prettyprint"><code class="language-cs">using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class executeServiceLevelCustomWorkflowExample + { + public void main() + { + + var apiInstance = new OnapsoinfrainstanceManagementApi(); + var version = version_example; // String | + var serviceInstanceId = serviceInstanceId_example; // String | + var workflowUUID = workflowUUID_example; // String | + var body = new ServiceLevelWorkflowExecution(); // ServiceLevelWorkflowExecution | (optional) + + try + { + // Executing service level custom workflow + apiInstance.executeServiceLevelCustomWorkflow(version, serviceInstanceId, workflowUUID, body); + } + catch (Exception e) + { + Debug.Print("Exception when calling OnapsoinfrainstanceManagementApi.executeServiceLevelCustomWorkflow: " + e.Message ); + } + } + } +} +</code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-php"> + <pre class="prettyprint"><code class="language-php"><?php +require_once(__DIR__ . '/vendor/autoload.php'); + +$api_instance = new Swagger\Client\Api\OnapsoinfrainstanceManagementApi(); +$version = version_example; // String | +$serviceInstanceId = serviceInstanceId_example; // String | +$workflowUUID = workflowUUID_example; // String | +$body = ; // ServiceLevelWorkflowExecution | + +try { + $api_instance->executeServiceLevelCustomWorkflow($version, $serviceInstanceId, $workflowUUID, $body); +} catch (Exception $e) { + echo 'Exception when calling OnapsoinfrainstanceManagementApi->executeServiceLevelCustomWorkflow: ', $e->getMessage(), PHP_EOL; +} +?></code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-perl"> + <pre class="prettyprint"><code class="language-perl">use Data::Dumper; +use WWW::SwaggerClient::Configuration; +use WWW::SwaggerClient::OnapsoinfrainstanceManagementApi; + +my $api_instance = WWW::SwaggerClient::OnapsoinfrainstanceManagementApi->new(); +my $version = version_example; # String | +my $serviceInstanceId = serviceInstanceId_example; # String | +my $workflowUUID = workflowUUID_example; # String | +my $body = WWW::SwaggerClient::Object::ServiceLevelWorkflowExecution->new(); # ServiceLevelWorkflowExecution | + +eval { + $api_instance->executeServiceLevelCustomWorkflow(version => $version, serviceInstanceId => $serviceInstanceId, workflowUUID => $workflowUUID, body => $body); +}; +if ($@) { + warn "Exception when calling OnapsoinfrainstanceManagementApi->executeServiceLevelCustomWorkflow: $@\n"; +}</code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-python"> + <pre class="prettyprint"><code class="language-python">from __future__ import print_statement +import time +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint + +# create an instance of the API class +api_instance = swagger_client.OnapsoinfrainstanceManagementApi() +version = version_example # String | +serviceInstanceId = serviceInstanceId_example # String | +workflowUUID = workflowUUID_example # String | +body = # ServiceLevelWorkflowExecution | (optional) + +try: + # Executing service level custom workflow + api_instance.execute_service_level_custom_workflow(version, serviceInstanceId, workflowUUID, body=body) +except ApiException as e: + print("Exception when calling OnapsoinfrainstanceManagementApi->executeServiceLevelCustomWorkflow: %s\n" % e)</code></pre> + </div> + </div> + + <h2>Parameters</h2> + + <div class="methodsubtabletitle">Path parameters</div> + <table id="methodsubtable"> + <tr> + <th width="150px">Name</th> + <th>Description</th> + </tr> + <tr><td style="width:150px;">version*</td> +<td> + + + <div id="d2e199_executeServiceLevelCustomWorkflow_version"> + <div class="json-schema-view"> + <div class="primitive"> + <span class="type"> + String + </span> + + </div> + <div class="inner required"> + Required + </div> + </div> + </div> +</td> +</tr> + + <tr><td style="width:150px;">serviceInstanceId*</td> +<td> + + + <div id="d2e199_executeServiceLevelCustomWorkflow_serviceInstanceId"> + <div class="json-schema-view"> + <div class="primitive"> + <span class="type"> + String + </span> + + </div> + <div class="inner required"> + Required + </div> + </div> + </div> +</td> +</tr> + + <tr><td style="width:150px;">workflow_UUID*</td> +<td> + + + <div id="d2e199_executeServiceLevelCustomWorkflow_workflowUUID"> + <div class="json-schema-view"> + <div class="primitive"> + <span class="type"> + String + </span> + + </div> + <div class="inner required"> + Required + </div> + </div> + </div> +</td> +</tr> + + </table> + + + <div class="methodsubtabletitle">Body parameters</div> + <table id="methodsubtable"> + <tr> + <th width="150px">Name</th> + <th>Description</th> + </tr> + <tr><td style="width:150px;">body </td> +<td> + + +<script> +$(document).ready(function() { + var schemaWrapper = { + "in" : "body", + "name" : "body", + "required" : false, + "schema" : { + "$ref" : "#/definitions/ServiceLevelWorkflowExecution" + } +}; + var schema = schemaWrapper.schema; + if (schema.$ref != null) { + schema = defsParser.$refs.get(schema.$ref); + } else { + schemaWrapper.definitions = Object.assign({}, defs); + $RefParser.dereference(schemaWrapper).catch(function(err) { + console.log(err); + }); + } + + var view = new JSONSchemaView(schema,2,{isBodyParam: true}); + var result = $('#d2e199_executeServiceLevelCustomWorkflow_body'); + result.empty(); + result.append(view.render()); +}); +</script> +<div id="d2e199_executeServiceLevelCustomWorkflow_body"></div> +</td> +</tr> + + </table> + + + + <h2>Responses</h2> + <h3> Status: default - successful operation </h3> + + <ul class="nav nav-tabs nav-tabs-examples" > + </ul> + + <div class="tab-content" style='margin-bottom: 10px;'> + </div> + + </article> + </div> + <hr> + </section> <section id="api-OnapsoinframodelDistributions"> <h1>OnapsoinframodelDistributions</h1> <div id="api-OnapsoinframodelDistributions-updateModelDistributionStatus"> @@ -22297,6 +22845,333 @@ except ApiException as e: </div> <hr> </section> + <section id="api-OnapsoinfraworkflowSpecifications"> + <h1>OnapsoinfraworkflowSpecifications</h1> + <div id="api-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications"> + <article id="api-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0" data-group="User" data-name="queryWorkflowSpecifications" data-version="0"> + <div class="pull-left"> + <h1>queryWorkflowSpecifications</h1> + <p>Retrieve Workflow details based on the filter criteria</p> + </div> + <div class="pull-right"></div> + <div class="clearfix"></div> + <p></p> + <p class="marked"></p> + <p></p> + <br /> + <pre class="prettyprint language-html prettyprinted" data-type="get"><code><span class="pln">/onap/so/infra/workflowSpecifications/{version}/workflows</span></code></pre> + <p> + <h3>Usage and SDK Samples</h3> + </p> + <ul class="nav nav-tabs nav-tabs-examples"> + <li class="active"><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-curl">Curl</a></li> + <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-java">Java</a></li> + <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-android">Android</a></li> + <!--<li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-groovy">Groovy</a></li>--> + <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-objc">Obj-C</a></li> + <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-javascript">JavaScript</a></li> + <!--<li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-angular">Angular</a></li>--> + <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-csharp">C#</a></li> + <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-php">PHP</a></li> + <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-perl">Perl</a></li> + <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-python">Python</a></li> + </ul> + + <div class="tab-content"> + <div class="tab-pane active" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-curl"> + <pre class="prettyprint"><code class="language-bsh">curl -X GET "http://localhost/onap/so/infra/workflowSpecifications/{version}/workflows?resourceTarget="</code></pre> + </div> + <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-java"> + <pre class="prettyprint"><code class="language-java">import io.swagger.client.*; +import io.swagger.client.auth.*; +import io.swagger.client.model.*; +import io.swagger.client.api.OnapsoinfraworkflowSpecificationsApi; + +import java.io.File; +import java.util.*; + +public class OnapsoinfraworkflowSpecificationsApiExample { + + public static void main(String[] args) { + + OnapsoinfraworkflowSpecificationsApi apiInstance = new OnapsoinfraworkflowSpecificationsApi(); + String version = version_example; // String | + String resourceTarget = resourceTarget_example; // String | + try { + RetrievingWorkflowResponse result = apiInstance.queryWorkflowSpecifications(version, resourceTarget); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnapsoinfraworkflowSpecificationsApi#queryWorkflowSpecifications"); + e.printStackTrace(); + } + } +}</code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-android"> + <pre class="prettyprint"><code class="language-java">import io.swagger.client.api.OnapsoinfraworkflowSpecificationsApi; + +public class OnapsoinfraworkflowSpecificationsApiExample { + + public static void main(String[] args) { + OnapsoinfraworkflowSpecificationsApi apiInstance = new OnapsoinfraworkflowSpecificationsApi(); + String version = version_example; // String | + String resourceTarget = resourceTarget_example; // String | + try { + RetrievingWorkflowResponse result = apiInstance.queryWorkflowSpecifications(version, resourceTarget); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnapsoinfraworkflowSpecificationsApi#queryWorkflowSpecifications"); + e.printStackTrace(); + } + } +}</code></pre> + </div> + <!-- + <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-groovy"> + <pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre> + </div> --> + <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-objc"> + <pre class="prettyprint"><code class="language-cpp">String *version = version_example; // +String *resourceTarget = resourceTarget_example; // (optional) + +OnapsoinfraworkflowSpecificationsApi *apiInstance = [[OnapsoinfraworkflowSpecificationsApi alloc] init]; + +// Retrieve Workflow details based on the filter criteria +[apiInstance queryWorkflowSpecificationsWith:version + resourceTarget:resourceTarget + completionHandler: ^(RetrievingWorkflowResponse output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +</code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-javascript"> + <pre class="prettyprint"><code class="language-js">var SoGuilinApIs = require('so_guilin_ap_is'); + +var api = new SoGuilinApIs.OnapsoinfraworkflowSpecificationsApi() + +var version = version_example; // {String} + +var opts = { + 'resourceTarget': resourceTarget_example // {String} +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.queryWorkflowSpecifications(version, opts, callback); +</code></pre> + </div> + + <!--<div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-angular"> + <pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre> + </div>--> + <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-csharp"> + <pre class="prettyprint"><code class="language-cs">using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class queryWorkflowSpecificationsExample + { + public void main() + { + + var apiInstance = new OnapsoinfraworkflowSpecificationsApi(); + var version = version_example; // String | + var resourceTarget = resourceTarget_example; // String | (optional) + + try + { + // Retrieve Workflow details based on the filter criteria + RetrievingWorkflowResponse result = apiInstance.queryWorkflowSpecifications(version, resourceTarget); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling OnapsoinfraworkflowSpecificationsApi.queryWorkflowSpecifications: " + e.Message ); + } + } + } +} +</code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-php"> + <pre class="prettyprint"><code class="language-php"><?php +require_once(__DIR__ . '/vendor/autoload.php'); + +$api_instance = new Swagger\Client\Api\OnapsoinfraworkflowSpecificationsApi(); +$version = version_example; // String | +$resourceTarget = resourceTarget_example; // String | + +try { + $result = $api_instance->queryWorkflowSpecifications($version, $resourceTarget); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling OnapsoinfraworkflowSpecificationsApi->queryWorkflowSpecifications: ', $e->getMessage(), PHP_EOL; +} +?></code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-perl"> + <pre class="prettyprint"><code class="language-perl">use Data::Dumper; +use WWW::SwaggerClient::Configuration; +use WWW::SwaggerClient::OnapsoinfraworkflowSpecificationsApi; + +my $api_instance = WWW::SwaggerClient::OnapsoinfraworkflowSpecificationsApi->new(); +my $version = version_example; # String | +my $resourceTarget = resourceTarget_example; # String | + +eval { + my $result = $api_instance->queryWorkflowSpecifications(version => $version, resourceTarget => $resourceTarget); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling OnapsoinfraworkflowSpecificationsApi->queryWorkflowSpecifications: $@\n"; +}</code></pre> + </div> + + <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-python"> + <pre class="prettyprint"><code class="language-python">from __future__ import print_statement +import time +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint + +# create an instance of the API class +api_instance = swagger_client.OnapsoinfraworkflowSpecificationsApi() +version = version_example # String | +resourceTarget = resourceTarget_example # String | (optional) + +try: + # Retrieve Workflow details based on the filter criteria + api_response = api_instance.query_workflow_specifications(version, resourceTarget=resourceTarget) + pprint(api_response) +except ApiException as e: + print("Exception when calling OnapsoinfraworkflowSpecificationsApi->queryWorkflowSpecifications: %s\n" % e)</code></pre> + </div> + </div> + + <h2>Parameters</h2> + + <div class="methodsubtabletitle">Path parameters</div> + <table id="methodsubtable"> + <tr> + <th width="150px">Name</th> + <th>Description</th> + </tr> + <tr><td style="width:150px;">version*</td> +<td> + + + <div id="d2e199_queryWorkflowSpecifications_version"> + <div class="json-schema-view"> + <div class="primitive"> + <span class="type"> + String + </span> + + </div> + <div class="inner required"> + Required + </div> + </div> + </div> +</td> +</tr> + + </table> + + + + + <div class="methodsubtabletitle">Query parameters</div> + <table id="methodsubtable"> + <tr> + <th width="150px">Name</th> + <th>Description</th> + </tr> + <tr><td style="width:150px;">resourceTarget</td> +<td> + + + <div id="d2e199_queryWorkflowSpecifications_resourceTarget"> + <div class="json-schema-view"> + <div class="primitive"> + <span class="type"> + String + </span> + + </div> + </div> + </div> +</td> +</tr> + + </table> + + <h2>Responses</h2> + <h3> Status: default - List of workflow specifications on successful operation </h3> + + <ul class="nav nav-tabs nav-tabs-examples" > + <li class="active"> + <a data-toggle="tab" href="#responses-queryWorkflowSpecifications-default-schema">Schema</a> + </li> + + </ul> + + <div class="tab-content" style='margin-bottom: 10px;'> + <div class="tab-pane active" id="responses-queryWorkflowSpecifications-default-schema"> + <div id='responses-queryWorkflowSpecifications-default-schema-default' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;"> + <script> + $(document).ready(function() { + var schemaWrapper = { + "description" : "List of workflow specifications on successful operation", + "schema" : { + "$ref" : "#/definitions/RetrievingWorkflowResponse" + } +}; + var schema = schemaWrapper.schema; + if (schema.$ref != null) { + schema = defsParser.$refs.get(schema.$ref); + } else { + schemaWrapper.definitions = defs; + $RefParser.dereference(schemaWrapper).catch(function(err) { + console.log(err); + }); + } + + //console.log(JSON.stringify(schema)); + var view = new JSONSchemaView(schema, 3); + $('#responses-queryWorkflowSpecifications-default-schema-data').val(stringify(schema)); + var result = $('#responses-queryWorkflowSpecifications-default-schema-default'); + result.empty(); + result.append(view.render()); + }); + </script> + </div> + <input id='responses-queryWorkflowSpecifications-default-schema-data' type='hidden' value=''></input> + </div> + </div> + + </article> + </div> + <hr> + </section> </div> <div id="footer"> <div id="api-_footer"> diff --git a/docs/developer_info/Cxf_Logging.rst b/docs/developer_info/Cxf_Logging.rst new file mode 100644 index 0000000000..ea2bbf56ce --- /dev/null +++ b/docs/developer_info/Cxf_Logging.rst @@ -0,0 +1,210 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2020 Huawei Technologies Co., Ltd. + +CXF-logging: +============= +It is a logging framework from SO. Here basically we are having 2 interceptors which extends AbstractSoapInterceptor. + +SOAPLoggingInInterceptor: ++++++++++++++++++++++++++++ + +* This interceptor is responsible for Capturing requestId , client ip address , invocation id, service name, instance id, entry timestamp , log timestamp, Elapsed time for each request and update the MDC logger with staus In-progress. + +SOAPLoggingOutInterceptor: +++++++++++++++++++++++++++++ +* This interceptor is responsible for log timestamp , elapsed time for each request and checks for if there is any exception update the MDC loggers with 500 response code otherwise update the status as completed. + + +cxf-logging Used By below components of SO: +++++++++++++++++++++++++++++++++++++++++++++ +The cxf-logging framework is used by below components of so. + +mso-openstack-adapter. +mso-requests-db-adapter. +mso-sdnc-adapter. +mso-infrastructure-bpmn. + +cxf-logging dependency for using in other components: +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>cxf-logging</artifactId> + <version>${project.version}</version> + + </dependency> + +pom.xml: ++++++++++ +<?xml version="1.0"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <parent> + + <groupId>org.onap.so</groupId> + <artifactId>so</artifactId> + <version>1.6.0-SNAPSHOT</version> + + </parent> + <name>CXFLogging</name> + <description>Common CXF Logging Classes</description> + <dependencies> + + <dependency> + + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-client</artifactId> + <version>${cxf.version}</version> + + </dependency> + + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-bindings-soap</artifactId> + <version>${cxf.version}</version> + + </dependency> + + <dependency> + + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <version>${cxf.version}</version> + + </dependency> + + <dependency> + + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + + </dependency> + + <dependency> + + <groupId>org.slf4j</groupId> + <artifactId>slf4j-ext</artifactId> + + </dependency> + + <dependency> + + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + + </dependency> + + </dependencies> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + + </resource> + + <resource> + + <directory>src/main/java</directory> + + <includes> + + <include>*.java</include> + + </includes> + + </resource> + + </resources> + + </build> + + <artifactId>cxf-logging</artifactId> + +</project> + +Configuration file: +++++++++++++++++++++ +Here we can do configure the logger properties for the cxf-logging. + +<configuration> + + <property name="p_tim" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}"/> + + <property name="p_lvl" value="%level"/> + + <property name="p_log" value="%logger"/> + + <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/> + + <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/> + + <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/> + + <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/> + + <property name="p_thr" value="%thread"/> + + <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + + <encoder> + + <pattern>${pattern}</pattern> + + </encoder> + + </appender> + + <appender name="test" + class="org.onap.so.utils.TestAppender" /> + + <logger name="com.att.ecomp.audit" level="info" additivity="false"> + + <appender-ref ref="STDOUT" /> + + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + + <appender-ref ref="STDOUT" /> + + </logger> + + <logger name="com.att.eelf.error" level="WARN" additivity="false"> + + <appender-ref ref="STDOUT" /> + + </logger> + + <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> + <appender-ref ref="STDOUT" /> + + <appender-ref ref="test" /> + + </logger> + + <logger name="org.flywaydb" level="DEBUG" additivity="false"> + <appender-ref ref="STDOUT" /> + + </logger> + + <logger name="ch.vorburger" level="WARN" additivity="false"> + <appender-ref ref="STDOUT" /> + + </logger> + + <root level="WARN"> + <appender-ref ref="STDOUT" /> + <appender-ref ref="test" /> + + </root> + +</configuration> + diff --git a/docs/developer_info/Mso_Openstack_Adapter.rst b/docs/developer_info/Mso_Openstack_Adapter.rst new file mode 100644 index 0000000000..a8ca362537 --- /dev/null +++ b/docs/developer_info/Mso_Openstack_Adapter.rst @@ -0,0 +1,796 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2020 Huawei Technologies Co., Ltd. + +MSO-OPENSTACK-ADAPTER : +======================= + +.. contents:: :depth: 3 + +Cloud site operations +++++++++++++++++++++++ +* Here we have 3 api's createCloudRegion, updateCloudRegion, deleteCloudRegion. + +1.Create Cloud site/Cloud region: + +Path: /v1/cloud-region + +Method Type: POST + +Request Body: +************* +{ + "id": "MTN13", + "regionId": "mtn13", + "cloudVersion": "3.0", + "clli": "MDT13", + "platform": "testFlatform", + "orchestrator": "testOrchestrator", + "cloudifyId": "mtn13", + "cloudOwner": "testCloudOwner", + + "identityService": { + "identityUrl": "testUrl", + "msoId": "admin", + "msoPass": "admin", + "projectDomainName": "testDomain", + "userDomainName": "testDomain", + "adminTenant": "test", + "memberRole": "test", + "tenantMetadata": "test", + "identityServerType": "test", + "identityAuthenticationType": "test", + "lastUpdatedBy": "test", + "created": "date", + "updated": "date" + + }, + + "identityServiceId": "123", + "lastUpdatedBy": "test", + "created": "test", + "updated": "test", + "supportFabric": "true", + "uri": "test" + +} + +* In this api we can create cloud region and cloud site and saving in catalog db and in AAI. + +* This api requires cloud-region-id and cloudSite as inputs. + +* In createCloudRegion two steps are there. + +* CreateRegionInCatalogDb(cloudSite) :- here we are creating cloud region in catalogdb if it is not exists in db(cloud_sites). + +* CreateCloudRegionInAAI(cloudSite) :- mapping cloudSite into cloudregion , this cloudregion we are creating in AAI and create CloudRegion NetworkTechnology Relationship. + +2.Delete Cloud site: + +* Path:/v1/cloud-region/{cloud-region-id}/{cloud-owner} + +* Here we can delete Cloud site by cloud region id + +3.Update Cloud site: + +* Path:/v1/cloud-region/{cloud-region-id}/{cloud-owner} + +* Here we can update Cloud site by cloud region id + +Create Tenant in Cloud: +++++++++++++++++++++++++ + +Path: http://host:port/vnfs/rest/v1/tenants + +Method Type: POST + +Request Body: +************* + +{ +"cloudSiteId": "DAN", +"tenantName":"RAA_1", +"failIfExists": true, +"msoRequest": { +"requestId": "ra1", +"serviceInstanceId":"sa1" +} +} + +RESPONSE: +********** + +{ + +"cloudSiteId": "DAN", +"tenantId": "128e10b9996d43a7874f19bbc4eb6749", +"tenantCreated": true, +"tenantRollback": { +"tenantId": "128e10b9996d43a7874f19bbc4eb6749", +"cloudId": "DAN", // RAA? cloudId instead of cloudSiteId +"tenantCreated": true, +"msoRequest": { +"requestId": "ra1", +"serviceInstanceId": "sa1" + +} +} +} + +Code Flow: + +* Call to MSO createTenant adapter then call to catalog db for cloud site info and from cloud site get IdentityServerType. +* based on Cloud IdentityServerType it returns ORM or KEYSTONE Utils +* Query for a tenant with the specified name in the given cloud. If the tenant exists, return an MsoTenant object. If not, return null. +* Create a tenant with the specified name in the given cloud. If the tenant already exists, an Exception will be thrown. The MSO User will also be added to the "member" list of the new tenant to perform subsequent Nova/Heat commands in the tenant. If the MSO User association fails, the entire transaction will be rolled back. + +TaskServices +++++++++++++++ +**1. CreateInventory** + +Flow Diagram: + +.. image :: ../images/InventoryCreate.png + +Code Flow: + +* Get cloud site using cloud region id from catalog db. + +* Instantiate heat bridge client by passing required values. + +* Authenticate heat bridge client. + +* If authentication is success we are getting all stack resources(openstack servers. servers contains openstack images and flavours.) + +* From stack resources we are getting osServers/ compute resources. + +* CreatePserversAndPinterfacesIfNotPresentInAai --Transform Openstack Server object to AAI Pserver object. create pserver in AAI if it is not exist. and get openstackresource id's / ports -- transform ports to pinterface Object in AAI. + +* After extract osimages and os flavours from osservers. + +* After that transform osimages to AAI images and osflavours to AAI flavors and add to AAI. + +* Create Vservers in AAI and make relationships to AAI image, AAI flavor, AAI pserver, vf-module. + +* Add Vservers and Linterfaces to AAI--Transform port to Linterface and for that port Get Ip addresses and updateLInterfaceIps and updateLInterfaceVlan. + +* Finally update AAI. + +**2. AuditCreateStack** + +Flow Diagram: + +.. image :: ../images/InventoryAddAudit.png + +Code Flow: + +* First we are capturing entry timestamp, MSO REQUESTID, Servicename/topic name,partnername as openstack adapter, invocation id is generating one random uuid. + +* After that getting auditInventory details from externalTask object + +* From auditInventory object we are getting cloud region,clowd owner,tenant id, heatstack name.these details we are passing to get AAIObjectAuditList. + +* Use cloudRegion, tenantId, heatStackName to get resources from Heat client. + +* To get resources we need heat client it means getting keystone url and token. + +* Get keystone url based on server type(keystone/keystonev3) + +* From resources object we are getting novaResources and resource groups and neutronPortDetails. + +* Create VserverSet by passing resources, novaResources, neutronPortDetails and setting up servers with ports to Set of Servers. + +* From resource groups we are getting Link(stackLink) from that link we are extracting resource path .if path is present we are Fetching nested Resource Stack Information. + +* audit all vservers,l-interfaces and sub l-interfaces. and checking in these vservers , l-interfaces and sub interfaces are existed or not in AAI. + +* If AAIObjectAuditList is present then we are setting audit type as create and Heat stack name to AAIObjectAuditList. + +* If Audit create success putting in variable to complete external task other wise sending exception. + +* If retrycount=1 sending error as retrycount exhausted. + +**3. AuditQueryStack** + +Flow Diagram: + +.. image :: ../images/InventoryQueryAudit.png + + +Code Flow: + +* Get AuditInventory details from external task. + +* Get AAIObjectAuditList from auditHeatStack by passing these parametersauditInventory.getCloudRegion(),auditInventory.getCloudOwner(), auditInventory.getTenantId(), auditInventory.getHeatStackName(). + +* Fetching Top Level Stack Information.i.e get all the heat model resources. + +* From heat model resources get all OS::Nova::Servers and OS::Heat::ResourceGroups and neutronPortDetails. + +* Once u got all the stack info u create vserverset and add that vserverset to AAIObjectAuditList. + +* After add AAIObjectAuditList to requestdb if it is not exist in requestdb. + +* If it is success complete the external task. + +**4. AuditDeleteStack** + +Flow Diagram: + +.. image :: ../images/InventoryDeleteAudit.png + +Code Flow: + +* Get AuditInventory details from external task + +* GetStackDataFromRequestDb usiing AuditInventory details. + +* Get RequestProcessingData from requestdb using auditInventory.getVfModuleId(),auditInventory.getHeatStackName(), "AuditStackData". + +* From RequestProcessingData get AAIObjectAuditList. + +* If AAIObjectAuditList is empty check vservers is exist or not in AAI and set that result as setDoesObjectExist(true/false). + +* Else Auditing Vservers based on vf module relationships--i.e based on genericVnfId and vfModuleName get all the vservers and create AAIObject and set setDoesObjectExist(true) and set that object to list. + +* After that set audit type as delete and heatstackname and check that audit create success or not. + +* If it is success complete the external task. + +**5. DeleteInventory** + +Flow Diagram: + +.. image :: ../images/DeleteInventory.png + + +Code Flow: + +* Get CloudInformation from external task. + +* First get CloudSite details from catalog db by using regionid. + +* From CloudSite get CloudIdentity details. + +* Create a heatbridgeclient. and authenticate the heatbridge. + +* After that delete the VFmodule data using vnfid and vf moduleid. + +* Once delete success complete the external task. + +**6. StackService** + +Flow Diagram: + +.. image :: ../images/OpenstackAdapterInvoke.png + + +Code Flow: + +* From external task getting openstackAdapterTaskRequest and adding to string(xmlRequest). + +* From xmlrequest we are getting requestType. + +1. If requestType is createVolumeGroupRequest then we are creating volume group. + +* Marshalling xmlRequest to CreateVolumeGroupRequest. + +* From CreateVolumeGroupRequest getting completeVnfVfModuleType. + +* After that we are creating vf module by passing required paremeters. + +* If request type Start with X then we are orchestrating a VNF - *NOT* a module! + +* RequestType start with Volume then then we are sending true as volume request. + +* Creating a VnfRollback object by passing required parameters. + +* If nestedStackId is not null we are getting nested heat stack(stack information). + +* If nested heat stack is not null we are getting that output and storing into nestedVolumeOutputs object. + +* If nestedBaseStackId is not null we are getting nestedBaseHeatStack information and setting output to nestedBaseHeatStack. + +* If modelCustomizationUuid is available then with that mcu we are getting VFModuleCustomization(vfmc); + +* If we get VFModuleCustomization then we are extracting VfModule. + +* If vf version is not null then we will get vnfresource by passing vnftype and vnfversion. + +* By here - we would have either a vf or vnfResource. + +* If vf module is not null we are geting vnfresource from vf and from this vnfresource we are getting minversionvnf and maxversionvnf. + +* If minversionvnf and maxversionvnf are not null we are checking cloudConfig is null or not, if cloudConfig is not null then we are getting cloud site intormation by passing cloud site id. once we get the cloud site details we are getting min and max cloud site versions. + +* By the time we get here - heatTemplateId and heatEnvtId should be populated (or null) + +* If it is old way we will get heatTemplate directly. else if vf module is not null then +* If it is a volume request then we will get volumeheattemplate and volumeheatenvironment. +* If it is not a volume request then we will get ModuleHeatTemplate and HeatEnvironment. + +* Once we get heat templates we are getting nestedtemplates. + +* Also add the files: for any get_files associated with this vnf_resource_id + +* Add ability to turn on adding get_files with volume requests (by property). + +* If it is not a volume request get heat files from vf module. + +* CheckRequiredParameters in MsoVnfAdapterImpl.CHECK_REQD_PARAMS. + +* Parse envt entries to see if reqd parameter is there (before used a simple grep + +* Only submit to openstack the parameters in the envt that are in the heat template + +* Convert what we got as inputs (Map<String, String>) to a Map<String, Object> - where the object matches the param type identified in the template This will also not copy over params that aren't identified in the template + +* Now simply add the outputs as we received them - no need to convert to string + +* Add in the volume stack outputs if applicable + +* Get all heat template parameters and add to list. + +* Check for missing parameters null or not.if no missing parameters we can proceed for next step. + +* Next create stack with all required values. + +* After creating add heat stackname to vfrollback and copy heatstack outputs to outputs value. so now vf module is created successfully. + +* After sending the response to create volume group.once it is created that response we are setting to VolumeGroup response object. + +2. If requestType is createVfModuleRequest then we are creating VfModule. + +* Marshalling xmlRequest to CreateVolumeGroupRequest. + +* From CreateVolumeGroupRequest getting completeVnfVfModuleType. + +* After that we are creating vf module by passing required paremeters. + +* If request type Start with X then we are orchestrating a VNF - *NOT* a module! + +* RequestType start with Volume then then we are sending true as volume request. + +* Creating a VnfRollback object by passing required parameters. + +* If nestedStackId is not null we are getting nested heat stack(stack information). + +* If nested heat stack is not null we are getting that output and storing into nestedVolumeOutputs object. + +* If nestedBaseStackId is not null we are getting nestedBaseHeatStack information and setting output to nestedBaseHeatStack. + +* If modelCustomizationUuid is available then with that mcu we are getting VFModuleCustomization(vfmc); + +* If we get VFModuleCustomization then we are extracting VfModule. + +* If vf version is not null then we will get vnfresource by passing vnftype and vnfversion. + +* By here - we would have either a vf or vnfResource. + +* If vf module is not null we are geting vnfresource from vf and from this vnfresource we are getting minversionvnf and maxversionvnf. + +* If minversionvnf and maxversionvnf are not null we are checking cloudConfig is null or not, if cloudConfig is not null then we are getting cloud site intormation by passing cloud site id. once we get the cloud site details we are getting min and max cloud site versions. + +* By the time we get here - heatTemplateId and heatEnvtId should be populated (or null) + +* If it is old way we will get heatTemplate directly. else if vf module is not null then + +* If it is a volume request then we will get volumeheattemplate and volumeheatenvironment. + +* If it is not a volume request then we will get ModuleHeatTemplate and HeatEnvironment. + +* Once we get heat templates we are getting nestedtemplates. + +* Also add the files: for any get_files associated with this vnf_resource_id + +* Add ability to turn on adding get_files with volume requests (by property). + +* If it is not a volume request get heat files from vf module. + +* CheckRequiredParameters in MsoVnfAdapterImpl.CHECK_REQD_PARAMS. + +* Parse envt entries to see if reqd parameter is there (before used a simple grep + +* Only submit to openstack the parameters in the envt that are in the heat template + +* Convert what we got as inputs (Map<String, String>) to a Map<String, Object> - where the object matches the param type identified in the template This will also not copy over params that aren't identified in the template + +* Now simply add the outputs as we received them - no need to convert to string + +* Add in the volume stack outputs if applicable + +* Get all heat template parameters and add to list. + +* Check for missing parameters null or not.if no missing parameters we can proceed for next step. + +* Next create stack with all required values. + +* After creating add heat stackname to vfrollback and copy heatstack outputs to outputs value. so now vf module is created successfully. + +3. If requestType is deleteVfModuleRequest then we are deleting VfModule . + +* Get stackinfo using msoHeatUtils by passing cloudSiteId, cloudOwner, tenantId, vnfName parameters. + +* After that using modelCustomizationUuid we are getting VFModuleCustomizaiton--VFModule--heattemplate. + +* After that we are callling msoHeatUtils.deleteStack to delete StackInfo once it deletes we are updating status as deleted using msoHeatUtils.updateResourceStatus. + +4. If requestType is deleteVolumeGroupRequest then we are deleting volume group. + +* Making DeleteVolumeGroupRequest by Unmarshalling xml request. + +* Getting stack information by passing stackName, cloudSiteId, tenantId. + +* If current stack is null then we confirm that heat status not found. + +* If current stack is not null then we are deleting the stack. + +* Once volumegroup is deleted we are setting the response to perticular response class. + +5. If requestType is createNetworkRequest then we are creating network. + +* Making CreateNetworkRequest by Unmarshalling xmlrequest. + +* Check request is contrailRequest or not if it is contrailRequest we are setting shared,external,routeTargets,fqdns,routeTable values else we are setting physicalNetworkName and vlans. + +* Now all the above required values we are passing to create network. + +* Build a default NetworkRollback object (if no actions performed). + +* Getting the cloud site by passing cloudsite id. + +* After we are doing a network check and Retrieve the Network Resource definition. + +* If modelCustomizationUuid null and networkType is not null based on networkType we are getting Network Resource. + +* If modelCustomizationUuid not null then based on modelCustomizationUuid we are getting NetworkResourceCustomization and from that we are getting Network Resource. + +* If NetworkResourceCustomization is null then based on modelCustomizationUuid we are getting CollectionNetworkResourceCustomization and from that we are getting Network Resource. + +* Even though Network Resource is null we are sending error Unable to get network resource with NetworkType. + +* From the network resource we are extracting mode and network type. + +* All Networks are orchestrated via HEAT or Neutron if it is other than that we are sending error. + +* After that we are checking network resorce min and max versions with cloud site version if version is not supported throwing error. + +* After that validating the network parameters that if any parameter is missing. + +* Once we Retrieve the Network Resource we are getting heat template and NetworkType from that. + +* From the heat template we are getting template and checking that template contains os3nw if it is contains making flag is true. + +* First, look up to see if the Network already exists (by name).For HEAT orchestration of networks, the stack name will always match the network name + +* If stack is already exist with the network name throw an error. + +* After that from stackinfo get network id and network fqdn and get outputs from Stackinfo. + +* After that get subnetIdMap based on one subnet_id output or multiples subnet_%aaid% outputs from Stackinfo outputs. + +* After that update the updateResourceStatus as exits in requestdb. + +* Now we are Ready to deploy the new Network and Build the common set of HEAT template parameters + +* Validate (and update) the input parameters against the DB definition + +* Shouldn't happen unless DB config is wrong, since all networks use same inputs and inputs were already validated. + +* If subnets are not null and template is os3template then mergesubnetsAIC3. + +* If subnets are not null and template is not os3template then merge subnets. + +* If policyFqdns are not null & os3template true then mergePolicyRefs. + +* After that deploy the network stack-- create stack and once stack is created save into stackinfo. + +* For Heat-based orchestration, the MSO-tracked network ID is the heat stack, and the neutronNetworkId is the network UUID returned in stack outputs. + +* After update the resource status like network created successfully. + +* After set response to CreateNetworkResponse object. + + +6. If requestType is deleteNetworkRequest then we are deleting network. + +* Form a DeleteNetworkRequest by unmarshlling Xml request. + +* check for mandatory fields networkId, cloudSiteId, tenantId. + +* If it is there Retrieve the Network Resource definition. + +* After that get networkResource.from networkResource get heat template. + +* After that delete stackinfo udpate resource status as deleted. + +7. If requestType is updateNetworkRequest then we are updating Network. + +* Make UpdateNetworkRequest by unmarshalling xmlRequest. + +* Check the params contains key shared and external if it is contains get that shared and external keys. + +* Check the request is ContrailRequest or not, if it is ContrailRequest then get routeTargets , fqdns, routeTable from the actual request. + +* If it is not ContrailRequest then get the ProviderVlanNetwork details like physicalNetworkName and vlans. + +* Params to update network-req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), physicalNetworkName,vlans, routeTargets, shared, external, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(), subnetIdMap, networkRollback. + +* Update Network adapter with Network using networkName, networkType,cloudSiteId, tenantId. + +* Capture execution time for metrics. + +* Build a default rollback object (no actions performed) + +* Get cloud site details from catalog db using cloud site id. + +* If cloud site is not present send the error message like CloudSite does not exist in MSO Configuration. + +* Getting the cloud site by passing cloudsite id. + +* After we are doing a network check and Retrieve the Network Resource definition. + +* If modelCustomizationUuid null and networkType is not null based on networkType we are getting Network Resource. + +* If modelCustomizationUuid not null then based on modelCustomizationUuid we are getting NetworkResourceCustomization and from that we are getting Network Resource. + +* If NetworkResourceCustomization is null then based on modelCustomizationUuid we are getting CollectionNetworkResourceCustomization and from that we are getting Network Resource. + +* Even though Network Resource is null we are sending error Unable to get network resource with NetworkType. + +* From the network resource we are extracting mode and network type. + +* All Networks are orchestrated via HEAT or Neutron if it is other than that we are sending error. + +* After that we are checking network resorce min and max versions with cloud site version if version is not supported throwing error. + +* After that validating the network parameters that if any parameter is missing. + +* Once we Retrieve the Network Resource we are getting heat template and NetworkType from that. + +* Use an MsoNeutronUtils for all Neutron commands + +* If Orchestaration mode is NEUTRON Verify that the Network exists and For Neutron-based orchestration, the networkId is the Neutron Network UUID. + +* Get NetworkInfo from cloud site using networkId, tenantId, cloudSiteId as params. + +* If NetworkInfo is null then throw the error message as Network is does not exist. + +* Update the network in cloud site which is in catalog db using cloudSiteId,tenantId,networkId, neutronNetworkType, physicalNetworkName, vlans as params. + +* Add the network ID and previously queried vlans to the rollback object. + +* Save previous parameters such as NetworkName,PhysicalNetwork,Vlans to the NetworkRollback. + +* If Orchestaration mode is HEAT then First, look up to see that the Network already exists. For Heat-based orchestration, the networkId is the network Stack ID. + +* Get StackInfo by querystack using cloudSiteId, CLOUD_OWNER, tenantId, networkName. + +* If StackInfo is null throw error as Network not found else continue the flow. + +* Get the previous parameters such as previousNetworkName and previousPhysicalNetwork for rollback from StackInfo. + +* Get the previous vlans from the heat params and Update Stack with Previous VLANS. + +* Now we are Ready to deploy the updated Network via Heat. + +* Get the HeatTemplate from NetworkResource and now we got HEAT Template from DB. + +* Now get the OS::ContrailV2::VirtualNetwork property from property file , if template contains os3nw set flag as true. + +* Build the common set of HEAT template parameters such as neutronNetworkType, networkName, physicalNetworkName, vlans, routeTargets, shared, external, os3template. + +* Validate and update the input parameters against the DB definition and Shouldn't happen unless DB config is wrong, since all networks use same inputs. + +* If subnets are not null and template is os3template then mergesubnetsAIC3. + +* If subnets are not null and template is not os3template then merge subnets. + +* If policyFqdns are not null & os3template true then mergePolicyRefs. + +* If routeTableFqdns are not null os3template not null then mergeRouteTableRefs using routeTableFqdns, stackParams as params. + +* Get outputs from StackInfo and if key is contains subnet and os3template not null then one subnet output expected else multiples subnet outputs allowed. + +* Reach this point if createStack is successful.Populate remaining rollback info and response parameters and save previous parameters. + +* Now Network successfully updated via HEAT. + +8. If requestType is rollbackNetworkRequest then we are doing rollbackNetwork. + +* Make RollbackNetworkRequest by unmarshalling xmlRequest. + +* Get NetworkRollback from RollbackNetworkRequest. + +* If pollForCompletion is null then set flag as true. + +* Get the elements of the VnfRollback object for easier access. + +* ROLLBACK Network using networkId, cloudSiteId, tenantId. + +* If NetworkCreated then use tenantId, CLOUD_OWNER, cloudSiteId, networkId, pollForCompletion, timeoutMinutes params to delete stack. + +* Once deletion is success set the response to RollbackNetworkResponse. + +* Once task stack service is success set the status completed for the external task. + + +**7. PollService** + +Flow Diagram: + +.. image :: ../images/OpenstackAdapterPoller.png + + +Code Flow: + +* Get openstackAdapterTaskRequest as xmlRequest from the the external task. + +* Get requestType from the xmlRequest. + +1. If request type is createVolumeGroupRequest then Execute External Task Rollback Service for Create Volume Group. + +* Create CreateVolumeGroupRequest by unmarshalling xmlRequest. + +* Use CloudSiteId, CloudOwner, TenantId,VolumeGroupName, MsoRequest ,pollStackStatus as params to delete vnf. + +* Call to openstack to delete vnf if it is success nothing to return if it is failure return failure exception. + +* Once it is success set the boolean flags pollRollbackStatus and status as true. + +2. If request type is createVfModuleRequest then Execute External Task Rollback Service for Create Vf Module. + +* Create CreateVfModuleRequest by unmarshalling xmlRequest. + +* Use CloudSiteId, CloudOwner, TenantId,VfModuleName, VnfId, VfModuleId, ModelCustomizationUuid,MsoRequest ,Holder as params to delete vf module. + +* Call to openstack to get the stack outputs. + +* If modelCustomizationUuid is not null then use as a param to get the VfModuleCustomization and from VfModuleCustomization get the vf module details. + +* Use tenantId, cloudOwner, cloudSiteId, vnfName, pollForCompletion, timeoutMinutes as params to delete the stack .once it is success update the resources. + +* Once it is success set the boolean flags pollRollbackStatus and status as true. + +3. If requestType is deleteVfModuleRequest then Execute External Task Poll Service for Delete Vf Module. + +* Create DeleteVfModuleRequest by unmarshalling xmlRequest. + +* Get stackId from external task by using that get Stack. + +* Get pollingFrequency from properties file and calculate no.of polling attempts. + +* Using cloudSiteId, tenantId get Heatclient and once you got heatclient querystack to get the Stack object. + +* If Stack object is not null update the stack status in requestdb and it returns Stack object. + +* If Stack object is not null check the status is DELETE_COMPLETE then Stack Deletion completed successfully. + + +4. If requestType is deleteVolumeGroupRequest then Execute Execute External Task Poll Service for Delete Volume Group. + +* Create DeleteVfModuleRequest by unmarshalling xmlRequest. + +* Get stackId from external task by using that get Stack. + +* Get pollingFrequency from properties file and calculate no.of polling attempts. + +* Using cloudSiteId, tenantId get Heatclient and once you got heatclient querystack to get the Stack object. + +* If Stack object is not null update the stack status in requestdb and it returns Stack object. + +* If Stack object is not null check the status is DELETE_COMPLETE then Stack Deletion completed successfully. + +5. If requestType is deleteNetworkRequest then Execute External Task Poll Service for Delete Network. + +* Create DeleteVfModuleRequest by unmarshalling xmlRequest. + +* Get stackId from external task by using that get Stack. + +* Get pollingFrequency from properties file and calculate no.of polling attempts. + +* Using cloudSiteId, tenantId get Heatclient and once you got heatclient querystack to get the Stack object. + +* If Stack object is not null update the stack status in requestdb and it returns Stack object. + +* If Stack object is not null check the status is DELETE_COMPLETE then Stack Deletion completed successfully. + +6. If requestType is createNetworkRequest then get the PollRollbackStatus from the external task. + +* If pollRollbackStatus is true then Execute External Task Poll Service for Rollback Create Network. + +* Get stackId from external task by using that get Stack. + +* Get pollingFrequency from properties file and calculate no.of polling attempts. + +* Using cloudSiteId, tenantId get Heatclient and once you got heatclient querystack to get the Stack object. + +* If Stack object is not null update the stack status in requestdb and it returns Stack object. + +* If Stack object is not null check the status is DELETE_COMPLETE then Stack Deletion completed successfully. + +* If pollRollbackStatus is false then Execute External Task Poll Service for Create Network. + +* Get stackId from external task by using that get Stack. + +* Get pollingFrequency from properties file and calculate no.of polling attempts. + +* Using cloudSiteId, tenantId get Heatclient and once you got heatclient querystack to get the Stack object. + +* If Stack object is not null update the stack status in requestdb and it returns Stack object. + +* If Stack object is not null check the status is CREATE_COMPLETE then Stack Creation completed successfully. + +7. If requestType is createNetworkRequest then Execute External Task Rollback Service for Create Network. + +* Get stackId from external task by using that get Stack. + +* Get pollingFrequency from properties file and calculate no.of polling attempts. + +* Using cloudSiteId, tenantId get Heatclient and once you got heatclient querystack to get the Stack object. + +* If Stack object is not null update the stack status in requestdb and it returns Stack object. + +* If Stack object is not null check the status is UPDATE_COMPLETE then Stack Updation completed successfully. + +* Once task stack service is success set the status completed for the external task. + +**8. RollbackService** + +Flow Diagram: + +.. image :: ../images/OpenstackAdapterRollback.png + + +Code Flow: + +* Get openstackAdapterTaskRequest as xmlRequest from the the external task. + +* Get requestType from the xmlRequest. + +1. If request type is createVolumeGroupRequest then Execute External Task Rollback Service for Create Volume Group. + +* Making DeleteVolumeGroupRequest by Unmarshalling xml request. + +* Getting stack information by passing stackName, cloudSiteId, tenantId. + +* If current stack is null then we confirm that heat status not found. + +* If current stack is not null then we are deleting the stack. + +* Once volumegroup is deleted we are setting the response to perticular response class. + +2. If request type is createVfModuleRequest then Execute External Task Rollback Service for Create Vf Module. + +* Get stackinfo using msoHeatUtils by passing cloudSiteId, cloudOwner, tenantId, vnfName parameters. + +* After that using modelCustomizationUuid we are getting VFModuleCustomizaiton--VFModule--heattemplate. + +* After that we are callling msoHeatUtils.deleteStack to delete StackInfo once it deletes we are updating status as deleted using msoHeatUtils.updateResourceStatus. + +* Once it is success set the boolean flags pollRollbackStatus and status as true. + +3. If request type is createNetworkRequest then Execute External Task Rollback Service for Create Network. + +* Form a DeleteNetworkRequest by unmarshlling Xml request. + +* Check for mandatory fields networkId, cloudSiteId, tenantId. + +* If it is there Retrieve the Network Resource definition. + +* After that get networkResource.from networkResource get heat template. + +* After that delete stackinfo udpate resource status as deleted. + +* Once task stack service is success set the status completed for the external task. + + + + + + + + + + + diff --git a/docs/developer_info/developer_information.rst b/docs/developer_info/developer_information.rst index 570861345c..a060da60b0 100644 --- a/docs/developer_info/developer_information.rst +++ b/docs/developer_info/developer_information.rst @@ -20,5 +20,7 @@ SO Developer Information BPMN_Subprocess_Process_Flows.rst BPMN_Project_Deployment_Strategy.rst BPMN-INFRA_Workflow_Understanding.rst + Mso_Openstack_Adapter.rst + Cxf_Logging.rst instantiate/index.rst FAQs.rst diff --git a/docs/developer_info/mso_adapter_restinterface.rst b/docs/developer_info/mso_adapter_restinterface.rst new file mode 100644 index 0000000000..49a9cadba4 --- /dev/null +++ b/docs/developer_info/mso_adapter_restinterface.rst @@ -0,0 +1,288 @@ +Mso-adapters-rest-interface +--------------------------- +.. image:: ../images/module_structure.png + +It mainly contains the payload that is provided to different rest calls in SO + +Network +-------- +# 1. Network contain beans( classes with multiple attributes and thier setters and getters) and their corresponding mappers which will be used by the network adapter of SO. Contrail networking is used for cloud network automation + +Beans +----- + # a. ContrailPolicyRef : this class has following attribute + private ContrailPolicyRefSeq seq; + + Usage: adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java- while creating network in openstack, network stack is created depending on stackParams. So if pFqdns(FQDN address object is used in order to use DNS names in firewall policies) are there in the inputrequest to createNetwork, then mergePolicyRefs method is called, where for each input pFqdns, a new ContrailPolicyRef is created and appended to a list. Then this is added as value to stackParams with policy_refsdata as key. + + # b. ContrailPolicyRefSeq : Attributes are + private String major; + + private String minor ; + + Usage: adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java- As this is an attribute to the ContrailPolicyRef explained above. So when a new ContrailPolicyRef() is created in mergePolicyRefs method, correspondingly a new ContrailPolicyRefSeq should be created. + + # c. ContrailSubnet – Its a subnetwork having attributes + private ContrailSubnetIp subnet = new ContrailSubnetIp(); + + private String defaultGateway; + + private String subnetName; + + private Boolean enableDhcp(dynamic host config); + + private Boolean addrFromStart = true; + + private List<ContrailSubnetPool> allocationPools = new ArrayList<>(); + + private ContrailSubnetHostRoutes hostRoutes = new ContrailSubnetHostRoutes(); + + Usage : adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java- While creating network mergeSubnetsAIC3 is called if a list of subnets are present. The subnets are mapped to ContrailSubnet using ContrailSubnetMapper, and then are added to the heat template and stackparams which are used for network creation in openstack. + + # d. ContrailSubnetHostRoute : This is an attribute defined in contrailsubnet and has following attributes + private String prefix; + + private String nextHop; + + Usage : This is an attribute of ContrailSubnetHostRoutes , which is used within the contrailSubnet and thus is used in network creation and updation. + + # e. ContrailSubnetHostRoutes : This class is used to store an list of ContrailSubnetHostRoute + + private List<ContrailSubnetHostRoute> hostRoutes = new ArrayList<>(); + + Usage : attribute of contrailSubnet + + # f. ContrailSubnetIp : attributes are + private String ipPrefix; + + private String ipPrefixLen; + + This class is used to store the cidr value , which is used as a interrouting table, taking as ipaddress/total no . Eg : 10.0.0.0/24 means starting ip is 10.0.0.0, and total no of ip address possible here is 256 (2^(32-24)), the last address being 10.0.0.255. + + Usage : important attribute of contrailSubnet + + # g. ContrailSubnetPool : attributes are starting and ending ip address of the subnet + private String start; + + private String end; + + Usage: a list of ContrailSubnetPool forms an important attribute of contrailSubnet + +Mappers +------- + + # a. ContrailSubnetMapper : It is used to map the inputsubnet to a contrailSubnet + public ContrailSubnetMapper(Subnet inputSubnet) { + this.inputSubnet = inputSubnet; + + } + + The map method within is used for the mapping. Here first a contrailSubnet is created, and depending on whether the subnet has name or id, the contrailSubnet’s name is initialized, then if it has cidr , then a contrailSubnetIp is created, and is added into it, which is then added to contrailSubnet created before. Depending on whether input has allocationpool or hostroutes, these are casted into ContrailSubnetPool and ContrailSubnetHostRoute using ContrailSubnetPoolMapper and ContrailSubnetPoolMapper respectively. + + Usage: adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java :The subnets are mapped to ContrailSubnet using ContrailSubnetMapper, and then are added to the heat template and stackparams which are used for network creation + + # b. ContrailSubnetPoolMapper : It is used to map the pool within the subnets to contrailSubnetPool. Used within contrailSubnetMapper. Here, the particular pool is added only if it has both the start and end ip address. + + # c. ContrailSubnetHostRoute : It is used to map the host routes within the subnets to contrailSubnetHostRoute. Used within contrailSubnetMapper. Here, the particular host route is added if either of the next hop or ip prefix is defined. + +Network request +--------------- + +#2. Network request : It contains the payloads for different types of network requests + + # a. ContrailNetwork : + private String shared = "false"; + + private String external = "false"; + + private List<RouteTarget> routeTargets; + + private List<String> policyFqdns; + + private List<String> routeTableFqdns; + + Usage: contrailNetwork is an important attribute of CreateNetworkRequest, So is to be used where all the request to createNetwork is required. + + # 1. adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java : Here the input to createNetwork requires contrailNetwork parameter, so here it checks whether contrailNetwork is already present, if not a new is created. + + # 2.bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java : Here in createNetworkRequestMapper, createNetworkRequest is formed where in buildContrailNetwork, a new contrailNetwork is created and initialized. This request is used to create a network and set the corresponding execution variable + + # b. CreateNetworkError: It extends NetworkExceptionResponse. And is used when an error occurs during network creation + + # c. NetworkExceptionResponse : it extends NetworkResponseCommon. Attributes are + private String message; + + private MsoExceptionCategory category; + + private Boolean rolledBack; + + # d. NetworkResponseCommon: Attribute is + private String messageId; + + # e. CreateNetworkRequest: extends NetworkRequestCommon + private String cloudSiteId; + + private String tenantId; + + private String networkId; + + private String networkName; + + private String networkType; + + private String networkTypeVersion; + + private String modelCustomizationUuid; + + private String networkTechnology = "NEUTRON"; + + private List<Subnet> subnets; + + private ProviderVlanNetwork providerVlanNetwork; + + private ContrailNetwork contrailNetwork; + + private Boolean failIfExists = false; + + private Boolean backout = true; + + private Map<String, String> networkParams = new HashMap<>(); + + private MsoRequest msoRequest = new MsoRequest(); + + private boolean contrailRequest; + + Usage : + #1) bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java: Here in getNetworkVpnBinding, where VPN Binding data from AAI result is extracted. There in routeTargets is got, and is updated in the execution variable(“createNetworkRequest”). + + #2)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java – Here in createnetwork returns a CreateNetworkRequest which is updated in execution variable(“networkAdapterRequest”) + + #3)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java - + Here in createnetwork returns a CreateNetworkRequest which is updated in execution variable(“createNetworkRequest”) + + #4) bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java -Here createNetwork request is processed as a restclient post process with CreateNetworkRequest as input. + + # f. CreateNetworkResponse : extends NetworkResponseCommon + private String networkId; + + private String neutronNetworkId; + + private String networkStackId; + + private String networkFqdn; + + private Boolean networkCreated; + + private Map<String, String> subnetMap; + + private NetworkRollback rollback = new NetworkRollback(); + + Usage: + #1)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java :here after the network is created, the l3 network is updated with those parameters which come from execution variable("createNetworkResponse") + + #2)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java – depending on variable networkCreated of response, networkAdapterCreateRollback is set to true. + + #3)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java -Here createNetwork request is processed as a restclient post process with CreateNetworkRequest as input and CreateNetworkResponse as output + + # g.DeleteNetworkError : extends NetworkExceptionResponse + + # h. DeleteNetworkRequest:extends NetworkRequestCommon + private String cloudSiteId; + + private String tenantId; + + private String networkId; + + private String networkStackId; + + private String networkType; + + private String modelCustomizationUuid; + + private MsoRequest msoRequest = new MsoRequest(); + + Usage: + #1)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java – deleteNetworkRequestMapper returns a DeleteNetworkRequest, which is set to the execution variable(“networkAdapterRequest”) + + #2)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java - Here deleteNetwork request is processed as a restclient delete process with DeleteNetworkRequest as input. + + #3)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java – Here the deleteNetworkRequestMapper forms DeleteNetworkRequest object + + Similarly others are also implemented and used + +.. image:: ../images/nwrest.png + +Sdnc request +------------ + +#3. Sdnc request -These are required by the mso-sdnc-adapter + + # a. RequestInformation – This is an important parameter of SDNCServiceRequest. Thud is used during the conversion of SDNCServiceRequest to XMLstring. + + # b. ServiceInformation – This stores the important information like serviceId, servicetype and SubscriberName. Its parameter of SDNCServiceRequest. + + # c. SDNCErrorCommon – it extends SDNCResponseCommon . + + Usage : adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java – catching exception if any happens during request creation and a new SDNCErrorCommon is created. + + # d. SDNCRequestCommon – SDNCServiceRequest extends SDNCRequestCommon. It has some attributes like bpNotificationUrl(Endpoint on which BPMN can receive notifications from the SDNC adapter), bpTimeout ans sdncrequestId. + + # e. SDNCServiceRequest + Usage: adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java – Here the runRequest is happening, where we are posting this request using a restclient call with SDNCServiceRequest as input. + + # f. SDNCServiceResponse and SDNCServiceError + Usage:adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java – Here if the above runRequest returns a 2xx response code then a corresponding SDNCServiceResponse is created and returned or else SDNCServiceError is created and returned + +Tenant request +--------------- + +#4. These provide classes to be used by the so-adapters.tenant. + +The operator of a cloud can present unchangeable networks to the users, or give users the option to create, delete, connect and generally manipulate networks. The latter type of networks is called “tenant networks”. + +Used in adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/TenantAdapterRest.java + +The implementation and usage is similiar to the above classes + +.. image:: ../images/tenantrest.png + +VDU +--- + +#5. Vdu – these are used for the deployment and management of (cloud-agnostic) VDU . The abstract classes for instantiation of vdu, query vdu, delete vdu, update vdu are defined in here. + +These are implemented in adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java and adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java + +Vnfrest +------- + +#6. Vnfrest – These are used to manage vnfs and vgs. +These are used in the project similiar to networkrest +Foreg : Usage of DeleteVfModuleRequest: + +1)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java – Here in deleteVfModuleRequestMapper creates a new DeleteVfModuleRequest, and is set to the execution variable(“VNFREST_REQUEST” ) and “deleteVfModuleRequest” execution variable is set true + +2)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java - Here a delete rest request is send + +.. image:: ../images/vnfrest.png + + +OPENSTACK +--------- +Openstack is classified into beans, exceptions, and mappers + +MAPPERS +------- + # 1) JAXBContext: It is used to convert a object to xml(marshalling) and to convert xml to object (unmarshalling) . These marshalling and unmarshalling are overriden in the map adapters in mappers. + + # 2)NetworkInfoMapper – used to Capture the data from a Neutron Network object and cast it into a networkInfo( present in beans of openstack). Here in vlan information is located depending on network.getProviderNetworkType() , and if not then the segments within the network is iterated and is checked for the same. + Usage: It is used in adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java , where on createNetwork, queryNetwork and updateNetwork , the network is mapped by NetworkInfoMapper into networkInfo and returned. + + # 3) StackInfoMapper – used to Capture the data from a Stack object and cast it into a stackInfo( present in beans of openstack). + Usage: It is used in adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils , where all createStack, queryStack, updateStack, deleteStack is done, a new instance of stackInfo is returned + +Exceptions +---------- +These are set of msoexceptions provided, and would be used depending on what exception needs to be handled + +.. image:: ../images/msoexception.png diff --git a/docs/images/DeleteInventory.png b/docs/images/DeleteInventory.png Binary files differnew file mode 100644 index 0000000000..0fd6629db8 --- /dev/null +++ b/docs/images/DeleteInventory.png diff --git a/docs/images/InventoryAddAudit.png b/docs/images/InventoryAddAudit.png Binary files differnew file mode 100644 index 0000000000..9e61c15804 --- /dev/null +++ b/docs/images/InventoryAddAudit.png diff --git a/docs/images/InventoryCreate.png b/docs/images/InventoryCreate.png Binary files differnew file mode 100644 index 0000000000..7df732f1d1 --- /dev/null +++ b/docs/images/InventoryCreate.png diff --git a/docs/images/InventoryDeleteAudit.png b/docs/images/InventoryDeleteAudit.png Binary files differnew file mode 100644 index 0000000000..f2f08bf52b --- /dev/null +++ b/docs/images/InventoryDeleteAudit.png diff --git a/docs/images/InventoryQueryAudit.png b/docs/images/InventoryQueryAudit.png Binary files differnew file mode 100644 index 0000000000..34f6cad128 --- /dev/null +++ b/docs/images/InventoryQueryAudit.png diff --git a/docs/images/OpenstackAdapterInvoke.png b/docs/images/OpenstackAdapterInvoke.png Binary files differnew file mode 100644 index 0000000000..998c4721b0 --- /dev/null +++ b/docs/images/OpenstackAdapterInvoke.png diff --git a/docs/images/OpenstackAdapterPoller.png b/docs/images/OpenstackAdapterPoller.png Binary files differnew file mode 100644 index 0000000000..e95bede9a2 --- /dev/null +++ b/docs/images/OpenstackAdapterPoller.png diff --git a/docs/images/OpenstackAdapterRollback.png b/docs/images/OpenstackAdapterRollback.png Binary files differnew file mode 100644 index 0000000000..1e554263b0 --- /dev/null +++ b/docs/images/OpenstackAdapterRollback.png diff --git a/docs/images/module_structure.png b/docs/images/module_structure.png Binary files differnew file mode 100644 index 0000000000..c25441bd8e --- /dev/null +++ b/docs/images/module_structure.png diff --git a/docs/images/msoexception.png b/docs/images/msoexception.png Binary files differnew file mode 100644 index 0000000000..b9d2dfd5da --- /dev/null +++ b/docs/images/msoexception.png diff --git a/docs/images/nwrest.png b/docs/images/nwrest.png Binary files differnew file mode 100644 index 0000000000..58b66d59e0 --- /dev/null +++ b/docs/images/nwrest.png diff --git a/docs/images/tenantrest.png b/docs/images/tenantrest.png Binary files differnew file mode 100644 index 0000000000..ec1c77e61b --- /dev/null +++ b/docs/images/tenantrest.png diff --git a/docs/images/vnfrest.png b/docs/images/vnfrest.png Binary files differnew file mode 100644 index 0000000000..f61720708d --- /dev/null +++ b/docs/images/vnfrest.png diff --git a/graph-inventory/aai-client/pom.xml b/graph-inventory/aai-client/pom.xml index dc9bf47070..d95ef8d1c0 100644 --- a/graph-inventory/aai-client/pom.xml +++ b/graph-inventory/aai-client/pom.xml @@ -101,6 +101,8 @@ <singularClass>org.onap.aaiclient.client.aai.AAIObjectType</singularClass> <pluralClass>org.onap.aaiclient.client.aai.AAIObjectPlurals</pluralClass> <nameClass>org.onap.aaiclient.client.aai.AAIObjectName</nameClass> + <singleFragmentClass>org.onap.aaiclient.client.aai.entities.uri.AAISingleFragment</singleFragmentClass> + <pluralFragmentClass>org.onap.aaiclient.client.aai.entities.uri.AAIPluralFragment</pluralFragmentClass> </configuration> </execution> </executions> diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java index 5b68d0c69a..78f8350eff 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java @@ -74,6 +74,8 @@ public class AAIObjectPlurals implements AAIObjectBase, GraphInventoryObjectPlur new AAIObjectPlurals(AAIObjectType.INSTANCE_GROUP, AAINamespaceConstants.NETWORK, "/instance-groups"); public static final AAIObjectPlurals PNF = new AAIObjectPlurals(AAIObjectType.PNF, AAINamespaceConstants.NETWORK, "/pnfs"); + public static final AAIObjectPlurals PROJECT = + new AAIObjectPlurals(AAIObjectType.PROJECT, AAINamespaceConstants.BUSINESS, "/projects"); private final String uriTemplate; private final String partialUri; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIPluralFragment.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIPluralFragment.java new file mode 100644 index 0000000000..4733c55bf8 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIPluralFragment.java @@ -0,0 +1,20 @@ +package org.onap.aaiclient.client.aai.entities.uri; + +import java.io.Serializable; +import org.onap.aaiclient.client.graphinventory.GraphInventoryPluralFragment; + +public class AAIPluralFragment implements Serializable, GraphInventoryPluralFragment<AAIFluentPluralType> { + + private static final long serialVersionUID = 1L; + + private final AAIFluentPluralType type; + + public AAIPluralFragment(AAIFluentPluralType type) { + this.type = type; + } + + public AAIFluentPluralType get() { + return type; + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIResourceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIResourceUri.java index 3d01258f71..3d7fc0e198 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIResourceUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIResourceUri.java @@ -5,6 +5,6 @@ import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventorySingleResourceUri; public interface AAIResourceUri extends AAIBaseResourceUri<AAIResourceUri, AAIObjectType>, - GraphInventorySingleResourceUri<AAIResourceUri, AAIPluralResourceUri, AAIObjectType, AAIObjectPlurals> { + GraphInventorySingleResourceUri<AAIResourceUri, AAIPluralResourceUri, AAIObjectType, AAIObjectPlurals, AAISingleFragment, AAIPluralFragment> { } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUri.java index 40184b028b..041c02ff2d 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUri.java @@ -26,7 +26,8 @@ import org.onap.aaiclient.client.aai.AAIObjectPlurals; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.graphinventory.entities.uri.SimpleUri; -public class AAISimpleUri extends SimpleUri<AAIResourceUri, AAIPluralResourceUri, AAIObjectType, AAIObjectPlurals> +public class AAISimpleUri extends + SimpleUri<AAIResourceUri, AAIPluralResourceUri, AAIObjectType, AAIObjectPlurals, AAISingleFragment, AAIPluralFragment> implements AAIResourceUri { private static final long serialVersionUID = -6397024057188453229L; @@ -70,4 +71,16 @@ public class AAISimpleUri extends SimpleUri<AAIResourceUri, AAIPluralResourceUri return new AAISimplePluralUri(this, plural); } + @Override + public AAISimpleUri relatedTo(AAISingleFragment fragment) { + this.internalURI.path(relatedTo); + return new AAISimpleUri(this, fragment.get().build(), fragment.get().values()); + } + + @Override + public AAISimplePluralUri relatedTo(AAIPluralFragment fragment) { + this.internalURI.path(relatedTo); + return new AAISimplePluralUri(this, fragment.get().build()); + } + } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISingleFragment.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISingleFragment.java new file mode 100644 index 0000000000..a988899ed2 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISingleFragment.java @@ -0,0 +1,19 @@ +package org.onap.aaiclient.client.aai.entities.uri; + +import java.io.Serializable; +import org.onap.aaiclient.client.graphinventory.GraphInventorySingleFragment; + +public class AAISingleFragment implements Serializable, GraphInventorySingleFragment<AAIFluentSingleType> { + + private static final long serialVersionUID = 1L; + + private final AAIFluentSingleType type; + + public AAISingleFragment(AAIFluentSingleType type) { + this.type = type; + } + + public AAIFluentSingleType get() { + return type; + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTypeBase.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTypeBase.java index 1a258fcd88..3970a36a0b 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTypeBase.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTypeBase.java @@ -1,16 +1,25 @@ package org.onap.aaiclient.client.graphinventory; +import java.util.Collections; import java.util.List; public interface GraphInventoryFluentTypeBase { public interface Info { - String getPartialUri(); + default String getPartialUri() { + return ""; + } - List<String> getPaths(); + default List<String> getPaths() { + return Collections.emptyList(); + } } - Object[] values(); + default Object[] values() { + return new Object[] {}; + } - String uriTemplate(); + default String uriTemplate() { + return ""; + } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFragmentBase.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFragmentBase.java new file mode 100644 index 0000000000..b8cb64de30 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFragmentBase.java @@ -0,0 +1,6 @@ +package org.onap.aaiclient.client.graphinventory; + +public interface GraphInventoryFragmentBase<T> { + + T get(); +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryPluralFragment.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryPluralFragment.java new file mode 100644 index 0000000000..9fe3cda384 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryPluralFragment.java @@ -0,0 +1,9 @@ +package org.onap.aaiclient.client.graphinventory; + + + +public interface GraphInventoryPluralFragment<T extends GraphInventoryFluentType<? extends GraphInventoryObjectPlurals>> + extends GraphInventoryFragmentBase<T> { + + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryResourcesClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryResourcesClient.java index c564c5d5cb..343e888ce1 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryResourcesClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryResourcesClient.java @@ -33,8 +33,6 @@ import javax.ws.rs.core.GenericType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.onap.aai.domain.yang.Relationship; -import org.onap.so.client.RestClient; -import org.onap.so.client.RestProperties; import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryEdgeLabel; import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryResultWrapper; import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryPluralResourceUri; @@ -42,8 +40,10 @@ import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryResou import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventorySingleResourceUri; import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri; import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryMultipleItemsException; +import org.onap.so.client.RestClient; +import org.onap.so.client.RestProperties; -public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInventoryResourceUri<?, ?>, SingleUri extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PluralUri extends GraphInventoryPluralResourceUri<?, ?>, EdgeLabel extends GraphInventoryEdgeLabel, Wrapper extends GraphInventoryResultWrapper, TransactionalClient, SingleTransactionClient> { +public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInventoryResourceUri<?, ?>, SingleUri extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, PluralUri extends GraphInventoryPluralResourceUri<?, ?>, EdgeLabel extends GraphInventoryEdgeLabel, Wrapper extends GraphInventoryResultWrapper, TransactionalClient, SingleTransactionClient> { protected GraphInventoryClient client; @@ -101,7 +101,7 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @return */ public void connect(SingleUri uriA, SingleUri uriB) { - GraphInventorySingleResourceUri<?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone(); + GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone(); RestClient giRC = client.createClient(uriAClone.relationshipAPI()); giRC.put(this.buildRelationship(uriB)); } @@ -115,7 +115,7 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @return */ public void connect(SingleUri uriA, SingleUri uriB, EdgeLabel label) { - GraphInventorySingleResourceUri<?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone(); + GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone(); RestClient giRC = client.createClient(uriAClone.relationshipAPI()); giRC.put(this.buildRelationship(uriB, label)); } @@ -128,7 +128,7 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @return */ public void disconnect(SingleUri uriA, SingleUri uriB) { - GraphInventorySingleResourceUri<?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone(); + GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone(); RestClient giRC = client.createClient(uriAClone.relationshipAPI()); giRC.delete(this.buildRelationship(uriB)); } @@ -140,7 +140,7 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @return */ public void delete(SingleUri uri) { - GraphInventorySingleResourceUri<?, ?, ?, ?> clone = (SingleUri) uri.clone(); + GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?> clone = (SingleUri) uri.clone(); RestClient giRC = client.createClient(clone); Map<String, Object> result = giRC.get(new GenericType<Map<String, Object>>() {}).orElseThrow( () -> new NotFoundException(clone.build() + " does not exist in " + client.getGraphDBName())); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventorySingleFragment.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventorySingleFragment.java new file mode 100644 index 0000000000..711b93d5b8 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventorySingleFragment.java @@ -0,0 +1,7 @@ +package org.onap.aaiclient.client.graphinventory; + +public interface GraphInventorySingleFragment<T extends GraphInventoryFluentType<? extends GraphInventoryObjectType>> + extends GraphInventoryFragmentBase<T> { + + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryTransactionClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryTransactionClient.java index 7f7822b900..4390e7e6bc 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryTransactionClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryTransactionClient.java @@ -34,7 +34,7 @@ import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInventoryResourceUri<?, ?>, SingleUri extends GraphInventorySingleResourceUri<?, ?, ?, ?>, EdgeLabel extends GraphInventoryEdgeLabel> { +public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInventoryResourceUri<?, ?>, SingleUri extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, EdgeLabel extends GraphInventoryEdgeLabel> { protected static Logger logger = LoggerFactory.getLogger(GraphInventoryTransactionClient.class); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java index 881b7e9a8e..cc286a6a6b 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java @@ -36,7 +36,7 @@ import org.onap.so.jsonpath.JsonPathUtil; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -public abstract class GraphInventoryRelationships<Wrapper extends GraphInventoryResultWrapper<?>, Uri extends GraphInventorySingleResourceUri<?, ?, ?, ?>, Type extends GraphInventoryObjectType> { +public abstract class GraphInventoryRelationships<Wrapper extends GraphInventoryResultWrapper<?>, Uri extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, Type extends GraphInventoryObjectType> { protected final ObjectMapper mapper; protected Map<String, Object> map; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java index ac0e4a0c94..fbd4130fb0 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java @@ -2,8 +2,10 @@ package org.onap.aaiclient.client.graphinventory.entities.uri; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectPlurals; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType; +import org.onap.aaiclient.client.graphinventory.GraphInventoryPluralFragment; +import org.onap.aaiclient.client.graphinventory.GraphInventorySingleFragment; -public interface GraphInventorySingleResourceUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?>, P extends GraphInventoryPluralResourceUri<?, ?>, SingleObject extends GraphInventoryObjectType, PluralObject extends GraphInventoryObjectPlurals> +public interface GraphInventorySingleResourceUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, P extends GraphInventoryPluralResourceUri<?, ?>, SingleObject extends GraphInventoryObjectType, PluralObject extends GraphInventoryObjectPlurals, SingleFragment extends GraphInventorySingleFragment, PluralFragment extends GraphInventoryPluralFragment> extends GraphInventoryResourceUri<T, SingleObject> { public T resourceVersion(String version); @@ -13,4 +15,8 @@ public interface GraphInventorySingleResourceUri<T extends GraphInventorySingleR public P relatedTo(PluralObject plural); public T relatedTo(SingleObject type, String... values); + + public P relatedTo(PluralFragment fragment); + + public T relatedTo(SingleFragment fragment); } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleBaseUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleBaseUri.java index b668f465e9..d1e9e91f48 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleBaseUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleBaseUri.java @@ -22,7 +22,7 @@ import org.onap.aaiclient.client.graphinventory.entities.uri.parsers.UriParserSp import org.onap.aaiclient.client.graphinventory.exceptions.IncorrectNumberOfUriKeys; import org.springframework.web.util.UriUtils; -public abstract class SimpleBaseUri<T extends GraphInventoryResourceUri<?, ?>, Parent extends GraphInventorySingleResourceUri<?, ?, ?, ?>, S extends GraphInventoryObjectBase> +public abstract class SimpleBaseUri<T extends GraphInventoryResourceUri<?, ?>, Parent extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, S extends GraphInventoryObjectBase> implements GraphInventoryResourceUri<T, S> { private static final long serialVersionUID = -1011069933894179423L; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimplePluralUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimplePluralUri.java index d76661526c..1a3b38aff5 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimplePluralUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimplePluralUri.java @@ -28,7 +28,7 @@ import javax.ws.rs.core.UriBuilder; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectPlurals; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType; -public abstract class SimplePluralUri<T extends GraphInventoryPluralResourceUri<?, ?>, Parent extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PT extends GraphInventoryObjectPlurals, OT extends GraphInventoryObjectType> +public abstract class SimplePluralUri<T extends GraphInventoryPluralResourceUri<?, ?>, Parent extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, PT extends GraphInventoryObjectPlurals, OT extends GraphInventoryObjectType> extends SimpleBaseUri<T, Parent, PT> implements GraphInventoryPluralResourceUri<T, PT>, Serializable { private static final long serialVersionUID = -337701171277616439L; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleUri.java index e6a162bfda..570856d7f4 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleUri.java @@ -27,9 +27,11 @@ import java.net.URI; import javax.ws.rs.core.UriBuilder; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectPlurals; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType; +import org.onap.aaiclient.client.graphinventory.GraphInventoryPluralFragment; +import org.onap.aaiclient.client.graphinventory.GraphInventorySingleFragment; -public abstract class SimpleUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PT extends GraphInventoryPluralResourceUri<?, ?>, S extends GraphInventoryObjectType, P extends GraphInventoryObjectPlurals> - extends SimpleBaseUri<T, T, S> implements GraphInventorySingleResourceUri<T, PT, S, P> { +public abstract class SimpleUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?>, PT extends GraphInventoryPluralResourceUri<?, ?>, S extends GraphInventoryObjectType, P extends GraphInventoryObjectPlurals, SF extends GraphInventorySingleFragment<?>, PF extends GraphInventoryPluralFragment<?>> + extends SimpleBaseUri<T, T, S> implements GraphInventorySingleResourceUri<T, PT, S, P, SF, PF> { private static final long serialVersionUID = -337701171277616439L; protected static final String relationshipAPI = "/relationship-list/relationship"; diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriTest.java index f8dd1726d3..92e74163a7 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriTest.java @@ -32,6 +32,7 @@ import org.junit.Test; import org.onap.aaiclient.client.aai.AAIObjectPlurals; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; public class AAISimpleUriTest { @@ -43,7 +44,14 @@ public class AAISimpleUriTest { AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1").relatedTo(AAIObjectPlurals.PSERVER); String uriOutput = uri.build().toString(); - assertEquals("/network/generic-vnfs/generic-vnf/test1/related-to/pservers", uriOutput); + + String expected = "/network/generic-vnfs/generic-vnf/test1/related-to/pservers"; + assertEquals(expected, uriOutput); + + uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1") + .relatedTo(Types.PSERVERS.getFragment()); + uriOutput = uri.build().toString(); + assertEquals(expected, uriOutput); } @Test @@ -51,7 +59,17 @@ public class AAISimpleUriTest { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1") .relatedTo(AAIObjectType.PSERVER, "test2"); String uriOutput = uri.build().toString(); - assertEquals("/network/generic-vnfs/generic-vnf/test1/related-to/pservers/pserver/test2", uriOutput); + + String expected = "/network/generic-vnfs/generic-vnf/test1/related-to/pservers/pserver/test2"; + assertEquals(expected, uriOutput); + + uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1") + .relatedTo(Types.PSERVER.getFragment("test2")); + + uriOutput = uri.build().toString(); + + assertEquals(expected, uriOutput); + } @Test diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java index 4a8b7d90c6..efbeba203c 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java @@ -39,11 +39,13 @@ public class FluentGenerator { private final String pluralClass; private final String builderName; private final String nameClass; + private final String singleFragmentClass; + private final String pluralFragmentClass; public FluentGenerator(Log log, String location, String destinationClasspath, String swaggerLocation, String builderName, String singularBuilderClass, String pluralBuilderClass, String topLevelBuilderClass, - String baseBuilderClass, String singularClass, String pluralClass, String nameClass) - throws JsonProcessingException { + String baseBuilderClass, String singularClass, String pluralClass, String nameClass, + String singleFragmentClass, String pluralFragmentClass) throws JsonProcessingException { this.location = location; this.CLASSPATH = destinationClasspath; @@ -55,6 +57,8 @@ public class FluentGenerator { this.singularClass = singularClass; this.pluralClass = pluralClass; this.nameClass = nameClass; + this.singleFragmentClass = singleFragmentClass; + this.pluralFragmentClass = pluralFragmentClass; doc = new SwaggerConverter(log).getDoc(swaggerLocation); } @@ -241,7 +245,8 @@ public class FluentGenerator { } protected TypeSpec createTypes() { - List<FieldSpec> params = doc.values().stream().filter(item -> item.getType().equals("singular")) + List<FieldSpec> params = doc.values().stream() + .filter(item -> item.getType().equals("singular") || item.getType().equals("plural")) .sorted(Comparator.comparing(item -> item.getName())).map(item -> { ClassName nameType = ClassName.get(CLASSPATH, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, item.getName())) @@ -274,6 +279,18 @@ public class FluentGenerator { "\"" + oType.getPaths().stream().collect(Collectors.joining("\", \"")) + "\"") .build()); + if (oType.getType().equals("plural")) { + Pair<String, String> path = splitClasspath(this.pluralFragmentClass); + ClassName fragmentClass = ClassName.get(path.getLeft(), path.getRight()); + path = splitClasspath(this.baseBuilderClass); + ClassName baseClass = ClassName.get(path.getLeft(), path.getRight()); + + classFields.add(FieldSpec.builder(fragmentClass, "fragment") + .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC) + .initializer("new $T(new $L(new $T(){}))", fragmentClass, upperCamel(oType.getName()), baseClass) + .build()); + } + ClassName superInterface; String name; if (oType.getType().equals("plural")) { @@ -294,6 +311,34 @@ public class FluentGenerator { .addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).addStatement("return Info.paths").build()); methods.add(MethodSpec.methodBuilder("getPartialUri").returns(String.class).addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class).addStatement("return Info.partialUri").build()); + + if (oType.getType().equals("plural")) { + Pair<String, String> path = splitClasspath(this.pluralFragmentClass); + ClassName fragmentClass = ClassName.get(path.getLeft(), path.getRight()); + methods.add(MethodSpec.methodBuilder("getFragment").returns(fragmentClass).addModifiers(Modifier.PUBLIC) + .addStatement("return fragment").build()); + } else if (oType.getType().equals("singular")) { + Pair<String, String> path = splitClasspath(this.singleFragmentClass); + ClassName fragmentClass = ClassName.get(path.getLeft(), path.getRight()); + path = splitClasspath(this.baseBuilderClass); + ClassName baseClass = ClassName.get(path.getLeft(), path.getRight()); + List<ParameterSpec> typeParams = new ArrayList<>(); + + for (ObjectField oF : oType.getFields()) { + if (oF.getType().equals("string")) { + typeParams.add(ParameterSpec.builder(String.class, lowerCamel(makeValidJavaVariable(oF.getName()))) + .build()); + } else if (oF.getType().equals("integer")) { + typeParams.add( + ParameterSpec.builder(int.class, lowerCamel(makeValidJavaVariable(oF.getName()))).build()); + } + } + methods.add(MethodSpec.methodBuilder("getFragment").returns(fragmentClass).addParameters(typeParams) + .addModifiers(Modifier.PUBLIC) + .addStatement("return new $T(new $L(new $T(){}, $L))", fragmentClass, upperCamel(oType.getName()), + baseClass, typeParams.stream().map(item -> item.name).collect(Collectors.joining(", "))) + .build()); + } if (!oType.getType().equals("top level")) { classFields.add(FieldSpec.builder(String.class, "name") .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC).initializer("$S", name).build()); diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGeneratorMojo.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGeneratorMojo.java index 9de249faa2..8c672e3e7d 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGeneratorMojo.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGeneratorMojo.java @@ -34,13 +34,17 @@ public class FluentGeneratorMojo extends AbstractMojo { private String pluralClass; @Parameter private String nameClass; + @Parameter + private String singleFragmentClass; + @Parameter + private String pluralFragmentClass; public void execute() throws MojoExecutionException, MojoFailureException { try { new FluentGenerator(getLog(), destination, destinationClasspath, swaggerLocation, builderName, singularBuilderClass, pluralBuilderClass, topLevelBuilderClass, baseBuilderClass, singularClass, - pluralClass, nameClass).run(); + pluralClass, nameClass, singleFragmentClass, pluralFragmentClass).run(); } catch (JsonProcessingException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index 665fa547cc..c7692cb2cc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -396,7 +396,8 @@ public class E2EServiceInstances { ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, - "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON); + "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON, + null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -408,7 +409,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -484,7 +485,8 @@ public class E2EServiceInstances { ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, - "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON); + "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON, + null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -496,7 +498,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -715,7 +717,8 @@ public class E2EServiceInstances { ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, - "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON); + "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON, + null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -727,7 +730,7 @@ public class E2EServiceInstances { MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No recipe found in DB", action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -948,7 +951,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); throw validateException; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java index 168f82bdf3..d69c395f96 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java @@ -64,6 +64,7 @@ public class JerseyConfiguration extends ResourceConfig { register(GlobalHealthcheckHandler.class); register(NodeHealthcheckHandler.class); register(ServiceInstances.class); + register(Onap3gppServiceInstances.class); register(TasksHandler.class); register(CloudOrchestration.class); register(CloudResourcesOrchestration.class); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index 4ac8b73698..bf76cd3174 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -451,7 +451,7 @@ public class MsoRequest { } public void createErrorRequestRecord(Status status, String requestId, String errorMessage, Actions action, - String requestScope, String requestJSON) { + String requestScope, String requestJSON, String serviceInstanceId) { try { InfraActiveRequests request = new InfraActiveRequests(requestId); Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); @@ -463,6 +463,9 @@ public class MsoRequest { request.setRequestAction(action.toString()); request.setRequestScope(requestScope); request.setRequestBody(requestJSON); + if (serviceInstanceId != null) { + request.setServiceInstanceId(serviceInstanceId); + } Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); request.setEndTime(endTimeStamp); request.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java new file mode 100644 index 0000000000..3f05c79dad --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java @@ -0,0 +1,759 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.apihandlerinfra; + +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.UUID; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.apache.http.HttpStatus; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.apihandler.camundabeans.CamundaResponse; +import org.onap.so.apihandler.common.CamundaClient; +import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.apihandler.common.RequestClientParameter; +import org.onap.so.apihandler.common.ResponseBuilder; +import org.onap.so.apihandler.common.ResponseHandler; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; +import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; +import org.onap.so.apihandlerinfra.exceptions.ValidateException; +import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.ActivateOrDeactivate3gppService; +import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Allocate3gppService; +import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.DeAllocate3gppService; +import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Modify3gppService; +import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.QuerySubnetCapability; +import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.SubnetTypes; +import org.onap.so.constants.Status; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.LogConstants; +import org.onap.so.logger.LoggingAnchor; +import org.onap.so.logger.MessageEnum; +import org.onap.so.serviceinstancebeans.ModelType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.type.TypeReference; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; + +@Component +@Path("/onap/so/infra/onap3gppServiceInstances") +@OpenAPIDefinition(info = @Info(title = "/onap/so/infra/onap3gppServiceInstances", + description = "API Requests for 3GPP Service Instances")) +public class Onap3gppServiceInstances { + + private static final Logger logger = LoggerFactory.getLogger(Onap3gppServiceInstances.class); + + private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: "; + + private static final String SAVE_TO_DB = "save instance to db"; + + private static String uriPrefix = "/onap3gppServiceInstances/"; + + @Autowired + private MsoRequest msoRequest; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Autowired + private RequestsDbClient requestsDbClient; + + @Autowired + private RequestHandlerUtils requestHandlerUtils; + + @Autowired + private ResponseBuilder builder; + + @Autowired + private CamundaClient camundaClient; + + @Autowired + private ResponseHandler responseHandler; + + /** + * POST Requests for 3GPP Service create Instance on a version provided + * + * @throws ApiException + */ + + @POST + @Path("/{version:[vV][1]}/allocate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Create a 3GPP Service Instance on a version provided", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + public Response createServiceInstance(Allocate3gppService request, @PathParam("version") String version, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + return processServiceInstanceRequest(request, Action.createInstance, version, requestId, null, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + /** + * PUT Requests for 3GPP Service update Instance on a version provided + * + * @throws ApiException + */ + + @PUT + @Path("/{version:[vV][1]}/modify") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Modify a 3GPP Service Instance on a version provided", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + public Response updateServiceInstance(Modify3gppService request, @PathParam("version") String version, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); + return updateServiceInstances(request, Action.updateInstance, version, requestId, instanceIdMap, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + /** + * DELETE Requests for 3GPP Service delete Instance on a specified version + * + * @throws ApiException + */ + + @DELETE + @Path("/{version:[vV][1]}/deAllocate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Terminate/Deallocate a 3GPP Service Instance on a version provided", + responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + public Response deleteServiceInstance(DeAllocate3gppService request, @PathParam("version") String version, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); + return deleteServiceInstances(request, Action.deleteInstance, version, requestId, instanceIdMap, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + /** + * POST Requests for 3GPP Service Activate on a specified version + * + * @throws ApiException + */ + + @POST + @Path("/{version:[vV][1]}/activate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Activate a 3GPP Service Instance on a version provided", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + public Response activateServiceInstance(ActivateOrDeactivate3gppService request, + @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); + return activateOrDeactivateServiceInstances(request, Action.activateInstance, version, requestId, instanceIdMap, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + /** + * POST Requests for 3GPP Service DeActivate on a specified version + * + * @throws ApiException + */ + + @POST + @Path("/{version:[vV][1]}/deActivate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Deactivate a 3GPP Service Instance on a version provided", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + public Response deActivateServiceInstance(ActivateOrDeactivate3gppService request, + @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); + return activateOrDeactivateServiceInstances(request, Action.deactivateInstance, version, requestId, + instanceIdMap, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + /** + * + * GET requests for slice subnet capabilities on a specified version + * + * @param version + * @return + * @throws ApiException + */ + @GET + @Path("/{version:[vV][1]}/subnetCapabilityQuery") + @Operation(description = "Provides subnet capability based on subnet types", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response getSliceSubnetCapabilities(QuerySubnetCapability request, @PathParam("version") String version) + throws ApiException { + logger.debug("Request received {}", request); + List<SubnetTypes> subnetTypes = request.getSubnetTypes(); + return getSubnetCapabilities(subnetTypes, version); + } + + /** + * Process allocate service request and send request to corresponding workflow + * + * @param request + * @param action + * @param version + * @return + * @throws ApiException + */ + private Response processServiceInstanceRequest(Allocate3gppService request, Action action, String version, + String requestId, HashMap<String, String> instanceIdMap, String requestUri) throws ApiException { + String defaultServiceModelName = "COMMON_SS_DEFAULT"; + String requestScope = ModelType.service.name(); + String apiVersion = version.substring(1); + String serviceRequestJson = toString.apply(request); + if (serviceRequestJson != null) { + InfraActiveRequests currentActiveReq = createRequestObject(request, action, requestId, Status.IN_PROGRESS, + requestScope, serviceRequestJson); + String instanceName = request.getName(); + requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, + instanceName); + try { + requestsDbClient.save(currentActiveReq); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } + + RecipeLookupResult recipeLookupResult; + try { + recipeLookupResult = + getServiceInstanceOrchestrationURI(request.getModelUuid(), action, defaultServiceModelName); + } catch (Exception e) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + if (recipeLookupResult == null) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + String serviceInstanceType = request.getSubscriptionServiceType(); + RequestClientParameter parameter; + try { + parameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false) + .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()) + .setServiceInstanceId(null).setServiceType(serviceInstanceType) + .setRequestDetails(serviceRequestJson).setApiVersion(version).setALaCarte(false) + .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).setApiVersion(apiVersion).build(); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + } + return postBPELRequest(currentActiveReq, parameter, recipeLookupResult.getOrchestrationURI(), requestScope); + } else { + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, + MsoException.ServiceException, "JsonProcessingException occurred - serviceRequestJson is null", + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + return response; + } + } + + /** + * process modify service request and call corresponding workflow + * + * @param request + * @param action + * @param version + * @return + * @throws ApiException + */ + private Response updateServiceInstances(Modify3gppService request, Action action, String version, String requestId, + HashMap<String, String> instanceIdMap, String requestUri) throws ApiException { + String defaultServiceModelName = "COMMON_SS_DEFAULT"; + String requestScope = ModelType.service.name(); + String apiVersion = version.substring(1); + String serviceRequestJson = toString.apply(request); + if (serviceRequestJson != null) { + InfraActiveRequests currentActiveReq = createRequestObject(request, action, requestId, Status.IN_PROGRESS, + requestScope, serviceRequestJson); + String instanceName = request.getName(); + requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, + instanceName); + try { + requestsDbClient.save(currentActiveReq); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } + + RecipeLookupResult recipeLookupResult; + try { + recipeLookupResult = getServiceInstanceOrchestrationURI(null, action, defaultServiceModelName); + } catch (Exception e) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + if (recipeLookupResult == null) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + String serviceInstanceType = request.getSubscriptionServiceType(); + String serviceInstanceId = request.getServiceInstanceID(); + RequestClientParameter parameter; + try { + parameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false) + .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()) + .setServiceInstanceId(serviceInstanceId).setServiceType(serviceInstanceType) + .setRequestDetails(serviceRequestJson).setApiVersion(version).setALaCarte(false) + .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).setApiVersion(apiVersion).build(); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + } + return postBPELRequest(currentActiveReq, parameter, recipeLookupResult.getOrchestrationURI(), requestScope); + + } else { + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, + MsoException.ServiceException, "JsonProcessingException occurred - serviceRequestJson is null", + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + return response; + } + } + + /** + * process delete service instance request and call corresponding workflow + * + * @param request + * @param action + * @param version + * @return + * @throws ApiException + */ + private Response deleteServiceInstances(DeAllocate3gppService request, Action action, String version, + String requestId, HashMap<String, String> instanceIdMap, String requestUri) throws ApiException { + String defaultServiceModelName = "COMMON_SS_DEFAULT"; + String requestScope = ModelType.service.name(); + String apiVersion = version.substring(1); + String serviceRequestJson = toString.apply(request); + if (serviceRequestJson != null) { + InfraActiveRequests currentActiveReq = createRequestObject(request, action, requestId, Status.IN_PROGRESS, + requestScope, serviceRequestJson); + requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, null); + try { + requestsDbClient.save(currentActiveReq); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } + RecipeLookupResult recipeLookupResult; + try { + recipeLookupResult = getServiceInstanceOrchestrationURI(null, action, defaultServiceModelName); + } catch (Exception e) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + if (recipeLookupResult == null) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + String serviceInstanceType = request.getSubscriptionServiceType(); + String serviceInstanceId = request.getServiceInstanceID(); + RequestClientParameter parameter; + try { + parameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false) + .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()) + .setServiceInstanceId(serviceInstanceId).setServiceType(serviceInstanceType) + .setRequestDetails(serviceRequestJson).setApiVersion(version).setALaCarte(false) + .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).setApiVersion(apiVersion).build(); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + } + return postBPELRequest(currentActiveReq, parameter, recipeLookupResult.getOrchestrationURI(), requestScope); + } else { + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, + MsoException.ServiceException, "JsonProcessingException occurred - serviceRequestJson is null", + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + return response; + } + } + + /** + * process activate/deactivate service request and call corresponding workflow + * + * @param request the request object for activate/deactivate service + * @param action the action for the service + * @param version + * @return + * @throws ApiException + */ + private Response activateOrDeactivateServiceInstances(ActivateOrDeactivate3gppService request, Action action, + String version, String requestId, HashMap<String, String> instanceIdMap, String requestUri) + throws ApiException { + String defaultServiceModelName = "COMMON_SS_DEFAULT"; + String requestScope = ModelType.service.name(); + String apiVersion = version.substring(1); + String serviceRequestJson = toString.apply(request); + if (serviceRequestJson != null) { + InfraActiveRequests currentActiveReq = createRequestObject(request, action, requestId, Status.IN_PROGRESS, + requestScope, serviceRequestJson); + if (action == Action.activateInstance) { + requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, + request.getServiceInstanceID()); + } else { + requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, + null); + } + try { + requestsDbClient.save(currentActiveReq); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } + RecipeLookupResult recipeLookupResult; + try { + recipeLookupResult = getServiceInstanceOrchestrationURI(null, action, defaultServiceModelName); + } catch (Exception e) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + if (recipeLookupResult == null) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + String serviceInstanceType = request.getSubscriptionServiceType(); + String serviceInstanceId = request.getServiceInstanceID(); + RequestClientParameter parameter; + try { + parameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false) + .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()) + .setServiceInstanceId(serviceInstanceId).setServiceType(serviceInstanceType) + .setRequestDetails(serviceRequestJson).setApiVersion(version).setALaCarte(false) + .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).setApiVersion(apiVersion).build(); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + } + return postBPELRequest(currentActiveReq, parameter, recipeLookupResult.getOrchestrationURI(), requestScope); + } else { + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, + MsoException.ServiceException, "JsonProcessingException occurred - serviceRequestJson is null", + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + return response; + } + } + + // To be implemented for fetching Subnet capabilities + private Response getSubnetCapabilities(List<SubnetTypes> subnetTypes, String version) throws ApiException { + ObjectMapper oMapper = new ObjectMapper(); + InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json"); + Map<String, Object> subnetCapability = new HashMap<>(); + try { + subnetCapability = oMapper.readValue(inputStream, Map.class); + } catch (Exception e) { + logger.debug("Exception while reading subnet capability value from json", e); + } + Map<String, Object> responseMap = new HashMap<>(); + for (SubnetTypes value : subnetTypes) { + if (subnetCapability.containsKey(value.toString())) { + responseMap.put(value.toString(), subnetCapability.get(value.toString())); + } + } + String response = null; + try { + response = oMapper.writeValueAsString(responseMap); + } catch (JsonProcessingException e) { + logger.debug("Exception while converting subnet capability object to String {}", e); + } + return builder.buildResponse(HttpStatus.SC_OK, null, response, version); + } + + /** + * Getting recipes from catalogDb + * + * @param serviceModelUUID the service model version uuid + * @param action the action for the service + * @param defaultServiceModelName default service name + * @return the service recipe result + */ + private RecipeLookupResult getServiceInstanceOrchestrationURI(String serviceModelUUID, Action action, + String defaultServiceModelName) { + + RecipeLookupResult recipeLookupResult = getServiceURI(serviceModelUUID, action, defaultServiceModelName); + + if (recipeLookupResult != null) { + logger.debug("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + + Integer.toString(recipeLookupResult.getRecipeTimeout())); + } else { + logger.debug("No matching recipe record found"); + } + return recipeLookupResult; + } + + /** + * Getting recipes from catalogDb If Service recipe is not set, use default recipe, if set , use special recipe. + * + * @param serviceModelUUID the service version uuid + * @param action the action of the service. + * @param defaultServiceModelName default service name + * @return the service recipe result. + */ + private RecipeLookupResult getServiceURI(String serviceModelUUID, Action action, String defaultServiceModelName) { + + Service defaultServiceRecord = + catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + // set recipe as default generic recipe + ServiceRecipe recipe = + catalogDbClient.getFirstByServiceModelUUIDAndAction(defaultServiceRecord.getModelUUID(), action.name()); + // check the service special recipe + if (null != serviceModelUUID && !serviceModelUUID.isEmpty()) { + ServiceRecipe serviceSpecialRecipe = + catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceModelUUID, action.name()); + if (null != serviceSpecialRecipe) { + // set service special recipe. + recipe = serviceSpecialRecipe; + } + } + + if (recipe == null) { + return null; + } + return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout(), recipe.getParamXsd()); + + } + + Function<Object, String> toString = serviceRequest -> { + ObjectMapper mapper = new ObjectMapper(); + String requestAsString = null; + try { + requestAsString = mapper.writeValueAsString(serviceRequest); + } catch (JsonProcessingException e) { + logger.debug("Exception while converting service request object to String {}", e); + } + return requestAsString; + }; + + public InfraActiveRequests createRequestObject(Object request, Action action, String requestId, Status status, + String requestScope, String requestJson) { + InfraActiveRequests aq = new InfraActiveRequests(); + try { + String networkType = null; + String serviceInstanceName = null; + String serviceInstanceId = null; + if (action.name().equals("createInstance")) { + networkType = ((Allocate3gppService) request).getNetworkType(); + serviceInstanceName = ((Allocate3gppService) request).getName(); + aq.setServiceInstanceName(serviceInstanceName); + } else if (action.name().equals("updateInstance")) { + networkType = ((Modify3gppService) request).getNetworkType(); + serviceInstanceName = ((Modify3gppService) request).getName(); + serviceInstanceId = ((Modify3gppService) request).getServiceInstanceID(); + aq.setServiceInstanceName(serviceInstanceName); + aq.setServiceInstanceId(serviceInstanceId); + } else if (action.name().equals("deleteInstance")) { + networkType = ((DeAllocate3gppService) request).getNetworkType(); + serviceInstanceId = ((DeAllocate3gppService) request).getServiceInstanceID(); + aq.setServiceInstanceId(serviceInstanceId); + } else if (action.name().equals("activateInstance")) { + networkType = ((ActivateOrDeactivate3gppService) request).getNetworkType(); + serviceInstanceId = ((ActivateOrDeactivate3gppService) request).getServiceInstanceID(); + aq.setServiceInstanceName(serviceInstanceId); // setting serviceInstanceId as serviceInstanceName + // -->serviceInstanceName shouldn't be null for action - + // activateInstance duplicateRequests check + aq.setServiceInstanceId(serviceInstanceId); + } else if (action.name().equals("deactivateInstance")) { + networkType = ((ActivateOrDeactivate3gppService) request).getNetworkType(); + serviceInstanceId = ((ActivateOrDeactivate3gppService) request).getServiceInstanceID(); + aq.setServiceInstanceId(serviceInstanceId); + } + + aq.setRequestId(requestId); + aq.setRequestAction(action.toString()); + aq.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); + Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); + aq.setStartTime(startTimeStamp); + aq.setRequestScope(requestScope); + aq.setRequestBody(requestJson); + aq.setRequestStatus(status.toString()); + aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + aq.setNetworkType(networkType); + } catch (Exception e) { + logger.error("Exception when creation record request", e); + + if (!status.equals(Status.FAILED)) { + throw e; + } + } + return aq; + } + + private Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter parameter, + String orchestrationURI, String requestScope) throws ApiException { + ResponseEntity<String> response = + requestHandlerUtils.postRequest(currentActiveReq, parameter, orchestrationURI); + logger.debug("BPEL response : " + response); + int bpelStatus = responseHandler.setStatus(response.getStatusCodeValue()); + String jsonResponse; + try { + responseHandler.acceptedResponse(response); + CamundaResponse camundaResponse = responseHandler.getCamundaResponse(response); + String responseBody = camundaResponse.getResponse(); + if ("Success".equalsIgnoreCase(camundaResponse.getMessage())) { + jsonResponse = responseBody; + } else { + BPMNFailureException bpmnException = + new BPMNFailureException.Builder(String.valueOf(bpelStatus) + responseBody, bpelStatus, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).build(); + requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage()); + throw bpmnException; + } + } catch (ApiException e) { + requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, e.getMessage()); + throw e; + } + return builder.buildResponse(HttpStatus.SC_ACCEPTED, parameter.getRequestId(), jsonResponse, + parameter.getApiVersion()); + } +} + + diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index a68309f199..60e9c3b30a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -326,7 +326,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { String requestScope = requestScopeFromUri(requestUri); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, - requestScope, requestJSON); + requestScope, requestJSON, null); throw validateException; } @@ -518,20 +518,16 @@ public class RequestHandlerUtils extends AbstractRestHandler { } protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir) { + String serviceInstanceId = null; if (sir.getServiceInstanceId() != null) { - return sir.getServiceInstanceId(); - } else if (requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())) { - RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList(); - if (relatedInstances != null) { - for (RelatedInstanceList relatedInstanceList : relatedInstances) { - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - if (relatedInstance.getModelInfo().getModelType() == ModelType.service) { - return relatedInstance.getInstanceId(); - } - } + serviceInstanceId = sir.getServiceInstanceId(); + } else { + Optional<String> serviceInstanceIdForInstance = getServiceInstanceIdForInstanceGroup(requestScope, sir); + if (serviceInstanceIdForInstance.isPresent()) { + serviceInstanceId = serviceInstanceIdForInstance.get(); } } - return null; + return serviceInstanceId; } private String requestScopeFromUri(String requestUri) { @@ -916,6 +912,30 @@ public class RequestHandlerUtils extends AbstractRestHandler { return null; } + protected Optional<String> getServiceInstanceIdForValidationError(ServiceInstancesRequest sir, + HashMap<String, String> instanceIdMap, String requestScope) { + if (instanceIdMap != null && !instanceIdMap.isEmpty() && instanceIdMap.get("serviceInstanceId") != null) { + return Optional.of(instanceIdMap.get("serviceInstanceId")); + } else { + return getServiceInstanceIdForInstanceGroup(requestScope, sir); + } + } + + protected Optional<String> getServiceInstanceIdForInstanceGroup(String requestScope, ServiceInstancesRequest sir) { + if (requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())) { + RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList(); + if (relatedInstances != null) { + for (RelatedInstanceList relatedInstanceList : relatedInstances) { + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType() == ModelType.service) { + return Optional.ofNullable(relatedInstance.getInstanceId()); + } + } + } + } + return Optional.empty(); + } + private RecipeLookupResult getDefaultVnfUri(ServiceInstancesRequest sir, Actions action) { String defaultSource = getDefaultModel(sir); VnfRecipe vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 418ba05abf..2c8e92633c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -823,9 +823,17 @@ public class ServiceInstances extends AbstractRestHandler { sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); action = handleReplaceInstance(action, sir); - requestValidatorListenerRunner.runValidations(requestUri, instanceIdMap, sir, queryParams, action); String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); + try { + requestValidatorListenerRunner.runValidations(requestUri, instanceIdMap, sir, queryParams, action); + } catch (ApiException e) { + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, e.getMessage(), action, requestScope, + requestJSON, requestHandlerUtils + .getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).orElse(null)); + throw e; + } + InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); if (sir.getRequestDetails().getRequestParameters() != null) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/ActivateOrDeactivate3gppService.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/ActivateOrDeactivate3gppService.java new file mode 100644 index 0000000000..3f094a8cc9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/ActivateOrDeactivate3gppService.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.apihandlerinfra.onap3gppserviceinstancebeans; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for 3GPP service instance Activate request + */ + +public class ActivateOrDeactivate3gppService { + + @JsonProperty("serviceInstanceID") + private String serviceInstanceID; + + @JsonProperty("globalSubscriberId") + private String globalSubscriberId; + + @JsonProperty("subscriptionServiceType") + private String subscriptionServiceType; + + @JsonProperty("networkType") + private String networkType; + + @JsonProperty("additionalProperties") + private Map<String, Object> additionalProperties = new HashMap<>(); + + public String getServiceInstanceID() { + return serviceInstanceID; + } + + public void setServiceInstanceID(String serviceInstanceID) { + this.serviceInstanceID = serviceInstanceID; + } + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public Map<String, Object> getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + } + + + @Override + public String toString() { + return "ActivateOrDeactivate3gppService [serviceInstanceID=" + serviceInstanceID + ", globalSubscriberId=" + + globalSubscriberId + ", subscriptionServiceType=" + subscriptionServiceType + ", networkType=" + + networkType + ", additionalProperties=" + additionalProperties + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/Allocate3gppService.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/Allocate3gppService.java new file mode 100644 index 0000000000..0444e66842 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/Allocate3gppService.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.apihandlerinfra.onap3gppserviceinstancebeans; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for 3GPP service instance create request + */ +public class Allocate3gppService { + + @JsonProperty("name") + private String name; + + @JsonProperty("modelInvariantUuid") + private String modelInvariantUuid; + + @JsonProperty("modelUuid") + private String modelUuid; + + @JsonProperty("globalSubscriberId") + private String globalSubscriberId; + + @JsonProperty("subscriptionServiceType") + private String subscriptionServiceType; + + @JsonProperty("networkType") + private String networkType; + + @JsonProperty("additionalProperties") + private Map<String, Object> additionalProperties = new HashMap<>(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getModelInvariantUuid() { + return modelInvariantUuid; + } + + public void setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + } + + public String getModelUuid() { + return modelUuid; + } + + public void setModelUuid(String modelUuid) { + this.modelUuid = modelUuid; + } + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public Map<String, Object> getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @Override + public String toString() { + return "Allocate3gppService [name=" + name + ", modelInvariantUuid=" + modelInvariantUuid + ", modelUuid=" + + modelUuid + ", globalSubscriberId=" + globalSubscriberId + ", subscriptionServiceType=" + + subscriptionServiceType + ", networkType=" + networkType + ", additionalProperties=" + + additionalProperties + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/DeAllocate3gppService.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/DeAllocate3gppService.java new file mode 100644 index 0000000000..24ebb6b410 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/DeAllocate3gppService.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.apihandlerinfra.onap3gppserviceinstancebeans; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for 3GPP service instance terminate request + */ +public class DeAllocate3gppService { + + @JsonProperty("serviceInstanceID") + private String serviceInstanceID; + + @JsonProperty("globalSubscriberId") + private String globalSubscriberId; + + @JsonProperty("subscriptionServiceType") + private String subscriptionServiceType; + + @JsonProperty("networkType") + private String networkType; + + @JsonProperty("additionalProperties") + private Map<String, Object> additionalProperties = new HashMap<>(); + + public String getServiceInstanceID() { + return serviceInstanceID; + } + + public void setServiceInstanceID(String serviceInstanceID) { + this.serviceInstanceID = serviceInstanceID; + } + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public Map<String, Object> getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @Override + public String toString() { + return "DeAllocate3gppService [serviceInstanceID=" + serviceInstanceID + ", globalSubscriberId=" + + globalSubscriberId + ", subscriptionServiceType=" + subscriptionServiceType + ", networkType=" + + networkType + ", additionalProperties=" + additionalProperties + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/Modify3gppService.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/Modify3gppService.java new file mode 100644 index 0000000000..ffe76c06ef --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/Modify3gppService.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.apihandlerinfra.onap3gppserviceinstancebeans; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for 3GPP service instance Update request + */ +public class Modify3gppService { + + @JsonProperty("name") + private String name; + + @JsonProperty("serviceInstanceID") + private String serviceInstanceID; + + @JsonProperty("globalSubscriberId") + private String globalSubscriberId; + + @JsonProperty("subscriptionServiceType") + private String subscriptionServiceType; + + @JsonProperty("networkType") + private String networkType; + + @JsonProperty("additionalProperties") + private Map<String, Object> additionalProperties = new HashMap<>(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getServiceInstanceID() { + return serviceInstanceID; + } + + public void setServiceInstanceID(String serviceInstanceID) { + this.serviceInstanceID = serviceInstanceID; + } + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public Map<String, Object> getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @Override + public String toString() { + return "Modify3gppService [name=" + name + ", serviceInstanceID=" + serviceInstanceID + ", globalSubscriberId=" + + globalSubscriberId + ", subscriptionServiceType=" + subscriptionServiceType + ", networkType=" + + networkType + ", additionalProperties=" + additionalProperties + "]"; + } + +} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/UpdateExecutionParams.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java index 3f49b90626..c66b053609 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/UpdateExecutionParams.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. * ================================================================================ * 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. @@ -18,30 +18,30 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.v3.model; +package org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; -public class UpdateExecutionParams implements Serializable { +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; - private static final long serialVersionUID = 1L; +/** + * Model class for slice subnet capability query + */ +public class QuerySubnetCapability { - @JsonProperty("status") - private String status; + @JsonProperty("subnetTypes") + private List<SubnetTypes> subnetTypes; - public String getStatus() { - return status; + public List<SubnetTypes> getSubnetTypes() { + return subnetTypes; } - public void setStatus(String status) { - this.status = status; + public void setSubnetTypes(List<SubnetTypes> subnetTypes) { + this.subnetTypes = subnetTypes; } - @Override public String toString() { - return "UpdateExecutionParams{" + "status='" + status + '\'' + '}'; + return "QuerySubnetCapability [subnetType=" + subnetTypes + "]"; } - } diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/HttpMethod.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/SubnetTypes.java index 2c5097f1ad..5d6deb7158 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/HttpMethod.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/SubnetTypes.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. * ================================================================================ * 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. @@ -18,8 +18,8 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.base.client; +package org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans; -public enum HttpMethod { - HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS, TRACE +public enum SubnetTypes { + AN, AN_NF, CN, TN_FH, TN_MH, TN_BH } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json b/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json new file mode 100644 index 0000000000..0d5acef64a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json @@ -0,0 +1,25 @@ +{ + "AN": { + "latency": "5", + "maxNumberofUEs": "100", + "maxThroughput": "150", + "terminalDensity": "50" + }, + "CN": { + "latency": "10", + "maxThroughput": "50", + "maxNumberofConns": "100" + }, + "TN_FH": { + "latency": "10", + "maxThroughput": "100" + }, + "TN_MH": { + "latency": "5", + "maxThroughput": "50" + }, + "TN_BH": { + "latency": "10", + "maxThroughput": "100" + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java new file mode 100644 index 0000000000..c3c92be013 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java @@ -0,0 +1,198 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * 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.apihandlerinfra; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static org.junit.Assert.assertEquals; +import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_PARTNER_NAME; +import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID; +import static org.onap.logging.filter.base.Constants.HttpHeaders.TRANSACTION_ID; +import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.apache.http.HttpStatus; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.util.UriComponentsBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.QuerySubnetCapability; +import org.springframework.beans.factory.annotation.Autowired; + +public class Onap3gppServiceInstancesTest extends BaseTest { + + private String onap3gppServicesUri = "/onap/so/infra/onap3gppServiceInstances/"; + + private final ObjectMapper mapper = new ObjectMapper(); + + @Autowired + private Onap3gppServiceInstances objUnderTest; + + @Before + public void init() throws JsonProcessingException { + + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setServiceModelUUID(defaultService.getModelUUID()); + serviceRecipe.setRecipeTimeout(180); + serviceRecipe.setOrchestrationUri("/mso/async/services/commonNssmfTest"); + + wireMockServer.stubFor(get(urlPathEqualTo("/service/search/findFirstByModelNameOrderByModelVersionDesc")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlPathEqualTo("/serviceRecipe/search/findFirstByServiceModelUUIDAndAction")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK))); + wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK))); + Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any()); + } + + public String inputStream(String JsonInput) throws IOException { + JsonInput = "src/test/resources/Onap3gppServiceInstancesTest" + JsonInput; + return new String(Files.readAllBytes(Paths.get(JsonInput))); + } + + public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); + headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name"); + headers.set(TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + headers.set(ONAP_PARTNER_NAME, "VID"); + headers.set(REQUESTOR_ID, "xxxxxx"); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath)); + HttpEntity<String> request = new HttpEntity<>(requestJson, headers); + + return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class); + } + + @Test + public void createServiceInstanceTest() throws IOException { + String uri = onap3gppServicesUri + "v1/allocate"; + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( + aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") + .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); + + String expectedResponse = + "{\"jobId\":\"db245365e79c47ed88fcd60caa8f6549\",\"status\":\"\",\"statusDescription\":{}}"; + ResponseEntity<String> response = sendRequest(inputStream("/allocateRequest.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + String actualResponse = response.getBody(); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void updateServiceInstanceTest() throws IOException { + String uri = onap3gppServicesUri + "v1/modify"; + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( + aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") + .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); + + String expectedResponse = + "{\"jobId\":\"db245365e79c47ed88fcd60caa8f6549\",\"status\":\"\",\"statusDescription\":{}}"; + ResponseEntity<String> response = sendRequest(inputStream("/modifyRequest.json"), uri, HttpMethod.PUT); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + String actualResponse = response.getBody(); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void deleteServiceInstanceTest() throws IOException { + String uri = onap3gppServicesUri + "v1/deAllocate"; + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( + aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") + .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); + String expectedResponse = + "{\"jobId\":\"db245365e79c47ed88fcd60caa8f6549\",\"status\":\"\",\"statusDescription\":{}}"; + ResponseEntity<String> response = sendRequest(inputStream("/deAllocate.json"), uri, HttpMethod.DELETE); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + String actualResponse = response.getBody(); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void activateServiceInstanceTest() throws IOException { + String uri = onap3gppServicesUri + "v1/activate"; + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( + aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") + .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); + String expectedResponse = + "{\"jobId\":\"db245365e79c47ed88fcd60caa8f6549\",\"status\":\"\",\"statusDescription\":{}}"; + ResponseEntity<String> response = sendRequest(inputStream("/activateRequest.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + String actualResponse = response.getBody(); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void deActivateServiceInstance() throws IOException { + String uri = onap3gppServicesUri + "v1/deActivate"; + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( + aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") + .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); + String expectedResponse = + "{\"jobId\":\"db245365e79c47ed88fcd60caa8f6549\",\"status\":\"\",\"statusDescription\":{}}"; + ResponseEntity<String> response = sendRequest(inputStream("/deActivateRequest.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + String actualResponse = response.getBody(); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void getSliceSubnetCapabilitiesTest() throws IOException, ApiException { + String request = "{\"subnetTypes\":[\"AN\"]}"; + QuerySubnetCapability subnetCapabilityRequest = mapper.readValue(request, QuerySubnetCapability.class); + String expectedResponse = + "{\"AN\":{\"latency\":\"5\",\"maxNumberofUEs\":\"100\",\"maxThroughput\":\"150\",\"terminalDensity\":\"50\"}}"; + Response response = objUnderTest.getSliceSubnetCapabilities(subnetCapabilityRequest, "v1"); + String actualResponse = (String) response.getEntity(); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + assertEquals(expectedResponse, actualResponse); + } +} + + diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java index 7711608288..1f944da7ba 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java @@ -335,7 +335,6 @@ public class OrchestrationRequestsTest extends BaseTest { Map<String, List<String>> orchestrationMap = new HashMap<>(); orchestrationMap.put("modelType", values); - List<GetOrchestrationResponse> testResponses = new ArrayList<>(); List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap); HttpHeaders headers = new HttpHeaders(); @@ -427,7 +426,6 @@ public class OrchestrationRequestsTest extends BaseTest { public void testUnlockOrchestrationRequest_Valid_Status() throws JsonParseException, JsonMappingException, IOException, ValidationException { setupTestUnlockOrchestrationRequest_Valid_Status("5ffbabd6-b793-4377-a1ab-082670fbc7ac", "PENDING"); - ObjectMapper mapper = new ObjectMapper(); String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json"))); HttpHeaders headers = new HttpHeaders(); @@ -481,7 +479,6 @@ public class OrchestrationRequestsTest extends BaseTest { assertThat(actualProcessingData, sameBeanAs(expectedDataList)); } - public void setupTestGetOrchestrationRequest() throws Exception { // For testGetOrchestrationRequest wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-1a18-42e5-965d-8ea592502018")) diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java index 7f9ff98b19..2ba646fba0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java @@ -39,6 +39,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.HashMap; import java.util.List; import javax.ws.rs.core.MediaType; import org.apache.http.HttpStatus; @@ -338,4 +339,34 @@ public class RequestHandlerUtilsTest extends BaseTest { assertEquals(expectedBasicAuth, basicAuth); } + @Test + public void getServiceInstanceIdForValidationErrorTest() { + ServiceInstancesRequest sir = new ServiceInstancesRequest(); + String requestScope = "vnf"; + HashMap<String, String> instanceIdMap = new HashMap<String, String>(); + instanceIdMap.put("serviceInstanceId", "testServiceInstanceId"); + String serviceInstanceId = + requestHandlerUtils.getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).get(); + assertEquals("testServiceInstanceId", serviceInstanceId); + } + + @Test + public void getServiceInstanceIdForValidationErrorInstanceGroupTest() throws Exception { + ServiceInstancesRequest sir = + mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class); + String requestScope = "instanceGroup"; + String serviceInstanceId = + requestHandlerUtils.getServiceInstanceIdForValidationError(sir, null, requestScope).get(); + assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", serviceInstanceId); + } + + @Test + public void getServiceInstanceIdForInstanceGroupTest() throws Exception { + ServiceInstancesRequest sir = + mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class); + String requestScope = "instanceGroup"; + String serviceInstanceId = requestHandlerUtils.getServiceInstanceIdForInstanceGroup(requestScope, sir).get(); + assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", serviceInstanceId); + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/activateRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/activateRequest.json new file mode 100644 index 0000000000..e67809c80e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/activateRequest.json @@ -0,0 +1,9 @@ +{ + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX" + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/allocateRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/allocateRequest.json new file mode 100644 index 0000000000..24cea593b9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/allocateRequest.json @@ -0,0 +1,55 @@ +{ + "name": "eMBB-001", + "modelInvariantUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX", + "modelUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX-UUID", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "networkType": "an/cn/tn", + "additionalProperties": { + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + "perfReqEmbbList ": [ + { + "activityFactor": 50 + } + ] + }, + "maxNumberofUEs": 200, + "coverageAreaTAList": [ + "1", + "2", + "3", + "4" + ], + "latency": 2, + "resourceSharingLevel": "non-shared" + }, + "endPoints": [ + { + "nodeId": "", + "additionalInfo": { + "xxx": "xxx" + } + }, + { + "nodeId": "", + "additionalInfo": { + "xxx": "xxx" + } + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/deActivateRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/deActivateRequest.json new file mode 100644 index 0000000000..e67809c80e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/deActivateRequest.json @@ -0,0 +1,9 @@ +{ + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX" + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/deAllocate.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/deAllocate.json new file mode 100644 index 0000000000..50729317e3 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/deAllocate.json @@ -0,0 +1,13 @@ +{ + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "snssaiList": [ + "001-100001" + ], + "scriptName": "AN1", + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX" + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/modifyRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/modifyRequest.json new file mode 100644 index 0000000000..6a7db0165b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/modifyRequest.json @@ -0,0 +1,18 @@ +{ + "name": "eMBB-001", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "networkType": "an/cn/tn", + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX", + "additionalProperties": { + "modifyAction": "allocate/deallocate", + "snssaiList": [ + "001-100001" + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/BPMN_response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/BPMN_response.json new file mode 100644 index 0000000000..b2c29ac4c6 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/BPMN_response.json @@ -0,0 +1,7 @@ +{ + "response":"{\"jobId\":\"db245365e79c47ed88fcd60caa8f6549\",\"status\":\"\",\"statusDescription\":{}}", + "message":"Success", + "processInstanceID":"8878ccf8-1efc-11e8-b332-0050569a141e", + "variables":null, + "messageCode":202 +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java index 19e875f8bc..3827c0e19f 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java @@ -38,6 +38,8 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import uk.co.blackpepper.bowman.annotation.LinkedResource; import uk.co.blackpepper.bowman.annotation.RemoteResource; @@ -76,6 +78,7 @@ public class AllottedResource implements Serializable { private Date created; @OneToMany(cascade = CascadeType.ALL, mappedBy = "allottedResource") + @NotFound(action = NotFoundAction.IGNORE) private Set<AllottedResourceCustomization> allotedResourceCustomization; @Override 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 8d342b673d..ef90dd6984 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 @@ -20,6 +20,7 @@ package org.onap.so.db.catalog.client; +import com.google.common.base.Strings; import java.net.URI; import java.util.ArrayList; import java.util.Iterator; @@ -83,7 +84,6 @@ import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; -import com.google.common.base.Strings; import uk.co.blackpepper.bowman.Client; import uk.co.blackpepper.bowman.ClientFactory; import uk.co.blackpepper.bowman.Configuration; @@ -162,6 +162,7 @@ public class CatalogDbClient { protected static final String SOURCE = "source"; protected static final String RESOURCE_TARGET = "resourceTarget"; protected static final String FLAG = "flag"; + protected static final String OPERATION_NAME = "operationName"; private static final String TARGET_ENTITY = "SO:CatalogDB"; private static final String ASTERISK = "*"; @@ -215,6 +216,7 @@ public class CatalogDbClient { "/findBBNameSelectionReferenceByControllerActorAndScopeAndAction"; private String findWorkflowByResourceTarget = "/findByResourceTarget"; private String findProcessingFlagsByFlag = "/findByFlag"; + private String findWorkflowByOperationName = "/findByOperationName"; private String serviceURI; private String vfModuleURI; @@ -365,6 +367,7 @@ public class CatalogDbClient { + findBBNameSelectionReferenceByControllerActorAndScopeAndAction; findProcessingFlagsByFlag = endpoint + PROCESSING_FLAGS + SEARCH + findProcessingFlagsByFlag; + findWorkflowByOperationName = endpoint + WORKFLOW + SEARCH + findWorkflowByOperationName; serviceURI = endpoint + SERVICE + URI_SEPARATOR; vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR; @@ -1106,6 +1109,11 @@ public class CatalogDbClient { .queryParam(RESOURCE_TARGET, resourceTarget).build().toString())); } + public List<Workflow> findWorkflowByOperationName(String operationName) { + return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByOperationName) + .queryParam(OPERATION_NAME, operationName).build().toString())); + } + public ProcessingFlags findProcessingFlagsByFlag(String flag) { return this.getSingleResource(processingFlagsClient, getUri(UriBuilder.fromUri(findProcessingFlagsByFlag).queryParam(FLAG, flag).build().toString())); diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java index 93ec54a2eb..74843e5531 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java @@ -35,6 +35,8 @@ public interface WorkflowRepository extends JpaRepository<Workflow, Integer> { List<Workflow> findByResourceTarget(String resourceTarget); + List<Workflow> findByOperationName(String operationName); + /** * Used to fetch the @{link Workflow} by the Model UUID. * diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index 79e3cbcc08..6a5daa601a 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -204,4 +204,15 @@ public class CatalogDbClientTest { .queryParam(CatalogDbClient.RESOURCE_TARGET, pnf_resource).build())); } + @Test + public final void testFindWorkFlowByOperationName() { + final String operationName = "PNFSoftwareUpgrade"; + doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any()); + catalogDbClient.findWorkflowByOperationName(operationName); + + // verify + verify(catalogDbClient).getMultipleResources(any(Client.class), eq(UriBuilder.fromUri("/findByOperationName") + .queryParam(CatalogDbClient.OPERATION_NAME, operationName).build())); + } + } diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index a4a1e378d5..20b61e638a 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -271,6 +271,30 @@ </build> </image> <image> + <name>${docker.image.prefix}/so-oof-adapter</name> + <build> + <cleanup>try</cleanup> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> + <tags> + <tag>${project.version}</tag> + <tag>${project.version}-${maven.build.timestamp}</tag> + <tag>${project.docker.latesttag.version}</tag> + </tags> + <assembly> + <inline> + <dependencySets> + <dependencySet> + <includes> + <include>org.onap.so.adapters:mso-oof-adapter</include> + </includes> + <outputFileNameMapping>app.jar</outputFileNameMapping> + </dependencySet> + </dependencySets> + </inline> + </assembly> + </build> + </image> + <image> <name>${docker.image.prefix}/so-appc-orchestrator</name> <build> <cleanup>try</cleanup> @@ -469,7 +493,7 @@ <goal>push</goal> </goals> <configuration> - <image>${docker.image.prefix}/catalog-db-adapter,${docker.image.prefix}/request-db-adapter,${docker.image.prefix}/sdnc-adapter,${docker.image.prefix}/openstack-adapter,${docker.image.prefix}/vfc-adapter,${docker.image.prefix}/sdc-controller,${docker.image.prefix}/bpmn-infra,${docker.image.prefix}/api-handler-infra,${docker.image.prefix}/so-monitoring,${docker.image.prefix}/so-simulator,${docker.image.prefix}/mso-nssmf-adapter,${docker.image.prefix}/mso-cnf-adapter,${docker.image.prefix}/so-etsi-nfvo-ns-lcm</image> + <image>${docker.image.prefix}/catalog-db-adapter,${docker.image.prefix}/request-db-adapter,${docker.image.prefix}/sdnc-adapter,${docker.image.prefix}/openstack-adapter,${docker.image.prefix}/vfc-adapter,${docker.image.prefix}/sdc-controller,${docker.image.prefix}/bpmn-infra,${docker.image.prefix}/api-handler-infra,${docker.image.prefix}/so-monitoring,${docker.image.prefix}/so-simulator,${docker.image.prefix}/mso-nssmf-adapter,${docker.image.prefix}/so-oof-adapter,${docker.image.prefix}/mso-cnf-adapter,${docker.image.prefix}/so-etsi-nfvo-ns-lcm</image> </configuration> </execution> </executions> @@ -529,6 +553,11 @@ </dependency> <dependency> <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-oof-adapter</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> <artifactId>so-appc-orchestrator</artifactId> <version>${project.version}</version> </dependency> 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 dd14091daf..e4be7094df 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 @@ -56,6 +56,12 @@ \t%thread \t%n" /> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${errorPattern}</pattern> + </encoder> + </appender> + <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"> @@ -186,11 +192,12 @@ <appender-ref ref="asyncMetric" /> </logger> - <root level="WARN"> + <root level="INFO"> <appender-ref ref="asyncDebug" /> <appender-ref ref="asyncError" /> <appender-ref ref="asyncAudit" /> <appender-ref ref="asyncMetric" /> + <appender-ref ref="STDOUT" /> </root> </configuration>
\ No newline at end of file @@ -32,7 +32,6 @@ <module>so-optimization-clients</module> <module>so-sdn-clients</module> <module>bpmn</module> - <module>cloudify-client</module> <module>cxf-logging</module> <module>so-monitoring</module> <module>so-simulator</module> @@ -963,7 +962,7 @@ <dependency> <groupId>org.onap.aai.schema-service</groupId> <artifactId>aai-schema</artifactId> - <version>1.7.2</version> + <version>1.7.8</version> </dependency> </dependencies> </dependencyManagement> diff --git a/releases/1.7.1.cnf.yaml b/releases/1.7.1.cnf.yaml new file mode 100644 index 0000000000..b986786e5d --- /dev/null +++ b/releases/1.7.1.cnf.yaml @@ -0,0 +1,9 @@ +--- +distribution_type: 'container' +container_release_tag: '1.7.1' +project: 'so' +log_dir: 'so-maven-docker-stage-master/437/' +ref: '96f7bcf737cc10a3258b5c8cf11b5cc5fd1ee65c' +containers: + - name: 'so/mso-cnf-adapter' + version: '1.7.1-20200827T0421'
\ No newline at end of file diff --git a/so-etsi-nfvo/pom.xml b/so-etsi-nfvo/pom.xml index 8048f0c7d3..fa85460086 100644 --- a/so-etsi-nfvo/pom.xml +++ b/so-etsi-nfvo/pom.xml @@ -26,6 +26,8 @@ <okhttp-version>2.7.5</okhttp-version> <okio-version>1.13.0</okio-version> <jaxb-api>2.3.0</jaxb-api> + <snakeyaml-version>0.11</snakeyaml-version> + <hamcrest-version>2.2</hamcrest-version> </properties> <build> diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/src/main/resources/SOL005-NSLifecycleManagement-API.json b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/src/main/resources/SOL005-NSLifecycleManagement-API.json index 8257e6ba22..8a7eb9d006 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/src/main/resources/SOL005-NSLifecycleManagement-API.json +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/src/main/resources/SOL005-NSLifecycleManagement-API.json @@ -75,7 +75,8 @@ }, "retirementDate":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" } } } @@ -9667,7 +9668,8 @@ }, "startTime":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" }, "nsInstantiationLevelId":{ "description":"An identifier that is unique within a NS descriptor. Representation: string of variable length.\n", @@ -10745,7 +10747,8 @@ }, "scaleTime":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" } } }, @@ -13113,7 +13116,8 @@ }, "updateTime":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" } } }, @@ -15175,7 +15179,8 @@ }, "statusEnteredTime":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" }, "nsInstanceId":{ "description":"An identifier with the intention of being globally unique.\n", @@ -15194,7 +15199,8 @@ }, "startTime":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" }, "isAutomaticInvocation":{ "description":"Set to true if this NS LCM operation occurrence has been automatically triggered by the NFVO. This occurs in the case of auto-scaling, auto-healing and when a nested NS is modified as a result of an operation on its composite NS. Set to false otherwise.\n", @@ -15202,14 +15208,7 @@ }, "operationParams":{ "description":"Input parameters of the LCM operation. This attribute shall be formatted according to the request data type of the related LCM operation. The following mapping between lcmOperationType and the data type of this attribute shall apply: - INSTANTIATE: InstantiateNsRequest - SCALE: ScaleNsRequest - UPDATE: UpdateNsRequest - HEAL: HealNsRequest - TERMINATE: TerminateNsRequest This attribute shall be present if this data type is returned in a response to reading an individual resource, and may be present according to the chosen attribute selector parameter if this data type is returned in a response to a query of a container resource.\n", - "type":"string", - "enum":[ - "INSTANTIATE", - "SCALE", - "UPDATE", - "HEAL", - "TERMINATE" - ] + "type":"object" }, "isCancelPending":{ "description":"If the LCM operation occurrence is in \"PROCESSING\" or \"ROLLING_BACK\" state and the operation is being cancelled, this attribute shall be set to true. Otherwise, it shall be set to false.\n", @@ -16396,7 +16395,8 @@ }, "statusEnteredTime":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" }, "nsInstanceId":{ "description":"An identifier with the intention of being globally unique.\n", @@ -16415,7 +16415,8 @@ }, "startTime":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" }, "isAutomaticInvocation":{ "description":"Set to true if this NS LCM operation occurrence has been automatically triggered by the NFVO. This occurs in the case of auto-scaling, auto-healing and when a nested NS is modified as a result of an operation on its composite NS. Set to false otherwise.\n", @@ -16423,14 +16424,7 @@ }, "operationParams":{ "description":"Input parameters of the LCM operation. This attribute shall be formatted according to the request data type of the related LCM operation. The following mapping between lcmOperationType and the data type of this attribute shall apply: - INSTANTIATE: InstantiateNsRequest - SCALE: ScaleNsRequest - UPDATE: UpdateNsRequest - HEAL: HealNsRequest - TERMINATE: TerminateNsRequest This attribute shall be present if this data type is returned in a response to reading an individual resource, and may be present according to the chosen attribute selector parameter if this data type is returned in a response to a query of a container resource.\n", - "type":"string", - "enum":[ - "INSTANTIATE", - "SCALE", - "UPDATE", - "HEAL", - "TERMINATE" - ] + "type":"object" }, "isCancelPending":{ "description":"If the LCM operation occurrence is in \"PROCESSING\" or \"ROLLING_BACK\" state and the operation is being cancelled, this attribute shall be set to true. Otherwise, it shall be set to false.\n", @@ -19521,7 +19515,8 @@ }, "statusEnteredTime":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" }, "nsInstanceId":{ "description":"An identifier with the intention of being globally unique.\n", @@ -19540,7 +19535,8 @@ }, "startTime":{ "description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n", - "format":"date-time" + "format":"date-time", + "type":"string" }, "isAutomaticInvocation":{ "description":"Set to true if this NS LCM operation occurrence has been automatically triggered by the NFVO. This occurs in the case of auto-scaling, auto-healing and when a nested NS is modified as a result of an operation on its composite NS. Set to false otherwise.\n", @@ -19548,14 +19544,7 @@ }, "operationParams":{ "description":"Input parameters of the LCM operation. This attribute shall be formatted according to the request data type of the related LCM operation. The following mapping between lcmOperationType and the data type of this attribute shall apply: - INSTANTIATE: InstantiateNsRequest - SCALE: ScaleNsRequest - UPDATE: UpdateNsRequest - HEAL: HealNsRequest - TERMINATE: TerminateNsRequest This attribute shall be present if this data type is returned in a response to reading an individual resource, and may be present according to the chosen attribute selector parameter if this data type is returned in a response to a query of a container resource.\n", - "type":"string", - "enum":[ - "INSTANTIATE", - "SCALE", - "UPDATE", - "HEAL", - "TERMINATE" - ] + "type":"object" }, "isCancelPending":{ "description":"If the LCM operation occurrence is in \"PROCESSING\" or \"ROLLING_BACK\" state and the operation is being cancelled, this attribute shall be set to true. Otherwise, it shall be set to false.\n", diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/Application.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/Application.java index 24c09d489e..12f3bfc119 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/Application.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/Application.java @@ -1,19 +1,19 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Ericsson. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/AsyncThreadExecutorConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/AsyncThreadExecutorConfiguration.java index 2eaa710191..4427e1ac2f 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/AsyncThreadExecutorConfiguration.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/AsyncThreadExecutorConfiguration.java @@ -1,19 +1,19 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Ericsson. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/DefaultToShortClassNameBeanNameGenerator.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/DefaultToShortClassNameBeanNameGenerator.java index 13649ac80c..2546c9c23f 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/DefaultToShortClassNameBeanNameGenerator.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/app/DefaultToShortClassNameBeanNameGenerator.java @@ -1,23 +1,22 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.onap.so.etsi.nfvo.ns.lcm.app; import org.springframework.beans.factory.config.BeanDefinition; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/resources/application.yaml index 457e956f71..7f0fd93c8d 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/resources/application.yaml +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/resources/application.yaml @@ -11,6 +11,19 @@ # 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. +aai: + auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 + version: v19 + endpoint: https://aai.onap:8443 +camunda: + bpm: + admin-user: + id: admin + password: admin + history-level: full + job-execution: + max-pool-size: 30 + core-pool-size: 3 spring: security: usercredentials: @@ -22,7 +35,35 @@ spring: preferred-json-mapper: gson main: allow-bean-definition-overriding: true + datasource: + hikari: + camunda: + jdbcUrl: jdbc:mariadb://${DB_HOST}:${DB_PORT}/camundabpmn + username: ${DB_USERNAME} + password: ${DB_PASSWORD} + driver-class-name: org.mariadb.jdbc.Driver + pool-name: bpmn-pool + registerMbeans: true + nfvo: + jdbcUrl: jdbc:mariadb://${DB_HOST}:${DB_PORT}/nfvo + username: ${NFVO_USERNAME} + password: ${NFVO_PASSWORD} + driver-class-name: org.mariadb.jdbc.Driver + pool-name: nfvo-pool + registerMbeans: true server: port: 9095 tomcat: - max-threads: 50
\ No newline at end of file + max-threads: 50 +mso: + key: 07a7159d3bf51a0e53be7a8f89699be7 +so: + adapters: + sol003-adapter: + url: https://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1 + auth: Basic dm5mbTpwYXNzd29yZDEk +etsi-catalog-manager: + base: + endpoint: http://modeling-etsicatalog.onap:8806/api +so-etsi-nfvo-ns-lcm: + endpoint: http://so-etsi-nfvo-ns-lcm.onap:9095
\ No newline at end of file diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml index 734d4e071e..1c13ecac25 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml @@ -8,4 +8,99 @@ </parent> <artifactId>so-etsi-nfvo-ns-lcm-bpmn-flows</artifactId> <name>SO ETSI NFVO NS LCM BPMN Flows</name> + + <build> + <plugins> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <so.log.level>DEBUG</so.log.level> + </systemPropertyVariables> + <rerunFailingTestsCount>2</rerunFailingTestsCount> + <parallel>suites</parallel> + <useUnlimitedThreads>false</useUnlimitedThreads> + <threadCount>1</threadCount> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.onap.so.etsi.nfvo</groupId> + <artifactId>so-etsi-nfvo-ns-lcm-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.etsi.nfvo</groupId> + <artifactId>so-etsi-nfvo-ns-lcm-database-service</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-pkgm-ext-clients</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-lcm-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>aai-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.camunda.bpm.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId> + <version>${camunda.springboot.version}</version> + <exclusions> + <exclusion> + <groupId>org.camunda.bpmn</groupId> + <artifactId>camunda-engine-rest-core</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + </dependency> + <dependency> + <groupId>com.shazam</groupId> + <artifactId>shazamcrest</artifactId> + <version>${snakeyaml-version}</version> + <exclusions> + <exclusion> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </exclusion> + <exclusion> + <groupId>com.vaadin.external.google</groupId> + <artifactId>android-json</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest</artifactId> + <version>${hamcrest-version}</version> + <scope>test</scope> + </dependency> + </dependencies> </project>
\ No newline at end of file diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaCustomConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaCustomConfiguration.java new file mode 100644 index 0000000000..33923f400e --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaCustomConfiguration.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.NS_WORKFLOW_ENGINE; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.TENANT_ID; +import static org.slf4j.LoggerFactory.getLogger; +import org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration; +import org.camunda.bpm.spring.boot.starter.configuration.Ordering; +import org.camunda.bpm.spring.boot.starter.configuration.impl.AbstractCamundaConfiguration; +import org.slf4j.Logger; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Component +@Order(Ordering.DEFAULT_ORDER + 1) +public class CamundaCustomConfiguration extends AbstractCamundaConfiguration { + private static final Logger logger = getLogger(CamundaCustomConfiguration.class); + + @Override + public void preInit(final SpringProcessEngineConfiguration processEngineConfiguration) { + logger.info("Setting DeploymentTenantId to {} and DeploymentName to {}", TENANT_ID, NS_WORKFLOW_ENGINE); + processEngineConfiguration.setDeploymentTenantId(TENANT_ID); + processEngineConfiguration.setDeploymentName(NS_WORKFLOW_ENGINE); + super.preInit(processEngineConfiguration); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java new file mode 100644 index 0000000000..946bd38cbe --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + + +import static org.slf4j.LoggerFactory.getLogger; +import javax.sql.DataSource; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.jmx.export.MBeanExporter; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Configuration +@EnableTransactionManagement +@Profile({"!test"}) +public class CamundaDatabaseConfiguration { + + private static final Logger logger = getLogger(CamundaDatabaseConfiguration.class); + + @Autowired(required = false) + private MBeanExporter mBeanExporter; + + @Bean + @ConfigurationProperties(prefix = "spring.datasource.hikari.camunda") + public HikariConfig camundaDbConfig() { + logger.debug("Creating HikariConfig bean ... "); + return new HikariConfig(); + } + + @Primary + @Bean(name = "dataSource") + public DataSource dataSource() { + if (mBeanExporter != null) { + mBeanExporter.addExcludedBean("dataSource"); + } + logger.debug("Creating HikariDataSource bean ... "); + final HikariConfig hikariConfig = this.camundaDbConfig(); + return new HikariDataSource(hikariConfig); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaVariableNameConstants.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaVariableNameConstants.java new file mode 100644 index 0000000000..e90391d51a --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaVariableNameConstants.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class CamundaVariableNameConstants { + + public static final String JOB_ID_PARAM_NAME = "jobId"; + public static final String JOB_BUSINESS_KEY_PARAM_NAME = "jobBusinessKey"; + public static final String CREATE_NS_REQUEST_PARAM_NAME = "createNsRequest"; + public static final String GLOBAL_CUSTOMER_ID_PARAM_NAME = "globalCustomerId"; + public static final String SERVICE_TYPE_PARAM_NAME = "serviceType"; + + + public static final String NS_PACKAGE_MODEL_PARAM_NAME = "NSPackageModel"; + public static final String CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME = + "CreateNsWorkflowProcessingException"; + public static final String CREATE_NS_RESPONSE_PARAM_NAME = "createNsResponse"; + + public static final String INSTANTIATE_NS_REQUEST_PARAM_NAME = "instantiateNsRequest"; + public static final String OCC_ID_PARAM_NAME = "occId"; + public static final String NS_INSTANCE_ID_PARAM_NAME = "NsInstanceId"; + public static final String NETWORK_SERVICE_DESCRIPTOR_PARAM_NAME = "NetworkServiceDescriptor"; + public static final String VNF_CREATE_INSTANTIATE_REQUESTS = "vnfCreateInstantiateRequests"; + + public static final String NF_INST_ID_PARAM_NAME = "NF_INST_ID"; + public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse"; + public static final String OPERATION_STATUS_PARAM_NAME = "operationStatus"; + + private CamundaVariableNameConstants() {} + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/Constants.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/Constants.java new file mode 100644 index 0000000000..a2128fc2af --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/Constants.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class Constants { + + public static final String TENANT_ID = "ns-workflow-engine-tenant"; + public static final String NS_WORKFLOW_ENGINE = "NS-WORKFLOW-ENGINE"; + public static final String CREATE_NS_WORKFLOW_NAME = "CreateNs"; + public static final String INSTANTIATE_NS_WORKFLOW_NAME = "InstantiateNs"; + public static final String GET_NS_OCCURRENCE_OPERATION_STATUS_NAME = "GetNsOccurrenceOperationStatus"; + + + private Constants() {} + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/GsonProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/GsonProvider.java new file mode 100644 index 0000000000..31961d5b86 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/GsonProvider.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + +import java.time.LocalDateTime; +import org.onap.so.etsi.nfvo.ns.lcm.JSON; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.utils.LocalDateTimeTypeAdapter; +import org.springframework.stereotype.Component; +import org.threeten.bp.OffsetDateTime; +import com.google.gson.Gson; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Component +public class GsonProvider { + + private final JSON.OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new JSON.OffsetDateTimeTypeAdapter(); + + public Gson getGson() { + return JSON.createGson().registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) + .registerTypeAdapter(LocalDateTime.class, new LocalDateTimeTypeAdapter()).create(); + } + + +} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyConnectException.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/EtsiCatalogManagerRequestFailureException.java index 5bcc27bafc..553d2f1cf8 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyConnectException.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/EtsiCatalogManagerRequestFailureException.java @@ -1,38 +1,41 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. + * + * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions; -package org.onap.so.cloudify.base.client; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; /** - * Custom RuntimeException to report connection errors to Openstack endpoints. Must be a RuntimeException to conform - * with OpenstackClient interface, which does not declare specific Exceptions. + * @author Waqas Ikram (waqas.ikram@est.tech) + * */ -public class CloudifyConnectException extends CloudifyBaseException { +@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) +public class EtsiCatalogManagerRequestFailureException extends RuntimeException { - private static final long serialVersionUID = 7294957362769575271L; + private static final long serialVersionUID = 66862444537194516L; - public CloudifyConnectException(String message) { + public EtsiCatalogManagerRequestFailureException(final String message) { super(message); } - public CloudifyConnectException(String message, Throwable cause) { + public EtsiCatalogManagerRequestFailureException(final String message, final Throwable cause) { super(message, cause); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java new file mode 100644 index 0000000000..0dcadfd4d8 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions; + +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) +public class NsRequestProcessingException extends RuntimeException { + + private static final long serialVersionUID = 66862444537194516L; + private InlineResponse400 problemDetails; + + public NsRequestProcessingException(final String message) { + super(message); + } + + public NsRequestProcessingException(final String message, final InlineResponse400 problemDetails) { + super(message); + this.problemDetails = problemDetails; + } + + @Override + public synchronized Throwable fillInStackTrace() { + return this; + } + + public InlineResponse400 getProblemDetails() { + return problemDetails; + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiClientProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiClientProvider.java new file mode 100644 index 0000000000..673662aae8 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiClientProvider.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai; + +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class AaiClientProvider { + + @Bean + public AAIResourcesClient getAaiClient() { + return new AAIResourcesClient(); + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiPropertiesImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiPropertiesImpl.java new file mode 100644 index 0000000000..3df3580907 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiPropertiesImpl.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai; + +import org.onap.aaiclient.client.aai.AAIProperties; +import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.so.spring.SpringContextHelper; +import org.springframework.context.ApplicationContext; +import java.net.MalformedURLException; +import java.net.URL; + +public class AaiPropertiesImpl implements AAIProperties { + + private final String endpoint; + private final String encryptedBasicAuth; + private final String encryptionKey; + private final String aaiVersion; + + public AaiPropertiesImpl() { + + final ApplicationContext context = SpringContextHelper.getAppContext(); + this.endpoint = context.getEnvironment().getProperty("aai.endpoint"); + this.encryptedBasicAuth = context.getEnvironment().getProperty("aai.auth"); + this.encryptionKey = context.getEnvironment().getProperty("mso.key"); + this.aaiVersion = context.getEnvironment().getProperty("aai.version"); + } + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(endpoint); + } + + @Override + public String getSystemName() { + return "MSO"; + } + + @Override + public AAIVersion getDefaultVersion() { + for (final AAIVersion version : AAIVersion.values()) { + if (version.toString().equalsIgnoreCase(this.aaiVersion)) { + return version; + } ; + + } + return AAIVersion.LATEST; + } + + @Override + public String getAuth() { + return encryptedBasicAuth; + } + + @Override + public String getKey() { + return encryptionKey; + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProvider.java new file mode 100644 index 0000000000..53062395cf --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProvider.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai; + +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.ServiceInstance; +import java.util.Optional; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public interface AaiServiceProvider { + + void createServiceInstance(final String globalCustomerId, final String serviceType, + final ServiceInstance aaiServiceInstance); + + void createGenericVnfAndConnectServiceInstance(final String serviceInstanceId, final String vnfId, + final GenericVnf genericVnf); + + void connectGenericVnfToTenant(final String vnfId, final String cloudOwner, final String cloudRegion, + final String tenantId); + + Optional<GenericVnf> getGenericVnf(final String vnfId); + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java new file mode 100644 index 0000000000..049746c6ab --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai; + +import java.util.Optional; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +@Service +public class AaiServiceProviderImpl implements AaiServiceProvider { + private static final Logger logger = LoggerFactory.getLogger(AaiServiceProviderImpl.class); + private final AaiClientProvider aaiClientProvider; + + @Autowired + public AaiServiceProviderImpl(final AaiClientProvider aaiClientProvider) { + this.aaiClientProvider = aaiClientProvider; + } + + @Override + public void createServiceInstance(final String globalCustomerId, final String serviceType, + final ServiceInstance aaiServiceInstance) { + logger.info("Creating service instance in AAI: {}", aaiServiceInstance); + final AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustomerId, serviceType, aaiServiceInstance.getServiceInstanceId()); + aaiClientProvider.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(aaiServiceInstance)); + + } + + @Override + public void createGenericVnfAndConnectServiceInstance(final String serviceInstanceId, final String vnfId, + final GenericVnf genericVnf) { + logger.info("Creating GenericVnf in AAI: {}", genericVnf); + final AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + final AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + aaiClientProvider.getAaiClient().createIfNotExists(genericVnfURI, Optional.of(genericVnf)) + .connect(genericVnfURI, serviceInstanceURI); + + } + + @Override + public void connectGenericVnfToTenant(final String vnfId, final String cloudOwner, final String cloudRegion, + final String tenantId) { + logger.info("Connecting GenericVnf {} to {}/{}/{} in AAI", vnfId, cloudOwner, cloudRegion, tenantId); + final AAIResourceUri tenantURI = + AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId); + final AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + aaiClientProvider.getAaiClient().connect(tenantURI, genericVnfURI); + } + + @Override + public Optional<GenericVnf> getGenericVnf(final String vnfId) { + return aaiClientProvider.getAaiClient().get(GenericVnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + } +} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyBaseException.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java index b8006cb45f..65d982c6cc 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyBaseException.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java @@ -1,42 +1,39 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. + * + * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog; -package org.onap.so.cloudify.base.client; +import java.util.Optional; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.NsdInfo; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.VnfPkgInfo; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; /** - * A common abstract parent of all Openstack Exception types, allowing calling classes the choice to catch all error - * exceptions together. + * @author Waqas Ikram (waqas.ikram@est.tech) + * */ -public abstract class CloudifyBaseException extends RuntimeException { - private static final long serialVersionUID = 1L; +public interface EtsiCatalogPackageManagementServiceProvider { + + Optional<NsdInfo> getNSPackageModel(final String nsdId); - /* - * Implement only the basic constructors - */ - public CloudifyBaseException() {} + Optional<VnfPkgInfo> getVnfPkgInfo(final String vnfPkgId); - public CloudifyBaseException(String message) { - super(message); - } + Optional<NetworkServiceDescriptor> getNetworkServiceDescriptor(final String nsdId); - public CloudifyBaseException(String message, Throwable cause) { - super(message, cause); - } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java new file mode 100644 index 0000000000..75dd7107a7 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_SERVICE_PROVIDER_BEAN; +import java.util.Optional; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.NsdInfo; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.VnfPkgInfo; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.EtsiCatalogManagerRequestFailureException; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptorParser; +import org.onap.so.rest.service.HttpRestServiceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class EtsiCatalogPackageManagementServiceProviderImpl implements EtsiCatalogPackageManagementServiceProvider { + + private static final Logger logger = LoggerFactory.getLogger(EtsiCatalogPackageManagementServiceProviderImpl.class); + + private final HttpRestServiceProvider httpServiceProvider; + private final EtsiCatalogUrlProvider etsiCatalogUrlProvider; + private final NetworkServiceDescriptorParser networkServiceDescriptorParser; + + @Autowired + public EtsiCatalogPackageManagementServiceProviderImpl(final EtsiCatalogUrlProvider etsiCatalogUrlProvider, + @Qualifier(ETSI_CATALOG_SERVICE_PROVIDER_BEAN) final HttpRestServiceProvider httpServiceProvider, + final NetworkServiceDescriptorParser networkServiceDescriptorParser) { + this.etsiCatalogUrlProvider = etsiCatalogUrlProvider; + this.httpServiceProvider = httpServiceProvider; + this.networkServiceDescriptorParser = networkServiceDescriptorParser; + } + + @Override + public Optional<NsdInfo> getNSPackageModel(final String nsdId) { + try { + final ResponseEntity<NsdInfo> response = + httpServiceProvider.getHttpResponse(etsiCatalogUrlProvider.getNsPackageUrl(nsdId), NsdInfo.class); + if (response.getStatusCode().is2xxSuccessful()) { + return Optional.ofNullable(response.getBody()); + } + return Optional.empty(); + } catch (final Exception restProcessingException) { + logger.error("Caught exception while getting NS package model for: {}", nsdId, restProcessingException); + throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.", + restProcessingException); + } + } + + @Override + public Optional<VnfPkgInfo> getVnfPkgInfo(final String vnfPkgId) { + try { + final ResponseEntity<VnfPkgInfo> response = httpServiceProvider + .getHttpResponse(etsiCatalogUrlProvider.getVnfPackageUrl(vnfPkgId), VnfPkgInfo.class); + if (response.getStatusCode().is2xxSuccessful()) { + return Optional.ofNullable(response.getBody()); + } + return Optional.empty(); + } catch (final Exception restProcessingException) { + logger.error("Caught exception while getting VNF package model for: {}", vnfPkgId, restProcessingException); + throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.", + restProcessingException); + } + } + + @Override + public Optional<NetworkServiceDescriptor> getNetworkServiceDescriptor(final String nsdId) { + try { + final ResponseEntity<byte[]> response = httpServiceProvider + .getHttpResponse(etsiCatalogUrlProvider.getNsPackageContentUrl(nsdId), byte[].class); + if (response.getStatusCode().is2xxSuccessful()) { + if (response.hasBody()) { + return networkServiceDescriptorParser.parse(response.getBody()); + } + logger.error("Received response without body ..."); + } + return Optional.empty(); + } catch (final Exception restProcessingException) { + logger.error("Caught exception while getting NS package content for: {}", nsdId, restProcessingException); + throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.", + restProcessingException); + } + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java new file mode 100644 index 0000000000..8c6ea92428 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java @@ -0,0 +1,188 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog; + +import java.io.IOException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.util.Iterator; +import java.util.concurrent.TimeUnit; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.ssl.SSLContextBuilder; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; +import org.onap.so.configuration.rest.BasicHttpHeadersProvider; +import org.onap.so.configuration.rest.HttpClientConnectionConfiguration; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider; +import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; +import org.onap.so.rest.service.HttpRestServiceProvider; +import org.onap.so.rest.service.HttpRestServiceProviderImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.GsonHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.client.RestTemplate; + +/** + * Configures the HttpRestServiceProvider to make REST calls to the ETSI Catalog Manager + * + * @author gareth.roper@est.tech + */ + +@Configuration +public class EtsiCatalogServiceProviderConfiguration { + public static final String ETSI_CATALOG_REST_TEMPLATE_BEAN = "etsiCatalogRestTemplate"; + + public static final String ETSI_CATALOG_SERVICE_PROVIDER_BEAN = "etsiCatalogServiceProvider"; + + private final static Logger LOGGER = LoggerFactory.getLogger(EtsiCatalogServiceProviderConfiguration.class); + + private final HttpClientConnectionConfiguration clientConnectionConfiguration; + + @Value("${etsi-catalog-manager.http.client.ssl.trust-store:#{null}}") + private Resource trustStore; + @Value("${etsi-catalog-manager.http.client.ssl.trust-store-password:#{null}}") + private String trustStorePassword; + + private final GsonProvider gsonProvider; + + @Autowired + public EtsiCatalogServiceProviderConfiguration( + final HttpClientConnectionConfiguration clientConnectionConfiguration, final GsonProvider gsonProvider) { + this.clientConnectionConfiguration = clientConnectionConfiguration; + this.gsonProvider = gsonProvider; + } + + @Bean + @Qualifier(ETSI_CATALOG_REST_TEMPLATE_BEAN) + public RestTemplate etsiCatalogRestTemplate() { + final RestTemplate restTemplate = new RestTemplate(); + restTemplate.getInterceptors().add(new SOSpringClientFilter()); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); + return restTemplate; + } + + @Bean + @Qualifier(ETSI_CATALOG_SERVICE_PROVIDER_BEAN) + public HttpRestServiceProvider etsiCatalogHttpRestServiceProvider( + @Qualifier(ETSI_CATALOG_REST_TEMPLATE_BEAN) final RestTemplate restTemplate) { + setGsonMessageConverter(restTemplate); + + final HttpClientBuilder httpClientBuilder = getHttpClientBuilder(); + if (trustStore != null) { + try { + LOGGER.debug("Setting up HttpComponentsClientHttpRequestFactory with SSL Context"); + LOGGER.debug("Setting client trust-store: {}", trustStore.getURL()); + LOGGER.debug("Creating SSLConnectionSocketFactory with AllowAllHostsVerifier ... "); + final SSLContext sslContext = new SSLContextBuilder() + .loadTrustMaterial(trustStore.getURL(), trustStorePassword.toCharArray()).build(); + final SSLConnectionSocketFactory sslConnectionSocketFactory = + new SSLConnectionSocketFactory(sslContext, AllowAllHostsVerifier.INSTANCE); + httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory); + final Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder + .<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", sslConnectionSocketFactory).build(); + + httpClientBuilder.setConnectionManager(getConnectionManager(socketFactoryRegistry)); + } catch (final KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException + | IOException exception) { + LOGGER.error("Error reading truststore, TLS connection will fail.", exception); + } + + } else { + LOGGER.debug("Setting connection manager without SSL ConnectionSocketFactory ..."); + httpClientBuilder.setConnectionManager(getConnectionManager()); + } + + final HttpComponentsClientHttpRequestFactory factory = + new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build()); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); + + return new HttpRestServiceProviderImpl(restTemplate, new BasicHttpHeadersProvider().getHttpHeaders()); + } + + private PoolingHttpClientConnectionManager getConnectionManager( + final Registry<ConnectionSocketFactory> socketFactoryRegistry) { + return new PoolingHttpClientConnectionManager(socketFactoryRegistry, null, null, null, + clientConnectionConfiguration.getTimeToLiveInMins(), TimeUnit.MINUTES); + } + + private PoolingHttpClientConnectionManager getConnectionManager() { + return new PoolingHttpClientConnectionManager(clientConnectionConfiguration.getTimeToLiveInMins(), + TimeUnit.MINUTES); + } + + private HttpClientBuilder getHttpClientBuilder() { + return HttpClientBuilder.create().setMaxConnPerRoute(clientConnectionConfiguration.getMaxConnectionsPerRoute()) + .setMaxConnTotal(clientConnectionConfiguration.getMaxConnections()) + .setDefaultRequestConfig(getRequestConfig()); + } + + private RequestConfig getRequestConfig() { + return RequestConfig.custom().setSocketTimeout(clientConnectionConfiguration.getSocketTimeOutInMiliSeconds()) + .setConnectTimeout(clientConnectionConfiguration.getConnectionTimeOutInMilliSeconds()).build(); + } + + private static final class AllowAllHostsVerifier implements HostnameVerifier { + + private static final AllowAllHostsVerifier INSTANCE = new AllowAllHostsVerifier(); + + @Override + public boolean verify(final String hostname, final SSLSession session) { + LOGGER.debug("Skipping hostname verification ..."); + return true; + } + + } + + public void setGsonMessageConverter(final RestTemplate restTemplate) { + final Iterator<HttpMessageConverter<?>> iterator = restTemplate.getMessageConverters().iterator(); + while (iterator.hasNext()) { + if (iterator.next() instanceof MappingJackson2HttpMessageConverter) { + iterator.remove(); + } + } + restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gsonProvider.getGson())); + } + + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java new file mode 100644 index 0000000000..e3c159c7b0 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class EtsiCatalogUrlProvider { + + @Value("${etsi-catalog-manager.base.endpoint}") + private String etsiCatalogManagerEndpoint; + + public EtsiCatalogUrlProvider() {} + + public String getNsPackageUrl(final String nsdId) { + return etsiCatalogManagerEndpoint + "/nsd/v1/ns_descriptors/" + nsdId; + } + + public String getNsPackageContentUrl(final String nsdId) { + return etsiCatalogManagerEndpoint + "/nsd/v1/ns_descriptors/" + nsdId + "/nsd_content"; + } + + public String getVnfPackageUrl(final String vnfPkgId) { + return etsiCatalogManagerEndpoint + "/vnfpkgm/v1/vnf_packages/" + vnfPkgId; + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java new file mode 100644 index 0000000000..fe710ec00b --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java @@ -0,0 +1,148 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm; + +import java.io.IOException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.util.Iterator; +import javax.net.ssl.SSLContext; +import org.apache.http.client.HttpClient; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; +import org.onap.so.configuration.rest.BasicHttpHeadersProvider; +import org.onap.so.configuration.rest.HttpComponentsClientConfiguration; +import org.onap.so.configuration.rest.HttpHeadersProvider; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider; +import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; +import org.onap.so.rest.service.HttpRestServiceProvider; +import org.onap.so.rest.service.HttpRestServiceProviderImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.GsonHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.client.RestTemplate; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Configuration +public class Sol003AdapterConfiguration { + + private static final Logger logger = LoggerFactory.getLogger(Sol003AdapterConfiguration.class); + + public static final String SOL003_ADAPTER_REST_TEMPLATE_BEAN = "Sol003AdapterRestTemplateBean"; + public static final String SOL003_ADAPTER_HTTP_REST_SERVICE_PROVIDER_BEAN = + "Sol003AdapterHttpRestServiceProviderBean"; + + @Value("${rest.http.client.configuration.ssl.trustStore:#{null}}") + private Resource trustStore; + + @Value("${rest.http.client.configuration.ssl.trustStorePassword:#{null}}") + private String trustStorePassword; + + @Value("so.adapters.sol003-adapter.auth:Basic dm5mbTpwYXNzd29yZDEk") + private String sol003AdapterBasicAuth; + + @Autowired + private GsonProvider gsonProvider; + + @Autowired + private HttpComponentsClientConfiguration httpComponentsClientConfiguration; + + @Bean + @Qualifier(SOL003_ADAPTER_REST_TEMPLATE_BEAN) + public RestTemplate sol003AdapterRestTemplate() { + final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = + httpComponentsClientConfiguration.httpComponentsClientHttpRequestFactory(); + final RestTemplate restTemplate = + new RestTemplate(new BufferingClientHttpRequestFactory(clientHttpRequestFactory)); + restTemplate.getInterceptors().add(new SOSpringClientFilter()); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); + return restTemplate; + + } + + @Bean + @Qualifier(SOL003_ADAPTER_HTTP_REST_SERVICE_PROVIDER_BEAN) + public HttpRestServiceProvider sol003AdapaterHttpRestServiceProvider( + @Qualifier(SOL003_ADAPTER_REST_TEMPLATE_BEAN) @Autowired final RestTemplate restTemplate) { + + if (trustStore != null) { + setTrustStore(restTemplate); + } + setGsonMessageConverter(restTemplate); + return getHttpRestServiceProvider(restTemplate, new BasicHttpHeadersProvider(sol003AdapterBasicAuth)); + } + + private void setTrustStore(final RestTemplate restTemplate) { + try { + final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(getSSLContext()); + final HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); + final HttpComponentsClientHttpRequestFactory factory = + new HttpComponentsClientHttpRequestFactory(httpClient); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); + } catch (Exception exception) { + logger.error("Error reading truststore, TLS connection to VNFM will fail.", exception); + } + } + + private SSLContext getSSLContext() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, + CertificateException, IOException { + if (trustStore != null) { + logger.info("Setting truststore: {}", trustStore.getURL()); + return new SSLContextBuilder().loadTrustMaterial(trustStore.getURL(), trustStorePassword.toCharArray()) + .build(); + } + logger.info("Setting Default SSL ..."); + return SSLContext.getDefault(); + + } + + private HttpRestServiceProvider getHttpRestServiceProvider(final RestTemplate restTemplate, + final HttpHeadersProvider httpHeadersProvider) { + return new HttpRestServiceProviderImpl(restTemplate, httpHeadersProvider.getHttpHeaders()); + } + + private void setGsonMessageConverter(final RestTemplate restTemplate) { + final Iterator<HttpMessageConverter<?>> iterator = restTemplate.getMessageConverters().iterator(); + while (iterator.hasNext()) { + if (iterator.next() instanceof MappingJackson2HttpMessageConverter) { + iterator.remove(); + } + } + restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gsonProvider.getGson())); + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProvider.java new file mode 100644 index 0000000000..c053ba94f1 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProvider.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm; + +import java.util.Optional; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse; + +public interface Sol003AdapterServiceProvider { + + Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, final CreateVnfRequest request); + + Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId); + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java new file mode 100644 index 0000000000..09fecc64ae --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterConfiguration.SOL003_ADAPTER_HTTP_REST_SERVICE_PROVIDER_BEAN; +import java.util.Optional; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse; +import org.onap.so.rest.exceptions.HttpResouceNotFoundException; +import org.onap.so.rest.exceptions.InvalidRestRequestException; +import org.onap.so.rest.exceptions.RestProcessingException; +import org.onap.so.rest.service.HttpRestServiceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +@Service +public class Sol003AdapterServiceProviderImpl implements Sol003AdapterServiceProvider { + + private static final Logger LOGGER = LoggerFactory.getLogger(Sol003AdapterServiceProviderImpl.class); + public static final String RECEIVED_RESPONSE_WITHOUT_BODY = "Received response without body: {}"; + + private final Sol003AdapterUrlProvider urlProvider; + private final HttpRestServiceProvider httpServiceProvider; + + @Autowired + public Sol003AdapterServiceProviderImpl(final Sol003AdapterUrlProvider urlProvider, + @Qualifier(SOL003_ADAPTER_HTTP_REST_SERVICE_PROVIDER_BEAN) final HttpRestServiceProvider httpServiceProvider) { + this.urlProvider = urlProvider; + this.httpServiceProvider = httpServiceProvider; + } + + @Override + public Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, + final CreateVnfRequest request) { + try { + final String url = urlProvider.getCreateInstantiateUrl(vnfId); + + final ResponseEntity<CreateVnfResponse> response = + httpServiceProvider.postHttpRequest(request, url, CreateVnfResponse.class); + + final HttpStatus httpStatus = response.getStatusCode(); + if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) { + LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value()); + return Optional.empty(); + } + + if (!response.hasBody()) { + LOGGER.error(RECEIVED_RESPONSE_WITHOUT_BODY, response); + return Optional.empty(); + } + + final CreateVnfResponse createVnfResponse = response.getBody(); + + if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) { + LOGGER.error("Received invalid instantiation response: {}", response); + return Optional.empty(); + } + + return Optional.of(createVnfResponse); + } catch (final RestProcessingException | InvalidRestRequestException + | HttpResouceNotFoundException httpInvocationException) { + LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException); + return Optional.empty(); + } + + } + + @Override + public Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId) { + try { + final String url = urlProvider.getJobStatusUrl(jobId); + + final ResponseEntity<QueryJobResponse> response = + httpServiceProvider.getHttpResponse(url, QueryJobResponse.class); + + final HttpStatus httpStatus = response.getStatusCode(); + + if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) { + LOGGER.error("Unable to invoke HTTP GET using URL: {}, Response Code: ", url, httpStatus.value()); + return Optional.empty(); + } + + if (!response.hasBody()) { + LOGGER.error(RECEIVED_RESPONSE_WITHOUT_BODY, response); + return Optional.empty(); + } + return Optional.of(response.getBody()); + } catch (final RestProcessingException | InvalidRestRequestException | HttpResouceNotFoundException exception) { + LOGGER.error("Unexpected error while processing job request", exception); + throw exception; + } + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterUrlProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterUrlProvider.java new file mode 100644 index 0000000000..351d4bf88c --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterUrlProvider.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm; + +import java.net.URI; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.util.UriComponentsBuilder; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class Sol003AdapterUrlProvider { + + private final URI baseUri; + + @Autowired + public Sol003AdapterUrlProvider( + @Value("${so.adapters.sol003-adapter.url:https://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/}") final String sol003AdapterUrl) { + this.baseUri = UriComponentsBuilder.fromHttpUrl(sol003AdapterUrl).build().toUri(); + } + + /** + * Get VNFM create and instantiate URL + * + * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in AAI. + * @return VNFM create and instantiate URL + */ + public String getCreateInstantiateUrl(final String vnfId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString(); + } + + /** + * Get job status URL + * + * @param jobId The instantiation job identifier + * @return job status URL + */ + public String getJobStatusUrl(final String jobId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment("jobs").pathSegment(jobId).build().toString(); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java new file mode 100644 index 0000000000..58ca2507bd --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; + +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Objects; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class FileEntry { + + private boolean isDirectory; + private String filePath; + private byte[] fileContent; + + public boolean isDirectory() { + return isDirectory; + } + + public void setDirectory(final boolean isDirectory) { + this.isDirectory = isDirectory; + } + + public FileEntry isDirectory(final boolean isDirectory) { + this.isDirectory = isDirectory; + return this; + } + + public String getFilePath() { + return filePath; + } + + public void setFilename(final String filePath) { + this.filePath = filePath; + } + + public FileEntry filePath(final String filePath) { + this.filePath = filePath; + return this; + } + + public byte[] getFileContent() { + return fileContent; + } + + public void setFileContent(final byte[] fileContent) { + this.fileContent = fileContent; + } + + public FileEntry fileContent(final byte[] fileContent) { + this.fileContent = fileContent; + return this; + } + + public InputStream getFileContentAsStream() { + if (fileContent == null || fileContent.length == 0) { + return null; + } + return new ByteArrayInputStream(fileContent); + } + + @Override + public int hashCode() { + return Objects.hash(isDirectory, filePath, fileContent); + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof FileEntry) { + final FileEntry other = (FileEntry) obj; + return Objects.equals(isDirectory, other.isDirectory) && Objects.equals(filePath, other.filePath) + && Objects.equals(fileContent, other.fileContent); + } + return false; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class FileEntry {\n"); + sb.append(" isDirectory: ").append(toIndentedString(isDirectory)).append("\n"); + sb.append(" filePath: ").append(toIndentedString(filePath)).append("\n"); + sb.append(" fileContent size: ").append(toIndentedString(fileContent != null ? fileContent.length : 0)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileParser.java new file mode 100644 index 0000000000..9df5262302 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileParser.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; + +import java.util.Map; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public interface FileParser { + + Map<String, Object> getFileContent(final FileEntry entryDefinitionFileEntry); + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptor.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptor.java new file mode 100644 index 0000000000..6b4fee7151 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptor.java @@ -0,0 +1,121 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; + +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class NetworkServiceDescriptor implements Serializable { + + private static final long serialVersionUID = -1739293595041180242L; + + private String type; + + private Map<String, Object> properties = new HashMap<>(); + + private List<VirtualNetworkFunction> vnfs = new ArrayList<>(); + + public String getType() { + return type; + } + + public void setType(final String type) { + this.type = type; + } + + public NetworkServiceDescriptor type(final String type) { + this.type = type; + return this; + } + + public Map<String, Object> getProperties() { + return properties; + } + + public void setProperties(final Map<String, Object> properties) { + this.properties = properties; + } + + public NetworkServiceDescriptor properties(final Map<String, Object> properties) { + this.properties = properties; + return this; + } + + public List<VirtualNetworkFunction> getVnfs() { + return vnfs; + } + + public void setVnfs(final List<VirtualNetworkFunction> vnfs) { + if (vnfs != null) { + this.vnfs = vnfs; + } else { + this.vnfs = new ArrayList<>(); + } + } + + public NetworkServiceDescriptor addVnfPkgIdsItem(final VirtualNetworkFunction vnf) { + if (this.vnfs == null) { + this.vnfs = new ArrayList<>(); + } + this.vnfs.add(vnf); + return this; + } + + public NetworkServiceDescriptor vnfs(final List<VirtualNetworkFunction> vnfs) { + this.vnfs = vnfs; + return this; + } + + @Override + public int hashCode() { + return Objects.hash(type, properties, vnfs); + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof NetworkServiceDescriptor) { + final NetworkServiceDescriptor other = (NetworkServiceDescriptor) obj; + return Objects.equals(type, other.type) && Objects.equals(properties, other.properties) + && Objects.equals(vnfs, other.vnfs); + } + return false; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class NetworkServiceDescriptor {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append(" vnfs: ").append(toIndentedString(vnfs)).append("\n"); + sb.append("}"); + return sb.toString(); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParser.java new file mode 100644 index 0000000000..33737f4c17 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParser.java @@ -0,0 +1,209 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class NetworkServiceDescriptorParser { + public static final String NS_NODE_TYPE = "tosca.nodes.nfv.NS"; + private static final String NODE_TYPE = "node_type"; + private static final String SUBSTITUTION_MAPPINGS = "substitution_mappings"; + private static final Logger logger = LoggerFactory.getLogger(NetworkServiceDescriptorParser.class); + private static final String VNF_TYPE = "tosca.nodes.nfv.VNF"; + private static final String PROPERTIES = "properties"; + private static final String TYPE = "type"; + private static final String NODE_TEMPLATES = "node_templates"; + private static final String TOPOLOGY_TEMPLATE = "topology_template"; + private static final String ENTRY_DEFINITIONS = "Entry-Definitions"; + private static final String TOSCA_META_PATH_FILE_NAME = "TOSCA-Metadata/TOSCA.meta"; + private final ToscaMetadataParser toscaMetadataParser; + private final FileParser fileParser; + + @Autowired + public NetworkServiceDescriptorParser(final ToscaMetadataParser toscaMetadataParser, final FileParser fileParser) { + this.toscaMetadataParser = toscaMetadataParser; + this.fileParser = fileParser; + } + + public Optional<NetworkServiceDescriptor> parse(final byte[] zipBytes) { + try { + final Map<String, FileEntry> files = getZipContent(zipBytes); + if (isMetaFilePresent(files)) { + final Optional<ToscaMetadata> optional = + toscaMetadataParser.parse(files.get(TOSCA_META_PATH_FILE_NAME)); + if (optional.isPresent()) { + final ToscaMetadata toscaMetadata = optional.get(); + logger.info("Parsed ToscaMetadata {}", toscaMetadata); + final String entryDefinitionFile = toscaMetadata.getEntry(ENTRY_DEFINITIONS); + if (entryDefinitionFile != null && files.containsKey(entryDefinitionFile)) { + final Map<String, Object> fileContent = + fileParser.getFileContent(files.get(entryDefinitionFile)); + final Map<String, Object> topologyTemplates = getTopologyTemplates(fileContent); + final Map<String, Object> nodeTemplates = getNodeTemplates(topologyTemplates); + + final Optional<NetworkServiceDescriptor> nsdOptional = + getNetworkServiceDescriptor(topologyTemplates);; + if (nsdOptional.isPresent()) { + final NetworkServiceDescriptor networkServiceDescriptor = nsdOptional.get(); + networkServiceDescriptor.setVnfs(getVirtualNetworkFunctions(nodeTemplates)); + return Optional.of(networkServiceDescriptor); + } + + } + } + + } + + } catch (final Exception exception) { + logger.error("Unable to parser nsd zip content", exception); + } + logger.error("Unable to parser nsd zip content"); + return Optional.empty(); + } + + @SuppressWarnings("unchecked") + private Optional<NetworkServiceDescriptor> getNetworkServiceDescriptor( + final Map<String, Object> topologyTemplates) { + final Map<String, Object> substitutionMappings = + (Map<String, Object>) topologyTemplates.get(SUBSTITUTION_MAPPINGS); + final Object nodeType = substitutionMappings.get(NODE_TYPE); + if (substitutionMappings != null && nodeType != null && NS_NODE_TYPE.equals(nodeType)) { + final NetworkServiceDescriptor networkServiceDescriptor = new NetworkServiceDescriptor(); + networkServiceDescriptor.setType(nodeType.toString()); + networkServiceDescriptor.setProperties((Map<String, Object>) substitutionMappings.get(PROPERTIES)); + return Optional.of(networkServiceDescriptor); + } + logger.error("No {} found in fileContent: {}", SUBSTITUTION_MAPPINGS, topologyTemplates); + + return Optional.empty(); + } + + private List<VirtualNetworkFunction> getVirtualNetworkFunctions(final Map<String, Object> nodeTemplates) { + final List<VirtualNetworkFunction> vnfs = new ArrayList<>(); + for (final Entry<String, Object> entry : nodeTemplates.entrySet()) { + @SuppressWarnings("unchecked") + final Map<String, Object> entryValue = (Map<String, Object>) entry.getValue(); + final Object type = entryValue.get(TYPE); + if (type != null && type.equals(VNF_TYPE)) { + @SuppressWarnings("unchecked") + final Map<String, Object> vnfProperties = (Map<String, Object>) entryValue.get(PROPERTIES); + final VirtualNetworkFunction vnf = new VirtualNetworkFunction(); + vnf.setVnfName(entry.getKey()); + + if (vnfProperties != null && !vnfProperties.isEmpty()) { + final Object vnfDescriptorId = vnfProperties.get("descriptor_id"); + @SuppressWarnings("unchecked") + final List<String> vnfmInfoList = (List<String>) vnfProperties.get("vnfm_info"); + if (vnfDescriptorId != null && vnfmInfoList != null) { + vnf.setVnfmInfoList(vnfmInfoList); + vnf.setVnfdId(vnfDescriptorId.toString()); + vnf.setProperties(vnfProperties); + vnfs.add(vnf); + } else { + logger.warn("descriptor_id missing {}", entryValue); + } + } + } + + } + return vnfs; + } + + private Map<String, Object> getNodeTemplates(final Map<String, Object> topologyTemplates) { + @SuppressWarnings("unchecked") + final Map<String, Object> nodeTemplates = (Map<String, Object>) topologyTemplates.get(NODE_TEMPLATES); + if (nodeTemplates != null) { + logger.debug("Found nodeTemplates: {}", topologyTemplates); + return nodeTemplates; + } + logger.error("No {} found in fileContent: {}", NODE_TEMPLATES, topologyTemplates); + return Collections.emptyMap(); + } + + private Map<String, Object> getTopologyTemplates(final Map<String, Object> fileContent) { + @SuppressWarnings("unchecked") + final Map<String, Object> topologyTemplates = (Map<String, Object>) fileContent.get(TOPOLOGY_TEMPLATE); + if (topologyTemplates != null) { + logger.debug("Found {}: {}", TOPOLOGY_TEMPLATE, topologyTemplates); + + return topologyTemplates; + } + logger.error("No {} found in fileContent: {}", TOPOLOGY_TEMPLATE, fileContent); + return Collections.emptyMap(); + } + + private boolean isMetaFilePresent(final Map<String, FileEntry> files) { + return files.containsKey(TOSCA_META_PATH_FILE_NAME); + } + + private Map<String, FileEntry> getZipContent(final byte[] zipBytes) { + final Map<String, FileEntry> files = new HashMap<>(); + try (final ZipInputStream inputZipStream = new ZipInputStream(new ByteArrayInputStream(zipBytes));) { + ZipEntry zipEntry; + while ((zipEntry = inputZipStream.getNextEntry()) != null) { + logger.info("{} : {}", zipEntry.getName(), zipEntry.isDirectory()); + if (files.get(zipEntry.getName()) != null) { + logger.warn("{} File entry already exists ...", zipEntry.getName()); + } else { + final FileEntry fileEntry = new FileEntry().filePath(zipEntry.getName()) + .fileContent(getBytes(inputZipStream)).isDirectory(zipEntry.isDirectory()); + files.put(zipEntry.getName(), fileEntry); + + } + + } + return files; + } catch (final Exception exception) { + logger.error("Unable to parser nsd zip content", exception); + return Collections.emptyMap(); + } + } + + private byte[] getBytes(final ZipInputStream inputZipStream) throws IOException { + try { + return IOUtils.toByteArray(inputZipStream); + } catch (final IOException exception) { + logger.error("Could not read bytes from file", exception); + throw exception; + } + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadata.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadata.java new file mode 100644 index 0000000000..c07a55c459 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadata.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; + +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class ToscaMetadata { + + private Map<String, String> entries = new HashMap<>(); + + public Map<String, String> getEntries() { + return entries; + } + + public void addEntry(final String name, final String value) { + this.entries.put(name, value); + } + + public boolean hasEntry(final String name) { + return this.entries.containsKey(name); + } + + public String getEntry(final String name) { + return this.entries.get(name); + } + + @Override + public int hashCode() { + return Objects.hash(entries); + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof ToscaMetadata) { + final ToscaMetadata other = (ToscaMetadata) obj; + return Objects.equals(entries, other.entries); + } + return false; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ToscaMetadata {\n"); + sb.append(" entries: ").append(toIndentedString(entries)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadataParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadataParser.java new file mode 100644 index 0000000000..fe23f5ef8d --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadataParser.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; + +import static org.apache.commons.lang3.StringUtils.isNotBlank; +import java.util.List; +import java.util.Optional; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class ToscaMetadataParser { + private static final String ATTRIBUTE_VALUE_SEPARATOR = ":"; + private static final Logger logger = LoggerFactory.getLogger(ToscaMetadataParser.class); + + public Optional<ToscaMetadata> parse(final FileEntry toscaMetaFile) { + try { + final ToscaMetadata toscaMetadata = new ToscaMetadata(); + final List<String> lines = IOUtils.readLines(toscaMetaFile.getFileContentAsStream(), "utf-8"); + for (final String line : lines) { + final String trimmedLine = line.trim(); + if (!trimmedLine.isEmpty() && trimmedLine.contains(ATTRIBUTE_VALUE_SEPARATOR)) { + final String[] entry = trimmedLine.split(ATTRIBUTE_VALUE_SEPARATOR); + if (entry.length >= 2 && isNotBlank(entry[0]) && isNotBlank(entry[1])) { + toscaMetadata.addEntry(entry[0].trim(), entry[1].trim()); + } else { + logger.warn("Unexpected line in metadata file: {}", line); + } + } else { + logger.warn("Unexpected line does not contain valid separator {} in metadata file: {}", + ATTRIBUTE_VALUE_SEPARATOR, line); + } + + } + return Optional.of(toscaMetadata); + + } catch (final Exception exception) { + logger.error("Unable to parser metadata file content", exception); + } + return Optional.empty(); + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/VirtualNetworkFunction.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/VirtualNetworkFunction.java new file mode 100644 index 0000000000..f4c3632589 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/VirtualNetworkFunction.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; + +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class VirtualNetworkFunction implements Serializable { + + private static final long serialVersionUID = 3164293220359211834L; + + private String vnfdId; + private String vnfName; + private List<String> vnfmInfoList; + private Map<String, Object> properties = new HashMap<>(); + + public String getVnfdId() { + return vnfdId; + } + + public void setVnfdId(final String vnfdId) { + this.vnfdId = vnfdId; + } + + public VirtualNetworkFunction vnfdId(final String vnfdId) { + this.vnfdId = vnfdId; + return this; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(final String vnfName) { + this.vnfName = vnfName; + } + + public VirtualNetworkFunction vnfName(final String vnfName) { + this.vnfName = vnfName; + return this; + } + + public List<String> getVnfmInfoList() { + return vnfmInfoList; + } + + public void setVnfmInfoList(final List<String> vnfmInfoList) { + this.vnfmInfoList = vnfmInfoList; + } + + public VirtualNetworkFunction vnfmInfoList(final List<String> vnfmInfoList) { + this.vnfmInfoList = vnfmInfoList; + return this; + } + + public Map<String, Object> getProperties() { + return properties; + } + + public void setProperties(final Map<String, Object> properties) { + this.properties = properties; + } + + public VirtualNetworkFunction properties(final Map<String, Object> properties) { + this.properties = properties; + return this; + } + + @Override + public int hashCode() { + return Objects.hash(vnfdId, vnfName, vnfmInfoList, properties); + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof VirtualNetworkFunction) { + final VirtualNetworkFunction other = (VirtualNetworkFunction) obj; + return Objects.equals(vnfdId, other.vnfdId) && Objects.equals(vnfName, other.vnfName) + && Objects.equals(vnfmInfoList, other.vnfmInfoList) && Objects.equals(properties, other.properties); + } + return false; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class VirtualNetworkFunction {\n"); + sb.append(" vnfdId: ").append(toIndentedString(vnfdId)).append("\n"); + sb.append(" vnfName: ").append(toIndentedString(vnfName)).append("\n"); + sb.append(" vnfmInfo: ").append(toIndentedString(vnfmInfoList)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + + sb.append("}"); + return sb.toString(); + } + + +} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponse.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/YamlFileParser.java index 6b70e5fa95..ac8f782a99 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponse.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/YamlFileParser.java @@ -1,39 +1,39 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. + * + * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; -package org.onap.so.cloudify.base.client; - -import java.io.InputStream; -import java.io.Serializable; import java.util.Map; +import org.springframework.stereotype.Service; +import org.yaml.snakeyaml.Yaml; -public interface CloudifyResponse extends Serializable { - - public <T> T getEntity(Class<T> returnType); - - public <T> T getErrorEntity(Class<T> returnType); - - public InputStream getInputStream(); - - public String getHeader(String name); - - public Map<String, String> headers(); +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class YamlFileParser implements FileParser { + + @Override + public Map<String, Object> getFileContent(final FileEntry entryDefinitionFileEntry) { + final Yaml yaml = new Yaml(); + return yaml.load(entryDefinitionFileEntry.getFileContentAsStream()); + } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java new file mode 100644 index 0000000000..13cdc60b1b --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java @@ -0,0 +1,252 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_REQUEST_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.GLOBAL_CUSTOMER_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.INSTANTIATE_NS_REQUEST_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.JOB_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OCC_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.SERVICE_TYPE_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.CREATE_NS_WORKFLOW_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.INSTANTIATE_NS_WORKFLOW_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction.INSTANTIATE; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.ERROR; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED_WITH_ERROR; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.STARTING; +import static org.slf4j.LoggerFactory.getLogger; +import java.time.Instant; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.NsRequestProcessingException; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpType; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.model.CreateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; +import org.onap.so.etsi.nfvo.ns.lcm.model.InstantiateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import com.google.common.collect.ImmutableSet; +import com.google.gson.Gson; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class JobExecutorService { + + private static final Logger logger = getLogger(JobExecutorService.class); + + private static final ImmutableSet<JobStatusEnum> JOB_FINISHED_STATES = + ImmutableSet.of(FINISHED, ERROR, FINISHED_WITH_ERROR); + + private static final int SLEEP_TIME_IN_SECONDS = 5; + + @Value("${so-etsi-ns-lcm-workflow-engine.requesttimeout.timeoutInSeconds:300}") + private int timeOutInSeconds; + + private final DatabaseServiceProvider databaseServiceProvider; + private final WorkflowExecutorService workflowExecutorService; + private final WorkflowQueryService workflowQueryService; + private Gson gson; + + @Autowired + public JobExecutorService(final DatabaseServiceProvider databaseServiceProvider, + final WorkflowExecutorService workflowExecutorService, final WorkflowQueryService workflowQueryService, + final GsonProvider gsonProvider) { + this.databaseServiceProvider = databaseServiceProvider; + this.workflowExecutorService = workflowExecutorService; + this.workflowQueryService = workflowQueryService; + gson = gsonProvider.getGson(); + } + + public NsInstancesNsInstance runCreateNsJob(final CreateNsRequest createNsRequest, final String globalCustomerId, + final String serviceType) { + logger.info("Starting 'Create NS' workflow job for request:\n{}", createNsRequest); + final NfvoJob newJob = new NfvoJob().startTime(LocalDateTime.now()).jobType("NS").jobAction(JobAction.CREATE) + .resourceId(createNsRequest.getNsdId()).resourceName(createNsRequest.getNsName()) + .status(JobStatusEnum.STARTING).progress(5); + databaseServiceProvider.addJob(newJob); + + logger.info("New job created in database :\n{}", newJob); + + workflowExecutorService.executeWorkflow(newJob.getJobId(), CREATE_NS_WORKFLOW_NAME, + getVariables(newJob.getJobId(), createNsRequest, globalCustomerId, serviceType)); + + final ImmutablePair<String, JobStatusEnum> immutablePair = + waitForJobToFinish(newJob.getJobId(), JOB_FINISHED_STATES); + + if (immutablePair.getRight() == null) { + final String message = "Failed to create NS for request: \n" + createNsRequest; + logger.error(message); + throw new NsRequestProcessingException(message); + } + final JobStatusEnum finalJobStatus = immutablePair.getRight(); + final String processInstanceId = immutablePair.getLeft(); + + if (!FINISHED.equals(finalJobStatus)) { + + final Optional<InlineResponse400> optional = workflowQueryService.getProblemDetails(processInstanceId); + if (optional.isPresent()) { + final InlineResponse400 problemDetails = optional.get(); + final String message = + "Failed to create NS for request: \n" + createNsRequest + " due to \n" + problemDetails; + logger.error(message); + throw new NsRequestProcessingException(message, problemDetails); + } + + final String message = "Received unexpected Job Status: " + finalJobStatus + + " Failed to Create NS for request: \n" + createNsRequest; + logger.error(message); + throw new NsRequestProcessingException(message); + } + + logger.debug("Will query for CreateNsResponse using processInstanceId:{}", processInstanceId); + final Optional<NsInstancesNsInstance> optional = workflowQueryService.getCreateNsResponse(processInstanceId); + if (optional.isEmpty()) { + final String message = + "Unable to find CreateNsReponse in Camunda History for process instance: " + processInstanceId; + logger.error(message); + throw new NsRequestProcessingException(message); + } + return optional.get(); + } + + public String runInstantiateNsJob(final String nsInstanceId, final InstantiateNsRequest instantiateNsRequest) { + + final NfvoJob newJob = new NfvoJob().startTime(LocalDateTime.now()).jobType("NS").jobAction(INSTANTIATE) + .resourceId(nsInstanceId).status(STARTING).progress(0); + databaseServiceProvider.addJob(newJob); + logger.info("New job created in database :\n{}", newJob); + + final LocalDateTime currentDateTime = LocalDateTime.now(); + final NsLcmOpOcc newNsLcmOpOcc = new NsLcmOpOcc().id(nsInstanceId).operation(NsLcmOpType.INSTANTIATE) + .operationState(OperationStateEnum.PROCESSING).stateEnteredTime(currentDateTime) + .startTime(currentDateTime).isAutoInnovation(false).isCancelPending(false) + .operationParams(gson.toJson(instantiateNsRequest)); + databaseServiceProvider.addNSLcmOpOcc(newNsLcmOpOcc); + logger.info("New NSLcmOpOcc created in database :\n{}", newNsLcmOpOcc); + + workflowExecutorService.executeWorkflow(newJob.getJobId(), INSTANTIATE_NS_WORKFLOW_NAME, + getVariables(nsInstanceId, newJob.getJobId(), newNsLcmOpOcc.getId(), instantiateNsRequest)); + + final ImmutableSet<JobStatusEnum> jobFinishedStates = + ImmutableSet.of(FINISHED, ERROR, FINISHED_WITH_ERROR, IN_PROGRESS); + final ImmutablePair<String, JobStatusEnum> immutablePair = + waitForJobToFinish(newJob.getJobId(), jobFinishedStates); + + if (immutablePair.getRight() == null) { + final String message = "Failed to Instantiate NS for request: \n" + instantiateNsRequest; + logger.error(message); + throw new NsRequestProcessingException(message); + } + + final JobStatusEnum finalJobStatus = immutablePair.getRight(); + + if (IN_PROGRESS.equals(finalJobStatus) || FINISHED.equals(finalJobStatus)) { + logger.info("Instantiation Job status: {}", finalJobStatus); + + + return newNsLcmOpOcc.getId(); + } + + final String message = "Received unexpected Job Status: " + finalJobStatus + + " Failed to instantiate NS for request: \n" + instantiateNsRequest; + logger.error(message); + throw new NsRequestProcessingException(message); + } + + private ImmutablePair<String, JobStatusEnum> waitForJobToFinish(final String jobId, + final ImmutableSet<JobStatusEnum> jobFinishedStates) { + try { + final long startTimeInMillis = System.currentTimeMillis(); + final long timeOutTime = startTimeInMillis + TimeUnit.SECONDS.toMillis(timeOutInSeconds); + + logger.info("Will wait till {} for {} job to finish", Instant.ofEpochMilli(timeOutTime).toString(), jobId); + JobStatusEnum currentJobStatus = null; + while (timeOutTime > System.currentTimeMillis()) { + + final Optional<NfvoJob> optional = databaseServiceProvider.getJob(jobId); + + if (optional.isEmpty()) { + logger.error("Unable to find Job using jobId: {}", jobId); + return ImmutablePair.nullPair(); + } + + final NfvoJob nfvoJob = optional.get(); + currentJobStatus = nfvoJob.getStatus(); + logger.info("Received job status response: \n ", nfvoJob); + if (jobFinishedStates.contains(nfvoJob.getStatus())) { + logger.info("Job finished \n {}", currentJobStatus); + return ImmutablePair.of(nfvoJob.getProcessInstanceId(), currentJobStatus); + } + + logger.info("Haven't received one of finish state {} yet, will try again in {} seconds", + jobFinishedStates, SLEEP_TIME_IN_SECONDS); + TimeUnit.SECONDS.sleep(SLEEP_TIME_IN_SECONDS); + + } + logger.warn("Timeout current job status: {}", currentJobStatus); + return ImmutablePair.nullPair(); + } catch (final InterruptedException interruptedException) { + Thread.currentThread().interrupt(); + logger.error("Sleep was interrupted", interruptedException); + return ImmutablePair.nullPair(); + } + } + + private Map<String, Object> getVariables(final String jobId, final CreateNsRequest createNsRequest, + final String globalCustomerId, final String serviceType) { + final Map<String, Object> variables = new HashMap<>(); + variables.put(JOB_ID_PARAM_NAME, jobId); + variables.put(CREATE_NS_REQUEST_PARAM_NAME, createNsRequest); + variables.put(GLOBAL_CUSTOMER_ID_PARAM_NAME, globalCustomerId); + variables.put(SERVICE_TYPE_PARAM_NAME, serviceType); + return variables; + } + + private Map<String, Object> getVariables(final String nsInstanceId, final String jobId, final String occId, + final InstantiateNsRequest instantiateNsRequest) { + final Map<String, Object> variables = new HashMap<>(); + variables.put(NS_INSTANCE_ID_PARAM_NAME, nsInstanceId); + variables.put(JOB_ID_PARAM_NAME, jobId); + variables.put(OCC_ID_PARAM_NAME, occId); + variables.put(INSTANTIATE_NS_REQUEST_PARAM_NAME, instantiateNsRequest); + return variables; + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowExecutorService.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowExecutorService.java new file mode 100644 index 0000000000..fa2b8d5507 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowExecutorService.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.TENANT_ID; +import static org.slf4j.LoggerFactory.getLogger; +import java.util.Map; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class WorkflowExecutorService { + + private static final Logger logger = getLogger(WorkflowExecutorService.class); + + private final RuntimeService runtimeService; + + @Autowired + public WorkflowExecutorService(final RuntimeService runtimeService) { + this.runtimeService = runtimeService; + } + + @Async + public void executeWorkflow(final String jobId, final String processDefinitionKey, + final Map<String, Object> variables) { + logger.info("Executing {} workflow with business key: {}", processDefinitionKey, jobId); + final ProcessInstance processInstance = runtimeService.createProcessInstanceByKey(processDefinitionKey) + .businessKey(jobId).setVariables(variables).processDefinitionTenantId(TENANT_ID).execute(); + + logger.info("Workflow running with processInstanceId: {} and business key: {}", + processInstance.getProcessInstanceId(), processInstance.getBusinessKey()); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowQueryService.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowQueryService.java new file mode 100644 index 0000000000..297e9c34af --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/WorkflowQueryService.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_RESPONSE_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.TENANT_ID; +import static org.slf4j.LoggerFactory.getLogger; +import java.util.Optional; +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.google.common.base.Strings; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class WorkflowQueryService { + + private static final Logger logger = getLogger(WorkflowQueryService.class); + + private final HistoryService camundaHistoryService; + + @Autowired + public WorkflowQueryService(final HistoryService camundaHistoryService) { + this.camundaHistoryService = camundaHistoryService; + } + + public Optional<NsInstancesNsInstance> getCreateNsResponse(final String processInstanceId) { + try { + + if (Strings.isNullOrEmpty(processInstanceId)) { + logger.error("Invalid processInstanceId: {}", processInstanceId); + return Optional.empty(); + } + + final HistoricVariableInstance historicVariableInstance = + getVariable(processInstanceId, CREATE_NS_RESPONSE_PARAM_NAME); + + if (historicVariableInstance != null) { + logger.info("Found HistoricVariableInstance : {}", historicVariableInstance); + final Object variableValue = historicVariableInstance.getValue(); + if (variableValue instanceof NsInstancesNsInstance) { + return Optional.ofNullable((NsInstancesNsInstance) variableValue); + } + logger.error("Unknown CreateNsResponse object type {} received value: {}", + historicVariableInstance.getValue() != null ? variableValue.getClass() : null, variableValue); + } + } catch (final ProcessEngineException processEngineException) { + logger.error("Unable to find {} variable using processInstanceId: {}", CREATE_NS_RESPONSE_PARAM_NAME, + processInstanceId, processEngineException); + } + logger.error("Unable to find {} variable using processInstanceId: {}", CREATE_NS_RESPONSE_PARAM_NAME, + processInstanceId); + return Optional.empty(); + + } + + public Optional<InlineResponse400> getProblemDetails(final String processInstanceId) { + try { + final HistoricVariableInstance historicVariableInstance = + getVariable(processInstanceId, CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME); + + logger.info("Found HistoricVariableInstance : {}", historicVariableInstance); + final Object variableValue = historicVariableInstance.getValue(); + if (variableValue instanceof InlineResponse400) { + return Optional.ofNullable((InlineResponse400) variableValue); + } + logger.error("Unknown ProblemDetails object type {} received value: {}", + historicVariableInstance.getValue() != null ? variableValue.getClass() : null, variableValue); + } catch (final ProcessEngineException processEngineException) { + logger.error("Unable to find {} variable using processInstanceId: {}", + CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, processInstanceId, processEngineException); + } + return Optional.empty(); + } + + + private HistoricVariableInstance getVariable(final String processInstanceId, final String name) { + return camundaHistoryService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId) + .variableName(name).tenantIdIn(TENANT_ID).singleResult(); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java new file mode 100644 index 0000000000..99116dacad --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.JOB_ID_PARAM_NAME; +import java.time.LocalDateTime; +import java.util.Optional; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public abstract class AbstractNetworkServiceTask { + private final Logger logger = LoggerFactory.getLogger(getClass()); + protected final DatabaseServiceProvider databaseServiceProvider; + + public AbstractNetworkServiceTask(final DatabaseServiceProvider jobServiceProvider) { + this.databaseServiceProvider = jobServiceProvider; + } + + public void setJobStatus(final DelegateExecution execution, final JobStatusEnum jobStatus, + final String description) { + logger.info("Setting Job Status to {}", jobStatus); + final NfvoJob nfvoJob = getNfvoJob(execution); + nfvoJob.status(jobStatus); + if (JobStatusEnum.STARTED.equals(jobStatus)) { + nfvoJob.processInstanceId(execution.getProcessInstanceId()); + } + + if (JobStatusEnum.FINISHED.equals(jobStatus)) { + nfvoJob.endTime(LocalDateTime.now()); + } + + nfvoJob.nfvoJobStatus( + new NfvoJobStatus().status(jobStatus).description(description).updatedTime(LocalDateTime.now())); + databaseServiceProvider.addJob(nfvoJob); + + } + + public void setJobStatusToError(final DelegateExecution execution, final String description) { + logger.info("Setting Job Status to {}", JobStatusEnum.ERROR); + + final String jobId = (String) execution.getVariable(JOB_ID_PARAM_NAME); + final Optional<NfvoJob> optional = databaseServiceProvider.getJob(jobId); + if (optional.isPresent()) { + final InlineResponse400 problemDetails = + (InlineResponse400) execution.getVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME); + + final NfvoJob nfvoJob = optional.get(); + nfvoJob.status(JobStatusEnum.ERROR).endTime(LocalDateTime.now()); + + if (problemDetails != null) { + logger.error("Found failed reason: {}", problemDetails); + nfvoJob.nfvoJobStatus(new NfvoJobStatus().status(JobStatusEnum.ERROR) + .description(problemDetails.getDetail()).updatedTime(LocalDateTime.now())); + } + nfvoJob.nfvoJobStatus(new NfvoJobStatus().status(JobStatusEnum.ERROR).description(description) + .updatedTime(LocalDateTime.now())); + + databaseServiceProvider.addJob(nfvoJob); + } + logger.info("Finished setting Job Status to {}", JobStatusEnum.ERROR); + + } + + protected void abortOperation(final DelegateExecution execution, final String message) { + abortOperation(execution, message, new InlineResponse400().detail(message)); + } + + protected void abortOperation(final DelegateExecution execution, final String message, + final InlineResponse400 problemDetails) { + logger.error(message); + execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, problemDetails); + throw new BpmnError("WORKFLOW_FAILED"); + } + + private NfvoJob getNfvoJob(final DelegateExecution execution) { + final String jobId = (String) execution.getVariable(JOB_ID_PARAM_NAME); + final Optional<NfvoJob> optional = databaseServiceProvider.getJob(jobId); + if (!optional.isPresent()) { + final String message = "Unable to find job using job id: " + jobId; + logger.error(message); + execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, + new InlineResponse400().detail(message)); + throw new BpmnError("WORKFLOW_FAILED"); + + } + return optional.get(); + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateRequest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateRequest.java new file mode 100644 index 0000000000..569d9b3352 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateRequest.java @@ -0,0 +1,167 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; + +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; +import java.io.Serializable; +import java.util.Map; +import java.util.Objects; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.Tenant; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class CreateInstantiateRequest implements Serializable { + private static final long serialVersionUID = -4371264952509580468L; + private String nsInstId; + private String vnfdId; + private String vnfName; + private String vnfPkgId; + private String nfType; + private Tenant tenant; + private Map<String, String> additionalParams; + + public String getNsInstId() { + return nsInstId; + } + + public void setNsInstId(final String nsInstId) { + this.nsInstId = nsInstId; + } + + public CreateInstantiateRequest nsInstId(final String nsInstId) { + this.nsInstId = nsInstId; + return this; + } + + public final String getVnfdId() { + return vnfdId; + } + + public final void setVnfdId(final String vnfdId) { + this.vnfdId = vnfdId; + } + + public CreateInstantiateRequest vnfdId(final String vnfdId) { + this.vnfdId = vnfdId; + return this; + } + + public final String getVnfName() { + return vnfName; + } + + public final void setVnfName(final String vnfName) { + this.vnfName = vnfName; + } + + public CreateInstantiateRequest vnfName(final String vnfName) { + this.vnfName = vnfName; + return this; + } + + public final String getVnfPkgId() { + return vnfPkgId; + } + + public final void setVnfPkgId(final String vnfPkgId) { + this.vnfPkgId = vnfPkgId; + } + + public CreateInstantiateRequest vnfPkgId(final String vnfPkgId) { + this.vnfPkgId = vnfPkgId; + return this; + } + + public final String getNfType() { + return nfType; + } + + public final void setNfType(final String nfType) { + this.nfType = nfType; + } + + public CreateInstantiateRequest nfType(final String nfType) { + this.nfType = nfType; + return this; + } + + public final Tenant getTenant() { + return tenant; + } + + public final void setTenant(final Tenant tenant) { + this.tenant = tenant; + } + + public CreateInstantiateRequest tenant(final Tenant tenant) { + this.tenant = tenant; + return this; + } + + public final Map<String, String> getAdditionalParams() { + return additionalParams; + } + + public final void setAdditionalParams(final Map<String, String> additionalParams) { + this.additionalParams = additionalParams; + } + + public CreateInstantiateRequest additionalParams(final Map<String, String> additionalParams) { + this.additionalParams = additionalParams; + return this; + } + + @Override + public int hashCode() { + return Objects.hash(nsInstId, vnfdId, vnfName, vnfPkgId, nfType, tenant, additionalParams); + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof CreateInstantiateRequest) { + final CreateInstantiateRequest other = (CreateInstantiateRequest) obj; + return Objects.equals(nsInstId, other.nsInstId) && Objects.equals(vnfdId, other.vnfdId) + && Objects.equals(vnfName, other.vnfName) && Objects.equals(vnfPkgId, other.vnfPkgId) + && Objects.equals(nfType, other.nfType) && Objects.equals(tenant, other.tenant) + && Objects.equals(additionalParams, other.additionalParams); + } + return false; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateInstantiateRequest {\n"); + sb.append(" nsInstId: ").append(toIndentedString(nsInstId)).append("\n"); + sb.append(" vnfdId: ").append(toIndentedString(vnfdId)).append("\n"); + sb.append(" vnfName: ").append(toIndentedString(vnfName)).append("\n"); + sb.append(" vnfPkgId: ").append(toIndentedString(vnfPkgId)).append("\n"); + sb.append(" nfType: ").append(toIndentedString(nfType)).append("\n"); + sb.append(" tenant: ").append(toIndentedString(tenant)).append("\n"); + sb.append(" additionalParams: ").append(toIndentedString(additionalParams)).append("\n"); + + sb.append("}"); + return sb.toString(); + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java new file mode 100644 index 0000000000..c33c67e540 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java @@ -0,0 +1,234 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.ERROR; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS; +import java.time.LocalDateTime; +import java.util.Optional; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.Tenant; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +@Component +public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { + private static final Logger logger = LoggerFactory.getLogger(CreateInstantiateVnfTask.class); + private static final String NF_INST_ID_PARAM_NAME = "NF_INST_ID"; + public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse"; + private final AaiServiceProvider aaiServiceProvider; + private final Sol003AdapterServiceProvider sol003AdapterServiceProvider; + + @Autowired + public CreateInstantiateVnfTask(final DatabaseServiceProvider databaseServiceProvider, + final AaiServiceProvider aaiServiceProvider, + final Sol003AdapterServiceProvider sol003AdapterServiceProvider) { + super(databaseServiceProvider); + this.aaiServiceProvider = aaiServiceProvider; + this.sol003AdapterServiceProvider = sol003AdapterServiceProvider; + } + + public void checkIfNfInstanceExistsInDb(final DelegateExecution execution) { + logger.info("Executing checkIfNfInstanceInDb"); + final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + logger.info("request: {}", request); + + setJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NF Instance record exists in database for " + + request.getNsInstId() + " and " + request.getVnfName()); + if (!databaseServiceProvider.isNsInstExists(request.getNsInstId(), request.getVnfName())) { + abortOperation(execution, + request.getNsInstId() + " " + request.getVnfName() + " VNF instance already exists"); + } + logger.info("Finished executing checkIfNfInstanceInDb ..."); + + } + + public void createNfInstanceInDb(final DelegateExecution execution) { + logger.info("Executing createNfInstanceInDb"); + final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + logger.info("request: {}", request); + + setJobStatus(execution, IN_PROGRESS, "Creating NF Instance record in database for " + request.getVnfName()); + + final Optional<NfvoNsInst> optional = databaseServiceProvider.getNfvoNsInst(request.getNsInstId()); + + if (optional.isEmpty()) { + abortOperation(execution, "NfvoNsInst: " + request.getNsInstId() + "not founda"); + } + + final NfvoNsInst nfvoNsInst = optional.get(); + final LocalDateTime now = LocalDateTime.now(); + final NfvoNfInst nfvoNfInst = new NfvoNfInst().status(State.NOT_INSTANTIATED).createTime(now) + .lastUpdateTime(now).name(request.getVnfName()).vnfdId(request.getVnfdId()) + .packageId(request.getVnfPkgId()).nfvoNsInst(nfvoNsInst); + databaseServiceProvider.saveNfvoNfInst(nfvoNfInst); + execution.setVariable(NF_INST_ID_PARAM_NAME, nfvoNfInst.getNfInstId()); + logger.info("Finished executing createNfInstanceInDb ..."); + + } + + public void createGenericVnfInAai(final DelegateExecution execution) { + logger.info("Executing createGenericVnfInAai"); + try { + final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + + setJobStatus(execution, IN_PROGRESS, "Creating GenericVnf record in AAI for " + request.getVnfName()); + + final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId); + + final GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId(nfInstId); + genericVnf.setVnfName(request.getVnfName()); + genericVnf.setVnfType(nfvoNsInst.getName() + "/" + request.getVnfName()); + genericVnf.setServiceId(request.getNsInstId()); + genericVnf.setNfType(request.getNfType()); + genericVnf.setOperationalStatus("Created"); + genericVnf.setIsClosedLoopDisabled(false); + + aaiServiceProvider.createGenericVnfAndConnectServiceInstance(nsInstId, nfInstId, genericVnf); + + final Tenant tenant = request.getTenant(); + aaiServiceProvider.connectGenericVnfToTenant(nfInstId, tenant.getCloudOwner(), tenant.getRegionName(), + tenant.getTenantId()); + + } catch (final Exception exception) { + final String message = "Unable to Create GenericVnf in AAI"; + logger.error(message, exception); + abortOperation(execution, message); + } + + logger.info("Finished executing createGenericVnfInAai ..."); + } + + public void invokeCreateInstantiationRequest(final DelegateExecution execution) { + logger.info("Executing invokeCreateInstantiationRequest"); + + try { + final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + logger.info("request: {}", request); + + setJobStatus(execution, IN_PROGRESS, + "Invoking SOL003 adapter for creating and instantiating VNF: " + request.getVnfName()); + + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId); + final CreateVnfRequest vnfRequest = new CreateVnfRequest(); + vnfRequest.setTenant(request.getTenant()); + vnfRequest.setName(nfvoNsInst.getName() + "." + request.getVnfName()); + vnfRequest.setPkgId(request.getVnfPkgId()); + vnfRequest.setAdditionalParams(request.getAdditionalParams()); + final String vnfId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); + final Optional<CreateVnfResponse> optional = + sol003AdapterServiceProvider.invokeCreateInstantiationRequest(vnfId, vnfRequest); + + if (!optional.isPresent()) { + final String errorMessage = "Unexpected error while processing create and instantiation request"; + logger.error(errorMessage); + abortOperation(execution, errorMessage); + } + + final CreateVnfResponse vnfResponse = optional.get(); + + logger.info("Vnf instantiation response: {}", vnfResponse); + execution.setVariable(CREATE_VNF_RESPONSE_PARAM_NAME, vnfResponse); + setJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapater creating and instantiating VNF: " + + request.getVnfName() + " CreaetVnfResponse Job Id: " + vnfResponse.getJobId()); + logger.debug("Finished executing invokeCreateInstantiationRequest ..."); + } catch (final Exception exception) { + final String message = "Unable to invoke create and instantiation request"; + logger.error(message, exception); + abortOperation(execution, message); + } + + } + + public void updateNfInstanceStatusToInstantiated(final DelegateExecution execution) { + logger.info("Executing updateNfInstanceStatusToInstantiated"); + + updateNfInstanceStatus(execution, State.INSTANTIATED); + final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + setJobStatus(execution, FINISHED, "Successfully created and Instantiated VNF: " + request.getVnfName() + + " will set status to " + State.INSTANTIATED); + + logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); + + } + + public void updateNfInstanceStatusToFailed(final DelegateExecution execution) { + logger.info("Executing updateNfInstanceStatusToActive"); + + updateNfInstanceStatus(execution, State.FAILED); + final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + setJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName() + + " will set status to " + State.FAILED); + + logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); + + } + + private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) { + final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); + + final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(nfInstId); + if (!optional.isPresent()) { + final String message = "Unable to find NfvoNfInst record in database using nfInstId: " + nfInstId; + logger.error(message); + + abortOperation(execution, message); + + } + + final NfvoNfInst nfvoNfInst = optional.get(); + nfvoNfInst.setStatus(vnfStatus); + databaseServiceProvider.saveNfvoNfInst(nfvoNfInst); + } + + private NfvoNsInst getNfvoNsInst(final DelegateExecution execution, final String nsInstId) { + logger.info("Getting NfvoNsInst to update with nsInstId: {}", nsInstId); + final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstId); + + if (!optionalNfvoNsInst.isPresent()) { + final String message = "Unable to find NS Instance in datababse using id: " + nsInstId; + abortOperation(execution, message); + } + + return optionalNfvoNsInst.get(); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateNsTask.java new file mode 100644 index 0000000000..fa7187b388 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateNsTask.java @@ -0,0 +1,221 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_REQUEST_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_RESPONSE_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.GLOBAL_CUSTOMER_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_PACKAGE_MODEL_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.SERVICE_TYPE_PARAM_NAME; +import java.time.LocalDateTime; +import java.util.Optional; +import java.util.UUID; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.NsdInfo; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.EtsiCatalogManagerRequestFailureException; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog.EtsiCatalogPackageManagementServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.model.CreateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance.NsStateEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Component +public class CreateNsTask extends AbstractNetworkServiceTask { + private static final String NETWORK_SERVICE_NAME = "NetworkService"; + private static final String NETWORK_SERVICE_ROLE = "NetworkService"; + private static final String DOES_NS_PACKAGE_EXISTS_PARAM_NAME = "doesNsPackageExists"; + private static final String DOES_NS_INSTANCE_EXISTS_PARAM_NAME = "doesNsInstanceExists"; + private static final Logger logger = LoggerFactory.getLogger(CreateNsTask.class); + private final EtsiCatalogPackageManagementServiceProvider etsiCatalogPackageManagementServiceProvider; + private final AaiServiceProvider aaiServiceProvider; + + @Autowired + public CreateNsTask(final DatabaseServiceProvider databaseServiceProvider, + final AaiServiceProvider aaiServiceProvider, + final EtsiCatalogPackageManagementServiceProvider etsiCatalogPackageManagementServiceProvider) { + super(databaseServiceProvider); + this.aaiServiceProvider = aaiServiceProvider; + this.etsiCatalogPackageManagementServiceProvider = etsiCatalogPackageManagementServiceProvider; + } + + public void setJobStatusToStarted(final DelegateExecution execution) { + setJobStatus(execution, JobStatusEnum.STARTED, "Create NS workflow process started"); + } + + public void setJobStatusToFinished(final DelegateExecution execution) { + setJobStatus(execution, JobStatusEnum.FINISHED, "Create NS workflow process finished"); + } + + public void setJobStatusToError(final DelegateExecution execution) { + setJobStatusToError(execution, "Create NS workflow process failed"); + } + + public void getNsPackage(final DelegateExecution execution) { + logger.info("Retrieving NS package from ETSI Catalog Manager ..."); + setJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Retrieving NS package from ETSI Catalog Manager"); + + final CreateNsRequest createNsRequest = (CreateNsRequest) execution.getVariable(CREATE_NS_REQUEST_PARAM_NAME); + + try { + final Optional<NsdInfo> optional = + etsiCatalogPackageManagementServiceProvider.getNSPackageModel(createNsRequest.getNsdId()); + + if (optional.isPresent()) { + final NsdInfo packageModel = optional.get(); + logger.info("NS Package exists {}", packageModel); + execution.setVariable(NS_PACKAGE_MODEL_PARAM_NAME, packageModel); + execution.setVariable(DOES_NS_PACKAGE_EXISTS_PARAM_NAME, true); + } else { + final String message = "Unable to find NS package using NsdId: " + createNsRequest.getNsdId(); + logger.error(message); + execution.setVariable(DOES_NS_PACKAGE_EXISTS_PARAM_NAME, false); + execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, + new InlineResponse400().detail(message)); + } + + } catch (final EtsiCatalogManagerRequestFailureException failureException) { + final String message = + "Unexpected exception occured while getting ns package using nsdId: " + createNsRequest.getNsdId(); + logger.error(message, failureException); + + execution.setVariable(DOES_NS_PACKAGE_EXISTS_PARAM_NAME, false); + + execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, + new InlineResponse400().title(message).detail(message)); + } + + } + + public void doesNsInstanceExistsInDb(final DelegateExecution execution) { + logger.info("Executing doesNsInstanceExistsInDb ..."); + + setJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NS package exists in database"); + + final CreateNsRequest createNsRequest = + (CreateNsRequest) execution.getVariables().get(CREATE_NS_REQUEST_PARAM_NAME); + + final boolean exists = databaseServiceProvider.isNsInstExists(createNsRequest.getNsName()); + logger.info("Ns Instance entry {} exists in database", exists ? "does" : "doesn't"); + execution.setVariable(DOES_NS_INSTANCE_EXISTS_PARAM_NAME, exists); + + if (exists) { + final Optional<NfvoNsInst> optional = + databaseServiceProvider.getNfvoNsInstByName(createNsRequest.getNsName()); + final NfvoNsInst nfvoNsInst = optional.get(); + execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400() + .detail("Ns Instance already exists in database : " + nfvoNsInst.toString())); + } + + logger.info("Finished executing doesNsInstanceExistsInDb ..."); + + } + + public void createNsInstanceInDb(final DelegateExecution execution) { + logger.info("Executing createNsInstanceInDb ..."); + + setJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NS package exists"); + + final CreateNsRequest createNsRequest = (CreateNsRequest) execution.getVariable(CREATE_NS_REQUEST_PARAM_NAME); + final NsdInfo packageMode = (NsdInfo) execution.getVariable(NS_PACKAGE_MODEL_PARAM_NAME); + + final String globalCustomerId = (String) execution.getVariable(GLOBAL_CUSTOMER_ID_PARAM_NAME); + final String serviceType = (String) execution.getVariable(SERVICE_TYPE_PARAM_NAME); + + final String nsInstId = UUID.randomUUID().toString(); + execution.setVariable(NS_INSTANCE_ID_PARAM_NAME, nsInstId); + + databaseServiceProvider.saveNfvoNsInst(new NfvoNsInst().nsInstId(nsInstId).name(createNsRequest.getNsName()) + .nsPackageId(packageMode.getId()).nsdId(packageMode.getNsdId()) + .nsdInvariantId(packageMode.getNsdInvariantId()).description(createNsRequest.getNsDescription()) + .status(State.NOT_INSTANTIATED).statusUpdatedTime(LocalDateTime.now()) + .globalCustomerId(globalCustomerId).serviceType(serviceType)); + logger.info("Finished executing createNsInstanceInDb ..."); + + } + + + public void createNsInstanceInAai(final DelegateExecution execution) { + logger.info("Executing createNsInstanceInAai ..."); + try { + setJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Creating NS Instance in AAI"); + + final CreateNsRequest createNsRequest = + (CreateNsRequest) execution.getVariable(CREATE_NS_REQUEST_PARAM_NAME); + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + + final String globalCustomerId = (String) execution.getVariable(GLOBAL_CUSTOMER_ID_PARAM_NAME); + final String serviceType = (String) execution.getVariable(SERVICE_TYPE_PARAM_NAME); + + final ServiceInstance aaiServiceInstance = new ServiceInstance(); + aaiServiceInstance.setServiceInstanceId(nsInstId); + aaiServiceInstance.setServiceInstanceName(createNsRequest.getNsName()); + aaiServiceInstance.setServiceType(NETWORK_SERVICE_NAME); + aaiServiceInstance.setServiceRole(NETWORK_SERVICE_ROLE); + + aaiServiceProvider.createServiceInstance(globalCustomerId, serviceType, aaiServiceInstance); + } catch (final Exception exception) { + final String message = "Unable to Create Service Instance in AAI"; + logger.error(message, exception); + abortOperation(execution, message, new InlineResponse400().detail(message)); + } + logger.info("Finished executing createNsInstanceInAai ..."); + + } + + public void setCreateNsResponse(final DelegateExecution execution) { + logger.info("Executing setCreateNsResponse ..."); + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + final Optional<NfvoNsInst> optional = databaseServiceProvider.getNfvoNsInst(nsInstId); + + if (optional.isPresent()) { + final NfvoNsInst nfvoNsInst = optional.get(); + final NsInstancesNsInstance response = new NsInstancesNsInstance().id(nfvoNsInst.getNsInstId()) + .nsInstanceName(nfvoNsInst.getName()).nsdId(nfvoNsInst.getNsdId()) + .nsdInfoId(nfvoNsInst.getNsPackageId()).nsInstanceDescription(nfvoNsInst.getDescription()) + .nsState(NsStateEnum.fromValue(nfvoNsInst.getStatus().toString())); + logger.info("Saving CreateNsResponse: {} in Execution ...", response); + execution.setVariable(CREATE_NS_RESPONSE_PARAM_NAME, response); + } else { + final String message = "Unable to find NS Instance in datababse using id: " + nsInstId; + logger.error(message); + abortOperation(execution, message); + } + + logger.info("Finished executing setCreateNsResponse ..."); + + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java new file mode 100644 index 0000000000..8d212045ad --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java @@ -0,0 +1,416 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.INSTANTIATE_NS_REQUEST_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NETWORK_SERVICE_DESCRIPTOR_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OCC_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.VNF_CREATE_INSTANTIATE_REQUESTS; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.STARTED; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.Tenant; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.NsdInfo; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.VnfPkgInfo; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.EtsiCatalogManagerRequestFailureException; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog.EtsiCatalogPackageManagementServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.VirtualNetworkFunction; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.model.InstantiateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author Andrew Lamb (andrew.a.lamb@est.tech) + * + */ +@Component +public class InstantiateNsTask extends AbstractNetworkServiceTask { + + private static final String IS_NS_INSTANTIATION_SUCCESSFUL_PARAM_NAME = "isNsInstantiationSuccessful"; + private static final String VNFD_ID_TO_VNF_PKG_ID_MAPPING_PARAM_NAME = "vnfdIdToVnfPkgIdMapping"; + private static final Logger logger = LoggerFactory.getLogger(InstantiateNsTask.class); + private final EtsiCatalogPackageManagementServiceProvider etsiCatalogPackageManagementServiceProvider; + + @Autowired + public InstantiateNsTask(final DatabaseServiceProvider databaseServiceProvider, + final EtsiCatalogPackageManagementServiceProvider etsiCatalogPackageManagementServiceProvider) { + super(databaseServiceProvider); + this.etsiCatalogPackageManagementServiceProvider = etsiCatalogPackageManagementServiceProvider; + + } + + public void setJobStatusToStarted(final DelegateExecution execution) { + setJobStatus(execution, STARTED, "Instantiate NS workflow process started"); + } + + public void setJobStatusToFinished(final DelegateExecution execution) { + setJobStatus(execution, FINISHED, "Instantiate NS workflow process finished"); + } + + public void updateNsInstanceStatusToInstantiating(final DelegateExecution execution) { + logger.info("Executing updateNsInstanceStatusToInstantiating"); + setJobStatus(execution, IN_PROGRESS, "Updating NfvoNsInst Status to " + State.INSTANTIATING); + updateNsInstanceStatus(execution, State.INSTANTIATING); + + logger.info("Finished executing updateNsInstanceStatusToInstantiating ..."); + } + + + public void checkIfVnfInstantiationWasSuccessful(final DelegateExecution execution) { + logger.info("Executing checkIfVnfInstantiationWasSuccessful"); + + @SuppressWarnings("unchecked") + final List<CreateInstantiateRequest> requests = + (List<CreateInstantiateRequest>) execution.getVariable(VNF_CREATE_INSTANTIATE_REQUESTS); + + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + final List<NfvoNfInst> nfInstances = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId); + + if (nfInstances == null || nfInstances.isEmpty()) { + final String message = "Found empty nf instances"; + abortOperation(execution, message); + } + + if (requests.size() != nfInstances.size()) { + final String message = "Missing nf Instance. Request triggered: " + requests.size() + + " Nf Instace reqeust found in database " + nfInstances.size(); + abortOperation(execution, message); + } + + execution.setVariable(IS_NS_INSTANTIATION_SUCCESSFUL_PARAM_NAME, true); + + nfInstances.stream().forEach(instance -> { + if (!State.INSTANTIATED.equals(instance.getStatus())) { + logger.error("VNF : {} {} instantiation failed", instance.getNfInstId(), instance.getName()); + execution.setVariable(IS_NS_INSTANTIATION_SUCCESSFUL_PARAM_NAME, false); + } + }); + + logger.info("Finished executing checkIfVnfInstantiationWasSuccessful ..."); + } + + public void updateNsInstanceStatusToInstantiated(final DelegateExecution execution) { + logger.info("Executing updateNsInstanceStatusToInstantiated"); + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + setJobStatus(execution, FINISHED, "Successfully " + State.INSTANTIATED + " NS: " + nsInstId); + + updateNsInstanceStatus(execution, State.INSTANTIATED); + logger.info("Finished executing updateNsInstanceStatusToInstantiated ..."); + } + + public void getAndParseNsdFromEtsiCatalog(final DelegateExecution execution) { + logger.info("Executing getAndParseNsdFromEtsiCatalog"); + setJobStatus(execution, IN_PROGRESS, "Retrieving and parsing NSD from ETSI Catalog Manager"); + final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution); + final String nsPackageId = nfvoNsInst.getNsPackageId(); + + try { + final Optional<NetworkServiceDescriptor> optional = + etsiCatalogPackageManagementServiceProvider.getNetworkServiceDescriptor(nsPackageId); + + if (!optional.isPresent()) { + final String message = "Unable to parse NSD " + nsPackageId; + logger.error(message); + abortOperation(execution, message); + } + + final NetworkServiceDescriptor networkServiceDescriptor = optional.get(); + logger.info("Found {}", networkServiceDescriptor); + execution.setVariable(NETWORK_SERVICE_DESCRIPTOR_PARAM_NAME, networkServiceDescriptor); + + } catch (final EtsiCatalogManagerRequestFailureException failureException) { + final String message = + "Unexpected exception occured while getting nsd content using nsPackageId: " + nsPackageId; + logger.error(message, failureException); + + abortOperation(execution, message); + } + + logger.info("Finished executing getAndParseNsdFromEtsiCatalog ..."); + + } + + public void prepareCreateInstantiateRequests(final DelegateExecution execution) { + logger.info("Executing prepareCreateInstantiateRequests ..."); + setJobStatus(execution, IN_PROGRESS, "Preparing VNF CreateInstantiate requests"); + final NetworkServiceDescriptor networkServiceDescriptor = + (NetworkServiceDescriptor) execution.getVariable(NETWORK_SERVICE_DESCRIPTOR_PARAM_NAME); + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + + final InstantiateNsRequest instantiateNsRequest = + (InstantiateNsRequest) execution.getVariable(INSTANTIATE_NS_REQUEST_PARAM_NAME); + + final List<NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf> additionalParamsForVnfList = + instantiateNsRequest.getAdditionalParamsForVnf(); + + @SuppressWarnings("unchecked") + final Map<String, String> vnfdIdToVnfPkgIdMapping = + (Map<String, String>) execution.getVariable(VNFD_ID_TO_VNF_PKG_ID_MAPPING_PARAM_NAME); + + final List<CreateInstantiateRequest> requests = new ArrayList<>(); + + for (final VirtualNetworkFunction vnf : networkServiceDescriptor.getVnfs()) { + final List<String> vnfmInfoList = vnf.getVnfmInfoList(); + + final String vnfdId = vnf.getVnfdId(); + final String vnfPkgId = vnfdIdToVnfPkgIdMapping.get(vnfdId); + if (vnfdId == null || vnfmInfoList.isEmpty() || vnfPkgId == null) { + final String message = "Unable to find VnfdId/vnfmInfo/VnfPkgId for vnf: " + vnf; + abortOperation(execution, message); + } + + final Optional<Tenant> optional = getTenant(vnfPkgId, additionalParamsForVnfList); + if (!optional.isPresent()) { + final String message = "Unable to find Tenant information for " + vnfdId + " in instantiateNsRequest : " + + instantiateNsRequest; + abortOperation(execution, message); + } + + final Tenant tenant = optional.get(); + final CreateInstantiateRequest createInstantiateRequest = new CreateInstantiateRequest().nsInstId(nsInstId) + .vnfdId(vnfdId).vnfName(vnf.getVnfName()).vnfPkgId(vnfPkgId).nfType(vnfmInfoList.get(0)) + .tenant(tenant).additionalParams(getAdditionalParams(vnfPkgId, additionalParamsForVnfList)); + + logger.info("Adding request to list: {}", createInstantiateRequest); + requests.add(createInstantiateRequest); + + } + execution.setVariable(VNF_CREATE_INSTANTIATE_REQUESTS, requests); + + logger.info("Finished executing prepareCreateInstantiateRequests ..."); + } + + public void getVnfPkgIdForEachVnfdId(final DelegateExecution execution) { + logger.info("Executing getVnfPkgIdForEachVnfdId ..."); + + setJobStatus(execution, IN_PROGRESS, "Getting VnfPkgId for each VnfdId"); + + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId); + + final String nsPackageId = nfvoNsInst.getNsPackageId(); + final NsdInfo nsdInfo = getNsdInfo(execution, nsPackageId); + + final Map<String, String> vnfdIdToVnfPkgIdMapping = new HashMap<>(); + try { + for (final String vnfPkgId : nsdInfo.getVnfPkgIds()) { + final Optional<VnfPkgInfo> optional = + etsiCatalogPackageManagementServiceProvider.getVnfPkgInfo(vnfPkgId); + + if (!optional.isPresent()) { + final String message = "Unable to find VNF package using NS vnfPkgId: " + vnfPkgId; + logger.error(message); + abortOperation(execution, message); + } + final VnfPkgInfo vnfPkgInfo = optional.get(); + vnfdIdToVnfPkgIdMapping.put(vnfPkgInfo.getVnfdId(), vnfPkgId); + + } + logger.info("vnfdIdToVnfPkgIdMapping: {}", vnfdIdToVnfPkgIdMapping); + execution.setVariable(VNFD_ID_TO_VNF_PKG_ID_MAPPING_PARAM_NAME, vnfdIdToVnfPkgIdMapping); + + } catch (final EtsiCatalogManagerRequestFailureException failureException) { + final String message = + "Unexpected exception occured while getting VNF package using nsPackageId: " + nsPackageId; + logger.error(message, failureException); + + abortOperation(execution, message); + } + + logger.info("Finished executing getVnfPkgIdForEachVnfdId ..."); + + } + + public void logTimeOut(final DelegateExecution execution) { + logger.error("Vnf instantiation timedOut ..."); + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + final List<NfvoNfInst> nfInstances = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId); + if (nfInstances != null) { + nfInstances.stream().forEach(instance -> { + logger.info("Current status {} of vnf: {}", instance.getStatus(), instance.getName()); + }); + } + } + + public void setJobStatusToError(final DelegateExecution execution) { + updateNsInstanceStatus(execution, State.FAILED); + setJobStatusToError(execution, "Instantiate NS workflow process failed"); + } + + + public void updateNsLcmOpOccStatusToCompleted(final DelegateExecution execution) { + logger.info("Executing updateNsLcmOpOccStatusToCompleted ..."); + final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME); + + final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId); + + if (!optional.isPresent()) { + final String message = "Unable to find record for NSLcmOpOcc in database using id: " + occId; + logger.error(message); + abortOperation(execution, message); + } + + final NsLcmOpOcc nsLcmOpOcc = optional.get(); + final OperationStateEnum operationStateCompleted = OperationStateEnum.COMPLETED; + logger.info("Setting operation state to {} for id: {}", operationStateCompleted, occId); + nsLcmOpOcc.setOperationState(operationStateCompleted); + databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc); + + logger.info("Finished executing updateNsLcmOpOccStatusToCompleted ..."); + + } + + public void updateNsLcmOpOccStatusToFailed(final DelegateExecution execution) { + logger.info("Executing updateNsLcmOpOccStatusToFailed ..."); + final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME); + + final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId); + + if (optional.isPresent()) { + final NsLcmOpOcc nsLcmOpOcc = optional.get(); + final OperationStateEnum operationStateFailed = OperationStateEnum.FAILED; + logger.info("Setting operation state to {} for id: {}", operationStateFailed, occId); + nsLcmOpOcc.setOperationState(operationStateFailed); + + databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc); + } else { + logger.error("Unable to find record for NSLcmOpOcc in database using id: {}", occId); + } + + logger.info("Finished executing updateNsLcmOpOccStatusToFailed ..."); + + } + + private NsdInfo getNsdInfo(final DelegateExecution execution, final String nsPackageId) { + try { + final Optional<NsdInfo> optional = + etsiCatalogPackageManagementServiceProvider.getNSPackageModel(nsPackageId); + + if (optional.isPresent()) { + final NsdInfo packageModel = optional.get(); + logger.info("NS Package exists {}", packageModel); + return packageModel; + } + + } catch (final EtsiCatalogManagerRequestFailureException failureException) { + final String message = + "Unexpected exception occured while getting ns package using nsPackageId: " + nsPackageId; + logger.error(message, failureException); + + abortOperation(execution, message); + } + + final String message = "Unable to find NS package using NS package id: " + nsPackageId; + logger.error(message); + abortOperation(execution, message); + return null; + + } + + private void updateNsInstanceStatus(final DelegateExecution execution, final State nsStatus) { + final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution); + logger.info("Updating NfvoNsInst Status to {} and saving to DB", nsStatus); + nfvoNsInst.setStatus(nsStatus); + databaseServiceProvider.saveNfvoNsInst(nfvoNsInst); + } + + private Optional<Tenant> getTenant(final String vnfPkgId, + final List<NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf> additionalParamsForVnfList) { + + final Optional<NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf> optional = additionalParamsForVnfList + .stream().filter(entry -> vnfPkgId.equals(entry.getVnfProfileId())).findFirst(); + + if (optional.isPresent()) { + final NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf additionalParamsForVnf = optional.get(); + @SuppressWarnings("unchecked") + final Map<String, Object> additionalParams = + (Map<String, Object>) additionalParamsForVnf.getAdditionalParams(); + final String vimId = (String) additionalParams.get("vim_id"); + if (vimId != null) { + final String[] splitString = vimId.split("_"); + if (splitString.length == 3) { + logger.info("Found Tenant in instantiateNsRequest using vnfPkgId: {}", vnfPkgId); + return Optional.of(new Tenant().cloudOwner(splitString[0]).regionName(splitString[1]) + .tenantId(splitString[2])); + } + + } + } + + logger.error("Unable to find Tenant in instantiateNsRequest using vnfPkgId: {}", vnfPkgId); + return Optional.empty(); + } + + @SuppressWarnings("unchecked") + private Map<String, String> getAdditionalParams(final String vnfPkgId, + final List<NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf> additionalParamsForVnfList) { + + final Optional<NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf> optional = additionalParamsForVnfList + .stream().filter(entry -> vnfPkgId.equals(entry.getVnfProfileId())).findFirst(); + + if (optional.isPresent()) { + final NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf additionalParamsForVnf = optional.get(); + if (additionalParamsForVnf instanceof Map) { + logger.info("Found AdditionalParams in instantiateNsRequest using vnfPkgId: {}", vnfPkgId); + return (Map<String, String>) additionalParamsForVnf.getAdditionalParams(); + } + } + + return Collections.emptyMap(); + + } + + private NfvoNsInst getNfvoNsInst(final DelegateExecution execution) { + final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); + return getNfvoNsInst(execution, nsInstId); + } + + private NfvoNsInst getNfvoNsInst(final DelegateExecution execution, final String nsInstId) { + logger.info("Getting NfvoNsInst to update with nsInstId: {}", nsInstId); + final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstId); + + if (!optionalNfvoNsInst.isPresent()) { + final String message = "Unable to find NS Instance in database using id: " + nsInstId; + abortOperation(execution, message); + } + + return optionalNfvoNsInst.get(); + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorInstantiateSol003AdapterNodeTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorInstantiateSol003AdapterNodeTask.java new file mode 100644 index 0000000000..51fa6b9381 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorInstantiateSol003AdapterNodeTask.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; + +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Component +public class MonitorInstantiateSol003AdapterNodeTask extends MonitorSol003AdapterNodeTask { + public static final String CREATE_VNF_NODE_STATUS = "createVnfNodeStatus"; + public static final String VNF_CREATED = "Created"; + + @Autowired + public MonitorInstantiateSol003AdapterNodeTask(final DatabaseServiceProvider databaseServiceProvider, + final AaiServiceProvider aaiServiceProvider) { + super(databaseServiceProvider, aaiServiceProvider); + } + + @Override + public String getNodeStatusVariableName() { + return CREATE_VNF_NODE_STATUS; + } + + @Override + public boolean isOrchestrationStatusValid(final String orchestrationStatus) { + return VNF_CREATED.equalsIgnoreCase(orchestrationStatus); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterCreateJobTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterCreateJobTask.java new file mode 100644 index 0000000000..3c91598dfb --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterCreateJobTask.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_VNF_RESPONSE_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OPERATION_STATUS_PARAM_NAME; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Component +public class MonitorSol003AdapterCreateJobTask extends MonitorSol003AdapterJobTask { + + private static final Logger LOGGER = LoggerFactory.getLogger(MonitorSol003AdapterCreateJobTask.class); + + @Autowired + public MonitorSol003AdapterCreateJobTask(final Sol003AdapterServiceProvider sol003AdapterServiceProvider, + final DatabaseServiceProvider databaseServiceProvider) { + super(sol003AdapterServiceProvider, databaseServiceProvider); + } + + public void getCurrentOperationStatus(final DelegateExecution execution) { + try { + LOGGER.debug("Executing getCurrentOperationStatus ..."); + final CreateVnfResponse vnfInstantiateResponse = + (CreateVnfResponse) execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME); + execution.setVariable(OPERATION_STATUS_PARAM_NAME, + getOperationStatus(execution, vnfInstantiateResponse.getJobId())); + LOGGER.debug("Finished executing getCurrentOperationStatus ..."); + } catch (final Exception exception) { + final String message = "Unable to invoke get current Operation status"; + LOGGER.error(message, exception); + abortOperation(execution, message); + + } + } + + /** + * Log and throw exception on timeout for job status + * + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + */ + public void timeOutLogFailue(final DelegateExecution execution) { + final String message = "Instantiation operation time out"; + LOGGER.error(message); + abortOperation(execution, message); + } + + /** + * Check the final status of instantiation throw exception if not completed successfully + * + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + */ + public void checkIfOperationWasSuccessful(final DelegateExecution execution) { + LOGGER.debug("Executing checkIfOperationWasSuccessful ..."); + final OperationStateEnum operationStatus = + (OperationStateEnum) execution.getVariable(OPERATION_STATUS_PARAM_NAME); + final CreateVnfResponse vnfInstantiateResponse = + (CreateVnfResponse) execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME); + + if (operationStatus == null) { + final String message = "Unable to instantiate jobId: " + + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + + "Unable to retrieve OperationStatus"; + LOGGER.error(message); + abortOperation(execution, message); + } + if (operationStatus != OperationStateEnum.COMPLETED) { + final String message = "Unable to instantiate jobId: " + + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + + " OperationStatus: " + operationStatus; + LOGGER.error(message); + abortOperation(execution, message); + } + + LOGGER.debug("Successfully completed instatiation of job {}", vnfInstantiateResponse); + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterJobTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterJobTask.java new file mode 100644 index 0000000000..bac79dfa3e --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterJobTask.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OPERATION_STATUS_PARAM_NAME; +import java.util.Optional; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStatusRetrievalStatusEnum; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.google.common.collect.ImmutableSet; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Component +public class MonitorSol003AdapterJobTask extends AbstractNetworkServiceTask { + + private static final Logger LOGGER = LoggerFactory.getLogger(MonitorSol003AdapterJobTask.class); + public static final ImmutableSet<OperationStateEnum> OPERATION_FINISHED_STATES = + ImmutableSet.of(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK); + public static final ImmutableSet<OperationStatusRetrievalStatusEnum> OPERATION_RETRIEVAL_STATES = ImmutableSet + .of(OperationStatusRetrievalStatusEnum.STATUS_FOUND, OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS); + protected final Sol003AdapterServiceProvider sol003AdapterServiceProvider; + + @Autowired + public MonitorSol003AdapterJobTask(final Sol003AdapterServiceProvider sol003AdapterServiceProvider, + final DatabaseServiceProvider databaseServiceProvider) { + super(databaseServiceProvider); + this.sol003AdapterServiceProvider = sol003AdapterServiceProvider; + } + + public boolean hasOperationFinished(final DelegateExecution execution) { + LOGGER.debug("Executing hasOperationFinished ..."); + + final OperationStateEnum operationStatus = + (OperationStateEnum) execution.getVariable(OPERATION_STATUS_PARAM_NAME); + if (operationStatus != null) { + return OPERATION_FINISHED_STATES.contains(operationStatus); + } + LOGGER.debug("OperationStatus is not present yet... "); + LOGGER.debug("Finished executing hasOperationFinished ..."); + return false; + } + + protected OperationStateEnum getOperationStatus(final DelegateExecution execution, final String jobId) { + + final Optional<QueryJobResponse> instantiateOperationJobStatus = + sol003AdapterServiceProvider.getInstantiateOperationJobStatus(jobId); + + if (instantiateOperationJobStatus.isPresent()) { + final QueryJobResponse queryJobResponse = instantiateOperationJobStatus.get(); + + if (!OPERATION_RETRIEVAL_STATES.contains(queryJobResponse.getOperationStatusRetrievalStatus())) { + final String message = "Received invalid operation retrieval state: " + + queryJobResponse.getOperationStatusRetrievalStatus(); + LOGGER.error(message); + abortOperation(execution, message); + } + if (queryJobResponse.getOperationState() != null) { + final OperationStateEnum operationStatus = queryJobResponse.getOperationState(); + LOGGER.debug("Operation {} with {} and operation retrieval status : {}", queryJobResponse.getId(), + operationStatus, queryJobResponse.getOperationStatusRetrievalStatus()); + return queryJobResponse.getOperationState(); + } + + LOGGER.debug("Operation {} without operationStatus and operation retrieval status :{}", + queryJobResponse.getId(), queryJobResponse.getOperationStatusRetrievalStatus()); + } + return null; + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java new file mode 100644 index 0000000000..e27e0c1579 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; + +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NF_INST_ID_PARAM_NAME; +import java.util.Optional; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public abstract class MonitorSol003AdapterNodeTask extends AbstractNetworkServiceTask { + + private static final Logger LOGGER = LoggerFactory.getLogger(MonitorSol003AdapterNodeTask.class); + private final AaiServiceProvider aaiServiceProvider; + + public MonitorSol003AdapterNodeTask(final DatabaseServiceProvider databaseServiceProvider, + final AaiServiceProvider aaiServiceProvider) { + super(databaseServiceProvider); + this.aaiServiceProvider = aaiServiceProvider; + } + + /** + * Check the final status of vnf in A&AI + * + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + */ + public void getNodeStatus(final DelegateExecution execution) { + try { + LOGGER.debug("Executing getNodeStatus ..."); + final String vnfId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); + + LOGGER.debug("Query A&AI for generic VNF using vnfID: {}", vnfId); + final Optional<GenericVnf> aaiGenericVnfOptional = aaiServiceProvider.getGenericVnf(vnfId); + + if (!aaiGenericVnfOptional.isPresent()) { + abortOperation(execution, "Unable to invoke Sol003 adapter for create and instantiate vnfId" + vnfId); + } + final GenericVnf genericVnf = aaiGenericVnfOptional.get(); + final String orchestrationStatus = genericVnf.getOrchestrationStatus(); + LOGGER.debug("Found generic vnf with orchestration status : {}", orchestrationStatus); + + execution.setVariable(getNodeStatusVariableName(), isOrchestrationStatusValid(orchestrationStatus)); + + } catch (final Exception exception) { + LOGGER.error("Unable to get vnf from AAI", exception); + abortOperation(execution, "Unable to get vnf from AAI"); + } + } + + /** + * Get variable to store in execution context + * + * @return the variable name + */ + public abstract String getNodeStatusVariableName(); + + /** + * @param orchestrationStatus the orchestration status from A&AI + * @return true if valid + */ + public abstract boolean isOrchestrationStatusValid(final String orchestrationStatus); + + public void timeOutLogFailue(final DelegateExecution execution) { + final String message = "Node operation time out"; + LOGGER.error(message); + abortOperation(execution, message); + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java new file mode 100644 index 0000000000..34959ee0f0 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.utils; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class LocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> { + + private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + @Override + public void write(final JsonWriter out, final LocalDateTime localDateTime) throws IOException { + if (localDateTime == null) { + out.nullValue(); + } else { + out.value(FORMATTER.format(localDateTime)); + } + } + + @Override + public LocalDateTime read(final JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + final String dateTime = in.nextString(); + return LocalDateTime.parse(dateTime, FORMATTER); + } + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateInstantiateVnf.bpmn b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateInstantiateVnf.bpmn new file mode 100644 index 0000000000..025faa4128 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateInstantiateVnf.bpmn @@ -0,0 +1,159 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1uf6nd9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="CreateInstantiateVnf" name="CreateInstantiateVnf" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_02bjz2v</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="Activity_19rmtjr" name="Create NF Instance (VNF) record in DB" camunda:expression="${CreateInstantiateVnfTask.createNfInstanceInDb(execution)}"> + <bpmn:incoming>Flow_123uagz</bpmn:incoming> + <bpmn:outgoing>Flow_03p6ifi</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_02bjz2v" sourceRef="StartEvent_1" targetRef="Activity_1cluqgp" /> + <bpmn:endEvent id="Event_14qdixj"> + <bpmn:incoming>Flow_0srinh7</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_03p6ifi" sourceRef="Activity_19rmtjr" targetRef="Activity_0rto3n3" /> + <bpmn:serviceTask id="Activity_0rto3n3" name="Create Generic VNF and Connect to Service Instance in AAI" camunda:expression="${CreateInstantiateVnfTask.createGenericVnfInAai(execution)}"> + <bpmn:incoming>Flow_03p6ifi</bpmn:incoming> + <bpmn:outgoing>Flow_1c3kc4e</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1c3kc4e" sourceRef="Activity_0rto3n3" targetRef="ServiceTask_0iry5yw" /> + <bpmn:serviceTask id="Activity_1cluqgp" name="Check If NF Instance (VNF) exists in DB" camunda:expression="${CreateInstantiateVnfTask.checkIfNfInstanceExistsInDb(execution)}"> + <bpmn:incoming>Flow_02bjz2v</bpmn:incoming> + <bpmn:outgoing>Flow_123uagz</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_123uagz" sourceRef="Activity_1cluqgp" targetRef="Activity_19rmtjr" /> + <bpmn:serviceTask id="ServiceTask_0iry5yw" name=" Invoke VNFM Adaptor " camunda:asyncAfter="true" camunda:expression="${CreateInstantiateVnfTask.invokeCreateInstantiationRequest(execution)}"> + <bpmn:incoming>Flow_1c3kc4e</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0xzptc2</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:callActivity id="CallActivity_1yilxx3" name="Monitor Sol003 adapter Instantiation Job" calledElement="MonitorSol003AdapterCreateJob"> + <bpmn:extensionElements> + <camunda:in source="createVnfResponse" target="createVnfResponse" /> + <camunda:in source="jobId" target="jobId" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0xzptc2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_053tvct</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:callActivity id="CallActivity_0p84lpt" name="Monitor Sol003 adapter Create Node Status" calledElement="MonitorSol003AdapterCreateNodeStatus"> + <bpmn:extensionElements> + <camunda:in source="NF_INST_ID" target="NF_INST_ID" /> + <camunda:in source="createVnfResponse" target="createVnfResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_053tvct</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0h7yluk</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_0xzptc2" sourceRef="ServiceTask_0iry5yw" targetRef="CallActivity_1yilxx3" /> + <bpmn:sequenceFlow id="SequenceFlow_053tvct" sourceRef="CallActivity_1yilxx3" targetRef="CallActivity_0p84lpt" /> + <bpmn:sequenceFlow id="SequenceFlow_0h7yluk" sourceRef="CallActivity_0p84lpt" targetRef="Activity_0g3dip7" /> + <bpmn:serviceTask id="Activity_0g3dip7" name="Update NF Instance (VNF) Status to INSTANTIATED" camunda:expression="${CreateInstantiateVnfTask.updateNfInstanceStatusToInstantiated(execution)}"> + <bpmn:incoming>SequenceFlow_0h7yluk</bpmn:incoming> + <bpmn:outgoing>Flow_0srinh7</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0srinh7" sourceRef="Activity_0g3dip7" targetRef="Event_14qdixj" /> + <bpmn:subProcess id="Activity_0qtgdm9" name="Error Handling" triggeredByEvent="true"> + <bpmn:startEvent id="Event_08zcwc2" name="error"> + <bpmn:outgoing>Flow_06q1m6i</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1ppvn77" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1wkm29u" name="end"> + <bpmn:incoming>Flow_0anjylz</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_0ltxcii" name="Update NF Instance (VNF) Status to FAILED" camunda:asyncBefore="true" camunda:expression="${CreateInstantiateVnfTask.updateNfInstanceStatusToFailed(execution)}"> + <bpmn:incoming>Flow_06q1m6i</bpmn:incoming> + <bpmn:outgoing>Flow_0anjylz</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_06q1m6i" sourceRef="Event_08zcwc2" targetRef="Activity_0ltxcii" /> + <bpmn:sequenceFlow id="Flow_0anjylz" sourceRef="Activity_0ltxcii" targetRef="Event_1wkm29u" /> + </bpmn:subProcess> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateInstantiateVnf"> + <bpmndi:BPMNEdge id="SequenceFlow_0h7yluk_di" bpmnElement="SequenceFlow_0h7yluk"> + <di:waypoint x="1030" y="117" /> + <di:waypoint x="1080" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_053tvct_di" bpmnElement="SequenceFlow_053tvct"> + <di:waypoint x="880" y="117" /> + <di:waypoint x="930" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0xzptc2_di" bpmnElement="SequenceFlow_0xzptc2"> + <di:waypoint x="740" y="117" /> + <di:waypoint x="780" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_123uagz_di" bpmnElement="Flow_123uagz"> + <di:waypoint x="350" y="117" /> + <di:waypoint x="380" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1c3kc4e_di" bpmnElement="Flow_1c3kc4e"> + <di:waypoint x="610" y="117" /> + <di:waypoint x="640" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_03p6ifi_di" bpmnElement="Flow_03p6ifi"> + <di:waypoint x="480" y="117" /> + <di:waypoint x="510" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_02bjz2v_di" bpmnElement="Flow_02bjz2v"> + <di:waypoint x="215" y="117" /> + <di:waypoint x="250" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0srinh7_di" bpmnElement="Flow_0srinh7"> + <di:waypoint x="1180" y="117" /> + <di:waypoint x="1232" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="179" y="99" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_19rmtjr_di" bpmnElement="Activity_19rmtjr"> + <dc:Bounds x="380" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0rto3n3_di" bpmnElement="Activity_0rto3n3"> + <dc:Bounds x="510" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1cluqgp_di" bpmnElement="Activity_1cluqgp"> + <dc:Bounds x="250" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0iry5yw_di" bpmnElement="ServiceTask_0iry5yw"> + <dc:Bounds x="640" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1yilxx3_di" bpmnElement="CallActivity_1yilxx3"> + <dc:Bounds x="780" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0p84lpt_di" bpmnElement="CallActivity_0p84lpt"> + <dc:Bounds x="930" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_14qdixj_di" bpmnElement="Event_14qdixj"> + <dc:Bounds x="1232" y="99" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0g3dip7_di" bpmnElement="Activity_0g3dip7"> + <dc:Bounds x="1080" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0qtgdm9_di" bpmnElement="Activity_0qtgdm9" isExpanded="true"> + <dc:Bounds x="430" y="270" width="438" height="130" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_06q1m6i_di" bpmnElement="Flow_06q1m6i"> + <di:waypoint x="488" y="333" /> + <di:waypoint x="580" y="333" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0anjylz_di" bpmnElement="Flow_0anjylz"> + <di:waypoint x="680" y="333" /> + <di:waypoint x="812" y="333" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_08zcwc2_di" bpmnElement="Event_08zcwc2"> + <dc:Bounds x="452" y="315" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="458" y="358" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1wkm29u_di" bpmnElement="Event_1wkm29u"> + <dc:Bounds x="812" y="315" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="822" y="357" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ltxcii_di" bpmnElement="Activity_0ltxcii"> + <dc:Bounds x="580" y="293" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateNs.bpmn b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateNs.bpmn new file mode 100644 index 0000000000..815b76c907 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/CreateNs.bpmn @@ -0,0 +1,266 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1l4zor5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="CreateNs" name=" CreateNs" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start Process"> + <bpmn:outgoing>Flow_1tqn5q5</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1" name="End Process"> + <bpmn:incoming>Flow_0t87ov3</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_1tqn5q5" sourceRef="StartEvent_1" targetRef="Activity_15ksfz6" /> + <bpmn:serviceTask id="Activity_15ksfz6" name="Set Job Status to STARTED" camunda:asyncBefore="true" camunda:expression="${CreateNsTask.setJobStatusToStarted(execution)}"> + <bpmn:incoming>Flow_1tqn5q5</bpmn:incoming> + <bpmn:outgoing>Flow_0y07mxe</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0y07mxe" sourceRef="Activity_15ksfz6" targetRef="Activity_12yonzp" /> + <bpmn:serviceTask id="Activity_1r4l8w8" name="Set Job Status to FINISHED" camunda:expression="${CreateNsTask.setJobStatusToFinished(execution)}"> + <bpmn:incoming>Flow_1rtsvpm</bpmn:incoming> + <bpmn:outgoing>Flow_0t87ov3</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0t87ov3" sourceRef="Activity_1r4l8w8" targetRef="EndEvent_1" /> + <bpmn:exclusiveGateway id="Gateway_0fuwzjj" name="Does Ns Package exists?"> + <bpmn:incoming>Flow_09582uw</bpmn:incoming> + <bpmn:outgoing>Flow_1f4vi10</bpmn:outgoing> + <bpmn:outgoing>Flow_0qabgp7</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:serviceTask id="Activity_12yonzp" name="Get Ns Package from ETSI Catalog Manager" camunda:expression="${CreateNsTask.getNsPackage(execution)}"> + <bpmn:incoming>Flow_0y07mxe</bpmn:incoming> + <bpmn:outgoing>Flow_09582uw</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_09582uw" sourceRef="Activity_12yonzp" targetRef="Gateway_0fuwzjj" /> + <bpmn:subProcess id="Activity_06ko4e2" name="Error Handling" triggeredByEvent="true"> + <bpmn:startEvent id="Event_1ibvrn2" name="error"> + <bpmn:outgoing>Flow_0554tjv</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0lc46mh" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_02f7sr1" name="end"> + <bpmn:incoming>Flow_04xvpee</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0554tjv" sourceRef="Event_1ibvrn2" targetRef="Activity_1sj0nvr" /> + <bpmn:serviceTask id="Activity_1sj0nvr" name="Set Job Status to ERROR" camunda:asyncBefore="true" camunda:expression="${CreateNsTask.setJobStatusToError(execution)}"> + <bpmn:incoming>Flow_0554tjv</bpmn:incoming> + <bpmn:outgoing>Flow_04xvpee</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_04xvpee" sourceRef="Activity_1sj0nvr" targetRef="Event_02f7sr1" /> + </bpmn:subProcess> + <bpmn:subProcess id="Activity_1dx9fz6" name="Java Exception Handling" triggeredByEvent="true"> + <bpmn:startEvent id="Event_0zne7ch" name="error"> + <bpmn:outgoing>Flow_0j1otrx</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1p3h4ta" errorRef="Error_0s855yd" camunda:errorCodeVariable="BPMN_javaExpCode" camunda:errorMessageVariable="BPMN_javaExpMsg" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_0bcyh7u"> + <bpmn:incoming>Flow_0oqv7vl</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0j1otrx" sourceRef="Event_0zne7ch" targetRef="Activity_15uwy90" /> + <bpmn:serviceTask id="Activity_15uwy90" name="Set Job Status to ERROR" camunda:asyncBefore="true" camunda:expression="${CreateNsTask.setJobStatusToError(execution)}"> + <bpmn:incoming>Flow_0j1otrx</bpmn:incoming> + <bpmn:outgoing>Flow_0oqv7vl</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0oqv7vl" sourceRef="Activity_15uwy90" targetRef="Event_0bcyh7u" /> + </bpmn:subProcess> + <bpmn:sequenceFlow id="Flow_1f4vi10" name="No" sourceRef="Gateway_0fuwzjj" targetRef="Event_016q8gu"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{not doesNsPackageExists}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="Event_016q8gu"> + <bpmn:incoming>Flow_1f4vi10</bpmn:incoming> + <bpmn:incoming>Flow_1yql1cm</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1ugx52k" errorRef="Error_0rqvnym" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_0qabgp7" name="Yes" sourceRef="Gateway_0fuwzjj" targetRef="Activity_0vlb2nk"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{doesNsPackageExists}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="Activity_0vlb2nk" name="Check NS Instance exists In DB " camunda:expression="${CreateNsTask.doesNsInstanceExistsInDb(execution)}"> + <bpmn:incoming>Flow_0qabgp7</bpmn:incoming> + <bpmn:outgoing>Flow_1exrj2b</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1exrj2b" sourceRef="Activity_0vlb2nk" targetRef="Gateway_0d7n517" /> + <bpmn:exclusiveGateway id="Gateway_0d7n517"> + <bpmn:incoming>Flow_1exrj2b</bpmn:incoming> + <bpmn:outgoing>Flow_1rkg44s</bpmn:outgoing> + <bpmn:outgoing>Flow_1yql1cm</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_1rkg44s" name="No" sourceRef="Gateway_0d7n517" targetRef="Activity_09tqz8x"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{not doesNsInstanceExists}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1yql1cm" name="Yes" sourceRef="Gateway_0d7n517" targetRef="Event_016q8gu"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{doesNsInstanceExists}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="Activity_09tqz8x" name="Create NS Instance record in DB" camunda:expression="${CreateNsTask.createNsInstanceInDb(execution)}"> + <bpmn:incoming>Flow_1rkg44s</bpmn:incoming> + <bpmn:outgoing>Flow_1jvfwd2</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1jvfwd2" sourceRef="Activity_09tqz8x" targetRef="Activity_1akc79d" /> + <bpmn:serviceTask id="Activity_1akc79d" name="Create NS Instance in AAI" camunda:expression="${CreateNsTask.createNsInstanceInAai(execution)}"> + <bpmn:incoming>Flow_1jvfwd2</bpmn:incoming> + <bpmn:outgoing>Flow_0e5hvno</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0e5hvno" sourceRef="Activity_1akc79d" targetRef="Activity_03ht66t" /> + <bpmn:serviceTask id="Activity_03ht66t" name="Set Create NS Response" camunda:expression="${CreateNsTask.setCreateNsResponse(execution)}"> + <bpmn:incoming>Flow_0e5hvno</bpmn:incoming> + <bpmn:outgoing>Flow_1rtsvpm</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1rtsvpm" sourceRef="Activity_03ht66t" targetRef="Activity_1r4l8w8" /> + </bpmn:process> + <bpmn:error id="Error_0s855yd" name="java.lang.Exception" errorCode="java.lang.Exception" /> + <bpmn:error id="Error_0rqvnym" name="CreateNsProcessingException" errorCode="CREATE_NS_PROCESSING_EXCEPTION" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateNs"> + <bpmndi:BPMNEdge id="Flow_1rtsvpm_di" bpmnElement="Flow_1rtsvpm"> + <di:waypoint x="1160" y="157" /> + <di:waypoint x="1160" y="230" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0e5hvno_di" bpmnElement="Flow_0e5hvno"> + <di:waypoint x="1070" y="117" /> + <di:waypoint x="1110" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1jvfwd2_di" bpmnElement="Flow_1jvfwd2"> + <di:waypoint x="930" y="117" /> + <di:waypoint x="970" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1yql1cm_di" bpmnElement="Flow_1yql1cm"> + <di:waypoint x="760" y="142" /> + <di:waypoint x="760" y="230" /> + <di:waypoint x="668" y="230" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="766" y="183" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1rkg44s_di" bpmnElement="Flow_1rkg44s"> + <di:waypoint x="785" y="117" /> + <di:waypoint x="830" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="799" y="99" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1exrj2b_di" bpmnElement="Flow_1exrj2b"> + <di:waypoint x="700" y="117" /> + <di:waypoint x="735" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0qabgp7_di" bpmnElement="Flow_0qabgp7"> + <di:waypoint x="565" y="117" /> + <di:waypoint x="600" y="117" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="579" y="99" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1f4vi10_di" bpmnElement="Flow_1f4vi10"> + <di:waypoint x="540" y="142" /> + <di:waypoint x="540" y="230" /> + <di:waypoint x="632" y="230" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="548" y="183" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_09582uw_di" bpmnElement="Flow_09582uw"> + <di:waypoint x="480" y="117" /> + <di:waypoint x="515" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0t87ov3_di" bpmnElement="Flow_0t87ov3"> + <di:waypoint x="1160" y="310" /> + <di:waypoint x="1160" y="357" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0y07mxe_di" bpmnElement="Flow_0y07mxe"> + <di:waypoint x="350" y="117" /> + <di:waypoint x="380" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1tqn5q5_di" bpmnElement="Flow_1tqn5q5"> + <di:waypoint x="208" y="117" /> + <di:waypoint x="250" y="117" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="172" y="99" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="142" width="67" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0db1w1a_di" bpmnElement="EndEvent_1"> + <dc:Bounds x="1142" y="357" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1129" y="400" width="63" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_15ksfz6_di" bpmnElement="Activity_15ksfz6"> + <dc:Bounds x="250" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1r4l8w8_di" bpmnElement="Activity_1r4l8w8"> + <dc:Bounds x="1110" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0fuwzjj_di" bpmnElement="Gateway_0fuwzjj" isMarkerVisible="true"> + <dc:Bounds x="515" y="92" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="498" y="62" width="88" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_12yonzp_di" bpmnElement="Activity_12yonzp"> + <dc:Bounds x="380" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_06ko4e2_di" bpmnElement="Activity_06ko4e2" isExpanded="true"> + <dc:Bounds x="431" y="310" width="438" height="130" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_04xvpee_di" bpmnElement="Flow_04xvpee"> + <di:waypoint x="681" y="373" /> + <di:waypoint x="813" y="373" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0554tjv_di" bpmnElement="Flow_0554tjv"> + <di:waypoint x="489" y="373" /> + <di:waypoint x="581" y="373" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_1ibvrn2_di" bpmnElement="Event_1ibvrn2"> + <dc:Bounds x="453" y="355" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="459" y="398" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_02f7sr1_di" bpmnElement="Event_02f7sr1"> + <dc:Bounds x="813" y="355" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="823" y="397" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1sj0nvr_di" bpmnElement="Activity_1sj0nvr"> + <dc:Bounds x="581" y="333" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1dx9fz6_di" bpmnElement="Activity_1dx9fz6" isExpanded="true"> + <dc:Bounds x="431" y="470" width="438" height="130" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0oqv7vl_di" bpmnElement="Flow_0oqv7vl"> + <di:waypoint x="680" y="533" /> + <di:waypoint x="772" y="533" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0j1otrx_di" bpmnElement="Flow_0j1otrx"> + <di:waypoint x="522" y="533" /> + <di:waypoint x="580" y="533" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_0zne7ch_di" bpmnElement="Event_0zne7ch"> + <dc:Bounds x="486" y="515" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="493" y="558" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0bcyh7u_di" bpmnElement="Event_0bcyh7u"> + <dc:Bounds x="772" y="515" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_15uwy90_di" bpmnElement="Activity_15uwy90"> + <dc:Bounds x="580" y="493" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0spfqz1_di" bpmnElement="Event_016q8gu"> + <dc:Bounds x="632" y="212" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0vlb2nk_di" bpmnElement="Activity_0vlb2nk"> + <dc:Bounds x="600" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0d7n517_di" bpmnElement="Gateway_0d7n517" isMarkerVisible="true"> + <dc:Bounds x="735" y="92" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_09tqz8x_di" bpmnElement="Activity_09tqz8x"> + <dc:Bounds x="830" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1akc79d_di" bpmnElement="Activity_1akc79d"> + <dc:Bounds x="970" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_03ht66t_di" bpmnElement="Activity_03ht66t"> + <dc:Bounds x="1110" y="77" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/InstantiateNs.bpmn b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/InstantiateNs.bpmn new file mode 100644 index 0000000000..ba9e641d84 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/InstantiateNs.bpmn @@ -0,0 +1,331 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0mdda96" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0"> + <bpmn:process id="InstantiateNs" name="InstantiateNs" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start Process"> + <bpmn:outgoing>SequenceFlow_16k0f61</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_16k0f61" sourceRef="StartEvent_1" targetRef="Activity_194tqy0" /> + <bpmn:serviceTask id="Task_0opnwx0" name="Update NS Instance status to INSTANTIATING" camunda:expression="${InstantiateNsTask.updateNsInstanceStatusToInstantiating(execution)}"> + <bpmn:incoming>Flow_04pxtdd</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0bdznyp</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:endEvent id="EndEvent_0szswbo" name="End Process"> + <bpmn:incoming>Flow_1pcu8aa</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0bdznyp" sourceRef="Task_0opnwx0" targetRef="Activity_1jrym1e" /> + <bpmn:serviceTask id="Activity_194tqy0" name="Set Job Status to STARTED" camunda:asyncBefore="true" camunda:expression="${InstantiateNsTask.setJobStatusToStarted(execution)}"> + <bpmn:incoming>SequenceFlow_16k0f61</bpmn:incoming> + <bpmn:outgoing>Flow_04pxtdd</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_04pxtdd" sourceRef="Activity_194tqy0" targetRef="Task_0opnwx0" /> + <bpmn:subProcess id="Activity_0pjxszh" name="Error Handling" triggeredByEvent="true"> + <bpmn:startEvent id="Event_1rpzcl3" name="error"> + <bpmn:outgoing>Flow_07bh7l7</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0m2e0oa" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1fcw3ei" name="end"> + <bpmn:incoming>Flow_1wa1jpl</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_0ddja9m" name="Set Job Status to ERROR" camunda:asyncBefore="true" camunda:expression="${InstantiateNsTask.setJobStatusToError(execution)}"> + <bpmn:incoming>Flow_0n3dai5</bpmn:incoming> + <bpmn:outgoing>Flow_1wa1jpl</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1wa1jpl" sourceRef="Activity_0ddja9m" targetRef="Event_1fcw3ei" /> + <bpmn:sequenceFlow id="Flow_07bh7l7" sourceRef="Event_1rpzcl3" targetRef="Activity_1miy3hw" /> + <bpmn:serviceTask id="Activity_1miy3hw" name="Update NSLcmOpOcc operation status to FAILED" camunda:asyncBefore="true" camunda:expression="${InstantiateNsTask.updateNsLcmOpOccStatusToFailed(execution)}"> + <bpmn:incoming>Flow_07bh7l7</bpmn:incoming> + <bpmn:outgoing>Flow_0n3dai5</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0n3dai5" sourceRef="Activity_1miy3hw" targetRef="Activity_0ddja9m" /> + </bpmn:subProcess> + <bpmn:subProcess id="Activity_0mtscwq" name="Java Exception Handling" triggeredByEvent="true"> + <bpmn:startEvent id="Event_0lqr6al" name="error"> + <bpmn:outgoing>Flow_05lo00r</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_02lwl19" errorRef="Error_0jsct8p" camunda:errorCodeVariable="BPMN_javaExpCode" camunda:errorMessageVariable="BPMN_javaExpMsg" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_05ty7c4"> + <bpmn:incoming>Flow_16aryg5</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Activity_1ezu7d4" name="Set Job Status to ERROR" camunda:asyncBefore="true" camunda:expression="${InstantiateNsTask.setJobStatusToError(execution)}"> + <bpmn:incoming>Flow_09zcw2a</bpmn:incoming> + <bpmn:outgoing>Flow_16aryg5</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_16aryg5" sourceRef="Activity_1ezu7d4" targetRef="Event_05ty7c4" /> + <bpmn:sequenceFlow id="Flow_05lo00r" sourceRef="Event_0lqr6al" targetRef="Activity_17leldb" /> + <bpmn:serviceTask id="Activity_17leldb" name="Update NSLcmOpOcc operation status to FAILED" camunda:asyncBefore="true" camunda:expression="${InstantiateNsTask.updateNsLcmOpOccStatusToFailed(execution)}"> + <bpmn:incoming>Flow_05lo00r</bpmn:incoming> + <bpmn:outgoing>Flow_09zcw2a</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_09zcw2a" sourceRef="Activity_17leldb" targetRef="Activity_1ezu7d4" /> + </bpmn:subProcess> + <bpmn:serviceTask id="Activity_1w09i1k" name="Set Job Status to FINISHED" camunda:expression="${InstantiateNsTask.setJobStatusToFinished(execution)}"> + <bpmn:incoming>Flow_1i36dw4</bpmn:incoming> + <bpmn:outgoing>Flow_1pcu8aa</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1pcu8aa" sourceRef="Activity_1w09i1k" targetRef="EndEvent_0szswbo" /> + <bpmn:serviceTask id="Activity_1jrym1e" name="Get and parse NSD from ETSI Catalog" camunda:expression="${InstantiateNsTask.getAndParseNsdFromEtsiCatalog(execution)}"> + <bpmn:incoming>SequenceFlow_0bdznyp</bpmn:incoming> + <bpmn:outgoing>Flow_10zjw0w</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_10zjw0w" sourceRef="Activity_1jrym1e" targetRef="Activity_1kikjaf" /> + <bpmn:callActivity id="Activity_1b2s2wr" name="Create and Instantiate each Vnf" calledElement="CreateInstantiateVnf"> + <bpmn:extensionElements> + <camunda:in source="request" target="request" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="NsInstanceId" target="NsInstanceId" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1irbp9b</bpmn:incoming> + <bpmn:outgoing>Flow_0mi4nqa</bpmn:outgoing> + <bpmn:multiInstanceLoopCharacteristics camunda:asyncAfter="true" camunda:collection="${vnfCreateInstantiateRequests}" camunda:elementVariable="request" /> + </bpmn:callActivity> + <bpmn:boundaryEvent id="Event_0rbb817" name="Overall Wait" attachedToRef="Activity_1b2s2wr"> + <bpmn:outgoing>Flow_17zn7we</bpmn:outgoing> + <bpmn:timerEventDefinition id="TimerEventDefinition_13ud1f4"> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT3H</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:boundaryEvent> + <bpmn:sequenceFlow id="Flow_17zn7we" sourceRef="Event_0rbb817" targetRef="Activity_16z66xm" /> + <bpmn:serviceTask id="Activity_0eou3y4" name="Prepare Create Instantiate requests" camunda:expression="${InstantiateNsTask.prepareCreateInstantiateRequests(execution)}"> + <bpmn:incoming>Flow_01ju1mj</bpmn:incoming> + <bpmn:outgoing>Flow_1irbp9b</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1irbp9b" sourceRef="Activity_0eou3y4" targetRef="Activity_1b2s2wr" /> + <bpmn:serviceTask id="Activity_1kikjaf" name="Get Vnf Pkg ID for each VNFD ID" camunda:expression="${InstantiateNsTask.getVnfPkgIdForEachVnfdId(execution)}"> + <bpmn:incoming>Flow_10zjw0w</bpmn:incoming> + <bpmn:outgoing>Flow_01ju1mj</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_01ju1mj" sourceRef="Activity_1kikjaf" targetRef="Activity_0eou3y4" /> + <bpmn:serviceTask id="Activity_16cvdbw" name="Update NS Instance status to INSTANTIATED" camunda:expression="${InstantiateNsTask.updateNsInstanceStatusToInstantiated(execution)}"> + <bpmn:incoming>Flow_1nieng0</bpmn:incoming> + <bpmn:outgoing>Flow_0xptc0r</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0xptc0r" sourceRef="Activity_16cvdbw" targetRef="Activity_0gkpdft" /> + <bpmn:endEvent id="Event_1e4bwip"> + <bpmn:incoming>Flow_10oprxr</bpmn:incoming> + <bpmn:incoming>Flow_1p21p1m</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0vg6v5r" errorRef="Error_0jsct8p" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="Gateway_0nxf0rv" name="is Successful?"> + <bpmn:incoming>Flow_15m4nm1</bpmn:incoming> + <bpmn:outgoing>Flow_1nieng0</bpmn:outgoing> + <bpmn:outgoing>Flow_10oprxr</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_1nieng0" name="Yes" sourceRef="Gateway_0nxf0rv" targetRef="Activity_16cvdbw"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{isNsInstantiationSuccessful}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="Activity_14iwa8x" name="Check if VNF Instantiation was Successful" camunda:expression="${InstantiateNsTask.checkIfVnfInstantiationWasSuccessful(execution)}"> + <bpmn:incoming>Flow_0mi4nqa</bpmn:incoming> + <bpmn:outgoing>Flow_15m4nm1</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_0mi4nqa" sourceRef="Activity_1b2s2wr" targetRef="Activity_14iwa8x" /> + <bpmn:sequenceFlow id="Flow_15m4nm1" sourceRef="Activity_14iwa8x" targetRef="Gateway_0nxf0rv" /> + <bpmn:serviceTask id="Activity_16z66xm" name="Log TimeOut" camunda:expression="${InstantiateNsTask.logTimeOut(execution)}"> + <bpmn:incoming>Flow_17zn7we</bpmn:incoming> + <bpmn:outgoing>Flow_1p21p1m</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_10oprxr" name="No" sourceRef="Gateway_0nxf0rv" targetRef="Event_1e4bwip"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{not isNsInstantiationSuccessful}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1p21p1m" sourceRef="Activity_16z66xm" targetRef="Event_1e4bwip" /> + <bpmn:serviceTask id="Activity_0gkpdft" name="Update NSLcmOpOcc operation status to COMPLETED" camunda:expression="${InstantiateNsTask.updateNsLcmOpOccStatusToCompleted(execution)}"> + <bpmn:incoming>Flow_0xptc0r</bpmn:incoming> + <bpmn:outgoing>Flow_1i36dw4</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="Flow_1i36dw4" sourceRef="Activity_0gkpdft" targetRef="Activity_1w09i1k" /> + </bpmn:process> + <bpmn:error id="Error_0jsct8p" name="InstantiateNsProcessingException" errorCode="INSTANTIATE_NS_PROCESSING_EXCEPTION" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="InstantiateNs"> + <bpmndi:BPMNEdge id="Flow_1p21p1m_di" bpmnElement="Flow_1p21p1m"> + <di:waypoint x="1250" y="270" /> + <di:waypoint x="1332" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_10oprxr_di" bpmnElement="Flow_10oprxr"> + <di:waypoint x="1350" y="146" /> + <di:waypoint x="1350" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1358" y="196" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_15m4nm1_di" bpmnElement="Flow_15m4nm1"> + <di:waypoint x="1250" y="121" /> + <di:waypoint x="1325" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0mi4nqa_di" bpmnElement="Flow_0mi4nqa"> + <di:waypoint x="1090" y="121" /> + <di:waypoint x="1150" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1nieng0_di" bpmnElement="Flow_1nieng0"> + <di:waypoint x="1375" y="121" /> + <di:waypoint x="1430" y="121" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1393" y="103" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0xptc0r_di" bpmnElement="Flow_0xptc0r"> + <di:waypoint x="1530" y="121" /> + <di:waypoint x="1580" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_01ju1mj_di" bpmnElement="Flow_01ju1mj"> + <di:waypoint x="800" y="121" /> + <di:waypoint x="850" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1irbp9b_di" bpmnElement="Flow_1irbp9b"> + <di:waypoint x="950" y="121" /> + <di:waypoint x="990" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_17zn7we_di" bpmnElement="Flow_17zn7we"> + <di:waypoint x="1070" y="179" /> + <di:waypoint x="1070" y="270" /> + <di:waypoint x="1150" y="270" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_10zjw0w_di" bpmnElement="Flow_10zjw0w"> + <di:waypoint x="649" y="121" /> + <di:waypoint x="700" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1pcu8aa_di" bpmnElement="Flow_1pcu8aa"> + <di:waypoint x="1820" y="121" /> + <di:waypoint x="1862" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_04pxtdd_di" bpmnElement="Flow_04pxtdd"> + <di:waypoint x="360" y="121" /> + <di:waypoint x="400" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0bdznyp_di" bpmnElement="SequenceFlow_0bdznyp"> + <di:waypoint x="500" y="121" /> + <di:waypoint x="549" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_16k0f61_di" bpmnElement="SequenceFlow_16k0f61"> + <di:waypoint x="208" y="121" /> + <di:waypoint x="260" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1i36dw4_di" bpmnElement="Flow_1i36dw4"> + <di:waypoint x="1680" y="121" /> + <di:waypoint x="1720" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="172" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="157" y="146" width="67" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1y7xfqt_di" bpmnElement="Task_0opnwx0"> + <dc:Bounds x="400" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_194tqy0_di" bpmnElement="Activity_194tqy0"> + <dc:Bounds x="260" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0szswbo_di" bpmnElement="EndEvent_0szswbo"> + <dc:Bounds x="1862" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1848" y="79" width="63" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1w09i1k_di" bpmnElement="Activity_1w09i1k"> + <dc:Bounds x="1720" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0gkpdft_di" bpmnElement="Activity_0gkpdft"> + <dc:Bounds x="1580" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0pjxszh_di" bpmnElement="Activity_0pjxszh" isExpanded="true"> + <dc:Bounds x="380" y="270" width="510" height="130" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_07bh7l7_di" bpmnElement="Flow_07bh7l7"> + <di:waypoint x="438" y="333" /> + <di:waypoint x="500" y="333" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1wa1jpl_di" bpmnElement="Flow_1wa1jpl"> + <di:waypoint x="760" y="333" /> + <di:waypoint x="822" y="333" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0n3dai5_di" bpmnElement="Flow_0n3dai5"> + <di:waypoint x="600" y="333" /> + <di:waypoint x="660" y="333" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_1rpzcl3_di" bpmnElement="Event_1rpzcl3"> + <dc:Bounds x="402" y="315" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="408" y="358" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1miy3hw_di" bpmnElement="Activity_1miy3hw"> + <dc:Bounds x="500" y="293" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0ddja9m_di" bpmnElement="Activity_0ddja9m"> + <dc:Bounds x="660" y="293" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1fcw3ei_di" bpmnElement="Event_1fcw3ei"> + <dc:Bounds x="822" y="315" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="832" y="357" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0mtscwq_di" bpmnElement="Activity_0mtscwq" isExpanded="true"> + <dc:Bounds x="380" y="430" width="510" height="130" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_05lo00r_di" bpmnElement="Flow_05lo00r"> + <di:waypoint x="438" y="493" /> + <di:waypoint x="500" y="493" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_16aryg5_di" bpmnElement="Flow_16aryg5"> + <di:waypoint x="760" y="493" /> + <di:waypoint x="822" y="493" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_09zcw2a_di" bpmnElement="Flow_09zcw2a"> + <di:waypoint x="600" y="493" /> + <di:waypoint x="660" y="493" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_0lqr6al_di" bpmnElement="Event_0lqr6al"> + <dc:Bounds x="402" y="475" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="409" y="518" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_17leldb_di" bpmnElement="Activity_17leldb"> + <dc:Bounds x="500" y="453" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1ezu7d4_di" bpmnElement="Activity_1ezu7d4"> + <dc:Bounds x="660" y="453" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_05ty7c4_di" bpmnElement="Event_05ty7c4"> + <dc:Bounds x="822" y="475" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1jrym1e_di" bpmnElement="Activity_1jrym1e"> + <dc:Bounds x="549" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1xjmizv_di" bpmnElement="Activity_1b2s2wr"> + <dc:Bounds x="990" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0eou3y4_di" bpmnElement="Activity_0eou3y4"> + <dc:Bounds x="850" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1kikjaf_di" bpmnElement="Activity_1kikjaf"> + <dc:Bounds x="700" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16cvdbw_di" bpmnElement="Activity_16cvdbw"> + <dc:Bounds x="1430" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_16umj30_di" bpmnElement="Event_1e4bwip"> + <dc:Bounds x="1332" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0nxf0rv_di" bpmnElement="Gateway_0nxf0rv" isMarkerVisible="true"> + <dc:Bounds x="1325" y="96" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1320" y="66" width="71" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_14iwa8x_di" bpmnElement="Activity_14iwa8x"> + <dc:Bounds x="1150" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_16z66xm_di" bpmnElement="Activity_16z66xm"> + <dc:Bounds x="1150" y="230" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_0rbb817_di" bpmnElement="Event_0rbb817"> + <dc:Bounds x="1052" y="143" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1000" y="183" width="60" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/META-INF/services/org.onap.so.client.RestProperties new file mode 100644 index 0000000000..9d9ba7371a --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/META-INF/services/org.onap.so.client.RestProperties @@ -0,0 +1 @@ +org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiPropertiesImpl
\ No newline at end of file diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/MonitorSol003AdapterCreateJob.bpmn b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/MonitorSol003AdapterCreateJob.bpmn new file mode 100644 index 0000000000..a9204ec442 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/MonitorSol003AdapterCreateJob.bpmn @@ -0,0 +1,160 @@ +<?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_12gnsyw" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> + <bpmn:process id="MonitorSol003AdapterCreateJob" name="MonitorSol003AdapterCreateJob" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>SequenceFlow_1x3tbl0</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_0rf1gde"> + <bpmn:incoming>SequenceFlow_1543qy7</bpmn:incoming> + </bpmn:endEvent> + <bpmn:subProcess id="SubProcess_19j0v63"> + <bpmn:incoming>SequenceFlow_1x3tbl0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1v4yr3f</bpmn:outgoing> + <bpmn:startEvent id="StartEvent_01r97z2"> + <bpmn:outgoing>SequenceFlow_0s1plu9</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_1hkl6yy" default="SequenceFlow_1vmxw9g"> + <bpmn:incoming>SequenceFlow_153a3kp</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1vmxw9g</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0is7myf</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_1besn3n" name="Wait between checks" camunda:asyncAfter="true"> + <bpmn:incoming>SequenceFlow_1vmxw9g</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0etw572</bpmn:outgoing> + <bpmn:timerEventDefinition id="TimerEventDefinition_0qgh11t"> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT15S</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:intermediateCatchEvent> + <bpmn:endEvent id="EndEvent_1ohsce9"> + <bpmn:incoming>SequenceFlow_0is7myf</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0s1plu9" sourceRef="StartEvent_01r97z2" targetRef="ServiceTask_17jlnng" /> + <bpmn:sequenceFlow id="SequenceFlow_0etw572" sourceRef="IntermediateCatchEvent_1besn3n" targetRef="ServiceTask_17jlnng" /> + <bpmn:serviceTask id="ServiceTask_17jlnng" name=" Get Current Operation Status " camunda:asyncAfter="true" camunda:expression="${MonitorSol003AdapterCreateJobTask.getCurrentOperationStatus(execution)}"> + <bpmn:incoming>SequenceFlow_0etw572</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0s1plu9</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_153a3kp</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1vmxw9g" sourceRef="ExclusiveGateway_1hkl6yy" targetRef="IntermediateCatchEvent_1besn3n" /> + <bpmn:sequenceFlow id="SequenceFlow_0is7myf" sourceRef="ExclusiveGateway_1hkl6yy" targetRef="EndEvent_1ohsce9"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${MonitorSol003AdapterCreateJobTask.hasOperationFinished(execution)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_153a3kp" sourceRef="ServiceTask_17jlnng" targetRef="ExclusiveGateway_1hkl6yy" /> + </bpmn:subProcess> + <bpmn:endEvent id="EndEvent_1w3t3t0" name="Timeout Exception"> + <bpmn:incoming>SequenceFlow_0bcgtzj</bpmn:incoming> + <bpmn:terminateEventDefinition id="TerminateEventDefinition_0fjecl3" /> + </bpmn:endEvent> + <bpmn:boundaryEvent id="BoundaryEvent_0xiabzp" name="Overall Wait" attachedToRef="SubProcess_19j0v63"> + <bpmn:outgoing>SequenceFlow_1i1o9sh</bpmn:outgoing> + <bpmn:timerEventDefinition id="TimerEventDefinition_10kqw61"> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT3H</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:boundaryEvent> + <bpmn:sequenceFlow id="SequenceFlow_1v4yr3f" sourceRef="SubProcess_19j0v63" targetRef="ServiceTask_1gms128" /> + <bpmn:sequenceFlow id="SequenceFlow_1i1o9sh" sourceRef="BoundaryEvent_0xiabzp" targetRef="ServiceTask_1s87b92" /> + <bpmn:sequenceFlow id="SequenceFlow_1x3tbl0" sourceRef="StartEvent_1" targetRef="SubProcess_19j0v63" /> + <bpmn:serviceTask id="ServiceTask_1s87b92" name=" Time Out Log Failure " camunda:asyncAfter="true" camunda:expression="${MonitorSol003AdapterCreateJobTask.timeOutLogFailue(execution)}"> + <bpmn:incoming>SequenceFlow_1i1o9sh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0bcgtzj</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0bcgtzj" sourceRef="ServiceTask_1s87b92" targetRef="EndEvent_1w3t3t0" /> + <bpmn:serviceTask id="ServiceTask_1gms128" name=" Check if operation was successful " camunda:asyncAfter="true" camunda:expression="${MonitorSol003AdapterCreateJobTask.checkIfOperationWasSuccessful(execution)}"> + <bpmn:incoming>SequenceFlow_1v4yr3f</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1543qy7</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1543qy7" sourceRef="ServiceTask_1gms128" targetRef="EndEvent_0rf1gde" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="MonitorSol003AdapterCreateJob"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="161" y="330" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0rf1gde_di" bpmnElement="EndEvent_0rf1gde"> + <dc:Bounds x="1102" y="100" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_19j0v63_di" bpmnElement="SubProcess_19j0v63" isExpanded="true"> + <dc:Bounds x="301" y="248" width="523" height="200" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1w3t3t0_di" bpmnElement="EndEvent_1w3t3t0"> + <dc:Bounds x="1102" y="322" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1095" y="282" width="49" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="BoundaryEvent_0xiabzp_di" bpmnElement="BoundaryEvent_0xiabzp"> + <dc:Bounds x="806" y="322" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="794" y="361" width="61" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1v4yr3f_di" bpmnElement="SequenceFlow_1v4yr3f"> + <di:waypoint x="563" y="248" /> + <di:waypoint x="563" y="118" /> + <di:waypoint x="923" y="118" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1i1o9sh_di" bpmnElement="SequenceFlow_1i1o9sh"> + <di:waypoint x="842" y="340" /> + <di:waypoint x="923" y="340" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_01r97z2_di" bpmnElement="StartEvent_01r97z2"> + <dc:Bounds x="330" y="306" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1hkl6yy_di" bpmnElement="ExclusiveGateway_1hkl6yy" isMarkerVisible="true"> + <dc:Bounds x="609" y="299" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_1besn3n_di" bpmnElement="IntermediateCatchEvent_1besn3n"> + <dc:Bounds x="550" y="378" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="537" y="421" width="66" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1ohsce9_di" bpmnElement="EndEvent_1ohsce9"> + <dc:Bounds x="722" y="306" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1x3tbl0_di" bpmnElement="SequenceFlow_1x3tbl0"> + <di:waypoint x="197" y="348" /> + <di:waypoint x="301" y="348" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_17jlnng_di" bpmnElement="ServiceTask_17jlnng"> + <dc:Bounds x="425" y="284" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0s1plu9_di" bpmnElement="SequenceFlow_0s1plu9"> + <di:waypoint x="366" y="324" /> + <di:waypoint x="425" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0etw572_di" bpmnElement="SequenceFlow_0etw572"> + <di:waypoint x="550" y="396" /> + <di:waypoint x="486" y="396" /> + <di:waypoint x="486" y="367" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1vmxw9g_di" bpmnElement="SequenceFlow_1vmxw9g"> + <di:waypoint x="634" y="349" /> + <di:waypoint x="634" y="396" /> + <di:waypoint x="586" y="396" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0is7myf_di" bpmnElement="SequenceFlow_0is7myf"> + <di:waypoint x="659" y="324" /> + <di:waypoint x="722" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_153a3kp_di" bpmnElement="SequenceFlow_153a3kp"> + <di:waypoint x="525" y="324" /> + <di:waypoint x="609" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1s87b92_di" bpmnElement="ServiceTask_1s87b92"> + <dc:Bounds x="923" y="300" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0bcgtzj_di" bpmnElement="SequenceFlow_0bcgtzj"> + <di:waypoint x="1023" y="340" /> + <di:waypoint x="1102" y="340" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1gms128_di" bpmnElement="ServiceTask_1gms128"> + <dc:Bounds x="923" y="78" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1543qy7_di" bpmnElement="SequenceFlow_1543qy7"> + <di:waypoint x="1023" y="118" /> + <di:waypoint x="1102" y="118" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/MonitorSol003AdapterCreateNodeStatus.bpmn b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/MonitorSol003AdapterCreateNodeStatus.bpmn new file mode 100644 index 0000000000..c0de5e0352 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/resources/MonitorSol003AdapterCreateNodeStatus.bpmn @@ -0,0 +1,138 @@ +<?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_1ko0frn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> + <bpmn:process id="MonitorSol003AdapterCreateNodeStatus" name="MonitorSol003AdapterCreateNodeStatus" isExecutable="true"> + <bpmn:startEvent id="StartEvent_0k0qfjb"> + <bpmn:outgoing>SequenceFlow_1miob62</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:subProcess id="SubProcess_10wotbc"> + <bpmn:incoming>SequenceFlow_1miob62</bpmn:incoming> + <bpmn:startEvent id="StartEvent_0r9qf43"> + <bpmn:outgoing>SequenceFlow_1moaz0q</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_00xtlfj" default="SequenceFlow_1luu31f"> + <bpmn:incoming>SequenceFlow_0qvy3sn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1rxbeqi</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1luu31f</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_0xuznv9" name="Wait between checks" camunda:asyncAfter="true"> + <bpmn:incoming>SequenceFlow_1luu31f</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_09t51ao</bpmn:outgoing> + <bpmn:timerEventDefinition id="TimerEventDefinition_0vrbrge"> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT15S</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:intermediateCatchEvent> + <bpmn:endEvent id="EndEvent_0tei3i9"> + <bpmn:incoming>SequenceFlow_1rxbeqi</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="ServiceTask_0y71su8" name=" Get node status " camunda:asyncAfter="true" camunda:expression="${MonitorInstantiateSol003AdapterNodeTask.getNodeStatus(execution)}"> + <bpmn:incoming>SequenceFlow_1moaz0q</bpmn:incoming> + <bpmn:incoming>SequenceFlow_09t51ao</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0qvy3sn</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1rxbeqi" name=" create vnf success " sourceRef="ExclusiveGateway_00xtlfj" targetRef="EndEvent_0tei3i9"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("createVnfNodeStatus")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1luu31f" sourceRef="ExclusiveGateway_00xtlfj" targetRef="IntermediateCatchEvent_0xuznv9" /> + <bpmn:sequenceFlow id="SequenceFlow_1moaz0q" sourceRef="StartEvent_0r9qf43" targetRef="ServiceTask_0y71su8" /> + <bpmn:sequenceFlow id="SequenceFlow_0qvy3sn" sourceRef="ServiceTask_0y71su8" targetRef="ExclusiveGateway_00xtlfj" /> + <bpmn:sequenceFlow id="SequenceFlow_09t51ao" sourceRef="IntermediateCatchEvent_0xuznv9" targetRef="ServiceTask_0y71su8" /> + </bpmn:subProcess> + <bpmn:endEvent id="EndEvent_1b83rci" name="Timeout Exception"> + <bpmn:incoming>SequenceFlow_0uiqnl8</bpmn:incoming> + <bpmn:terminateEventDefinition id="TerminateEventDefinition_12rjfva" /> + </bpmn:endEvent> + <bpmn:serviceTask id="ServiceTask_12qp0ty" name=" Time Out Log Failure " camunda:asyncAfter="true" camunda:expression="${MonitorSol003AdapterNodeTask.timeOutLogFailue(execution)}"> + <bpmn:incoming>SequenceFlow_0qcc5x4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0uiqnl8</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:boundaryEvent id="BoundaryEvent_1f5o5i9" name="Overall Wait" attachedToRef="SubProcess_10wotbc"> + <bpmn:outgoing>SequenceFlow_0qcc5x4</bpmn:outgoing> + <bpmn:timerEventDefinition id="TimerEventDefinition_1t3ya63"> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT3H</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:boundaryEvent> + <bpmn:sequenceFlow id="SequenceFlow_1miob62" sourceRef="StartEvent_0k0qfjb" targetRef="SubProcess_10wotbc" /> + <bpmn:sequenceFlow id="SequenceFlow_0uiqnl8" sourceRef="ServiceTask_12qp0ty" targetRef="EndEvent_1b83rci" /> + <bpmn:sequenceFlow id="SequenceFlow_0qcc5x4" sourceRef="BoundaryEvent_1f5o5i9" targetRef="ServiceTask_12qp0ty" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="MonitorSol003AdapterCreateNodeStatus"> + <bpmndi:BPMNShape id="StartEvent_0k0qfjb_di" bpmnElement="StartEvent_0k0qfjb"> + <dc:Bounds x="155" y="159" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_10wotbc_di" bpmnElement="SubProcess_10wotbc" isExpanded="true"> + <dc:Bounds x="293" y="77" width="523" height="200" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1b83rci_di" bpmnElement="EndEvent_1b83rci"> + <dc:Bounds x="1096" y="151" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1089" y="111" width="49" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_12qp0ty_di" bpmnElement="ServiceTask_12qp0ty"> + <dc:Bounds x="917" y="129" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="BoundaryEvent_1f5o5i9_di" bpmnElement="BoundaryEvent_1f5o5i9"> + <dc:Bounds x="800" y="151" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="788" y="190" width="61" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1miob62_di" bpmnElement="SequenceFlow_1miob62"> + <di:waypoint x="191" y="177" /> + <di:waypoint x="293" y="177" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0uiqnl8_di" bpmnElement="SequenceFlow_0uiqnl8"> + <di:waypoint x="1017" y="169" /> + <di:waypoint x="1096" y="169" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qcc5x4_di" bpmnElement="SequenceFlow_0qcc5x4"> + <di:waypoint x="836" y="169" /> + <di:waypoint x="917" y="169" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_0r9qf43_di" bpmnElement="StartEvent_0r9qf43"> + <dc:Bounds x="324" y="135" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_00xtlfj_di" bpmnElement="ExclusiveGateway_00xtlfj" isMarkerVisible="true"> + <dc:Bounds x="603" y="128" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_0xuznv9_di" bpmnElement="IntermediateCatchEvent_0xuznv9"> + <dc:Bounds x="544" y="207" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="532" y="250" width="66" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0tei3i9_di" bpmnElement="EndEvent_0tei3i9"> + <dc:Bounds x="716" y="135" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0y71su8_di" bpmnElement="ServiceTask_0y71su8"> + <dc:Bounds x="412" y="113" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1rxbeqi_di" bpmnElement="SequenceFlow_1rxbeqi"> + <di:waypoint x="653" y="153" /> + <di:waypoint x="716" y="153" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="660" y="135" width="50" height="80" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1luu31f_di" bpmnElement="SequenceFlow_1luu31f"> + <di:waypoint x="628" y="178" /> + <di:waypoint x="628" y="225" /> + <di:waypoint x="580" y="225" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1moaz0q_di" bpmnElement="SequenceFlow_1moaz0q"> + <di:waypoint x="360" y="153" /> + <di:waypoint x="412" y="153" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qvy3sn_di" bpmnElement="SequenceFlow_0qvy3sn"> + <di:waypoint x="512" y="153" /> + <di:waypoint x="603" y="153" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_09t51ao_di" bpmnElement="SequenceFlow_09t51ao"> + <di:waypoint x="544" y="225" /> + <di:waypoint x="451" y="225" /> + <di:waypoint x="452" y="193" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java new file mode 100644 index 0000000000..86f2879966 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/BaseTest.java @@ -0,0 +1,150 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + +import static org.camunda.bpm.engine.history.HistoricProcessInstance.STATE_ACTIVE; +import static org.slf4j.LoggerFactory.getLogger; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.runner.RunWith; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import com.github.tomakehurst.wiremock.WireMockServer; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration +@AutoConfigureWireMock(port = 0) +public abstract class BaseTest { + protected static final String ETSI_CATALOG_URL = "http://modeling-etsicatalog.onap:8806/api"; + protected static final String SOL003_ADAPTER_ENDPOINT_URL = "https://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1"; + protected static final String GLOBAL_CUSTOMER_ID = UUID.randomUUID().toString(); + protected static final String NSD_INVARIANT_ID = UUID.randomUUID().toString(); + protected static final String SERVICE_TYPE = "NetworkService"; + protected static final String UUID_REGEX = + "[0-9a-zA-Z]{8}\\-[0-9a-zA-Z]{4}\\-[0-9a-zA-Z]{4}\\-[0-9a-zA-Z]{4}\\-[0-9a-zA-Z]{12}"; + protected static final String RANDOM_JOB_ID = UUID.randomUUID().toString(); + + protected static final Logger logger = getLogger(BaseTest.class); + + private static final long TIME_OUT_IN_SECONDS = 60; + private static final int SLEEP_TIME_IN_SECONDS = 5; + + @Autowired + private HistoryService historyService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + protected DatabaseServiceProvider databaseServiceProvider; + + @Autowired + protected WireMockServer wireMockServer; + + public NfvoJob createNewNfvoJob(final String jobAction, final String nsdId, final String nsName) { + final NfvoJob newJob = new NfvoJob().startTime(LocalDateTime.now()).jobType("NS").jobAction(JobAction.CREATE) + .status(JobStatusEnum.STARTING).resourceId(nsdId).resourceName(nsName); + databaseServiceProvider.addJob(newJob); + return newJob; + } + + public Optional<NfvoJob> getNfvoJob(final String jobId) { + return databaseServiceProvider.getJob(jobId); + } + + public Optional<NfvoJob> getJobByResourceId(final String resourceId) { + return databaseServiceProvider.getJobByResourceId(resourceId); + } + + public ProcessInstance executeWorkflow(final String processDefinitionKey, final String businessKey, + final Map<String, Object> variables) { + return runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey, variables); + } + + public HistoricProcessInstance getHistoricProcessInstance(final String processInstanceId) { + return historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); + } + + public HistoricVariableInstance getVariable(final String processInstanceId, final String name) { + return historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId) + .variableName(name).singleResult(); + } + + public List<HistoricVariableInstance> getVariables(final String processInstanceId) { + return historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list(); + } + + public boolean waitForProcessInstanceToFinish(final String processInstanceId) throws InterruptedException { + final long startTimeInMillis = System.currentTimeMillis(); + final long timeOutTime = startTimeInMillis + TimeUnit.SECONDS.toMillis(TIME_OUT_IN_SECONDS); + while (timeOutTime > System.currentTimeMillis()) { + + if (isProcessEndedByProcessInstanceId(processInstanceId)) { + logger.info("processInstanceId: {} is finished", processInstanceId); + return true; + } + logger.info("processInstanceId: {} is still running", processInstanceId); + logger.info("Process instance {} not finished yet, will try again in {} seconds", processInstanceId, + SLEEP_TIME_IN_SECONDS); + TimeUnit.SECONDS.sleep(SLEEP_TIME_IN_SECONDS); + } + logger.warn("Timeout {} process didn't finished ", processInstanceId); + return false; + } + + + public boolean isProcessEndedByProcessInstanceId(final String processInstanceId) { + return !isProcessInstanceActive(processInstanceId) && isProcessInstanceEnded(processInstanceId); + } + + private boolean isProcessInstanceActive(final String processInstanceId) { + final HistoricProcessInstance processInstance = getHistoricProcessInstance(processInstanceId); + return processInstance != null && STATE_ACTIVE.equalsIgnoreCase(processInstance.getState()); + } + + private boolean isProcessInstanceEnded(final String processInstanceId) { + return runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null; + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/DefaultToShortClassNameBeanNameGenerator.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/DefaultToShortClassNameBeanNameGenerator.java new file mode 100644 index 0000000000..f91cf9d0c3 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/DefaultToShortClassNameBeanNameGenerator.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.AnnotationBeanNameGenerator; +import org.springframework.util.ClassUtils; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class DefaultToShortClassNameBeanNameGenerator extends AnnotationBeanNameGenerator { + + @Override + protected String buildDefaultBeanName(final BeanDefinition definition) { + return ClassUtils.getShortName(definition.getBeanClassName()); + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/TestApplication.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/TestApplication.java new file mode 100644 index 0000000000..18d601930c --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/TestApplication.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.ComponentScan.Filter; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@SpringBootApplication(scanBasePackages = {"org.onap.so"}) +@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class}) +@ComponentScan(basePackages = {"org.onap"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) +public class TestApplication { + + public static void main(final String[] args) { + new SpringApplication(TestApplication.class).run(args); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParserTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParserTest.java new file mode 100644 index 0000000000..2bebf1c30a --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParserTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Map; +import java.util.Optional; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.TestApplication; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class NetworkServiceDescriptorParserTest { + + private static final String VALID_ETSI_NSD_FILE = "src/test/resources/ns.csar"; + private static final String INVALID_ETSI_NSD_FILE = "src/test/resources/invalid_ns.csar"; + + @Autowired + private NetworkServiceDescriptorParser objUnderTest; + + @Test + public void testValidEtsiNsd_ableToParseIt() throws IOException { + final byte[] zipBytes = Files.readAllBytes(Paths.get(getAbsolutePath(VALID_ETSI_NSD_FILE))); + final Optional<NetworkServiceDescriptor> optional = objUnderTest.parse(zipBytes); + assertTrue(optional.isPresent()); + final NetworkServiceDescriptor actualNsd = optional.get(); + assertEquals(NetworkServiceDescriptorParser.NS_NODE_TYPE, actualNsd.getType()); + assertFalse(actualNsd.getProperties().isEmpty()); + + final Map<String, Object> actualNsdProperties = actualNsd.getProperties(); + assertEquals(5, actualNsdProperties.size()); + assertEquals("ffdddc5d-a44b-45ae-8fc3-e6551cce350f", actualNsdProperties.get("descriptor_id")); + assertEquals(5, actualNsd.getVnfs().size()); + + } + + @Test + public void testEmptyEtsiNsd_returnEmptyOptional() throws IOException { + assertFalse(objUnderTest.parse(new byte[] {}).isPresent()); + } + + @Test + public void testInvalidEtsiNsd_returnEmptyOptional() throws IOException { + final byte[] zipBytes = Files.readAllBytes(Paths.get(getAbsolutePath(INVALID_ETSI_NSD_FILE))); + assertFalse(objUnderTest.parse(zipBytes).isPresent()); + } + + private String getAbsolutePath(final String path) { + final File file = new File(path); + return file.getAbsolutePath(); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/CreateNsTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/CreateNsTaskTest.java new file mode 100644 index 0000000000..05213a344f --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/CreateNsTaskTest.java @@ -0,0 +1,387 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.workflow.engine.tasks; + +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.notFound; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_REST_TEMPLATE_BEAN; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.NsdInfo; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.BaseTest; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.NsRequestProcessingException; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service.JobExecutorService; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service.WorkflowQueryService; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; +import org.onap.so.etsi.nfvo.ns.lcm.model.CreateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance.NsStateEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.GsonHttpMessageConverter; +import org.springframework.test.web.client.MockRestServiceServer; +import org.springframework.web.client.RestTemplate; +import com.github.tomakehurst.wiremock.client.WireMock; +import com.google.gson.Gson; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class CreateNsTaskTest extends BaseTest { + private static final String NSD_ID = UUID.randomUUID().toString(); + private static final String NS_NAME = "CreateNetworkService-" + NSD_ID; + private static final String CREATE_NS_WORKFLOW_NAME = "CreateNs"; + + @Autowired + @Qualifier(ETSI_CATALOG_REST_TEMPLATE_BEAN) + private RestTemplate restTemplate; + + @Autowired + private GsonProvider gsonProvider; + + @Autowired + private JobExecutorService objUnderTest; + + @Autowired + private WorkflowQueryService workflowQueryService; + + private MockRestServiceServer mockRestServiceServer; + + private Gson gson; + + @Before + public void before() { + wireMockServer.resetAll(); + final MockRestServiceServer.MockRestServiceServerBuilder builder = MockRestServiceServer.bindTo(restTemplate); + builder.ignoreExpectOrder(true); + mockRestServiceServer = builder.build(); + gson = gsonProvider.getGson(); + restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + } + + @After + public void after() { + wireMockServer.resetAll(); + mockRestServiceServer.reset(); + } + + @Test + public void testCreateNsWorkflow_SuccessfullCase() throws InterruptedException { + final CreateNsRequest createNsRequest = getCreateNsRequest(); + + mockEtsiCatalogEndpoints(); + mockAAIEndpoints(createNsRequest); + + final NsInstancesNsInstance nsResponse = + objUnderTest.runCreateNsJob(createNsRequest, GLOBAL_CUSTOMER_ID, SERVICE_TYPE); + assertNotNull(nsResponse); + assertNotNull(nsResponse.getId()); + + final Optional<NfvoJob> optional = getJobByResourceId(createNsRequest.getNsdId()); + assertTrue(optional.isPresent()); + final NfvoJob nfvoJob = optional.get(); + + assertTrue(waitForProcessInstanceToFinish(nfvoJob.getProcessInstanceId())); + + mockRestServiceServer.verify(); + final HistoricProcessInstance historicProcessInstance = + getHistoricProcessInstance(nfvoJob.getProcessInstanceId()); + assertNotNull(historicProcessInstance); + + assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState()); + assertTrue(databaseServiceProvider.isNsInstExists(createNsRequest.getNsName())); + + final NfvoJob actualJob = optional.get(); + assertEquals(JobStatusEnum.FINISHED, actualJob.getStatus()); + + assertEquals(NS_NAME, nsResponse.getNsInstanceName()); + assertEquals(NsStateEnum.NOT_INSTANTIATED, nsResponse.getNsState()); + + final HistoricVariableInstance doesNsPackageExistsVar = + getVariable(nfvoJob.getProcessInstanceId(), "doesNsPackageExists"); + assertNotNull(doesNsPackageExistsVar); + assertTrue((boolean) doesNsPackageExistsVar.getValue()); + + final HistoricVariableInstance doesNsInstanceExistsVar = + getVariable(nfvoJob.getProcessInstanceId(), "doesNsInstanceExists"); + assertNotNull(doesNsInstanceExistsVar); + assertFalse((boolean) doesNsInstanceExistsVar.getValue()); + + } + + @Test + public void testCreateNsWorkflow_FailsToGetNsPackage() throws InterruptedException { + final String nsdId = UUID.randomUUID().toString(); + final String nsdName = NS_NAME + "-" + System.currentTimeMillis(); + final CreateNsRequest createNsRequest = getCreateNsRequest(nsdId, nsdName); + + mockRestServiceServer.expect(requestTo(ETSI_CATALOG_URL + "/nsd/v1/ns_descriptors/" + nsdId)) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.NOT_FOUND)); + + try { + objUnderTest.runCreateNsJob(createNsRequest, GLOBAL_CUSTOMER_ID, SERVICE_TYPE); + fail("runCreateNsJob should throw exception"); + } catch (final Exception exception) { + assertEquals(NsRequestProcessingException.class, exception.getClass()); + } + + final Optional<NfvoJob> optional = getJobByResourceId(createNsRequest.getNsdId()); + assertTrue(optional.isPresent()); + final NfvoJob nfvoJob = optional.get(); + assertEquals(JobStatusEnum.ERROR, nfvoJob.getStatus()); + + assertTrue(waitForProcessInstanceToFinish(nfvoJob.getProcessInstanceId())); + + mockRestServiceServer.verify(); + final HistoricProcessInstance historicProcessInstance = + getHistoricProcessInstance(nfvoJob.getProcessInstanceId()); + assertNotNull(historicProcessInstance); + + assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState()); + + + final HistoricVariableInstance nsResponseVariable = + getVariable(nfvoJob.getProcessInstanceId(), CamundaVariableNameConstants.CREATE_NS_RESPONSE_PARAM_NAME); + assertNull(nsResponseVariable); + + final Optional<InlineResponse400> problemDetailsOptional = + workflowQueryService.getProblemDetails(nfvoJob.getProcessInstanceId()); + assertTrue(problemDetailsOptional.isPresent()); + + final InlineResponse400 problemDetails = problemDetailsOptional.get(); + assertNotNull(problemDetails); + assertNotNull(problemDetails.getDetail()); + + final HistoricVariableInstance doesNsPackageExistsVar = + getVariable(nfvoJob.getProcessInstanceId(), "doesNsPackageExists"); + assertNotNull(doesNsPackageExistsVar); + assertFalse((boolean) doesNsPackageExistsVar.getValue()); + assertEquals("Unexpected exception occured while getting ns package using nsdId: " + nsdId, + problemDetails.getDetail()); + } + + @Test + public void testCreateNsWorkflow_FailsToFindJobUsingJobId() throws InterruptedException { + final String nsdId = UUID.randomUUID().toString(); + final String nsdName = NS_NAME + "-" + System.currentTimeMillis(); + final CreateNsRequest createNsRequest = getCreateNsRequest(nsdId, nsdName); + + final String randomJobId = UUID.randomUUID().toString(); + final ProcessInstance processInstance = + executeWorkflow(CREATE_NS_WORKFLOW_NAME, randomJobId, getVariables(randomJobId, createNsRequest)); + assertTrue(waitForProcessInstanceToFinish(processInstance.getProcessInstanceId())); + + mockRestServiceServer.verify(); + final HistoricProcessInstance historicProcessInstance = + getHistoricProcessInstance(processInstance.getProcessInstanceId()); + assertNotNull(historicProcessInstance); + + assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState()); + + final HistoricVariableInstance nsResponseVariable = getVariable(processInstance.getProcessInstanceId(), + CamundaVariableNameConstants.CREATE_NS_RESPONSE_PARAM_NAME); + + assertNull(nsResponseVariable); + + final HistoricVariableInstance workflowExceptionVariable = getVariable(processInstance.getProcessInstanceId(), + CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME); + + final InlineResponse400 problemDetails = (InlineResponse400) workflowExceptionVariable.getValue(); + assertNotNull(problemDetails); + assertNotNull(problemDetails.getDetail()); + assertEquals("Unable to find job using job id: " + randomJobId, problemDetails.getDetail()); + + } + + @Test + public void testCreateNsWorkflow_NsInstanceExistsInDb() throws InterruptedException { + final String nsdId = UUID.randomUUID().toString(); + final String nsdName = NS_NAME + "-" + System.currentTimeMillis(); + final CreateNsRequest createNsRequest = getCreateNsRequest(nsdId, nsdName); + + databaseServiceProvider.saveNfvoNsInst(new NfvoNsInst().nsInstId(nsdId).name(createNsRequest.getNsName()) + .nsPackageId(UUID.randomUUID().toString()).nsdId(nsdId).nsdInvariantId(nsdId) + .description(createNsRequest.getNsDescription()).status(State.INSTANTIATED) + .statusUpdatedTime(LocalDateTime.now()).globalCustomerId(GLOBAL_CUSTOMER_ID).serviceType(SERVICE_TYPE)); + + mockEtsiCatalogEndpoints(nsdId); + + try { + objUnderTest.runCreateNsJob(createNsRequest, GLOBAL_CUSTOMER_ID, SERVICE_TYPE); + fail("runCreateNsJob should throw exception"); + } catch (final Exception exception) { + assertEquals(NsRequestProcessingException.class, exception.getClass()); + } + + final Optional<NfvoJob> optional = getJobByResourceId(createNsRequest.getNsdId()); + assertTrue(optional.isPresent()); + final NfvoJob nfvoJob = optional.get(); + assertEquals(JobStatusEnum.ERROR, nfvoJob.getStatus()); + + assertTrue(waitForProcessInstanceToFinish(nfvoJob.getProcessInstanceId())); + + mockRestServiceServer.verify(); + final HistoricProcessInstance historicProcessInstance = + getHistoricProcessInstance(nfvoJob.getProcessInstanceId()); + assertNotNull(historicProcessInstance); + + assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState()); + assertTrue(databaseServiceProvider.isNsInstExists(createNsRequest.getNsName())); + + final HistoricVariableInstance historicVariableInstance = + getVariable(nfvoJob.getProcessInstanceId(), CamundaVariableNameConstants.CREATE_NS_RESPONSE_PARAM_NAME); + + assertNull(historicVariableInstance); + + final Optional<InlineResponse400> problemDetailsOptional = + workflowQueryService.getProblemDetails(nfvoJob.getProcessInstanceId()); + + final InlineResponse400 problemDetails = problemDetailsOptional.get(); + assertNotNull(problemDetails); + assertNotNull(problemDetails.getDetail()); + assertTrue(problemDetails.getDetail().startsWith("Ns Instance already exists in database")); + + final HistoricVariableInstance doesNsInstanceExistsVar = + getVariable(nfvoJob.getProcessInstanceId(), "doesNsInstanceExists"); + assertNotNull(doesNsInstanceExistsVar); + assertTrue((boolean) doesNsInstanceExistsVar.getValue()); + + } + + @Test + public void testCreateNsWorkflow_FailToCreateResouceInAai() throws InterruptedException { + final String nsdId = UUID.randomUUID().toString(); + final String nsdName = NS_NAME + "-" + System.currentTimeMillis(); + final CreateNsRequest createNsRequest = getCreateNsRequest(nsdId, nsdName); + + mockEtsiCatalogEndpoints(nsdId); + + final String modelEndpoint = getAiaServiceInstancelEndPoint(createNsRequest); + wireMockServer.stubFor(put(urlMatching(modelEndpoint)).willReturn(WireMock.serverError())); + wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(WireMock.serverError())); + + try { + objUnderTest.runCreateNsJob(createNsRequest, GLOBAL_CUSTOMER_ID, SERVICE_TYPE); + fail("runCreateNsJob should throw exception"); + } catch (final Exception exception) { + assertEquals(NsRequestProcessingException.class, exception.getClass()); + } + final Optional<NfvoJob> optional = getJobByResourceId(createNsRequest.getNsdId()); + assertTrue(optional.isPresent()); + final NfvoJob nfvoJob = optional.get(); + assertEquals(JobStatusEnum.ERROR, nfvoJob.getStatus()); + + mockRestServiceServer.verify(); + final HistoricProcessInstance historicProcessInstance = + getHistoricProcessInstance(nfvoJob.getProcessInstanceId()); + assertNotNull(historicProcessInstance); + + assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState()); + assertTrue(databaseServiceProvider.isNsInstExists(createNsRequest.getNsName())); + + final Optional<InlineResponse400> problemDetailsOptional = + workflowQueryService.getProblemDetails(nfvoJob.getProcessInstanceId()); + + final InlineResponse400 problemDetails = problemDetailsOptional.get(); + assertNotNull(problemDetails); + assertEquals("Unable to Create Service Instance in AAI", problemDetails.getDetail()); + + } + + private void mockAAIEndpoints(final CreateNsRequest createNsRequest) { + final String modelEndpoint = getAiaServiceInstancelEndPoint(createNsRequest); + + wireMockServer.stubFor(put(urlMatching(modelEndpoint)).willReturn(ok())); + wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(notFound())); + } + + private String getAiaServiceInstancelEndPoint(final CreateNsRequest createNsRequest) { + return "/aai/v[0-9]+/business/customers/customer/" + GLOBAL_CUSTOMER_ID + + "/service-subscriptions/service-subscription/" + SERVICE_TYPE + + "/service-instances/service-instance/.*"; + } + + private void mockEtsiCatalogEndpoints(final String nsdId) { + mockRestServiceServer.expect(requestTo(ETSI_CATALOG_URL + "/nsd/v1/ns_descriptors/" + nsdId)) + .andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess(gson.toJson(getNSPackageModel(NSD_ID)), MediaType.APPLICATION_JSON)); + } + + private void mockEtsiCatalogEndpoints() { + mockEtsiCatalogEndpoints(NSD_ID);; + } + + private NsdInfo getNSPackageModel(final String nsdId) { + return new NsdInfo().id(nsdId).nsdId(nsdId).nsdInvariantId(NSD_INVARIANT_ID).nsdName("vcpe").nsdDesigner("ONAP") + .vnfPkgIds(Arrays.asList(GLOBAL_CUSTOMER_ID)); + } + + private CreateNsRequest getCreateNsRequest() { + return getCreateNsRequest(NSD_ID, NS_NAME); + } + + private CreateNsRequest getCreateNsRequest(final String nsdId, final String nsName) { + return new CreateNsRequest().nsdId(nsdId).nsName(nsName); + } + + private Map<String, Object> getVariables(final String jobId, final CreateNsRequest createNsRequest) { + final Map<String, Object> variables = new HashMap<>(); + variables.put(CamundaVariableNameConstants.JOB_ID_PARAM_NAME, jobId); + variables.put(CamundaVariableNameConstants.CREATE_NS_REQUEST_PARAM_NAME, createNsRequest); + variables.put(CamundaVariableNameConstants.GLOBAL_CUSTOMER_ID_PARAM_NAME, GLOBAL_CUSTOMER_ID); + variables.put(CamundaVariableNameConstants.SERVICE_TYPE_PARAM_NAME, SERVICE_TYPE); + + return variables; + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/InstantiateNsTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/InstantiateNsTaskTest.java new file mode 100644 index 0000000000..00e9433eac --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/InstantiateNsTaskTest.java @@ -0,0 +1,327 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.workflow.engine.tasks; + +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.notFound; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.onap.aaiclient.client.aai.AAIVersion.V19; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NETWORK_SERVICE_DESCRIPTOR_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_REST_TEMPLATE_BEAN; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterConfiguration.SOL003_ADAPTER_REST_TEMPLATE_BEAN; +import static org.springframework.test.web.client.ExpectedCount.times; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.hamcrest.text.MatchesPattern; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.aaiclient.client.aai.entities.Results; +import org.onap.aaiclient.client.graphinventory.entities.Resource; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStatusRetrievalStatusEnum; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.NsdInfo; +import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.VnfPkgInfo; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.BaseTest; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service.JobExecutorService; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.model.InstantiateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.GsonHttpMessageConverter; +import org.springframework.test.web.client.MockRestServiceServer; +import org.springframework.web.client.RestTemplate; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; + +/** + * @author Andrew Lamb (andrew.a.lamb@est.tech) + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class InstantiateNsTaskTest extends BaseTest { + + private static final String TENANT_ID = "6ca8680feba04dad9254f423c6e28e1c"; + private static final String CLOUD_REGION = "regionOne"; + private static final String CLOUD_OWNER = "CloudOwner"; + private static final String UUID_REGEX = + "[0-9a-zA-Z]{8}\\-[0-9a-zA-Z]{4}\\-[0-9a-zA-Z]{4}\\-[0-9a-zA-Z]{4}\\-[0-9a-zA-Z]{12}"; + private static final String VCPE_VBRGEMU_VNFD_ID = "b1bb0ce7-2222-4fa7-95ed-4840d70a1102"; + private static final String VCPE_VBNG = "b1bb0ce7-2222-4fa7-95ed-4840d70a1101"; + private static final String VCPE_INFRA_VNFD_ID = "b1bb0ce7-2222-4fa7-95ed-4840d70a1100"; + private static final String VGMUX_VNFD_ID = "0408f076-e6c0-4c82-9940-272fddbb82de"; + private static final String VGW_VNFD_ID = "3fca3543-07f5-492f-812c-ed462e4f94f4"; + private static final String[] VCPE_VNFDS = + new String[] {VGW_VNFD_ID, VGMUX_VNFD_ID, VCPE_INFRA_VNFD_ID, VCPE_VBNG, VCPE_VBRGEMU_VNFD_ID}; + private static final String SAMPLE_NSD_FILE = "src/test/resources/ns.csar"; + private static final String NS_NAME = "InstantiateNetworkService"; + + @Autowired + private DatabaseServiceProvider databaseServiceProvider; + + @Autowired + @Qualifier(ETSI_CATALOG_REST_TEMPLATE_BEAN) + private RestTemplate etsiCatalogRestTemplate; + + @Autowired + @Qualifier(SOL003_ADAPTER_REST_TEMPLATE_BEAN) + private RestTemplate sol003AdapterRestTemplate; + + private MockRestServiceServer mockEtsiCatalogRestServiceServer; + + private MockRestServiceServer mockSol003AdapterRestServiceServer; + + @Autowired + private JobExecutorService objUnderTest; + + @Autowired + private GsonProvider gsonProvider; + + private Gson gson; + + private static final Map<String, String> VNFD_ID_TO_VNFPKG_ID_MAPPING = new HashMap<>(); + static { + for (final String vnfd : VCPE_VNFDS) { + VNFD_ID_TO_VNFPKG_ID_MAPPING.put(vnfd, UUID.randomUUID().toString()); + } + } + + @Before + public void before() { + wireMockServer.resetAll(); + gson = gsonProvider.getGson(); + + mockEtsiCatalogRestServiceServer = + MockRestServiceServer.bindTo(etsiCatalogRestTemplate).ignoreExpectOrder(true).build(); + mockSol003AdapterRestServiceServer = + MockRestServiceServer.bindTo(sol003AdapterRestTemplate).ignoreExpectOrder(true).build(); + + etsiCatalogRestTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + sol003AdapterRestTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + + } + + @After + public void after() { + wireMockServer.resetAll(); + mockEtsiCatalogRestServiceServer.reset(); + } + + @Test + public void testInstantiateNsWorkflow_JustUpdateStatus_SuccessfullCase() throws InterruptedException, IOException { + final String nsdId = UUID.randomUUID().toString(); + final String nsdName = NS_NAME + "-" + System.currentTimeMillis(); + + final NfvoNsInst newNfvoNsInst = new NfvoNsInst().nsInstId(nsdId).name(nsdName) + .nsPackageId(UUID.randomUUID().toString()).nsPackageId(nsdId).nsdId(nsdId).nsdInvariantId(nsdId) + .status(State.NOT_INSTANTIATED).statusUpdatedTime(LocalDateTime.now()); + + databaseServiceProvider.saveNfvoNsInst(newNfvoNsInst); + + mockSol003AdapterEndpoints(); + mockAAIEndpoints(nsdId); + mockEtsiCatalogEndpoints(nsdId); + + final String nsLcmOpOccId = + objUnderTest.runInstantiateNsJob(newNfvoNsInst.getNsInstId(), getInstantiateNsRequest()); + + final Optional<NfvoJob> optional = getJobByResourceId(newNfvoNsInst.getNsInstId()); + assertTrue(optional.isPresent()); + final NfvoJob nfvoJob = optional.get(); + + assertTrue(waitForProcessInstanceToFinish(nfvoJob.getProcessInstanceId())); + + final HistoricProcessInstance historicProcessInstance = + getHistoricProcessInstance(nfvoJob.getProcessInstanceId()); + assertNotNull(historicProcessInstance); + + assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState()); + + // check if value in database has updated + final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsdId); + final NfvoNsInst nfvoNsInst = optionalNfvoNsInst.get(); + assertEquals(State.INSTANTIATED, nfvoNsInst.getStatus()); + + final HistoricVariableInstance historicVariableInstance = + getVariable(nfvoJob.getProcessInstanceId(), NETWORK_SERVICE_DESCRIPTOR_PARAM_NAME); + assertNotNull(historicVariableInstance); + final NetworkServiceDescriptor nsd = (NetworkServiceDescriptor) historicVariableInstance.getValue(); + assertNotNull(nsd); + + assertEquals(VNFD_ID_TO_VNFPKG_ID_MAPPING.size(), nsd.getVnfs().size()); + + final List<NfvoNfInst> nfvoNfInsts = databaseServiceProvider.getNfvoNfInstByNsInstId(nsdId); + assertNotNull(nsd); + assertEquals(VNFD_ID_TO_VNFPKG_ID_MAPPING.size(), nfvoNfInsts.size()); + + final Optional<NsLcmOpOcc> optionalNsLcmOpOcc = databaseServiceProvider.getNsLcmOpOcc(nsLcmOpOccId); + assertTrue(optionalNsLcmOpOcc.isPresent()); + + assertEquals(OperationStateEnum.COMPLETED, optionalNsLcmOpOcc.get().getOperationState()); + + final Map<String, NfvoNfInst> nfvoNfInstsMap = + nfvoNfInsts.stream().collect(Collectors.toMap(NfvoNfInst::getVnfdId, nfvoNfInst -> nfvoNfInst)); + + for (final Entry<String, String> entry : VNFD_ID_TO_VNFPKG_ID_MAPPING.entrySet()) { + assertTrue(nfvoNfInstsMap.containsKey(entry.getKey())); + assertEquals(State.INSTANTIATED, nfvoNfInstsMap.get(entry.getKey()).getStatus()); + + } + + } + + private void mockSol003AdapterEndpoints() { + mockSol003AdapterRestServiceServer + .expect(times(VNFD_ID_TO_VNFPKG_ID_MAPPING.size()), + requestTo(MatchesPattern.matchesPattern(SOL003_ADAPTER_ENDPOINT_URL + "/vnfs/.*"))) + .andExpect(method(HttpMethod.POST)) + .andRespond(withSuccess(gson.toJson(new CreateVnfResponse().jobId(UUID.randomUUID().toString())), + MediaType.APPLICATION_JSON)); + + mockSol003AdapterRestServiceServer + .expect(times(VNFD_ID_TO_VNFPKG_ID_MAPPING.size()), + requestTo(MatchesPattern.matchesPattern(SOL003_ADAPTER_ENDPOINT_URL + "/jobs/.*"))) + .andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess(gson.toJson( + new org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse().operationState( + org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum.COMPLETED) + .operationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND)), + MediaType.APPLICATION_JSON)); + } + + private void mockEtsiCatalogEndpoints(final String nsdId) throws IOException { + mockEtsiCatalogRestServiceServer.expect(requestTo(ETSI_CATALOG_URL + "/nsd/v1/ns_descriptors/" + nsdId)) + .andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess(gson.toJson(getNSPackageModel(nsdId)), MediaType.APPLICATION_JSON)); + mockEtsiCatalogRestServiceServer + .expect(requestTo(ETSI_CATALOG_URL + "/nsd/v1/ns_descriptors/" + nsdId + "/nsd_content")) + .andExpect(method(HttpMethod.GET)).andRespond(withSuccess( + getFileContent(getAbsolutePath(SAMPLE_NSD_FILE)), MediaType.APPLICATION_OCTET_STREAM)); + + for (final Entry<String, String> entry : VNFD_ID_TO_VNFPKG_ID_MAPPING.entrySet()) { + mockEtsiCatalogRestServiceServer + .expect(requestTo(ETSI_CATALOG_URL + "/vnfpkgm/v1/vnf_packages/" + entry.getValue())) + .andExpect(method(HttpMethod.GET)).andRespond(withSuccess( + gson.toJson(getVnfPkgInfo(entry.getKey(), entry.getValue())), MediaType.APPLICATION_JSON)); + } + + } + + private VnfPkgInfo getVnfPkgInfo(final String vnfdId, final String vnfPkgId) { + return new VnfPkgInfo().id(vnfPkgId).vnfdId(vnfdId); + } + + private InstantiateNsRequest getInstantiateNsRequest() { + final Map<String, Object> additionalParams = new HashMap<>(); + additionalParams.put("vim_id", CLOUD_OWNER + "_" + CLOUD_REGION + "_" + TENANT_ID); + + final InstantiateNsRequest instantiateNsRequest = new InstantiateNsRequest().nsFlavourId("default"); + + for (final Entry<String, String> entry : VNFD_ID_TO_VNFPKG_ID_MAPPING.entrySet()) { + instantiateNsRequest + .addAdditionalParamsForVnfItem(new NsInstancesnsInstanceIdinstantiateAdditionalParamsForVnf() + .vnfProfileId(entry.getValue()).additionalParams(additionalParams)); + } + + return instantiateNsRequest; + } + + private NsdInfo getNSPackageModel(final String nsdId) { + return new NsdInfo().id(nsdId).nsdId(nsdId).nsdInvariantId(NSD_INVARIANT_ID).nsdName("vcpe").nsdDesigner("ONAP") + .vnfPkgIds(new ArrayList<>(VNFD_ID_TO_VNFPKG_ID_MAPPING.values())); + } + + private byte[] getFileContent(final String path) throws IOException { + return Files.readAllBytes(Paths.get(path)); + } + + + private String getAbsolutePath(final String path) { + return new File(path).getAbsolutePath(); + } + + private void mockAAIEndpoints(final String nsdId) throws JsonProcessingException { + final String modelEndpoint = "/aai/" + V19 + "/network/generic-vnfs/generic-vnf/" + UUID_REGEX; + + wireMockServer.stubFor( + get(urlMatching(modelEndpoint + "\\?resultIndex=0&resultSize=1&format=count")).willReturn(notFound())); + + wireMockServer.stubFor(put(urlMatching(modelEndpoint)).willReturn(ok())); + wireMockServer.stubFor(put(urlMatching(modelEndpoint + "/relationship-list/relationship")).willReturn(ok())); + + wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(ok()) + .willReturn(okJson("{\"orchestration-status\": \"Created\"}"))); + + wireMockServer.stubFor(get(urlMatching("/aai/" + V19 + "/nodes/service-instances/service-instance/.*")) + .willReturn(okJson(getResourceResultsResponseAsJson(nsdId)))); + + wireMockServer.stubFor( + put(urlMatching("/aai/" + V19 + "/cloud-infrastructure/cloud-regions/cloud-region/" + CLOUD_OWNER + "/" + + CLOUD_REGION + "/tenants/tenant/" + TENANT_ID + "/relationship-list/relationship")) + .willReturn(ok())); + + } + + private String getResourceResultsResponseAsJson(final String nsdId) throws JsonProcessingException { + final Resource resource = new Resource(); + resource.setResourceType("service-instance"); + resource.setResourceLink("/aai/" + V19 + "/business/customers/customer/" + GLOBAL_CUSTOMER_ID + + "/service-subscriptions/service-subscription/NetworkService/service-instances/service-instance/" + + nsdId); + final Results<Resource> results = new Results<>(); + results.getResult().add(resource); + return new ObjectMapper().writeValueAsString(results); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorInstantiateSol003AdapterNodeTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorInstantiateSol003AdapterNodeTaskTest.java new file mode 100644 index 0000000000..ea720cd73b --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorInstantiateSol003AdapterNodeTaskTest.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.workflow.engine.tasks; + +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.BaseTest; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks.MonitorInstantiateSol003AdapterNodeTask; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class MonitorInstantiateSol003AdapterNodeTaskTest extends BaseTest { + + private static final String RANDOWM_GENERIC_VNF_ID = UUID.randomUUID().toString(); + private static final String MONITOR_SOL003_ADAPTER_CREATE_NODE_STATUS_WORKFLOW = + "MonitorSol003AdapterCreateNodeStatus"; + + @Before + public void before() { + wireMockServer.resetAll(); + } + + @Test + public void testMonitorSol003AdapterCreateNodeStatus_SuccessfullCase() throws InterruptedException { + + final String modelEndpoint = "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + UUID_REGEX; + + wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(ok()) + .willReturn(okJson("{\"orchestration-status\": \"Created\"}"))); + + + final ProcessInstance processInstance = executeWorkflow(MONITOR_SOL003_ADAPTER_CREATE_NODE_STATUS_WORKFLOW, + RANDOM_JOB_ID, getVariables(RANDOM_JOB_ID, RANDOWM_GENERIC_VNF_ID)); + + assertTrue(waitForProcessInstanceToFinish(processInstance.getProcessInstanceId())); + + final HistoricProcessInstance historicProcessInstance = + getHistoricProcessInstance(processInstance.getProcessInstanceId()); + assertNotNull(historicProcessInstance); + + assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState()); + + final HistoricVariableInstance nsResponseVariable = getVariable(processInstance.getProcessInstanceId(), + MonitorInstantiateSol003AdapterNodeTask.CREATE_VNF_NODE_STATUS); + + assertNotNull(nsResponseVariable); + assertTrue((boolean) nsResponseVariable.getValue()); + + } + + private Map<String, Object> getVariables(final String jobId, final String vnfId) { + final Map<String, Object> variables = new HashMap<>(); + variables.put(CamundaVariableNameConstants.JOB_ID_PARAM_NAME, jobId); + variables.put(CamundaVariableNameConstants.NF_INST_ID_PARAM_NAME, vnfId); + + return variables; + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorSol003AdapterCreateJobTaskTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorSol003AdapterCreateJobTaskTest.java new file mode 100644 index 0000000000..ff5c2a9105 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/workflow/engine/tasks/MonitorSol003AdapterCreateJobTaskTest.java @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.workflow.engine.tasks; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum.COMPLETED; +import static org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStatusRetrievalStatusEnum.STATUS_FOUND; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterConfiguration.SOL003_ADAPTER_REST_TEMPLATE_BEAN; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; +import java.util.HashMap; +import java.util.Map; +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.BaseTest; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.GsonHttpMessageConverter; +import org.springframework.test.web.client.MockRestServiceServer; +import org.springframework.web.client.RestTemplate; +import com.google.gson.Gson; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class MonitorSol003AdapterCreateJobTaskTest extends BaseTest { + + private static final String MONITOR_SOL003_ADAPTER_CREATE_JOB_WORKFLOW = "MonitorSol003AdapterCreateJob"; + + @Autowired + @Qualifier(SOL003_ADAPTER_REST_TEMPLATE_BEAN) + private RestTemplate restTemplate; + + @Autowired + private GsonProvider gsonProvider; + + private MockRestServiceServer mockRestServiceServer; + private Gson gson; + + @Before + public void before() { + wireMockServer.resetAll(); + final MockRestServiceServer.MockRestServiceServerBuilder builder = MockRestServiceServer.bindTo(restTemplate); + builder.ignoreExpectOrder(true); + mockRestServiceServer = builder.build(); + + gson = gsonProvider.getGson(); + restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + } + + + @Test + public void testMonitorSol003AdapterCreateJobTaskWorkflow_SuccessfullCase() throws InterruptedException { + + mockRestServiceServer.expect(requestTo(SOL003_ADAPTER_ENDPOINT_URL + "/jobs/" + RANDOM_JOB_ID)) + .andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess(gson.toJson(getQueryJobResponse()), MediaType.APPLICATION_JSON)); + + final ProcessInstance processInstance = executeWorkflow(MONITOR_SOL003_ADAPTER_CREATE_JOB_WORKFLOW, + RANDOM_JOB_ID, getVariables(RANDOM_JOB_ID, new CreateVnfResponse().jobId(RANDOM_JOB_ID))); + + assertTrue(waitForProcessInstanceToFinish(processInstance.getProcessInstanceId())); + + final HistoricProcessInstance historicProcessInstance = + getHistoricProcessInstance(processInstance.getProcessInstanceId()); + assertNotNull(historicProcessInstance); + + assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState()); + + final HistoricVariableInstance nsResponseVariable = getVariable(processInstance.getProcessInstanceId(), + CamundaVariableNameConstants.OPERATION_STATUS_PARAM_NAME); + + assertNotNull(nsResponseVariable); + assertEquals(COMPLETED, nsResponseVariable.getValue()); + + } + + @Test + public void testMonitorSol003AdapterCreateJobTaskWorkflow_FailurelCase() throws InterruptedException { + + mockRestServiceServer.expect(requestTo(SOL003_ADAPTER_ENDPOINT_URL + "/jobs/" + RANDOM_JOB_ID)) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.NOT_FOUND)); + + final ProcessInstance processInstance = executeWorkflow(MONITOR_SOL003_ADAPTER_CREATE_JOB_WORKFLOW, + RANDOM_JOB_ID, getVariables(RANDOM_JOB_ID, new CreateVnfResponse().jobId(RANDOM_JOB_ID))); + + assertTrue(waitForProcessInstanceToFinish(processInstance.getProcessInstanceId())); + + final HistoricProcessInstance historicProcessInstance = + getHistoricProcessInstance(processInstance.getProcessInstanceId()); + assertNotNull(historicProcessInstance); + + assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState()); + + final HistoricVariableInstance nsResponseVariable = getVariable(processInstance.getProcessInstanceId(), + CamundaVariableNameConstants.OPERATION_STATUS_PARAM_NAME); + + assertNull(nsResponseVariable); + + final HistoricVariableInstance workflowExceptionVariable = getVariable(processInstance.getProcessInstanceId(), + CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME); + + final InlineResponse400 problemDetails = (InlineResponse400) workflowExceptionVariable.getValue(); + assertNotNull(problemDetails); + assertNotNull(problemDetails.getDetail()); + } + + + private QueryJobResponse getQueryJobResponse() { + return new QueryJobResponse().id(RANDOM_JOB_ID).operationState(COMPLETED) + .operationStatusRetrievalStatus(STATUS_FOUND); + } + + private Map<String, Object> getVariables(final String jobId, final CreateVnfResponse createVnfResponse) { + final Map<String, Object> variables = new HashMap<>(); + variables.put(CamundaVariableNameConstants.JOB_ID_PARAM_NAME, jobId); + variables.put(CamundaVariableNameConstants.CREATE_VNF_RESPONSE_PARAM_NAME, createVnfResponse); + + return variables; + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/application.yaml new file mode 100644 index 0000000000..1fabfbaac9 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/application.yaml @@ -0,0 +1,49 @@ +# Copyright © 2020 Nordix Foundation +# +# 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. +spring: + main: + allow-bean-definition-overriding: true + datasource: + hikari: + camunda: + jdbcUrl: jdbc:h2:mem:example-simple;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + driver-class-name: org.h2.Driver + pool-name: ns-lcm-bpmn-pool + registerMbeans: true + nfvo: + jdbcUrl: jdbc:h2:mem:nfvo;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS nfvo; + driver-class-name: org.h2.Driver + pool-name: ns-lcm-bpmn-pool + registerMbeans: true + jpa: + generate-ddl: true + hibernate: + ddl-auto: create +hibernate: + dialect: org.hibernate.dialect.H2Dialect + hbm2ddl: + auto: create +aai: + version: v19 + endpoint: http://localhost:${wiremock.server.port} +etsi-catalog-manager: + base: + endpoint: http://modeling-etsicatalog.onap:8806/api +so-etsi-ns-lcm-workflow-engine: + requesttimeout: + timeoutInSeconds: 60 + +logging: + level: + org.reflections.Reflections: ERROR
\ No newline at end of file diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/invalid_ns.csar b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/invalid_ns.csar Binary files differnew file mode 100644 index 0000000000..63bad965b7 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/invalid_ns.csar diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/ns.csar b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/ns.csar Binary files differnew file mode 100644 index 0000000000..eb19c762ae --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/resources/ns.csar diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/pom.xml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/pom.xml index 8e1fba43f0..e0439073bb 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/pom.xml +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/pom.xml @@ -8,4 +8,28 @@ </parent> <artifactId>so-etsi-nfvo-ns-lcm-database-service</artifactId> <name>SO ETSI NFVO NS LCM Database Service</name> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + </dependency> + <dependency> + <groupId>org.flywaydb</groupId> + <artifactId>flyway-core</artifactId> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> </project>
\ No newline at end of file diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyTokenProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/JobAction.java index 7c31d9288f..8a22689f8a 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyTokenProvider.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/JobAction.java @@ -1,29 +1,29 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. + * + * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; -package org.onap.so.cloudify.base.client; - -public interface CloudifyTokenProvider { - - String getToken(); - - void expireToken(); +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public enum JobAction { + CREATE, INSTANTIATE, TERMINATE, DELETE; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/JobStatusEnum.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/JobStatusEnum.java new file mode 100644 index 0000000000..c67a3cc692 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/JobStatusEnum.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public enum JobStatusEnum { + STARTING, STARTED, IN_PROGRESS, ERROR, FINISHED, FINISHED_WITH_ERROR; + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java new file mode 100644 index 0000000000..9453caac9e --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java @@ -0,0 +1,274 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; + +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils; + + +@Entity +@Table(name = "JOB") +public class NfvoJob { + + @Id + @Column(name = "JOB_ID") + private String jobId; + + @Column(name = "JOB_TYPE") + private String jobType; + + @Enumerated(EnumType.STRING) + @Column(name = "JOB_ACTION") + private JobAction jobAction; + + @Column(name = "RESOURCE_ID") + private String resourceId; + + @Column(name = "RESOURCE_NAME") + private String resourceName; + + @Enumerated(EnumType.STRING) + @Column(name = "STATUS") + private JobStatusEnum status; + + @Column(name = "START_TIME") + private LocalDateTime startTime; + + @Column(name = "END_TIME") + private LocalDateTime endTime; + + @Column(name = "PROGRESS") + private int progress; + + @Column(name = "PROCESS_INSTANCE_ID") + private String processInstanceId; + + @OneToMany(mappedBy = "nfvoJob", cascade = CascadeType.ALL, fetch = FetchType.EAGER) + private List<NfvoJobStatus> nfvoJobStatuses = new ArrayList<>(); + + public NfvoJob() { + this.jobId = UUID.randomUUID().toString(); + } + + public void setJobId(final String jobId) { + this.jobId = jobId; + } + + public String getJobId() { + return jobId; + } + + public NfvoJob jobId(final String jobId) { + this.jobId = jobId; + return this; + } + + public String getJobType() { + return jobType; + } + + public void setJobType(final String jobType) { + this.jobType = jobType; + } + + public NfvoJob jobType(final String jobType) { + this.jobType = jobType; + return this; + } + + public JobAction getJobAction() { + return jobAction; + } + + public void setJobAction(final JobAction jobAction) { + this.jobAction = jobAction; + } + + public NfvoJob jobAction(final JobAction jobAction) { + this.jobAction = jobAction; + return this; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(final String resourceId) { + this.resourceId = resourceId; + } + + public NfvoJob resourceId(final String resourceId) { + this.resourceId = resourceId; + return this; + } + + public JobStatusEnum getStatus() { + return status; + } + + public void setStatus(final JobStatusEnum status) { + this.status = status; + } + + public NfvoJob status(final JobStatusEnum status) { + this.status = status; + return this; + } + + public LocalDateTime getStartTime() { + return startTime; + } + + public void setStartTime(final LocalDateTime startTime) { + this.startTime = startTime; + } + + public NfvoJob startTime(final LocalDateTime startTime) { + this.startTime = startTime; + return this; + } + + public LocalDateTime getEndTime() { + return endTime; + } + + public void setEndTime(final LocalDateTime endTime) { + this.endTime = endTime; + } + + public NfvoJob endTime(final LocalDateTime endTime) { + this.endTime = endTime; + return this; + } + + public int getProgress() { + return progress; + } + + public void setProgress(final int progress) { + this.progress = progress; + } + + public NfvoJob progress(final int progress) { + this.progress = progress; + return this; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public void setProcessInstanceId(final String processInstanceId) { + this.processInstanceId = processInstanceId; + } + + public NfvoJob processInstanceId(final String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(final String resourceName) { + this.resourceName = resourceName; + } + + public NfvoJob resourceName(final String resourceName) { + this.resourceName = resourceName; + return this; + } + + public List<NfvoJobStatus> getNfvoJobStatuses() { + return nfvoJobStatuses; + } + + public void setJobStatuses(final List<NfvoJobStatus> nfvoJobStatuses) { + this.nfvoJobStatuses = nfvoJobStatuses; + } + + public NfvoJob nfvoJobStatuses(final List<NfvoJobStatus> nfvoJobStatuses) { + this.nfvoJobStatuses = nfvoJobStatuses; + return this; + } + + public NfvoJob nfvoJobStatus(final NfvoJobStatus nfvoJobStatus) { + nfvoJobStatus.setNfvoJob(this); + this.nfvoJobStatuses.add(nfvoJobStatus); + return this; + } + + @Override + public int hashCode() { + return Objects.hash(jobId, processInstanceId, jobType, jobAction, startTime, endTime, status, progress, + resourceId, resourceName, nfvoJobStatuses); + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof NfvoJob) { + final NfvoJob other = (NfvoJob) obj; + return Objects.equals(jobId, other.jobId) && Objects.equals(processInstanceId, other.processInstanceId) + && Objects.equals(jobType, other.jobType) && Objects.equals(jobAction, other.jobAction) + && Objects.equals(progress, other.progress) && Objects.equals(status, other.status) + && Objects.equals(startTime, other.startTime) && Objects.equals(endTime, other.endTime) + && Objects.equals(status, other.status) && Objects.equals(resourceId, other.resourceId) + && Objects.equals(resourceName, other.resourceName) + && Utils.isEquals(nfvoJobStatuses, other.nfvoJobStatuses); + } + return false; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class NfvoJob {\n"); + sb.append(" jobId: ").append(toIndentedString(jobId)).append("\n"); + sb.append(" processInstanceId: ").append(toIndentedString(processInstanceId)).append("\n"); + sb.append(" jobType: ").append(toIndentedString(jobType)).append("\n"); + sb.append(" jobAction: ").append(toIndentedString(jobAction)).append("\n"); + sb.append(" progress: ").append(toIndentedString(progress)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); + sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n"); + sb.append(" resId: ").append(toIndentedString(resourceId)).append("\n"); + sb.append(" resName: ").append(toIndentedString(resourceName)).append("\n"); + sb.append(" nfvoJobStatuses: ").append(toIndentedString(nfvoJobStatuses)).append("\n"); + + sb.append("}"); + return sb.toString(); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java new file mode 100644 index 0000000000..89e07701ed --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; + +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; +import java.time.LocalDateTime; +import java.util.Objects; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "JOB_STATUS") +public class NfvoJobStatus { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ID") + private int id; + + @Enumerated(EnumType.STRING) + @Column(name = "STATUS") + private JobStatusEnum status; + + @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT") + private String description; + + @Column(name = "UPDATED_TIME") + private LocalDateTime updatedTime; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "JOB_ID") + private NfvoJob nfvoJob; + + public int getId() { + return id; + } + + public JobStatusEnum getStatus() { + return status; + } + + public void setStatus(final JobStatusEnum status) { + this.status = status; + } + + public NfvoJobStatus status(final JobStatusEnum status) { + this.status = status; + return this; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + + public NfvoJobStatus description(final String description) { + this.description = description; + return this; + } + + public LocalDateTime getUpdatedTime() { + return updatedTime; + } + + public void setUpdatedTime(final LocalDateTime updatedTime) { + this.updatedTime = updatedTime; + } + + public NfvoJobStatus updatedTime(final LocalDateTime addTime) { + this.updatedTime = addTime; + return this; + } + + public NfvoJob getNfvoJob() { + return nfvoJob; + } + + public void setNfvoJob(final NfvoJob nfvoJob) { + this.nfvoJob = nfvoJob; + } + + public NfvoJobStatus nfvoJob(final NfvoJob nfvoJob) { + this.nfvoJob = nfvoJob; + return this; + } + + + @Override + public int hashCode() { + return Objects.hash(id, status, updatedTime, description, nfvoJob.getJobId()); + } + + @Override + public boolean equals(final Object obj) { + + if (obj instanceof NfvoJobStatus) { + final NfvoJobStatus other = (NfvoJobStatus) obj; + return Objects.equals(id, other.id) && Objects.equals(status, other.status) + && Objects.equals(updatedTime, other.updatedTime) && Objects.equals(description, other.description) + && Objects.equals(nfvoJob.getJobId(), other.nfvoJob.getJobId()); + } + return false; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class NfvoJobStatus {\n"); + sb.append(" Id: ").append(toIndentedString(id)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" descp: ").append(toIndentedString(description)).append("\n"); + sb.append(" updatedTime: ").append(toIndentedString(updatedTime)).append("\n"); + sb.append(" jobId: ").append(nfvoJob != null ? toIndentedString(nfvoJob.getJobId()) : "").append("\n"); + sb.append("}"); + return sb.toString(); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java new file mode 100644 index 0000000000..e901e10596 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java @@ -0,0 +1,213 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; + +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; +import java.time.LocalDateTime; +import java.util.Objects; +import java.util.UUID; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +/** + * @author mukeshsharma (mukeshsharma@est.tech) + */ +@Entity +@Table(name = "NF_INST") +public class NfvoNfInst { + + @Id + @Column(name = "NF_INST_ID") + private String nfInstId; + + @Column(name = "NAME") + private String name; + + @Column(name = "VNFD_ID") + private String vnfdId; + + @Column(name = "PACKAGE_ID") + private String packageId; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "NS_INST_ID") + private NfvoNsInst nsInst; + + @Enumerated(EnumType.STRING) + @Column(name = "STATUS") + private State status; + + @Column(name = "CREATE_TIME") + private LocalDateTime createTime; + + @Column(name = "LAST_UPDATE_TIME") + private LocalDateTime lastUpdateTime; + + public NfvoNfInst() { + this.nfInstId = UUID.randomUUID().toString(); + } + + public String getNfInstId() { + return nfInstId; + } + + public void setNfInstId(final String nfInstId) { + this.nfInstId = nfInstId; + } + + public NfvoNfInst nfInstId(final String nfInstId) { + this.nfInstId = nfInstId; + return this; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public NfvoNfInst name(final String name) { + this.name = name; + return this; + } + + public String getVnfdId() { + return vnfdId; + } + + public void setVnfdId(final String vnfdId) { + this.vnfdId = vnfdId; + } + + public NfvoNfInst vnfdId(final String vnfdId) { + this.vnfdId = vnfdId; + return this; + } + + public String getPackageId() { + return packageId; + } + + public void setPackageId(final String packageId) { + this.packageId = packageId; + } + + public NfvoNfInst packageId(final String packageId) { + this.packageId = packageId; + return this; + } + + public NfvoNsInst getNsInst() { + return nsInst; + } + + public void setNsInst(final NfvoNsInst nsInst) { + this.nsInst = nsInst; + } + + public NfvoNfInst nfvoNsInst(final NfvoNsInst nfvoNsInst) { + this.nsInst = nfvoNsInst; + return this; + } + + public State getStatus() { + return status; + } + + public void setStatus(final State status) { + this.status = status; + } + + public NfvoNfInst status(final State status) { + this.status = status; + return this; + } + + public LocalDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(final LocalDateTime createTime) { + this.createTime = createTime; + } + + public NfvoNfInst createTime(final LocalDateTime createTime) { + this.createTime = createTime; + return this; + } + + public LocalDateTime getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(final LocalDateTime lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public NfvoNfInst lastUpdateTime(final LocalDateTime lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + return this; + } + + @Override + public boolean equals(final Object object) { + if (this == object) + return true; + if (object == null || getClass() != object.getClass()) + return false; + final NfvoNfInst that = (NfvoNfInst) object; + return Objects.equals(nfInstId, that.nfInstId) && Objects.equals(name, that.name) + && Objects.equals(vnfdId, that.vnfdId) && Objects.equals(packageId, that.packageId) + && Objects.equals(nsInst, that.nsInst) && Objects.equals(status, that.status) + && Objects.equals(createTime, that.createTime) && Objects.equals(lastUpdateTime, that.lastUpdateTime); + } + + @Override + public int hashCode() { + return Objects.hash(nfInstId, name, vnfdId, packageId, nsInst, status, createTime, lastUpdateTime); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class NfvoNfInst {\n"); + sb.append(" nfInstId: ").append(toIndentedString(nfInstId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" vnfdId: ").append(toIndentedString(vnfdId)).append("\n"); + sb.append(" packageId: ").append(toIndentedString(packageId)).append("\n"); + sb.append(" nsInst: ").append(nsInst != null ? toIndentedString(nsInst.getNsInstId()) : null).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" createTime: ").append(toIndentedString(createTime)).append("\n"); + sb.append(" lastUpdateTime: ").append(toIndentedString(lastUpdateTime)).append("\n"); + + sb.append("}"); + return sb.toString(); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java new file mode 100644 index 0000000000..dd8448fe56 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java @@ -0,0 +1,289 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Entity +@Table(name = "NS_INST") +public class NfvoNsInst { + + @Id + @Column(name = "NS_INST_ID") + private String nsInstId; + + @Column(name = "NAME") + private String name; + + @Column(name = "NS_PACKAGE_ID") + private String nsPackageId; + + @Column(name = "NSD_ID") + private String nsdId; + + @Column(name = "NSD_INVARIANT_ID") + private String nsdInvariantId; + + @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT") + private String description; + + @Enumerated(EnumType.STRING) + @Column(name = "STATUS") + private State status; + + @Column(name = "STATUS_UPDATED_TIME") + private LocalDateTime statusUpdatedTime; + + @Column(name = "GLOBAL_CUSTOMER_ID") + private String globalCustomerId; + + @Column(name = "SERVICE_TYPE") + private String serviceType; + + @OneToMany(mappedBy = "nsInst", cascade = CascadeType.ALL, fetch = FetchType.LAZY) + private List<NfvoNfInst> nfvoNfInsts = new ArrayList<>(); + + @OneToMany(mappedBy = "nfvoNsInst", cascade = CascadeType.ALL, fetch = FetchType.LAZY) + private List<NsLcmOpOcc> nsLcmOpOccs = new ArrayList<>(); + + public NfvoNsInst() { + this.nsInstId = UUID.randomUUID().toString(); + } + + public String getNsInstId() { + return nsInstId; + } + + public void setNsInstId(final String nsInstId) { + this.nsInstId = nsInstId; + } + + public NfvoNsInst nsInstId(final String nsInstId) { + this.nsInstId = nsInstId; + return this; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public NfvoNsInst name(final String name) { + this.name = name; + return this; + } + + public String getNsPackageId() { + return nsPackageId; + } + + public void setNsPackageId(final String nsPackageId) { + this.nsPackageId = nsPackageId; + } + + public NfvoNsInst nsPackageId(final String nsPackageId) { + this.nsPackageId = nsPackageId; + return this; + } + + public String getNsdId() { + return nsdId; + } + + public void setNsdId(final String nsdId) { + this.nsdId = nsdId; + } + + public NfvoNsInst nsdId(final String nsdId) { + this.nsdId = nsdId; + return this; + } + + public String getNsdInvariantId() { + return nsdInvariantId; + } + + public void setNsdInvariantId(final String nsdInvariantId) { + this.nsdInvariantId = nsdInvariantId; + } + + public NfvoNsInst nsdInvariantId(final String nsdInvariantId) { + this.nsdInvariantId = nsdInvariantId; + return this; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + + public NfvoNsInst description(final String description) { + this.description = description; + return this; + } + + public State getStatus() { + return status; + } + + public void setStatus(final State status) { + this.status = status; + } + + public NfvoNsInst status(final State status) { + this.status = status; + return this; + } + + public LocalDateTime getStatusUpdatedTime() { + return statusUpdatedTime; + } + + public void setStatusUpdatedTime(final LocalDateTime statusUpdatedTime) { + this.statusUpdatedTime = statusUpdatedTime; + } + + public NfvoNsInst statusUpdatedTime(final LocalDateTime statusUpdatedTime) { + this.statusUpdatedTime = statusUpdatedTime; + return this; + } + + public String getGlobalCustomerId() { + return globalCustomerId; + } + + public void setGlobalCustomerId(final String globalCustomerId) { + this.globalCustomerId = globalCustomerId; + } + + public NfvoNsInst globalCustomerId(final String globalCustomerId) { + this.globalCustomerId = globalCustomerId; + return this; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(final String serviceType) { + this.serviceType = serviceType; + } + + public NfvoNsInst serviceType(final String serviceType) { + this.serviceType = serviceType; + return this; + } + + public List<NfvoNfInst> getNfvoNfInsts() { + return nfvoNfInsts; + } + + public void setNfvoNfInsts(final List<NfvoNfInst> nfvoNfInsts) { + this.nfvoNfInsts = nfvoNfInsts; + } + + public NfvoNsInst nfvoNfInsts(final NfvoNfInst nfvoNfInsts) { + nfvoNfInsts.nfvoNsInst(this); + this.nfvoNfInsts.add(nfvoNfInsts); + return this; + } + + public List<NsLcmOpOcc> getNsLcmOpOccs() { + return nsLcmOpOccs; + } + + public void setNsLcmOpOccs(final List<NsLcmOpOcc> nsLcmOpOccs) { + this.nsLcmOpOccs = nsLcmOpOccs; + } + + public NfvoNsInst nsLcmOpOccs(final NsLcmOpOcc nsLcmOpOcc) { + nsLcmOpOcc.nfvoNsInst(this); + this.nsLcmOpOccs.add(nsLcmOpOcc); + return this; + } + + @Override + public int hashCode() { + return Objects.hash(nsInstId, name, nsPackageId, nsdId, nsdInvariantId, description, status, statusUpdatedTime, + globalCustomerId, serviceType, nfvoNfInsts, nsLcmOpOccs); + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof NfvoNsInst) { + final NfvoNsInst other = (NfvoNsInst) obj; + return Objects.equals(nsInstId, other.nsInstId) && Objects.equals(name, other.name) + && Objects.equals(nsPackageId, other.nsPackageId) && Objects.equals(nsdId, other.nsdId) + && Objects.equals(nsdInvariantId, other.nsdInvariantId) + && Objects.equals(description, other.description) && Objects.equals(status, other.status) + && Objects.equals(statusUpdatedTime, other.statusUpdatedTime) + && Objects.equals(globalCustomerId, other.globalCustomerId) + && Objects.equals(serviceType, other.serviceType) && Objects.equals(nfvoNfInsts, other.nfvoNfInsts) + && Objects.equals(nsLcmOpOccs, other.nsLcmOpOccs); + } + return false; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class NfvoNsInst {\n"); + sb.append(" nsInstId: ").append(toIndentedString(nsInstId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" nsPackageId: ").append(toIndentedString(nsPackageId)).append("\n"); + sb.append(" nsdId: ").append(toIndentedString(nsdId)).append("\n"); + sb.append(" nsdInvariantId: ").append(toIndentedString(nsdInvariantId)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" statusUpdatedTime: ").append(toIndentedString(statusUpdatedTime)).append("\n"); + sb.append(" globalCustomerId: ").append(toIndentedString(globalCustomerId)).append("\n"); + sb.append(" serviceType: ").append(toIndentedString(serviceType)).append("\n"); + sb.append(" nfvoNfInsts: ").append(toIndentedString(nfvoNfInsts)).append("\n"); + sb.append(" nsLcmOpOccs: ").append(toIndentedString(nsLcmOpOccs)).append("\n"); + + sb.append("}"); + return sb.toString(); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java new file mode 100644 index 0000000000..cb8f92070a --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java @@ -0,0 +1,233 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; + +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; +import java.time.LocalDateTime; +import java.util.Objects; +import java.util.UUID; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +/** + * @author mukeshsharma(mukeshsharma@est.tech) + */ +@Entity +@Table(name = "NS_LCM_OP_OCCS") +public class NsLcmOpOcc { + + @Id + @Column(name = "ID") + private String id; + + @Enumerated(EnumType.STRING) + @Column(name = "OPERATION_STATE") + private OperationStateEnum operationState; + + @Column(name = "STATE_ENTERED_TIME") + private LocalDateTime stateEnteredTime; + + @Column(name = "START_TIME") + private LocalDateTime startTime; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "NS_INST_ID") + private NfvoNsInst nfvoNsInst; + + @Enumerated(EnumType.STRING) + @Column(name = "OPERATION") + private NsLcmOpType operation; + + @Column(name = "IS_AUTO_INNOVATION") + private boolean isAutoInnovation; + + @Column(name = "OPERATION_PARAMS", columnDefinition = "LONGTEXT") + private String operationParams; + + @Column(name = "IS_CANCEL_PENDING") + private boolean isCancelPending; + + public NsLcmOpOcc() { + this.id = UUID.randomUUID().toString(); + } + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public NsLcmOpOcc id(final String id) { + this.id = id; + return this; + } + + public OperationStateEnum getOperationState() { + return operationState; + } + + public void setOperationState(final OperationStateEnum operationState) { + this.operationState = operationState; + } + + public NsLcmOpOcc operationState(final OperationStateEnum operationState) { + this.operationState = operationState; + return this; + } + + public LocalDateTime getStateEnteredTime() { + return stateEnteredTime; + } + + public void setStateEnteredTime(final LocalDateTime stateEnteredTime) { + this.stateEnteredTime = stateEnteredTime; + } + + public NsLcmOpOcc stateEnteredTime(final LocalDateTime stateEnteredTime) { + this.stateEnteredTime = stateEnteredTime; + return this; + } + + public LocalDateTime getStartTime() { + return startTime; + } + + public void setStartTime(final LocalDateTime startTime) { + this.startTime = startTime; + } + + public NsLcmOpOcc startTime(final LocalDateTime startTime) { + this.startTime = startTime; + return this; + } + + public NfvoNsInst getNfvoNsInst() { + return nfvoNsInst; + } + + public void setNfvoNsInst(final NfvoNsInst nfvoNsInst) { + this.nfvoNsInst = nfvoNsInst; + } + + public NsLcmOpOcc nfvoNsInst(final NfvoNsInst nfvoNsInst) { + this.nfvoNsInst = nfvoNsInst; + return this; + } + + public NsLcmOpType getOperation() { + return operation; + } + + public void setOperation(final NsLcmOpType operation) { + this.operation = operation; + } + + public NsLcmOpOcc operation(final NsLcmOpType operation) { + this.operation = operation; + return this; + } + + public boolean getIsAutoInnovation() { + return isAutoInnovation; + } + + public void setIsAutoInnovation(final boolean isAutoInnovation) { + this.isAutoInnovation = isAutoInnovation; + } + + public NsLcmOpOcc isAutoInnovation(final boolean isAutoInnovation) { + this.isAutoInnovation = isAutoInnovation; + return this; + } + + public String getOperationParams() { + return operationParams; + } + + public void setOperationParams(final String operationParams) { + this.operationParams = operationParams; + } + + public NsLcmOpOcc operationParams(final String operationParams) { + this.operationParams = operationParams; + return this; + } + + public boolean getIsCancelPending() { + return isCancelPending; + } + + public void setIsCancelPending(final boolean isCancelPending) { + this.isCancelPending = isCancelPending; + } + + public NsLcmOpOcc isCancelPending(final boolean isCancelPending) { + this.isCancelPending = isCancelPending; + return this; + } + + @Override + public boolean equals(final Object object) { + if (this == object) + return true; + if (object == null || getClass() != object.getClass()) + return false; + final NsLcmOpOcc that = (NsLcmOpOcc) object; + return Objects.equals(id, that.id) && Objects.equals(operationState, that.operationState) + && Objects.equals(stateEnteredTime, that.stateEnteredTime) && Objects.equals(startTime, that.startTime) + && Objects.equals(nfvoNsInst, that.nfvoNsInst) && Objects.equals(operation, that.operation) + && Objects.equals(isAutoInnovation, that.isAutoInnovation) + && Objects.equals(operationParams, that.operationParams) + && Objects.equals(isCancelPending, that.isCancelPending); + } + + @Override + public int hashCode() { + return Objects.hash(id, operationState, stateEnteredTime, startTime, nfvoNsInst, operation, isAutoInnovation, + operationParams, isCancelPending); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class NfvoNsInst {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" operationState: ").append(toIndentedString(operationState)).append("\n"); + sb.append(" stateEnteredTime: ").append(toIndentedString(stateEnteredTime)).append("\n"); + sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); + sb.append(" nfvoNsInst: ").append(nfvoNsInst != null ? toIndentedString(nfvoNsInst.getNsInstId()) : null) + .append("\n"); + sb.append(" operation: ").append(toIndentedString(operation)).append("\n"); + sb.append(" isAutoInnovation: ").append(toIndentedString(isAutoInnovation)).append("\n"); + sb.append(" operationParams: ").append(toIndentedString(operationParams)).append("\n"); + sb.append(" isCancelPending: ").append(toIndentedString(isCancelPending)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpType.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpType.java new file mode 100644 index 0000000000..351f9611c5 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpType.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public enum NsLcmOpType { + INSTANTIATE, TERMINATE, SCALE, UPDATE, HEAL; +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/OperationStateEnum.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/OperationStateEnum.java new file mode 100644 index 0000000000..236652e027 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/OperationStateEnum.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public enum OperationStateEnum { + PROCESSING, COMPLETED, PARTIALLY_COMPLETED, FAILED_TEMP, FAILED, ROLLING_BACK, ROLLED_BACK; + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/State.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/State.java new file mode 100644 index 0000000000..390c7fd776 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/State.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public enum State { + NOT_INSTANTIATED, INSTANTIATING, INSTANTIATED, FAILED; + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java new file mode 100644 index 0000000000..c55ef5728e --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils; + +import java.util.List; +import java.util.Objects; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class Utils { + + private Utils() {} + + public static final String toIndentedString(final Object object) { + return object == null ? "null" : object.toString().replace("\n", "\n "); + } + + + public static boolean isEquals(final List<?> first, List<?> second) { + if (first == null) { + return second == null; + } + if (first.isEmpty()) { + return second.isEmpty(); + } + if (first.size() == second.size()) { + for (int index = 0; index < first.size(); index++) { + if (!Objects.equals(first.get(index), second.get(index))) { + return false; + } + } + return true; + + } + return false; + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/config/NfvoDatabaseConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/config/NfvoDatabaseConfiguration.java new file mode 100644 index 0000000000..8f146e5378 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/config/NfvoDatabaseConfiguration.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.config; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jmx.export.MBeanExporter; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Configuration +@EnableTransactionManagement +@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", + basePackages = {"org.onap.so.etsi.nfvo.ns.lcm.database.repository"}) +public class NfvoDatabaseConfiguration { + + private static final String PERSISTENCE_UNIT = "nfvo"; + private static final String NFVO_DATA_SOURCE_QUALIFIER = "nfvoDataSource"; + + @Autowired(required = false) + private MBeanExporter mBeanExporter; + + @Bean + @ConfigurationProperties(prefix = "spring.datasource.hikari.nfvo") + public HikariConfig nfvoDbConfig() { + return new HikariConfig(); + } + + @Bean(name = NFVO_DATA_SOURCE_QUALIFIER) + public DataSource dataSource() { + if (mBeanExporter != null) { + mBeanExporter.addExcludedBean(NFVO_DATA_SOURCE_QUALIFIER); + } + final HikariConfig hikariConfig = this.nfvoDbConfig(); + return new HikariDataSource(hikariConfig); + } + + @Primary + @Bean(name = "entityManagerFactory") + public LocalContainerEntityManagerFactoryBean entityManagerFactory(final EntityManagerFactoryBuilder builder, + @Qualifier(NFVO_DATA_SOURCE_QUALIFIER) final DataSource dataSource) { + return builder.dataSource(dataSource).packages(NfvoJob.class.getPackage().getName()) + .persistenceUnit(PERSISTENCE_UNIT).build(); + } + + @Primary + @Bean(name = "transactionManager") + public PlatformTransactionManager transactionManager( + @Qualifier("entityManagerFactory") final EntityManagerFactory entityManagerFactory) { + return new JpaTransactionManager(entityManagerFactory); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java new file mode 100644 index 0000000000..696c7be5dd --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.repository; + +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.springframework.data.repository.CrudRepository; +import java.util.Optional; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * @author mukeshsharma(mukeshsharma@est.tech) + */ +public interface NSLcmOpOccRepository extends CrudRepository<NsLcmOpOcc, String> { + + Optional<NsLcmOpOcc> findById(final String id); +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobRepository.java new file mode 100644 index 0000000000..844f60827e --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobRepository.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.repository; + +import java.util.Optional; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.springframework.data.repository.CrudRepository; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public interface NfvoJobRepository extends CrudRepository<NfvoJob, String> { + + Optional<NfvoJob> findByResourceId(final String resourceId); + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobStatusRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobStatusRepository.java new file mode 100644 index 0000000000..c3fe469ff6 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobStatusRepository.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.repository; + +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus; +import org.springframework.data.repository.CrudRepository; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public interface NfvoJobStatusRepository extends CrudRepository<NfvoJobStatus, Integer> { +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoDeploymentAlreadyExists.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java index 62112f4feb..de14d43de4 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoDeploymentAlreadyExists.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java @@ -1,34 +1,38 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. + * + * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ +package org.onap.so.etsi.nfvo.ns.lcm.database.repository; -package org.onap.so.cloudify.exceptions; +import java.util.List; +import java.util.Optional; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; +import org.springframework.data.repository.CrudRepository; -public class MsoDeploymentAlreadyExists extends MsoCloudifyException { +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * @author mukeshsharma(mukeshsharma@est.tech) + */ +public interface NfvoNfInstRepository extends CrudRepository<NfvoNfInst, String> { - private static final long serialVersionUID = 1L; + Optional<NfvoNfInst> findByNfInstId(final String nfInstId); - // Constructor to create a new MsoCloudifyException instance - public MsoDeploymentAlreadyExists(String deploymentId, String cloud) { - // Set the detailed error as the Exception 'message' - super(409, "Conflict", - "Deployment " + deploymentId + " already exists in Cloudify Manager suppporting cloud " + cloud); - } + List<NfvoNfInst> findByNsInstNsInstId(final String nsInstId); + List<NfvoNfInst> findByNsInstNsInstIdAndName(final String nsInstId, final String name); } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java new file mode 100644 index 0000000000..beeeacf8cf --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNsInstRepository.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.repository; + +import java.util.Optional; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.springframework.data.repository.CrudRepository; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public interface NfvoNsInstRepository extends CrudRepository<NfvoNsInst, String> { + + Optional<NfvoNsInst> findByName(final String name); + + Optional<NfvoNsInst> findByNsInstId(final String nsInstId); + + boolean existsNfvoNsInstByName(final String name); + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java new file mode 100644 index 0000000000..368242515b --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java @@ -0,0 +1,141 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.service; + +import java.util.List; +import java.util.Optional; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NSLcmOpOccRepository; +import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoJobRepository; +import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoNfInstRepository; +import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoNsInstRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ + +@Service +public class DatabaseServiceProvider { + private static final Logger logger = LoggerFactory.getLogger(DatabaseServiceProvider.class); + + private final NfvoJobRepository nfvoJobRepository; + + private final NfvoNsInstRepository nfvoNsInstRepository; + + private final NfvoNfInstRepository nfvoNfInstRepository; + + private final NSLcmOpOccRepository nsLcmOpOccRepository; + + @Autowired + public DatabaseServiceProvider(final NfvoJobRepository nfvoJobRepository, + final NfvoNsInstRepository nfvoNsInstRepository, final NfvoNfInstRepository nfvoNfInstRepository, + final NSLcmOpOccRepository nsLcmOpOccRepository) { + this.nfvoJobRepository = nfvoJobRepository; + this.nfvoNsInstRepository = nfvoNsInstRepository; + this.nfvoNfInstRepository = nfvoNfInstRepository; + this.nsLcmOpOccRepository = nsLcmOpOccRepository; + } + + public boolean addJob(final NfvoJob job) { + logger.info("Adding NfvoJob: {} to database", job); + return nfvoJobRepository.save(job) != null; + } + + public Optional<NfvoJob> getJob(final String jobId) { + logger.info("Querying database for NfvoJob using jobId: {}", jobId); + return nfvoJobRepository.findById(jobId); + } + + public Optional<NfvoJob> getJobByResourceId(final String resourceId) { + logger.info("Querying database for NfvoJob using resourceId: {}", resourceId); + return nfvoJobRepository.findByResourceId(resourceId); + } + + public boolean isNsInstExists(final String name) { + logger.info("Checking if NfvoNsInst entry exists in database using name: {}", name); + return nfvoNsInstRepository.existsNfvoNsInstByName(name); + } + + public boolean isNsInstExists(final String nsInstId, final String nfName) { + logger.info("Checking if NfvoNfInst entry exists in database using nsInstId: {} and nfName: {}", nsInstId, + nfName); + return nfvoNfInstRepository.findByNsInstNsInstIdAndName(nsInstId, nfName).isEmpty(); + } + + public boolean saveNfvoNsInst(final NfvoNsInst nfvoNsInst) { + logger.info("Saving NfvoNsInst: {} to database", nfvoNsInst); + return nfvoNsInstRepository.save(nfvoNsInst) != null; + } + + public Optional<NfvoNsInst> getNfvoNsInst(final String nsInstId) { + logger.info("Querying database for NfvoNsInst using nsInstId: {}", nsInstId); + return nfvoNsInstRepository.findById(nsInstId); + } + + public Optional<NfvoNsInst> getNfvoNsInstByName(final String name) { + logger.info("Querying database for NfvoNsInst using name: {}", name); + return nfvoNsInstRepository.findByName(name); + } + + public boolean saveNfvoNfInst(final NfvoNfInst nfvoNfInst) { + logger.info("Saving NfvoNfInst: {} to database", nfvoNfInst); + return nfvoNfInstRepository.save(nfvoNfInst) != null; + } + + public Optional<NfvoNfInst> getNfvoNfInstByNfInstId(final String nfInstId) { + logger.info("Querying database for NfvoNfInst using nfInstId: {}", nfInstId); + return nfvoNfInstRepository.findByNfInstId(nfInstId); + } + + public List<NfvoNfInst> getNfvoNfInstByNsInstId(final String nsInstId) { + logger.info("Querying database for NfvoNfInst using nsInstId: {}", nsInstId); + return nfvoNfInstRepository.findByNsInstNsInstId(nsInstId); + } + + public List<NfvoNfInst> getNfvoNfInstByNsInstIdAndNfName(final String nsInstId, final String name) { + logger.info("Querying database for NfvoNfInst using nsInstId: {} and name : {} ", nsInstId, name); + return nfvoNfInstRepository.findByNsInstNsInstIdAndName(nsInstId, name); + } + + public Optional<NfvoNfInst> getNfvoNfInst(final String nfInstId) { + logger.info("Querying database for NfvoNfInst using nfInstId: {}", nfInstId); + return nfvoNfInstRepository.findByNfInstId(nfInstId); + } + + public boolean addNSLcmOpOcc(final NsLcmOpOcc nsLcmOpOcc) { + logger.info("Adding NSLcmOpOcc: {} to database", nsLcmOpOcc); + return nsLcmOpOccRepository.save(nsLcmOpOcc) != null; + } + + public Optional<NsLcmOpOcc> getNsLcmOpOcc(final String id) { + logger.info("Querying database for NsLcmOpOcc using id: {}", id); + return nsLcmOpOccRepository.findById(id); + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql new file mode 100644 index 0000000000..f41a8206e0 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql @@ -0,0 +1,74 @@ +use nfvo; + +CREATE TABLE IF NOT EXISTS `JOB` ( + `JOB_ID` varchar(255) NOT NULL, + `JOB_TYPE` varchar(255) NOT NULL, + `JOB_ACTION` varchar(255) NOT NULL, + `RESOURCE_ID` varchar(255) NOT NULL, + `RESOURCE_NAME` varchar(255) DEFAULT NULL, + `STATUS` varchar(255) NOT NULL, + `START_TIME` DATETIME DEFAULT NULL, + `END_TIME` DATETIME DEFAULT NULL, + `PROGRESS` int(11) DEFAULT NULL, + `PROCESS_INSTANCE_ID` varchar(255) DEFAULT NULL, + PRIMARY KEY (`JOB_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + + +CREATE TABLE IF NOT EXISTS `JOB_STATUS` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `UPDATED_TIME` DATETIME NOT NULL, + `DESCRIPTION` longtext DEFAULT NULL, + `STATUS` varchar(255) NOT NULL, + `JOB_ID` varchar(255) NOT NULL, + PRIMARY KEY (`ID`), + FOREIGN KEY (JOB_ID) + REFERENCES JOB(JOB_ID) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `NS_INST` ( + `NS_INST_ID` varchar(255) NOT NULL, + `NAME` varchar(255) NOT NULL, + `NS_PACKAGE_ID` varchar(255) DEFAULT NULL, + `NSD_ID` varchar(255) NOT NULL, + `NSD_INVARIANT_ID` varchar(255) NOT NULL, + `DESCRIPTION` longtext DEFAULT NULL, + `STATUS` varchar(255) NOT NULL, + `STATUS_UPDATED_TIME` DATETIME NOT NULL, + `GLOBAL_CUSTOMER_ID` varchar(255) DEFAULT NULL, + `SERVICE_TYPE` varchar(255) DEFAULT NULL, + PRIMARY KEY (`NS_INST_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `NF_INST` ( + `NF_INST_ID` varchar(255) NOT NULL, + `NAME` varchar(255) DEFAULT NULL, + `VNFD_ID` varchar(255) DEFAULT NULL, + `PACKAGE_ID` varchar(255) DEFAULT NULL, + `NS_INST_ID` varchar(255) NOT NULL, + `STATUS` varchar(255) NOT NULL, + `CREATE_TIME` DATETIME DEFAULT NULL, + `LAST_UPDATE_TIME` DATETIME DEFAULT NULL, + PRIMARY KEY (`NF_INST_ID`), + FOREIGN KEY (NS_INST_ID) + REFERENCES NS_INST(NS_INST_ID) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `NS_LCM_OP_OCCS` ( + `ID` varchar(255) NOT NULL, + `OPERATION_STATE` varchar(255) NOT NULL, + `STATE_ENTERED_TIME` DATETIME DEFAULT NULL, + `START_TIME` DATETIME DEFAULT NULL, + `NS_INST_ID` varchar(255) NOT NULL, + `OPERATION` varchar(255) NOT NULL, + `IS_AUTO_INNOVATION` varchar(255) NOT NULL, + `OPERATION_PARAMS` longtext NOT NULL, + `IS_CANCEL_PENDING` varchar(255) NOT NULL, + PRIMARY KEY (`ID`), + FOREIGN KEY (NS_INST_ID) + REFERENCES NS_INST(NS_INST_ID) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java new file mode 100644 index 0000000000..42579fd5e8 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java @@ -0,0 +1,176 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpType; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class DatabaseServiceProviderTest { + + private static final String RANDOM_ID = UUID.randomUUID().toString(); + private static final String DUMMY_NAME = "NAME"; + private static final LocalDateTime CURRENT_DATE_TIME = LocalDateTime.now(); + @Autowired + private DatabaseServiceProvider databaseServiceProvider; + + @Test + public void testAddJob_StoredInDatabase() { + final NfvoJob expected = new NfvoJob().jobType("TYPE").jobAction(JobAction.CREATE).resourceId(RANDOM_ID) + .resourceName(DUMMY_NAME).startTime(CURRENT_DATE_TIME).status(JobStatusEnum.STARTED); + databaseServiceProvider.addJob(expected); + + final Optional<NfvoJob> actual = databaseServiceProvider.getJob(expected.getJobId()); + assertEquals(expected, actual.get()); + } + + @Test + public void testAddJobWithJobStatus_StoredInDatabase() { + final NfvoJob job = new NfvoJob().jobType("TYPE").jobAction(JobAction.CREATE).resourceId(RANDOM_ID) + .resourceName(DUMMY_NAME).startTime(CURRENT_DATE_TIME).status(JobStatusEnum.STARTED); + databaseServiceProvider.addJob(job); + + final NfvoJobStatus jobStatus = new NfvoJobStatus().status(JobStatusEnum.STARTED) + .description("Create NS workflow process started").updatedTime(CURRENT_DATE_TIME); + databaseServiceProvider.addJob(job.nfvoJobStatus(jobStatus)); + + final Optional<NfvoJob> actual = databaseServiceProvider.getJob(job.getJobId()); + final NfvoJob actualNfvoJob = actual.get(); + + assertEquals(job.getJobId(), actualNfvoJob.getJobId()); + assertFalse(actualNfvoJob.getNfvoJobStatuses().isEmpty()); + assertEquals(job.getJobId(), actualNfvoJob.getNfvoJobStatuses().get(0).getNfvoJob().getJobId()); + + } + + @Test + public void testAddNsInst_StoredInDatabase_ableTofindByQuery() { + + final NfvoNsInst nsInst = new NfvoNsInst().name(DUMMY_NAME).nsdId(RANDOM_ID).status(State.NOT_INSTANTIATED) + .nsdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME); + + databaseServiceProvider.saveNfvoNsInst(nsInst); + + Optional<NfvoNsInst> actual = databaseServiceProvider.getNfvoNsInst(nsInst.getNsInstId()); + NfvoNsInst actualNfvoNsInst = actual.get(); + assertEquals(nsInst.getNsInstId(), actualNfvoNsInst.getNsInstId()); + assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdId()); + assertEquals(State.NOT_INSTANTIATED, actualNfvoNsInst.getStatus()); + assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdInvariantId()); + assertEquals(CURRENT_DATE_TIME, actualNfvoNsInst.getStatusUpdatedTime()); + + actual = databaseServiceProvider.getNfvoNsInstByName(DUMMY_NAME); + actualNfvoNsInst = actual.get(); + + assertEquals(nsInst.getNsInstId(), actualNfvoNsInst.getNsInstId()); + assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdId()); + assertEquals(State.NOT_INSTANTIATED, actualNfvoNsInst.getStatus()); + assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdInvariantId()); + assertEquals(CURRENT_DATE_TIME, actualNfvoNsInst.getStatusUpdatedTime()); + + + assertTrue(databaseServiceProvider.isNsInstExists(DUMMY_NAME)); + } + + @Test + public void testAddNfInst_StoredInDatabase_ableTofindByQuery() { + + final NfvoNsInst nsInst = new NfvoNsInst().name(DUMMY_NAME).nsdId(RANDOM_ID).status(State.NOT_INSTANTIATED) + .nsdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME); + + databaseServiceProvider.saveNfvoNsInst(nsInst); + + final NfvoNfInst nfInst = new NfvoNfInst().nfvoNsInst(nsInst).name(DUMMY_NAME).vnfdId(RANDOM_ID) + .status(State.NOT_INSTANTIATED).createTime(CURRENT_DATE_TIME).lastUpdateTime(CURRENT_DATE_TIME); + databaseServiceProvider.saveNfvoNfInst(nfInst); + + final Optional<NfvoNfInst> actual = databaseServiceProvider.getNfvoNfInstByNfInstId(nfInst.getNfInstId()); + final NfvoNfInst actualNfvoNfInst = actual.get(); + assertEquals(nsInst.getNsInstId(), actualNfvoNfInst.getNsInst().getNsInstId()); + assertEquals(nfInst.getNfInstId(), actualNfvoNfInst.getNfInstId()); + assertEquals(nfInst.getName(), actualNfvoNfInst.getName()); + assertEquals(nfInst.getVnfdId(), actualNfvoNfInst.getVnfdId()); + assertEquals(nfInst.getStatus(), actualNfvoNfInst.getStatus()); + assertEquals(nfInst.getCreateTime(), actualNfvoNfInst.getCreateTime()); + assertEquals(nfInst.getLastUpdateTime(), actualNfvoNfInst.getLastUpdateTime()); + + + List<NfvoNfInst> nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInst.getNsInstId()); + assertFalse(nfvoNfInstList.isEmpty()); + assertEquals(nsInst.getNsInstId(), nfvoNfInstList.get(0).getNsInst().getNsInstId()); + + nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstIdAndNfName(nsInst.getNsInstId(), DUMMY_NAME); + + assertFalse(nfvoNfInstList.isEmpty()); + assertEquals(nsInst.getNsInstId(), nfvoNfInstList.get(0).getNsInst().getNsInstId()); + assertEquals(DUMMY_NAME, nfvoNfInstList.get(0).getName()); + } + + @Test + public void testAddNsLcmOpOcc_StoredInDatabase_ableTofindByQuery() { + + final NfvoNsInst nsInst = new NfvoNsInst().name(DUMMY_NAME).nsdId(RANDOM_ID).status(State.NOT_INSTANTIATED) + .nsdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME); + + databaseServiceProvider.saveNfvoNsInst(nsInst); + + final NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc().nfvoNsInst(nsInst).operationState(OperationStateEnum.PROCESSING) + .isCancelPending(false).isAutoInnovation(false).operation(NsLcmOpType.INSTANTIATE) + .startTime(CURRENT_DATE_TIME).stateEnteredTime(CURRENT_DATE_TIME).operationParams(""); + + + databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc); + + final Optional<NsLcmOpOcc> actual = databaseServiceProvider.getNsLcmOpOcc(nsLcmOpOcc.getId()); + final NsLcmOpOcc actualLcmOpOcc = actual.get(); + assertEquals(nsLcmOpOcc.getId(), actualLcmOpOcc.getId()); + + assertEquals(nsInst.getNsInstId(), actualLcmOpOcc.getNfvoNsInst().getNsInstId()); + + } +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/TestApplication.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/TestApplication.java new file mode 100644 index 0000000000..921cae2343 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/TestApplication.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.etsi.nfvo.ns.lcm.database; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.ComponentScan.Filter; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@SpringBootApplication(scanBasePackages = {"org.onap.so"}) +@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class}) +@ComponentScan(basePackages = {"org.onap"}, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) +public class TestApplication { + + public static void main(final String[] args) { + new SpringApplication(TestApplication.class).run(args); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/UtilsTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/UtilsTest.java new file mode 100644 index 0000000000..632bda937c --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/UtilsTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import java.util.Arrays; +import java.util.Collections; +import org.junit.Test; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class UtilsTest { + + @Test + public void testTwoEmptyLists_equal() { + assertTrue(Utils.isEquals(Collections.emptyList(), Collections.emptyList())); + } + + @Test + public void testEmptyListAndNonEmpty_notEqual() { + assertFalse(Utils.isEquals(Collections.emptyList(), Arrays.asList("A"))); + } + + @Test + public void testTwoNullLists_equal() { + assertTrue(Utils.isEquals(null, null)); + } + + @Test + public void testNullListAndEmptyList_notEqual() { + assertFalse(Utils.isEquals(null, Collections.emptyList())); + } + + @Test + public void testTwoNotEmptyListsContainSameObjects_equal() { + assertTrue(Utils.isEquals(Arrays.asList("A"), Arrays.asList("A"))); + } + + @Test + public void testTwoNotEmptyListsContainsDifferentObjects_equal() { + assertFalse(Utils.isEquals(Arrays.asList("A"), Arrays.asList(1))); + } + + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml new file mode 100644 index 0000000000..adc36aca1d --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml @@ -0,0 +1,31 @@ +# Copyright © 2020 Nordix Foundation +# +# 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. +spring: + main: + web-application-type: none + datasource: + hikari: + nfvo: + jdbcUrl: jdbc:h2:mem:nfvo;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS nfvo; + driver-class-name: org.h2.Driver + pool-name: ns-lcm-bpmn-pool + registerMbeans: true + jpa: + generate-ddl: true + hibernate: + ddl-auto: create +hibernate: + dialect: org.hibernate.dialect.H2Dialect + hbm2ddl: + auto: create
\ No newline at end of file diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/pom.xml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/pom.xml index 2c3c394d01..6605602f53 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/pom.xml +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/pom.xml @@ -16,6 +16,11 @@ <version>${project.version}</version> </dependency> <dependency> + <groupId>org.onap.so.etsi.nfvo</groupId> + <artifactId>so-etsi-nfvo-ns-lcm-bpmn-flows</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> @@ -50,9 +55,24 @@ <version>${project.version}</version> </dependency> <dependency> + <groupId>org.onap.so.etsi.nfvo</groupId> + <artifactId>so-etsi-nfvo-ns-lcm-bpmn-flows</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/Constants.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/Constants.java index 97ad1743bc..d330df3bae 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/Constants.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/Constants.java @@ -1,19 +1,19 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/EtsiSoNsLcmManagerUrlProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/EtsiSoNsLcmManagerUrlProvider.java new file mode 100644 index 0000000000..da1649de57 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/EtsiSoNsLcmManagerUrlProvider.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm; + +import java.net.URI; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Configuration +public class EtsiSoNsLcmManagerUrlProvider { + + private final String etsiNsLcmManagerEndpoint; + + @Autowired + public EtsiSoNsLcmManagerUrlProvider( + @Value("${so-etsi-nfvo-ns-lcm.endpoint:http://so-etsi-nfvo-ns-lcm.onap:9095}") final String etsiNsLcmManagerEndpoint) { + this.etsiNsLcmManagerEndpoint = etsiNsLcmManagerEndpoint; + } + + public URI getCreatedNsResourceUri(final String nsInstanceId) { + return URI.create(etsiNsLcmManagerEndpoint + Constants.NS_LIFE_CYCLE_MANAGEMENT_BASE_URL + "/ns_instances/" + + nsInstanceId); + } + + public URI getInstantiatedOccUri(final String nsLcmOpOccId) { + return URI.create(etsiNsLcmManagerEndpoint + Constants.NS_LIFE_CYCLE_MANAGEMENT_BASE_URL + "/ns_lcm_op_occs/" + + nsLcmOpOccId); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/GsonSerializerConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/GsonSerializerConfiguration.java new file mode 100644 index 0000000000..2e11adae01 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/GsonSerializerConfiguration.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm; + +import java.time.LocalDateTime; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.utils.LocalDateTimeTypeAdapter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import com.google.gson.GsonBuilder; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Configuration +public class GsonSerializerConfiguration { + + @Bean + public GsonBuilder gsonBuilder() { + return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeTypeAdapter()); + } + +} + + diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLifeCycleManager.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLifeCycleManager.java new file mode 100644 index 0000000000..792ffdd00a --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLifeCycleManager.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.lifecycle; + +import static org.slf4j.LoggerFactory.getLogger; +import java.net.URI; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.onap.so.etsi.nfvo.ns.lcm.EtsiSoNsLcmManagerUrlProvider; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service.JobExecutorService; +import org.onap.so.etsi.nfvo.ns.lcm.model.CreateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.InstantiateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Service +public class NsLifeCycleManager { + private static final Logger logger = getLogger(NsLifeCycleManager.class); + + private final JobExecutorService jobExecutorService; + + @Value("${etsi-so-ns-workflow-engine.requesttimeout.create.timeoutInSeconds:300}") + private int timeOutInSeconds; + + private final EtsiSoNsLcmManagerUrlProvider etsiSoNsLcmManagerUrlProvider; + + @Autowired + public NsLifeCycleManager(final JobExecutorService jobExecutorService, + final EtsiSoNsLcmManagerUrlProvider etsiSoNsLcmManagerUrlProvider) { + this.jobExecutorService = jobExecutorService; + this.etsiSoNsLcmManagerUrlProvider = etsiSoNsLcmManagerUrlProvider; + } + + public ImmutablePair<URI, NsInstancesNsInstance> createNs(final CreateNsRequest createNsRequest, + final String globalCustomerId, final String serviceType) { + logger.info("Will execute Create Ns for CreateNsRequest: {}, globalCustomerId: {} and serviceType: {}", + createNsRequest, globalCustomerId, serviceType); + final NsInstancesNsInstance nsInstanceResponse = + jobExecutorService.runCreateNsJob(createNsRequest, globalCustomerId, serviceType); + + return ImmutablePair.of(etsiSoNsLcmManagerUrlProvider.getCreatedNsResourceUri(nsInstanceResponse.getId()), + nsInstanceResponse); + } + + public URI instantiateNs(final String nsInstanceId, final InstantiateNsRequest instantiateNsRequest) { + logger.info("Will execute Instantiate Ns for InstantiateNsRequest: {} and nsInstanceId: {}", + instantiateNsRequest, nsInstanceId); + final String nsLcmOpOccId = jobExecutorService.runInstantiateNsJob(nsInstanceId, instantiateNsRequest); + + return etsiSoNsLcmManagerUrlProvider.getInstantiatedOccUri(nsLcmOpOccId); + + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesController.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesController.java index aed4f4b9dd..ec79ce6329 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesController.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesController.java @@ -1,19 +1,19 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java index 4dd12589a0..87ec8420c6 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java @@ -1,19 +1,19 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -24,12 +24,17 @@ import static org.onap.so.etsi.nfvo.ns.lcm.Constants.HTTP_SERVICETYPE_HEADER_DEF import static org.onap.so.etsi.nfvo.ns.lcm.Constants.HTTP_SERVICETYPE_HEADER_PARM_NAME; import static org.onap.so.etsi.nfvo.ns.lcm.Constants.NS_LIFE_CYCLE_MANAGEMENT_BASE_URL; import static org.slf4j.LoggerFactory.getLogger; +import java.net.URI; import javax.ws.rs.core.MediaType; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.onap.so.etsi.nfvo.ns.lcm.lifecycle.NsLifeCycleManager; import org.onap.so.etsi.nfvo.ns.lcm.model.Body; import org.onap.so.etsi.nfvo.ns.lcm.model.CreateNsRequest; import org.onap.so.etsi.nfvo.ns.lcm.model.InstantiateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance; import org.onap.so.etsi.nfvo.ns.lcm.model.TerminateNsRequest; import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -53,6 +58,12 @@ import org.springframework.web.bind.annotation.RequestMapping; public class NsLifecycleManagementController { private static final Logger logger = getLogger(NsLifecycleManagementController.class); + private final NsLifeCycleManager nsLifeCycleManager; + + @Autowired + public NsLifecycleManagementController(final NsLifeCycleManager nsLifeCycleManager) { + this.nsLifeCycleManager = nsLifeCycleManager; + } /** * The POST method creates new {@link Body new NS instance resource} request. See Section Number: 6.3.1 for more @@ -74,7 +85,17 @@ public class NsLifecycleManagementController { @RequestBody final CreateNsRequest createNsRequest) { logger.info("Received Create NS Request: {}\n with globalCustomerId: {}\n serviceType: {}\n", createNsRequest, globalCustomerId, serviceType); - return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet"); + + final ImmutablePair<URI, NsInstancesNsInstance> nsInstance = + nsLifeCycleManager.createNs(createNsRequest, globalCustomerId, serviceType); + + final URI resourceUri = nsInstance.getLeft(); + final NsInstancesNsInstance createdNsresponse = nsInstance.getRight(); + + logger.info("NS resource created successfully. Resource location: {}, response: {}", resourceUri, + createdNsresponse); + + return ResponseEntity.created(resourceUri).body(createdNsresponse); } /** @@ -104,7 +125,10 @@ public class NsLifecycleManagementController { public ResponseEntity<?> instantiateNs(@PathVariable("nsInstanceId") final String nsInstanceId, @RequestBody final InstantiateNsRequest instantiateNsRequest) { logger.debug("Received instantiate NS request: {}\n with nsInstanceId: {}", instantiateNsRequest, nsInstanceId); - return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet"); + final URI resourceUri = nsLifeCycleManager.instantiateNs(nsInstanceId, instantiateNsRequest); + logger.info("{} Ns Instantiation started successfully. Resource Operation Occurrence uri: {}", nsInstanceId, + resourceUri); + return ResponseEntity.accepted().location(resourceUri).build(); } /** diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/exceptions/NsLcmControllerExceptionHandler.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/exceptions/NsLcmControllerExceptionHandler.java new file mode 100644 index 0000000000..3db04fcfe8 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/exceptions/NsLcmControllerExceptionHandler.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.rest.exceptions; + +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.NsRequestProcessingException; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; +import org.onap.so.etsi.nfvo.ns.lcm.rest.NsLifecycleManagementController; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@ControllerAdvice(assignableTypes = NsLifecycleManagementController.class) +public class NsLcmControllerExceptionHandler { + + @ExceptionHandler(NsRequestProcessingException.class) + public ResponseEntity<InlineResponse400> handleNsRequestProcessingException( + final NsRequestProcessingException nsRequestProcessingException) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(getInlineResponse400(nsRequestProcessingException)); + } + + @ExceptionHandler(Exception.class) + public ResponseEntity<InlineResponse400> handleNsRequestProcessingException(final Exception exception) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new InlineResponse400() + .status(HttpStatus.INTERNAL_SERVER_ERROR.value()).detail(exception.getMessage())); + } + + private InlineResponse400 getInlineResponse400(final NsRequestProcessingException nsRequestProcessingException) { + if (nsRequestProcessingException.getProblemDetails() != null) { + return nsRequestProcessingException.getProblemDetails(); + } + return new InlineResponse400().status(HttpStatus.INTERNAL_SERVER_ERROR.value()) + .detail(nsRequestProcessingException.getMessage()); + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/TestApplication.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/TestApplication.java index 6e5f6c0467..d6f4a83811 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/TestApplication.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/TestApplication.java @@ -1,19 +1,19 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Ericsson. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesControllerTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesControllerTest.java index ae491b6f1e..9eace927d6 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesControllerTest.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesControllerTest.java @@ -1,19 +1,19 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Ericsson. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java index 6f25092050..81c4e8fd68 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java @@ -1,19 +1,19 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Ericsson. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -24,18 +24,30 @@ package org.onap.so.etsi.nfvo.ns.lcm.rest; * */ import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import java.net.URISyntaxException; import java.time.LocalDateTime; +import java.util.List; import java.util.UUID; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.etsi.nfvo.ns.lcm.Constants; -import org.onap.so.etsi.nfvo.ns.lcm.JSON; import org.onap.so.etsi.nfvo.ns.lcm.TestApplication; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.NsRequestProcessingException; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service.JobExecutorService; import org.onap.so.etsi.nfvo.ns.lcm.model.CreateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; import org.onap.so.etsi.nfvo.ns.lcm.model.InstantiateNsRequest; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance; import org.onap.so.etsi.nfvo.ns.lcm.model.TerminateNsRequest; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.boot.web.server.LocalServerPort; @@ -57,27 +69,107 @@ import com.google.gson.Gson; @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class NsLifecycleManagementControllerTest { + private static final String EXPECTED_BASE_URL = + "http://so-etsi-nfvo-ns-lcm.onap:9095/so/so-etsi-nfvo-ns-lcm/v1/api/nslcm/v1"; + private static final String RANDOM_NS_LCM_OP_OCC_ID = UUID.randomUUID().toString(); + private static final String RANDOM_NS_INST_ID = UUID.randomUUID().toString(); + private static final String SERVICE_TYPE = "NetworkService"; + private static final String GLOBAL_CUSTOMER_ID = UUID.randomUUID().toString(); + private static final String EXPECTED_CREATE_REQ_LOCATION_URL = + EXPECTED_BASE_URL + "/ns_instances/" + RANDOM_NS_INST_ID; + private static final String EXPECTED_INSTANTIATE_REQ_LOCATION_URL = + EXPECTED_BASE_URL + "/ns_lcm_op_occs/" + RANDOM_NS_LCM_OP_OCC_ID; + @LocalServerPort private int port; private TestRestTemplate testRestTemplate; + @Autowired + private GsonProvider gsonProvider; + + @MockBean + private JobExecutorService mockedJobExecutorService; + @Before public void setUp() { - final Gson gson = JSON.createGson().create(); + final Gson gson = gsonProvider.getGson(); testRestTemplate = new TestRestTemplate( new RestTemplateBuilder().additionalMessageConverters(new GsonHttpMessageConverter(gson))); } @Test - public void testCreateNs_ValidCreateNsRequest() { + public void testCreateNs_ValidCreateNsRequest() throws URISyntaxException { + + final CreateNsRequest createNsRequest = getCreateNsRequest(); + + when(mockedJobExecutorService.runCreateNsJob(eq(createNsRequest), eq(GLOBAL_CUSTOMER_ID), eq(SERVICE_TYPE))) + .thenReturn(new NsInstancesNsInstance().id(RANDOM_NS_INST_ID)); + final String baseUrl = getNsLcmBaseUrl() + "/ns_instances"; final HttpHeaders headers = new HttpHeaders(); - headers.add(Constants.HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME, "GLOBAL_CUSTOMER_ID"); - final HttpEntity<?> request = new HttpEntity<>(getCreateNsRequest(), headers); - final ResponseEntity<Void> responseEntity = - testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, Void.class); - assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + headers.add(Constants.HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME, GLOBAL_CUSTOMER_ID); + final HttpEntity<?> request = new HttpEntity<>(createNsRequest, headers); + final ResponseEntity<NsInstancesNsInstance> responseEntity = + testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, NsInstancesNsInstance.class); + assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); + assertTrue(responseEntity.hasBody()); + assertNotNull(responseEntity.getBody()); + + final HttpHeaders httpHeaders = responseEntity.getHeaders(); + assertTrue(httpHeaders.containsKey(HttpHeaders.LOCATION)); + final List<String> actual = httpHeaders.get(HttpHeaders.LOCATION); + assertEquals(1, actual.size()); + assertEquals(EXPECTED_CREATE_REQ_LOCATION_URL, actual.get(0)); + } + + @Test + public void testCreateNs_createNsRequest_nsRequestProcessingExceptionThrown_returnInlineResponse400() + throws URISyntaxException { + + final CreateNsRequest createNsRequest = getCreateNsRequest(); + + final String message = "Unable to process request"; + when(mockedJobExecutorService.runCreateNsJob(eq(createNsRequest), eq(GLOBAL_CUSTOMER_ID), eq(SERVICE_TYPE))) + .thenThrow(new NsRequestProcessingException(message, new InlineResponse400().detail(message))); + + final String baseUrl = getNsLcmBaseUrl() + "/ns_instances"; + final HttpHeaders headers = new HttpHeaders(); + headers.add(Constants.HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME, GLOBAL_CUSTOMER_ID); + final HttpEntity<?> request = new HttpEntity<>(createNsRequest, headers); + final ResponseEntity<InlineResponse400> responseEntity = + testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, InlineResponse400.class); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + assertTrue(responseEntity.hasBody()); + assertNotNull(responseEntity.getBody()); + + final InlineResponse400 body = responseEntity.getBody(); + assertEquals(message, body.getDetail()); + + } + + @Test + public void testCreateNs_createNsRequest_exceptionThrown_returnInlineResponse400() throws URISyntaxException { + + final CreateNsRequest createNsRequest = getCreateNsRequest(); + + final String message = "Unable to process request"; + when(mockedJobExecutorService.runCreateNsJob(eq(createNsRequest), eq(GLOBAL_CUSTOMER_ID), eq(SERVICE_TYPE))) + .thenThrow(new RuntimeException(message)); + + final String baseUrl = getNsLcmBaseUrl() + "/ns_instances"; + final HttpHeaders headers = new HttpHeaders(); + headers.add(Constants.HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME, GLOBAL_CUSTOMER_ID); + final HttpEntity<?> request = new HttpEntity<>(createNsRequest, headers); + final ResponseEntity<InlineResponse400> responseEntity = + testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, InlineResponse400.class); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + assertTrue(responseEntity.hasBody()); + assertNotNull(responseEntity.getBody()); + + final InlineResponse400 body = responseEntity.getBody(); + assertEquals(message, body.getDetail()); + } @Test @@ -90,11 +182,39 @@ public class NsLifecycleManagementControllerTest { @Test public void testInstantiateNs_ValidInstantiateNsRequest() { - final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + UUID.randomUUID().toString() + "/instantiate"; - final HttpEntity<?> request = new HttpEntity<>(getInstantiateNsRequest()); + + final InstantiateNsRequest instantiateNsRequest = getInstantiateNsRequest(); + when(mockedJobExecutorService.runInstantiateNsJob(eq(RANDOM_NS_INST_ID), eq(instantiateNsRequest))) + .thenReturn(RANDOM_NS_LCM_OP_OCC_ID); + + final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + RANDOM_NS_INST_ID + "/instantiate"; + final HttpEntity<?> request = new HttpEntity<>(instantiateNsRequest); final ResponseEntity<Void> responseEntity = testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, Void.class); - assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode()); + + final HttpHeaders httpHeaders = responseEntity.getHeaders(); + assertTrue(httpHeaders.containsKey(HttpHeaders.LOCATION)); + final List<String> actual = httpHeaders.get(HttpHeaders.LOCATION); + assertEquals(1, actual.size()); + assertEquals(EXPECTED_INSTANTIATE_REQ_LOCATION_URL, actual.get(0)); + } + + @Test + public void testInstantiateNs_instantiateNsRequest_nsRequestProcessingExceptionThrown_returnInlineResponse400() { + final String message = "Unable to process request"; + final InstantiateNsRequest instantiateNsRequest = getInstantiateNsRequest(); + when(mockedJobExecutorService.runInstantiateNsJob(eq(RANDOM_NS_INST_ID), eq(instantiateNsRequest))) + .thenThrow(new NsRequestProcessingException(message, new InlineResponse400().detail(message))); + + final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + RANDOM_NS_INST_ID + "/instantiate"; + final HttpEntity<?> request = new HttpEntity<>(instantiateNsRequest); + final ResponseEntity<InlineResponse400> responseEntity = + testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, InlineResponse400.class); + + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + assertTrue(responseEntity.hasBody()); + assertNotNull(responseEntity.getBody()); } @Test @@ -116,7 +236,7 @@ public class NsLifecycleManagementControllerTest { } private CreateNsRequest getCreateNsRequest() { - return new CreateNsRequest().nsdId(UUID.randomUUID().toString()); + return new CreateNsRequest().nsdId(RANDOM_NS_INST_ID); } private String getNsLcmBaseUrl() { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml new file mode 100644 index 0000000000..44acda20a4 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml @@ -0,0 +1,39 @@ +# Copyright © 2020 Nordix Foundation +# +# 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. +spring: + main: + allow-bean-definition-overriding: true + flyway: + baseline-on-migrate: false + datasource: + hikari: + camunda: + jdbcUrl: jdbc:h2:mem:example-simple;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + driver-class-name: org.h2.Driver + pool-name: ns-lcm-bpmn-pool + registerMbeans: true + nfvo: + jdbcUrl: jdbc:h2:mem:NFVO;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS NFVO; + driver-class-name: org.h2.Driver + pool-name: ns-lcm-nfvo-pool + registerMbeans: true + jpa: + hibernate: + ddl-auto: none +logging: + level: + org.reflections.Reflections: ERROR +etsi-catalog-manager: + base: + endpoint: http://modeling-etsicatalog.onap:8806/api
\ No newline at end of file diff --git a/so-monitoring/so-monitoring-service/pom.xml b/so-monitoring/so-monitoring-service/pom.xml index 6671ac56d4..4a0f6cbe1d 100644 --- a/so-monitoring/so-monitoring-service/pom.xml +++ b/so-monitoring/so-monitoring-service/pom.xml @@ -104,6 +104,24 @@ </executions> </plugin> </plugins> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <excludes> + <exclude>**/*.p12</exclude> + <exclude>**/*.jks</exclude> + </excludes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <includes> + <include>**/*.p12</include> + <include>**/*.jks</include> + </includes> + </resource> + </resources> </build> </project> diff --git a/so-monitoring/so-monitoring-service/src/main/resources/application.yaml b/so-monitoring/so-monitoring-service/src/main/resources/application.yaml index dbccb76979..ef0b6aa786 100644 --- a/so-monitoring/so-monitoring-service/src/main/resources/application.yaml +++ b/so-monitoring/so-monitoring-service/src/main/resources/application.yaml @@ -1,8 +1,12 @@ server: + ssl: + keyStore: classpath:org.onap.so.p12 + keyStorePassword: 6IxlmmPs:HqNhzVP#VFuSs,% + trustStore: classpath:org.onap.so.trust.jks + trustStorePassword: 72z0TFN&xfSR;;&NrIP^QB,^ port: 9091 tomcat: max-threads: 50 -ssl-enable: false camunda: rest: api: @@ -19,3 +23,9 @@ mso: spring: main: allow-bean-definition-overriding: true + security: + usercredentials: + - + username: gui + password: '$2a$10$ndkDhATUid4a3g0JJVRv2esX4rtB.vzCn7iBhKyR1qZ/wDdvNzjTS' + role: GUI-Client diff --git a/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.p12 b/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.p12 Binary files differnew file mode 100644 index 0000000000..8fa921a884 --- /dev/null +++ b/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.p12 diff --git a/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.trust.jks b/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.trust.jks Binary files differnew file mode 100644 index 0000000000..39c310e27e --- /dev/null +++ b/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.trust.jks diff --git a/so-monitoring/so-monitoring-ui/pom.xml b/so-monitoring/so-monitoring-ui/pom.xml index 71480416d3..574d78287a 100644 --- a/so-monitoring/so-monitoring-ui/pom.xml +++ b/so-monitoring/so-monitoring-ui/pom.xml @@ -49,7 +49,7 @@ </goals> <phase>generate-resources</phase> <configuration> - <nodeVersion>v10.15.3</nodeVersion> + <nodeVersion>v10.19.0</nodeVersion> <yarnVersion>v1.7.0</yarnVersion> </configuration> </execution> diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/angular.json b/so-monitoring/so-monitoring-ui/src/main/frontend/angular.json index b58ee265d0..45feb6007c 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/angular.json +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/angular.json @@ -55,7 +55,9 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "ONAP-SO-Monitor:build" + "browserTarget": "ONAP-SO-Monitor:build", + "sslKey": "src/app/ssl/localhost.key", + "sslCert": "src/app/ssl/localhost.crt" }, "configurations": { "production": { diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/package.json b/so-monitoring/so-monitoring-ui/src/main/frontend/package.json index c793264e99..fcbeabed69 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/package.json +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "scripts": { "ng": "ng", - "start": "ng serve", + "start": "ng serve --ssl", "build": "ng build", "test": "ng test", "lint": "ng lint", diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.crt b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.crt new file mode 100644 index 0000000000..7995c0e2c3 --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.crt @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID5jCCAs6gAwIBAgIUPVNQnCGr+uu048oN/oILqbk+DKwwDQYJKoZIhvcNAQEL +BQAwgZ8xCzAJBgNVBAYTAkdCMQ8wDQYDVQQIDAZMb25kb24xDzANBgNVBAcMBkxv +bmRvbjEYMBYGA1UECgwPTXkgT3JnYW5pc2F0aW9uMR8wHQYDVQQLDBZNeSBPcmdh +bmlzYXRpb25hbCBVbml0MR8wHQYJKoZIhvcNAQkBFhBlbWFpbEBkb21haW4uY29t +MRIwEAYDVQQDDAlsb2NhbGhvc3QwHhcNMjAwODA3MTIyMjM2WhcNMzAwNTA3MTIy +MjM2WjCBnzELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwG +TG9uZG9uMRgwFgYDVQQKDA9NeSBPcmdhbmlzYXRpb24xHzAdBgNVBAsMFk15IE9y +Z2FuaXNhdGlvbmFsIFVuaXQxHzAdBgkqhkiG9w0BCQEWEGVtYWlsQGRvbWFpbi5j +b20xEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKCtMRhrl1o1obijVfREsIatq/fEiFETCtSx3mJVKjZjYNHFn2/OjvXo +ncABnhKiFND8XiLYEgzDw9rtX3l2RVe9gQm2zNUvKPcmO+D4Dsn6QJu8HS7uDU8m +gaXRiEUHsjD+jvEF/sUKjD565XRGd9qCyDpdtjra2W7CGZdzTrdepMRJhxMmA0fB +t3JsV/52WMCqU6drSxT8hH7PvXh4nwr9DQ2fvUZarRptiW2Dg9zSqO+6M3XWCvUI +jdm4Q0jxXY2jCLsh1oTo3dIYdHedB4LORXAPIRsLdJ1/ofl9NdyL20kG4ONIdJXv +5mTuPGBATGOWEJvD8TTxrZtEMx9GNTsCAwEAAaMYMBYwFAYDVR0RBA0wC4IJbG9j +YWxob3N0MA0GCSqGSIb3DQEBCwUAA4IBAQAIDUoitU/11f9ApfPXwtuDaPeX20sc +gSfq/MLQ9LttSi/SpAjebSlp12JNkZvxuV+2cPmc92NWv8WXqfyP+0BDhlGTm1qp +Hc/wRB9ASG/7Z1imAh+zpNXFe0fV0HpUqJx33ywiXLoMTTaSvwPSF4VEki8g9h2R +8zVXjsaE0ybi4eUIKG+ZJ2EBaVgLMEm+osVMnkTEWIeR3XN66Ko2SegvOrAjfOyz +CIqkDvPhowYkKVV4LSsFIgz+YKOVMxaEcHbrxciYKymmWQ/9I/ek8TUs8C4z6cKs +n+9nvYisfFpZ6tpMU+cgYkGezOCV5+nAri+SHoAfAOMXVPLACT39sOF9 +-----END CERTIFICATE----- diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.key b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.key new file mode 100644 index 0000000000..85e6b7e09d --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCgrTEYa5daNaG4 +o1X0RLCGrav3xIhREwrUsd5iVSo2Y2DRxZ9vzo716J3AAZ4SohTQ/F4i2BIMw8Pa +7V95dkVXvYEJtszVLyj3Jjvg+A7J+kCbvB0u7g1PJoGl0YhFB7Iw/o7xBf7FCow+ +euV0Rnfagsg6XbY62tluwhmXc063XqTESYcTJgNHwbdybFf+dljAqlOna0sU/IR+ +z714eJ8K/Q0Nn71GWq0abYltg4Pc0qjvujN11gr1CI3ZuENI8V2Nowi7IdaE6N3S +GHR3nQeCzkVwDyEbC3Sdf6H5fTXci9tJBuDjSHSV7+Zk7jxgQExjlhCbw/E08a2b +RDMfRjU7AgMBAAECggEAByszAY/rVM8HxCEleJyH87pT7d4K5vMejJbTATgjhgGx +FCrpDif9IOOcBjEMSHCK1TgtSwiw5XjmiCIHHHg2Z8/ArhpF0U0lWsGN8l+e6UwN +DeW6t5lPZrSlHCzZE5tgS+dPoVlPIKNz1mXNTv7F4i3rmQ8NTlrtUI/AbI1seanh +Ofb2yhHkkiHYIUridCDTuhk9hMmypHB9THA7SFRB7C9/zO8T95I2D1QQ5ZO5xKGg +rDAMacSeQMnuKNcyuF4RYoh0T4PmM1NFGH1F1+QKTAt5CU0rkZtMHZ9YuYPYCC1S +f1YrPQSJ5mFstaF9kWDp1rnR2J8Od/KU5ZSOgmvMoQKBgQDUithsDxnGEOQCKXfX +e6/kgaL7mB5Q/Pgeyiy5lyBjTLZcbFeaDzkRBR3zL5v8xbNZ4IsJqkaxJavrIwr4 +R2+WvuznEaeLhFds0ze57kDyV/uunsQwBSJSXYohCRiq1gc7nqpamSSpFFI9Ls81 +JmXSPdyosRWESjCTCrQffZFKhQKBgQDBh4VZ9lSAGfASKjkqGLncAEHcnCbavQoy +2DlHEhA+gZDvR2CSsunIxlQerZC78KcTA+oex54Ovi+NG8Rx6qyyywxiGjm0e1yG +B2z060CTO9PlMhs81kXJkUDxR4tHyMNtLaFKICJ9J6wZXBnYZcMU+Do7OhlRVoaL +qrNwhonsvwKBgCCTq3pckim+mwQN0RWRGrOefxmrBjKJo4osmNBVbpxpvKXL4V12 +qduG+kE08ea7crL67LStiapLSN+AfoTxhhQH7Y25MgH7Zd8DPM5dy0yZ2bS5Fv75 +Onp/ZdWMbGB6757eweOjB3B28ef4zb+qw/6GhtTAV7jwGiPfhx4wg911AoGBAIAP +1H82UK4/+6uZgyBHIl3hUbPRJKjkJOaGTEiqPFOQWz7rJY2NlMQF8U4nnjmvQm+D +zJ23i/DHiyG9+R1EpCjf0f7sybiTVSNfsIrVTXLgSRRGNt3oEGAUnTvMEu9ae284 +nZ02bHwTD3/sgTHADPpIVAgzJuO69Odg+sKAVK5zAoGAVn6bUm+QVuELmn8CNT+y +XsSks5gu0MDwuSbUwjuNjSGMEab2lwyIgY8CduopyJWLPgkVtALiuXxp6OzPNCE4 +pC/5HNaqawCQ7Kgbk6MjRwY551HQRgMG7wf9iFBP8sfdWG30vYFmiYWN4oUEDi5j +ytwU+extcKSRxj/O1op3KDI= +-----END PRIVATE KEY----- diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts index f0c63fe582..bf2f31d5c9 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts @@ -24,5 +24,5 @@ SPDX-License-Identifier: Apache-2.0 export const environment = { production: false, - soMonitoringBackendURL: 'http://so-monitoring:30224/so/monitoring/' + soMonitoringBackendURL: 'https://so-monitoring:30224/so/monitoring/' }; diff --git a/version.properties b/version.properties index 4bdcfa1b54..f56901fc20 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ major=1 minor=7 -patch=1 +patch=2 base_version=${major}.${minor}.${patch} |