diff options
146 files changed, 3722 insertions, 547 deletions
diff --git a/adapters/etsi-sol002-adapter/pom.xml b/adapters/etsi-sol002-adapter/pom.xml index 81e35d896d..5dee8fe8e6 100644 --- a/adapters/etsi-sol002-adapter/pom.xml +++ b/adapters/etsi-sol002-adapter/pom.xml @@ -82,6 +82,18 @@ </executions> </plugin> </plugins> + <resources> + <resource> + <directory>${basedir}/src/main/resources</directory> + <excludes> + <exclude>certs/*</exclude> + </excludes> + </resource> + <resource> + <directory>${basedir}/src/main/resources/certs</directory> + <filtering>false</filtering> + </resource> + </resources> </build> </project> diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java index 411572ff5b..38f7a0cd3f 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java @@ -20,17 +20,44 @@ package org.onap.so.adapters.vevnfm.configuration; +import java.io.IOException; +import java.security.*; +import java.security.cert.CertificateException; +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.so.adapters.vevnfm.provider.AuthorizationHeadersProvider; import org.onap.so.configuration.rest.HttpHeadersProvider; 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.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.web.client.RestTemplate; @Configuration public class ApplicationConfiguration { + private static final Logger logger = LoggerFactory.getLogger(ApplicationConfiguration.class); + + private final Resource clientKeyStore; + private final String clientKeyStorePassword; + private final Resource clientTrustStore; + private final String clientTrustStorePassword; + + public ApplicationConfiguration(final ConfigProperties configProperties) { + clientKeyStore = configProperties.getClientKeyStore(); + clientKeyStorePassword = configProperties.getClientKeyStorePassword(); + clientTrustStore = configProperties.getClientTrustStore(); + clientTrustStorePassword = configProperties.getClientTrustStorePassword(); + } + @Bean public AuthorizationHeadersProvider headersProvider() { return new AuthorizationHeadersProvider(); @@ -39,6 +66,35 @@ public class ApplicationConfiguration { @Bean public HttpRestServiceProvider restProvider(final RestTemplate restTemplate, final HttpHeadersProvider headersProvider) { + modify(restTemplate); return new HttpRestServiceProviderImpl(restTemplate, headersProvider); } + + private void modify(final RestTemplate restTemplate) { + + if (clientKeyStore == null || clientTrustStore == null) { + return; + } + + try { + final KeyStore keystore = KeyStore.getInstance("PKCS12"); + keystore.load(clientKeyStore.getInputStream(), clientKeyStorePassword.toCharArray()); + + final SSLContext sslContext = new SSLContextBuilder() + .loadTrustMaterial(clientTrustStore.getURL(), clientTrustStorePassword.toCharArray()) + .loadKeyMaterial(keystore, clientKeyStorePassword.toCharArray()).build(); + + logger.info("Setting truststore: {}", clientTrustStore.getURL()); + + final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext); + final HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); + final HttpComponentsClientHttpRequestFactory factory = + new HttpComponentsClientHttpRequestFactory(httpClient); + + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); + } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException + | IOException | UnrecoverableKeyException e) { + logger.error("Error reading truststore, TLS connection to VNFM will fail.", e); + } + } } diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java index d4ca5af0f2..a8a436ddc6 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java @@ -23,6 +23,7 @@ package org.onap.so.adapters.vevnfm.configuration; import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; @Configuration public class ConfigProperties { @@ -72,6 +73,18 @@ public class ConfigProperties { @Value("${spring.security.usercredentials[0].openpass}") private String springSecurityOpenpass; + @Value("${client.key-store:#{null}}") + private Resource clientKeyStore; + + @Value("${client.key-store-password:#{null}}") + private String clientKeyStorePassword; + + @Value("${client.trust-store:#{null}}") + private Resource clientTrustStore; + + @Value("${client.trust-store-password:#{null}}") + private String clientTrustStorePassword; + public String getVevnfmadapterVnfFilterJson() { return vevnfmadapterVnfFilterJson; } @@ -131,4 +144,20 @@ public class ConfigProperties { public String getSpringSecurityOpenpass() { return springSecurityOpenpass; } + + public Resource getClientKeyStore() { + return clientKeyStore; + } + + public String getClientKeyStorePassword() { + return clientKeyStorePassword; + } + + public Resource getClientTrustStore() { + return clientTrustStore; + } + + public String getClientTrustStorePassword() { + return clientTrustStorePassword; + } } diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java index c128275e43..eba1d087c6 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java @@ -28,7 +28,6 @@ import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.EnableRetry; import org.springframework.retry.annotation.Recover; @@ -44,7 +43,6 @@ public class StartupService { private final String vnfmDefaultEndpoint; private final AaiConnection aaiConnection; - @Autowired public StartupService(final ConfigProperties configProperties, final AaiConnection aaiConnection) { this.vnfmDefaultEndpoint = configProperties.getVnfmDefaultEndpoint(); this.aaiConnection = aaiConnection; diff --git a/adapters/etsi-sol002-adapter/src/main/resources/application.yaml b/adapters/etsi-sol002-adapter/src/main/resources/application.yaml index c69c95187a..f5b6bc3158 100644 --- a/adapters/etsi-sol002-adapter/src/main/resources/application.yaml +++ b/adapters/etsi-sol002-adapter/src/main/resources/application.yaml @@ -19,17 +19,23 @@ server: vevnfmadapter: vnf-filter-json: '{notificationTypes:[VnfLcmOperationOccurrenceNotification],operationStates:[COMPLETED]}' - endpoint: http://so-ve-vnfm-adapter.onap:9098 + endpoint: http://so-ve-vnfm-adapter:9098 + +client: + key-store: classpath:ve-vnfm-adapter.p12 + key-store-password: 'ywsqCy:EEo#j}HJHM7z^Rk[L' + trust-store: classpath:org.onap.so.trust.jks + trust-store-password: ',sx#.C*W)]wVgJC6ccFHI#:H' mso: key: 07a7159d3bf51a0e53be7a8f89699be7 aai: - endpoint: https://aai.onap:30233 + endpoint: https://aai:30233 auth: 75C4483F9C05E2C33A8602635FA532397EC44AB667A2B64DED4FEE08DD932F2E3C1FEE vnfm: - default-endpoint: https://so-vnfm-simulator.onap:9093 + default-endpoint: https://so-vnfm-simulator:9093 subscription: /vnflcm/v1/subscriptions notification: /lcm/v1/vnf/instances/notifications @@ -37,7 +43,7 @@ notification: vnf-filter-type: NONE dmaap: - endpoint: http://message-router.onap:30227 + endpoint: http://message-router:30227 topic: /events/unauthenticated.DCAE_CL_OUTPUT closed-loop: control: diff --git a/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks b/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks Binary files differnew file mode 100644 index 0000000000..1f0d8a550a --- /dev/null +++ b/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks diff --git a/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 b/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 Binary files differnew file mode 100644 index 0000000000..ae4fddc684 --- /dev/null +++ b/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 893f50c458..d78178f5ba 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -353,5 +353,10 @@ <artifactId>camunda-external-task-client</artifactId> <version>1.1.1</version> </dependency> + <dependency> + <groupId>com.github.seancfoley</groupId> + <artifactId>ipaddress</artifactId> + <version>2.0.0</version> + </dependency> </dependencies> </project> diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java index 15c5eda054..1f0422b0b2 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java @@ -47,20 +47,19 @@ public class DeleteAAIInventory { @Autowired protected Environment env; - public void heatbridge(CloudInformation cloudInformation, boolean dryrun) { + public void heatbridge(CloudInformation cloudInformation) { try { - if (!dryrun) { - logger.debug("Heatbridge delete executing"); + logger.debug("Heatbridge delete executing"); + + CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) + .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); + HeatBridgeApi heatBridgeClient = + new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudInformation.getOwner(), + cloudInformation.getRegionId(), cloudSite.getRegionId(), cloudInformation.getTenantId()); + heatBridgeClient.authenticate(); + heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId()); - CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) - .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); - CloudIdentity cloudIdentity = cloudSite.getIdentityService(); - HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, - cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(), - cloudInformation.getTenantId()); - heatBridgeClient.authenticate(); - heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId()); - } } catch (Exception ex) { logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java index 4d8c74dbfe..4e5e880f80 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java @@ -44,7 +44,7 @@ public class DeleteInventoryService { public void auditAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete") - .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000"))) + .lockDuration(externalTaskServiceUtils.getLockDurationMedium()) .handler(deleteInventory::executeExternalTask).open(); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java index c5feee2089..10faa2b08f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java @@ -60,14 +60,13 @@ public class DeleteInventoryTask extends ExternalTaskUtils { protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); - boolean inventoryException = false; String externalTaskId = externalTask.getId(); CloudInformation cloudInformation = externalTask.getVariable("cloudInformation"); boolean success = true; if (cloudInformation != null) { Integer retryCount = externalTask.getRetries(); try { - deleteInventory.heatbridge(cloudInformation, env.getProperty("heatBridgeDryrun", Boolean.class, true)); + deleteInventory.heatbridge(cloudInformation); } catch (Exception e) { logger.error("Error during inventory of stack", e); success = false; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java index db9a7cefae..d4a4bb792f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java @@ -70,7 +70,7 @@ public class TaskServices { public void auditAddAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong()) .handler(auditCreateStack::executeExternalTask).open(); } } @@ -79,7 +79,7 @@ public class TaskServices { public void auditDeleteAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong()) .handler(auditDeleteStack::executeExternalTask).open(); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java index eab0451aa6..df4229c985 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java @@ -108,7 +108,8 @@ public class CreateAAIInventory { if (!CollectionUtils.isEmpty(oobMgtNetNames)) { oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames); } - heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds); + heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds, + cloudInformation.getOwner()); logger.debug( "Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers."); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java index d0ca87df95..9c098863f2 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java @@ -134,8 +134,10 @@ public interface HeatBridgeApi { * * @param stackResources Openstack Heat stack resource list * @param oobMgtNetIds List of OOB network IDs list + * @param cloudOwner */ - void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds); + void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds, + String cloudOwner); /** * Query and build AAI actions for Openstack Compute resources to AAI's pserver and pinterface objects 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 53736e912f..92e9b13bb6 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 @@ -42,6 +42,7 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; import javax.annotation.Nonnull; +import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.validator.routines.InetAddressValidator; @@ -66,6 +67,7 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; import org.onap.logging.filter.base.ErrorCode; @@ -79,17 +81,21 @@ import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl; import org.onap.so.heatbridge.utils.HeatBridgeUtils; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; +import org.onap.so.spring.SpringContextHelper; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.IP; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.env.Environment; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; +import inet.ipaddr.IPAddressString; /** * This class provides an implementation of {@link HeatBridgeApi} @@ -109,6 +115,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { private String tenantId; private AaiHelper aaiHelper = new AaiHelper(); private CloudIdentity cloudIdentity; + private Environment env; + public HeatBridgeImpl(AAIResourcesClient resourcesClient, final CloudIdentity cloudIdentity, @Nonnull final String cloudOwner, @Nonnull final String cloudRegionId, @Nonnull final String regionId, @@ -124,7 +132,10 @@ public class HeatBridgeImpl implements HeatBridgeApi { this.regionId = regionId; this.tenantId = tenantId; this.resourcesClient = resourcesClient; - this.transaction = resourcesClient.beginSingleTransaction(); + if (resourcesClient != null) + this.transaction = resourcesClient.beginSingleTransaction(); + if (SpringContextHelper.getAppContext() != null) + this.env = SpringContextHelper.getAppContext().getEnvironment(); } public HeatBridgeImpl() { @@ -246,26 +257,25 @@ public class HeatBridgeImpl implements HeatBridgeApi { // Build vserver relationships to: image, flavor, pserver, vf-module vserver.setRelationshipList( aaiHelper.getVserverRelationshipList(cloudOwner, cloudRegionId, genericVnfId, vfModuleId, server)); - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegionId, - tenantId, vserver.getVserverId()), vserver); + transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, + cloudRegionId, tenantId, vserver.getVserverId()), Optional.of(vserver)); }); } @Override public void buildAddVserverLInterfacesToAaiAction(final List<Resource> stackResources, - final List<String> oobMgtNetIds) { + final List<String> oobMgtNetIds, String cloudOwner) { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); List<String> portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE); for (String portId : portIds) { Port port = osClient.getPortById(portId); + Network network = osClient.getNetworkById(port.getNetworkId()); LInterface lIf = new LInterface(); lIf.setInterfaceId(port.getId()); lIf.setInterfaceName(port.getName()); lIf.setMacaddr(port.getMacAddress()); - if (port.getProfile() != null && port.getProfile().get("physical_network") != null) { - lIf.setNetworkName((String) port.getProfile().get("physical_network")); - } + lIf.setNetworkName(network.getName()); lIf.setIsPortMirrored(false); lIf.setIsIpUnnumbered(false); lIf.setInMaint(false); @@ -282,12 +292,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { } } lIf.setL2Multicasting(isL2Multicast); + + transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, + cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName()), Optional.of(lIf)); + updateLInterfaceIps(port, lIf); - updateLInterfaceVlan(port, lIf); + if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) { + updateLInterfaceVlan(port, lIf); + } - // Update l-interface to the vserver - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, cloudRegionId, - tenantId, port.getDeviceId(), lIf.getInterfaceName()), lIf); + updateSriovPfToPserver(port, lIf); } } @@ -341,38 +355,35 @@ public class HeatBridgeImpl implements HeatBridgeApi { Vlan vlan = new Vlan(); Network network = osClient.getNetworkById(port.getNetworkId()); if (network.getNetworkType() != null && network.getNetworkType().equals(NetworkType.VLAN)) { - vlan.setVlanInterface(network.getName() + network.getProviderSegID()); - + vlan.setVlanInterface(port.getName() + network.getProviderSegID()); vlan.setVlanIdOuter(Long.parseLong(network.getProviderSegID())); vlan.setVlanIdInner(0L); vlan.setInMaint(false); vlan.setIsIpUnnumbered(false); vlan.setIsPrivate(false); - Vlans vlans = new Vlans(); - List<Vlan> vlanList = vlans.getVlan(); - vlanList.add(vlan); - lIf.setVlans(vlans); + + transaction + .createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).vlan(vlan.getVlanInterface())), + Optional.of(vlan)); } - // Build sriov-vf to the l-interface + if (port.getvNicType() != null && port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { - SriovVfs sriovVfs = new SriovVfs(); - // JAXB does not generate setters for list, however getter ensures its creation. - // Thus, all list manipulations must be made on live list. - List<SriovVf> sriovVfList = sriovVfs.getSriovVf(); SriovVf sriovVf = new SriovVf(); sriovVf.setPciId(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); sriovVf.setNeutronNetworkId(port.getNetworkId()); - if (port.getVifDetails() != null) { - sriovVf.setVfVlanFilter((String) port.getVifDetails().get(HeatBridgeConstants.OS_VLAN_NETWORK_KEY)); - } + sriovVf.setVfVlanFilter("0"); sriovVf.setVfVlanAntiSpoofCheck(false); sriovVf.setVfMacAntiSpoofCheck(false); - sriovVfList.add(sriovVf); - - lIf.setSriovVfs(sriovVfs); - // For the given port create sriov-pf for host pserver/p-interface if absent - updateSriovPfToPserver(port, lIf); + transaction + .createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).sriovVf(sriovVf.getPciId())), + Optional.of(sriovVf)); } } @@ -386,63 +397,82 @@ public class HeatBridgeImpl implements HeatBridgeApi { * @param lIf AAI l-interface object */ private void updateSriovPfToPserver(final Port port, final LInterface lIf) { - if (port.getProfile() == null || Strings - .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) { - logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update " - + "sriov-pf object for host pserver: " + port.getHostId()); - return; - } - Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName( - port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString()); - if (matchingPifName.isPresent()) { - // Update l-interface description - String pserverHostName = port.getHostId(); - lIf.setInterfaceDescription("Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); - try { - Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class, - AAIUriFactory - .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, matchingPifName.get()) - .depth(Depth.ONE)); - if (matchingPIf.isPresent()) { - SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs(); - if (pIfSriovPfs == null) { - pIfSriovPfs = new SriovPfs(); - } - // Extract PCI-ID from OS port object - String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); - - List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf(); - if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream() - .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { - // Add sriov-pf object with PCI-ID to AAI - SriovPf sriovPf = new SriovPf(); - sriovPf.setPfPciId(pfPciId); - logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName - + "/" + matchingPifName.get()); - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, pserverHostName, - matchingPifName.get(), sriovPf.getPfPciId()), sriovPf); + if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { + if (port.getProfile() == null || Strings + .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) { + logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update " + + "sriov-pf object for host pserver: " + port.getHostId()); + return; + } + Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName( + port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString()); + if (matchingPifName.isPresent()) { + // Update l-interface description + String pserverHostName = port.getHostId(); + lIf.setInterfaceDescription( + "Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); + try { + Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class, AAIUriFactory + .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, matchingPifName.get()) + .depth(Depth.ONE)); + if (matchingPIf.isPresent()) { + SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs(); + if (pIfSriovPfs == null) { + pIfSriovPfs = new SriovPfs(); + } + // Extract PCI-ID from OS port object + String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); + + List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf(); + if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream() + .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { + // Add sriov-pf object with PCI-ID to AAI + SriovPf sriovPf = new SriovPf(); + sriovPf.setPfPciId(pfPciId); + logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName + + "/" + matchingPifName.get()); + + AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, + pserverHostName, matchingPifName.get(), sriovPf.getPfPciId()); + + if (!resourcesClient.exists(sriovPfUri)) { + transaction.create(sriovPfUri, sriovPf); + + AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_VF, + cloudOwner, cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName(), + port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); + + transaction.connect(sriovPfUri, sriovVfUri); + } + } } + } catch (WebApplicationException e) { + // Silently log that we failed to update the Pserver p-interface with PCI-ID + logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName, + matchingPifName.get(), cloudOwner, tenantId, "OpenStack", "Heatbridge", + ErrorCode.DataError.getValue(), "Exception - Failed to add sriov-pf object to pserver", e); } - } catch (WebApplicationException e) { - // Silently log that we failed to update the Pserver p-interface with PCI-ID - logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName, matchingPifName.get(), - cloudOwner, tenantId, "OpenStack", "Heatbridge", ErrorCode.DataError.getValue(), - "Exception - Failed to add sriov-pf object to pserver", e); } } } private void updateLInterfaceIps(final Port port, final LInterface lIf) { - List<L3InterfaceIpv4AddressList> lInterfaceIps = lIf.getL3InterfaceIpv4AddressList(); 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.setL3InterfaceIpv4Address(ipAddress); lInterfaceIp.setNeutronNetworkId(port.getNetworkId()); lInterfaceIp.setNeutronSubnetId(ip.getSubnetId()); - lInterfaceIp.setL3InterfaceIpv4PrefixLength(32L); - lInterfaceIps.add(lInterfaceIp); + lInterfaceIp.setL3InterfaceIpv4PrefixLength(Long.parseLong(cidr.getNetworkPrefixLength().toString())); + + transaction.createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).l3InterfaceIpv4AddressList(ipAddress)), + Optional.of(lInterfaceIp)); } } } @@ -464,27 +494,34 @@ public class HeatBridgeImpl implements HeatBridgeApi { Objects.requireNonNull(vnfId, "Null vnf-id!"); Objects.requireNonNull(vfModuleId, "Null vf-module-id!"); try { - Optional<VfModule> vfModule = resourcesClient.get(VfModule.class, - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE)); - logger.debug("vfModule is present: {}", vfModule.isPresent()); - if (vfModule.isPresent()) { - - AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get()); - Optional<Relationships> relationships = resultWrapper.getRelationships(); - logger.debug("relationships is present: {}", relationships.isPresent()); - if (relationships.isPresent()) { - List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER); - logger.debug("vserverList isEmpty: {}", vserverUris.isEmpty()); - createTransactionToDeleteSriovPfFromPserver(vserverUris); - - if (!vserverUris.isEmpty()) { - for (AAIResourceUri vserverUri : vserverUris) { - logger.debug("Deleting Vservers: {}", vserverUri.toString()); + Optional<VfModule> vfModule = resourcesClient + .get(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE), + NotFoundException.class) + .asBean(VfModule.class); + + AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get()); + Optional<Relationships> relationships = resultWrapper.getRelationships(); + logger.debug("VfModule contains relationships in AAI: {}", relationships.isPresent()); + if (relationships.isPresent()) { + List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER); + logger.debug("VServer contains {} relationships in AAI", vserverUris.size()); + createTransactionToDeleteSriovPfFromPserver(vserverUris); + + if (!vserverUris.isEmpty()) { + for (AAIResourceUri vserverUri : vserverUris) { + if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + logger.debug("Would delete Vserver: {}", vserverUri.build().toString()); + } else { resourcesClient.delete(vserverUri); } } } } + + } catch (NotFoundException e) { + String msg = "Failed to commit delete heatbridge data transaction"; + logger.debug(msg + " with error: " + e); + throw new HeatBridgeException(msg, e); } catch (Exception e) { String msg = "Failed to commit delete heatbridge data transaction"; logger.debug(msg + " with error: " + e); @@ -507,8 +544,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { if (pciIds.contains(sriovPf.getPfPciId())) { logger.debug("creating transaction to delete SR-IOV PF: " + pIf.getInterfaceName() + " from PServer: " + pserverName); - resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, - pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId())); + if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + logger.debug("Would delete Sriov Pf: {}", + AAIUriFactory + .createResourceUri(AAIObjectType.SRIOV_PF, pserverName, + pIf.getInterfaceName(), sriovPf.getPfPciId()) + .build().toString()); + } else { + resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, + pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId())); + } } })); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 6817be8c49..c4d9cbe871 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -145,7 +145,6 @@ public class AaiHelper { vserver.setVserverId(serverId); vserver.setVserverName(server.getName()); vserver.setVserverName2(server.getName()); - vserver.setProvStatus(server.getStatus().value()); server.getLinks().stream().filter(link -> link.getRel().equals(HeatBridgeConstants.OS_RESOURCES_SELF_LINK_KEY)) .findFirst().ifPresent(link -> vserver.setVserverSelflink(link.getHref())); return vserver; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java index 7184ec1e93..8d47ff4ceb 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java @@ -42,6 +42,7 @@ import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; public interface OpenstackClient { @@ -92,4 +93,12 @@ public interface OpenstackClient { * @return List of filtered Network objects */ List<Network> listNetworksByFilter(Map<String, String> filterParams); + + /** + * Get a subnet object by subnet ID + * + * @param subnetId Unique UUID of the subnet. + * @return Subnet object. + */ + Subnet getSubnetById(String subnetId); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java index 5a2b0732dc..1505203d7c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java @@ -45,6 +45,7 @@ import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; abstract class OpenstackClientImpl implements OpenstackClient { @Override @@ -78,6 +79,11 @@ abstract class OpenstackClientImpl implements OpenstackClient { return (List<Network>) getClient().networking().network().list(filterParams); } + @Override + public Subnet getSubnetById(String subnetId) { + return getClient().networking().subnet().get(subnetId); + } + /** * Retrieves the specific client to utilize. * 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 464a17d2a5..643dd4cd9a 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 @@ -42,15 +42,18 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.doReturn; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.Set; import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Before; @@ -58,12 +61,13 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.SriovPf; -import org.onap.aai.domain.yang.Vserver; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; @@ -80,11 +84,13 @@ import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.compute.Server.Status; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.IP; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; 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.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; @@ -104,16 +110,20 @@ public class HeatBridgeImplTest { @Mock private AAIResourcesClient resourcesClient; + @Mock private AAISingleTransactionClient transaction; - private HeatBridgeImpl heatbridge; + @Mock + private Environment env; + + @InjectMocks + private HeatBridgeImpl heatbridge = + new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, REGION_ID, TENANT_ID); @Before public void setUp() throws HeatBridgeException, OpenstackClientException, BulkProcessFailed { - when(resourcesClient.beginSingleTransaction()).thenReturn(transaction); - heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, REGION_ID, TENANT_ID); } @Ignore @@ -252,7 +262,7 @@ public class HeatBridgeImplTest { // Assert ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class); - verify(transaction, times(2)).create(captor.capture(), any(Vserver.class)); + verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); List<AAIResourceUri> uris = captor.getAllValues(); assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, @@ -296,7 +306,7 @@ public class HeatBridgeImplTest { // Assert ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class); - verify(transaction, times(2)).create(captor.capture(), any(Vserver.class)); + verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); List<AAIResourceUri> uris = captor.getAllValues(); assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, @@ -396,7 +406,6 @@ public class HeatBridgeImplTest { verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); } - @Ignore @Test public void testUpdateVserverLInterfacesToAai() throws HeatBridgeException { // Arrange @@ -408,7 +417,6 @@ public class HeatBridgeImplTest { when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); when(port.getDeviceId()).thenReturn("test-device-id"); - when(port.getVifDetails()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_VLAN_NETWORK_KEY, "2345")); String pfPciId = "0000:08:00.0"; when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); @@ -430,12 +438,55 @@ public class HeatBridgeImplTest { PInterface pIf = mock(PInterface.class); when(pIf.getInterfaceName()).thenReturn("test-port-id"); when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf)); + when(env.getProperty("mso.cloudOwner.included", "")).thenReturn("CloudOwner"); // Act - heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2")); + heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); // Assert - verify(transaction, times(5)).create(any(AAIResourceUri.class), any(LInterface.class)); + verify(transaction, times(15)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + verify(osClient, times(5)).getPortById(anyString()); + verify(osClient, times(10)).getNetworkById(anyString()); + } + + @Test + public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException { + // Arrange + List<Resource> stackResources = (List<Resource>) extractTestStackResources(); + Port port = mock(Port.class); + when(port.getId()).thenReturn("test-port-id"); + when(port.getName()).thenReturn("test-port-name"); + when(port.getvNicType()).thenReturn(HeatBridgeConstants.OS_SRIOV_PORT_TYPE); + when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); + when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); + when(port.getDeviceId()).thenReturn("test-device-id"); + String pfPciId = "0000:08:00.0"; + when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, + HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); + + Network network = mock(Network.class); + when(network.getId()).thenReturn("test-network-id"); + when(network.getNetworkType()).thenReturn(NetworkType.VLAN); + when(network.getProviderSegID()).thenReturn("2345"); + + when(osClient.getPortById("212a203a-9764-4f42-84ea-731536a8f13a")).thenReturn(port); + when(osClient.getPortById("387e3904-8948-43d1-8635-b6c2042b54da")).thenReturn(port); + when(osClient.getPortById("70a09dfd-f1c5-4bc8-bd8f-dc539b8d662a")).thenReturn(port); + when(osClient.getPortById("12f88b4d-c8a4-4fbd-bcb4-7e36af02430b")).thenReturn(port); + when(osClient.getPortById("c54b9f45-b413-4937-bbe4-3c8a5689cfc9")).thenReturn(port); + when(osClient.getNetworkById(anyString())).thenReturn(network); + + SriovPf sriovPf = new SriovPf(); + sriovPf.setPfPciId(pfPciId); + PInterface pIf = mock(PInterface.class); + when(pIf.getInterfaceName()).thenReturn("test-port-id"); + when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf)); + + // Act + heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); + + // Assert + verify(transaction, times(5)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); verify(osClient, times(5)).getPortById(anyString()); verify(osClient, times(5)).getNetworkById(anyString()); } @@ -463,4 +514,6 @@ public class HeatBridgeImplTest { } return content; } + + } diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 42955c35c9..ac45f85711 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -64,8 +64,6 @@ mso: adapters: requestDb: endpoint: http://localhost:${wiremock.server.port} - audit: - lock-time: 240000 logPath: logs msb-ip: localhost msb-port: ${wiremock.server.port} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java index 20093be6a4..1da6fc096f 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java @@ -52,7 +52,6 @@ import org.onap.appc.client.lcm.model.ZULU; @Component public class ApplicationControllerClient { - @Autowired public Environment env; @@ -117,6 +116,7 @@ public class ApplicationControllerClient { controllerType = DEFAULT_CONTROLLER_TYPE; } controllerType = controllerType.toUpperCase(); + return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); } catch (AppcClientException e) { @@ -128,7 +128,7 @@ public class ApplicationControllerClient { } public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId, - Optional<String> request, String controllerType, ApplicationControllerCallback listener) + Optional<String> request, String controllerType, ApplicationControllerCallback listener, String requestorId) throws ApplicationControllerOrchestratorException { this.setControllerType(controllerType); Status status; @@ -142,7 +142,7 @@ public class ApplicationControllerClient { payload = new Payload(request.get()); } - status = runCommand(action, actionIdentifiers, payload, requestId, listener); + status = runCommand(action, actionIdentifiers, payload, requestId, listener, requestorId); if (appCSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) { throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode()); } else { @@ -152,11 +152,11 @@ public class ApplicationControllerClient { public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, - org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener) - throws ApplicationControllerOrchestratorException { + org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener, + String requestorId) throws ApplicationControllerOrchestratorException { Status status; Object requestObject; - requestObject = createRequest(action, actionIdentifiers, payload, requestID); + requestObject = createRequest(action, actionIdentifiers, payload, requestID, requestorId); appCSupport.logLCMMessage(requestObject); LifeCycleManagerStateful client = getAppCClient(); Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, true); @@ -194,12 +194,13 @@ public class ApplicationControllerClient { return properties; } - public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { + public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId, + String requestorId) { Object requestObject = appCSupport.getInput(action.name()); try { - CommonHeader commonHeader = buildCommonHeader(requestId); + CommonHeader commonHeader = buildCommonHeader(requestId, requestorId); requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, commonHeader); requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); @@ -215,12 +216,13 @@ public class ApplicationControllerClient { return requestObject; } - private CommonHeader buildCommonHeader(String requestId) { + private CommonHeader buildCommonHeader(String requestId, String requestorId) { CommonHeader commonHeader = new CommonHeader(); commonHeader.setApiVer(API_VER); commonHeader.setOriginatorId(ORIGINATOR_ID); commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); commonHeader.setSubRequestId(UUID.randomUUID().toString()); + commonHeader.setXOnapRequestorid(requestorId); Flags flags = new Flags(); String flagsMode = "NORMAL"; Mode mode = Mode.valueOf(flagsMode); diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java index 8e38935441..e61053d043 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java @@ -111,7 +111,7 @@ public class ApplicationControllerTaskImpl { status = appcClient.vnfCommand(request.getAction(), msoRequestId, request.getApplicationControllerVnf().getVnfId(), vserverId, payload, request.getControllerType(), - listener); + listener, request.getRequestorId()); return status; } diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java index 82b0695ed9..cac8e9e16a 100644 --- a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java @@ -63,6 +63,7 @@ public class ApplicationControllerTaskImplITTest { @Before public void setup() { request = new ApplicationControllerTaskRequest(); + request.setRequestorId("testRequestorId"); request.setBookName("testBookName"); request.setControllerType("testControllerType"); request.setFileParameters("testFileParams"); diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java index ff979acf7b..fe2b4f84b5 100644 --- a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java @@ -52,6 +52,7 @@ public class ApplicationControllerTaskImplTest { request.setNewSoftwareVersion("2.0"); request.setExistingSoftwareVersion("1.0"); request.setOperationsTimeout("30"); + request.setRequestorId("testRequestorId"); Map<String, String> reqConfigParams = new HashMap<>(); reqConfigParams.put("name1", "value1"); reqConfigParams.put("name2", "value2"); @@ -77,13 +78,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @@ -99,13 +100,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -118,13 +119,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -133,13 +134,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), - "testControllerType", listener)).thenReturn(new Status()); + "testControllerType", listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), - "testControllerType", listener); + "testControllerType", listener, "testRequestorId"); } @Test @@ -154,13 +155,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -179,13 +180,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -204,13 +205,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -224,13 +225,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -251,13 +252,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java index e867b670b7..e45811117c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java @@ -28,6 +28,7 @@ public class ExecuteBuildingBlock extends BuildingBlockBase<ExecuteBuildingBlock private BuildingBlock buildingBlock; private ConfigurationResourceKeys configurationResourceKeys; private Boolean homing = false; + private String oldVolumeGroupName; private static final long serialVersionUID = 3L; public BuildingBlock getBuildingBlock() { @@ -56,4 +57,13 @@ public class ExecuteBuildingBlock extends BuildingBlockBase<ExecuteBuildingBlock this.configurationResourceKeys = configurationResourceKeys; return this; } + + public String getOldVolumeGroupName() { + return oldVolumeGroupName; + } + + public ExecuteBuildingBlock setOldVolumeGroupName(String oldVolumeGroupName) { + this.oldVolumeGroupName = oldVolumeGroupName; + return this; + } } 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 fcc8484385..0cdf8a6e5d 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 @@ -750,6 +750,10 @@ public class BBInputSetup implements JavaDelegate { parameter.getInstanceName(), generatedVnfType, parameter.getInstanceParams()); vnf.getVolumeGroups().add(volumeGroup); if (parameter.getIsReplace()) { + if (parameter.getExecuteBB().getOldVolumeGroupName() != null + && !parameter.getExecuteBB().getOldVolumeGroupName().isEmpty()) { + volumeGroup.setVolumeGroupName(parameter.getExecuteBB().getOldVolumeGroupName()); + } mapCatalogVolumeGroup(volumeGroup, parameter.getModelInfo(), parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID); } else { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index 5a52e3a49d..4206596c94 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -104,7 +104,7 @@ public class ExecuteBuildingBlockRainyDay { handlingCode = "Abort"; } else { try { - if (gBBInput.getCustomer().getServiceSubscription() != null) { + if (gBBInput.getCustomer() != null && gBBInput.getCustomer().getServiceSubscription() != null) { serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) .getModelInfoServiceInstance().getServiceType(); } @@ -119,7 +119,7 @@ public class ExecuteBuildingBlockRainyDay { String vnfType = ASTERISK; String vnfName = ASTERISK; try { - if (gBBInput.getCustomer().getServiceSubscription() != null) { + if (gBBInput.getCustomer() != null && gBBInput.getCustomer().getServiceSubscription() != null) { for (GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances() .get(0).getVnfs()) { if (vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { @@ -173,7 +173,7 @@ public class ExecuteBuildingBlockRainyDay { String serviceRole = ASTERISK; try { - if (gBBInput.getCustomer().getServiceSubscription() != null) { + if (gBBInput.getCustomer() != null && gBBInput.getCustomer().getServiceSubscription() != null) { serviceRole = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) .getModelInfoServiceInstance().getServiceRole(); } 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 new file mode 100644 index 0000000000..58d0c6d374 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java @@ -0,0 +1,111 @@ +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/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index 4fb63651eb..2d41eb4e26 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.core.env.Environment; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -68,6 +69,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); long workflowPollInterval = 1000; + private static final String ASYNC_WAIT_TIME = "mso.workflow.async.waitTime"; @Autowired private WorkflowProcessor processor; @@ -75,6 +77,9 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { @Autowired private WorkflowContextHolder workflowContext; + @Autowired + private Environment env; + public void setProcessor(WorkflowProcessor processor) { this.processor = processor; } @@ -119,7 +124,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { protected WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { String requestId = getRequestId(inputVariables); long currentWaitTime = 0; - long waitTime = getWaitTime(inputVariables); + long waitTime = getWaitTime(); logger.debug("WorkflowAsyncResource.waitForResponse using timeout: " + waitTime); while (waitTime > currentWaitTime) { Thread.sleep(workflowPollInterval); @@ -185,18 +190,8 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { * @param inputVariables * @return */ - private long getWaitTime(Map<String, Object> inputVariables) { - String timeout = inputVariables.get("mso-service-request-timeout") == null ? null - : inputVariables.get("mso-service-request-timeout").toString(); - - if (timeout != null) { - try { - return Long.parseLong(timeout) * 1000; - } catch (NumberFormatException nex) { - logger.debug("Invalid input for mso-service-request-timeout"); - } - } - return DEFAULT_WAIT_TIME; + private long getWaitTime() { + return env.getProperty(ASYNC_WAIT_TIME, Long.class, new Long(DEFAULT_WAIT_TIME)); } } 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 new file mode 100644 index 0000000000..36e828448d --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java @@ -0,0 +1,124 @@ +/*- + * ============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-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml index e89bbec9e1..d1245ce92a 100644 --- a/bpmn/so-bpmn-tasks/pom.xml +++ b/bpmn/so-bpmn-tasks/pom.xml @@ -202,25 +202,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api-client</artifactId> - <version>${sdnc.northbound.version}</version> - <exclusions> - <exclusion> - <groupId>javax.ws.rs</groupId> - <artifactId>jsr311-api</artifactId> - </exclusion> - <exclusion> - <groupId>io.swagger</groupId> - <artifactId>swagger-annotations</artifactId> - </exclusion> - <exclusion> - <groupId>io.swagger</groupId> - <artifactId>swagger-models</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> <groupId>ch.vorburger.mariaDB4j</groupId> <artifactId>mariaDB4j</artifactId> <version>2.2.3</version> @@ -257,5 +238,10 @@ <artifactId>so-optimization-clients</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>so-sdn-clients</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> </project> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java index b337564dab..1f05522011 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -78,6 +78,9 @@ public class AppcOrchestratorPreProcessor { String identityUrl = execution.getVariable("identityUrl"); appcTaskRequest.setIdentityUrl(identityUrl); + String requestorId = gBBInput.getRequestContext().getRequestorId(); + appcTaskRequest.setRequestorId(requestorId); + if (gBBInput.getRequestContext().getRequestParameters() != null) { String payload = gBBInput.getRequestContext().getRequestParameters().getPayload(); if (payload == null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java index 6af8c2f9c5..5b6043f303 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.net.URI; import java.util.UUID; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java index a9611cbde5..48a384c48a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.util.List; import java.util.Map; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java index b1c95154c6..593c15d6cc 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.util.Map; import java.util.UUID; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java index b5957b3009..69606393c3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.util.Map; import java.util.UUID; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index f6642ab76a..901187e231 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.net.URI; import java.util.Map; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java index fd0af3a4dd..c2dcb8f290 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.net.URI; import java.util.ArrayList; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java index e154375d3d..7f754e3f13 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java @@ -20,7 +20,6 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import java.util.List; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlockBase; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; @@ -38,6 +37,7 @@ public class ConfigBuildingBlocksDataObject extends BuildingBlockBase<ConfigBuil private List<OrchestrationFlow> orchFlows; private Resource resourceKey; private ServiceInstancesRequest sIRequest; + private ReplaceInstanceRelatedInformation replaceInformation; public ServiceInstancesRequest getsIRequest() { return sIRequest; @@ -75,6 +75,15 @@ public class ConfigBuildingBlocksDataObject extends BuildingBlockBase<ConfigBuil return this; } + public ReplaceInstanceRelatedInformation getReplaceInformation() { + return replaceInformation; + } + + public ConfigBuildingBlocksDataObject setReplaceInformation(ReplaceInstanceRelatedInformation replaceInformation) { + this.replaceInformation = replaceInformation; + return this; + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ReplaceInstanceRelatedInformation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ReplaceInstanceRelatedInformation.java new file mode 100644 index 0000000000..d9e8fa55fa --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ReplaceInstanceRelatedInformation.java @@ -0,0 +1,16 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +public class ReplaceInstanceRelatedInformation { + + private String oldVolumeGroupName; + + public String getOldVolumeGroupName() { + return oldVolumeGroupName; + } + + public ReplaceInstanceRelatedInformation setOldVolumeGroupName(String oldVolumeGroupName) { + this.oldVolumeGroupName = oldVolumeGroupName; + return this; + } + +} 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 2921cada18..1a49e3af7f 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 @@ -222,16 +222,17 @@ public class WorkflowAction { } Resource resourceKey = getResourceKey(sIRequest, resourceType); + ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation(); if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) && resourceType.equals(WorkflowType.VFMODULE)) { logger.debug("Build a BB list for replacing BB modules"); - orchFlows = getVfModuleReplaceBuildingBlocks( - new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) - .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) - .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(true) - .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) - .setRequestDetails(requestDetails).setExecution(execution)); + orchFlows = getVfModuleReplaceBuildingBlocks(new ConfigBuildingBlocksDataObject() + .setsIRequest(sIRequest).setOrchFlows(orchFlows).setRequestId(requestId) + .setResourceKey(resourceKey).setApiVersion(apiVersion).setResourceId(resourceId) + .setRequestAction(requestAction).setaLaCarte(true).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails) + .setExecution(execution).setReplaceInformation(replaceInfo)); for (OrchestrationFlow orchFlow : orchFlows) { if (orchFlow.getFlowName().contains(CONFIGURATION)) { List<OrchestrationFlow> configOrchFlows = new ArrayList<>(); @@ -243,12 +244,13 @@ public class WorkflowAction { .setApiVersion(apiVersion).setResourceId(resourceId) .setRequestAction(requestAction).setaLaCarte(true).setVnfType(vnfType) .setWorkflowResourceIds(workflowResourceIds) - .setRequestDetails(requestDetails).setExecution(execution)); + .setRequestDetails(requestDetails).setExecution(execution) + .setReplaceInformation(replaceInfo)); flowsToExecute.addAll(configBuildingBlocks); } else { ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, - requestDetails, false, null, null, false); + requestDetails, false, null, null, false, replaceInfo); flowsToExecute.add(ebb); } } @@ -271,7 +273,7 @@ public class WorkflowAction { for (OrchestrationFlow orchFlow : orchFlows) { ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, - requestDetails, false, null, null, false); + requestDetails, false, null, null, false, replaceInfo); flowsToExecute.add(ebb); } } @@ -537,10 +539,11 @@ public class WorkflowAction { + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match")); } - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), - dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), - dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), - dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, vnfcName, true); + ExecuteBuildingBlock ebb = + buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), dataObj.getResourceKey(), + dataObj.getApiVersion(), dataObj.getResourceId(), dataObj.getRequestAction(), + dataObj.isaLaCarte(), dataObj.getVnfType(), dataObj.getWorkflowResourceIds(), + dataObj.getRequestDetails(), false, null, vnfcName, true, null); flowsToExecuteConfigs.add(ebb); } } @@ -565,14 +568,16 @@ public class WorkflowAction { && dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups() != null) { rebuildVolumeGroups = dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups(); } - + String volumeGroupName = ""; Optional<VolumeGroup> volumeGroupFromVfModule = bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, vfModuleId); if (volumeGroupFromVfModule.isPresent()) { String volumeGroupId = volumeGroupFromVfModule.get().getVolumeGroupId(); + volumeGroupName = volumeGroupFromVfModule.get().getVolumeGroupName(); logger.debug("Volume group id of the existing volume group is: " + volumeGroupId); volumeGroupExisted = true; dataObj.getWorkflowResourceIds().setVolumeGroupId(volumeGroupId); + dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName); } List<OrchestrationFlow> orchFlows = dataObj.getOrchFlows(); @@ -585,6 +590,7 @@ public class WorkflowAction { if (!volumeGroupExisted) { String newVolumeGroupId = UUID.randomUUID().toString(); dataObj.getWorkflowResourceIds().setVolumeGroupId(newVolumeGroupId); + dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName); logger.debug("newVolumeGroupId: " + newVolumeGroupId); } } @@ -1386,7 +1392,7 @@ public class WorkflowAction { resourceList.stream().filter(resource -> resource.getResourceType().equals(workflowType)) .forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, - isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration))); + isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration, null))); } protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows, @@ -1433,7 +1439,7 @@ public class WorkflowAction { for (Resource resource : vfModuleResourcesSorted) { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, - false)); + false, null)); } } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) { if (requestAction.equalsIgnoreCase(REPLACEINSTANCE) @@ -1453,8 +1459,9 @@ public class WorkflowAction { requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, true); } else { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, - requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, false)); + flowsToExecute + .add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, requestAction, + false, vnfType, workflowResourceIds, requestDetails, false, null, null, false, null)); } } return flowsToExecute; @@ -1463,7 +1470,8 @@ public class WorkflowAction { protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, - boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration) { + boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration, + ReplaceInstanceRelatedInformation replaceInfo) { BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString()) @@ -1471,7 +1479,10 @@ public class WorkflowAction { .setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse("")); Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(buildingBlock::setBpmnAction); Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(buildingBlock::setBpmnScope); - + String oldVolumeGroupName = ""; + if (replaceInfo != null) { + oldVolumeGroupName = replaceInfo.getOldVolumeGroupName(); + } if (resource != null && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) { @@ -1482,7 +1493,7 @@ public class WorkflowAction { ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion) .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType) .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock) - .setRequestDetails(requestDetails); + .setRequestDetails(requestDetails).setOldVolumeGroupName(oldVolumeGroupName); if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) { ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 343b25eb97..155011ece0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -334,6 +334,7 @@ public class WorkflowActionBBTasks { && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) { rollbackFlowsFiltered.remove(rollbackFlow); } else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Delete") + && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") && ROLLBACKTOCREATED.equals(handlingCode)) { rollbackFlowsFiltered.remove(rollbackFlow); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java index 4aa6a1026a..da675bb498 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java @@ -21,6 +21,7 @@ package org.onap.so.client.orchestration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -29,7 +30,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.net.URI; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java index 0123eb67be..dc59969492 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java @@ -24,6 +24,7 @@ package org.onap.so.client.orchestration; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -31,7 +32,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java index 960efea2f0..54efd23bf9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java @@ -22,6 +22,7 @@ package org.onap.so.client.orchestration; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -29,7 +30,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java index 01511eaccc..c500374dc1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java @@ -24,6 +24,7 @@ package org.onap.so.client.orchestration; import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -36,7 +37,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java index 27edeed02a..d198756b1e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java @@ -25,6 +25,7 @@ package org.onap.so.client.orchestration; import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -35,7 +36,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java index 38c74eecc7..d7d6da209e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java @@ -149,6 +149,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { private void fillRequiredAppcExecutionFields() { RequestContext context = new RequestContext(); context.setMsoRequestId("TEST-MSO-ID"); + context.setRequestorId("testRequestorId"); execution.setVariable("aicIdentity", "AIC-TEST"); execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); @@ -192,6 +193,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { "{\"request_parameters\":{\"host_ip_address\":\"10.10.10.10\"},\"configuration_parameters\":{\"name1\":\"value1\",\"name2\":\"value2\"}}"); context.setRequestParameters(requestParameters); context.setMsoRequestId("TEST-MSO-ID"); + context.setRequestorId("testRequestorId"); execution.setVariable("aicIdentity", "AIC-TEST"); execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java index 0eb0304cdf..d4f1660986 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import java.net.URI; import java.net.URISyntaxException; @@ -33,6 +33,8 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -78,81 +80,4 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup { Assert.assertEquals("MsoRequestId", genericInfo.getRequestInformation().getRequestId()); } - - - private VpnBondingLink getVpnBondingLink() { - VpnBondingLink vpnBondingLink = new VpnBondingLink(); - Configuration vrfConfiguration = getVRFConfiguration(); - vpnBondingLink.setVrfConfiguration(vrfConfiguration); - Configuration vnrConfiguration = getVNRConfiguration(); - vpnBondingLink.setVnrConfiguration(vnrConfiguration); - vpnBondingLink.setTransportServiceProxy(buildServiceProxy(buildServiceInstance(buildGenericVnf()))); - return vpnBondingLink; - } - - private RequestContext getRequestContext() { - RequestContext requestContext = new RequestContext(); - requestContext.setMsoRequestId("MsoRequestId"); - Map<String, Object> userParams = getUserParams(); - requestContext.setUserParams(userParams); - return requestContext; - } - - private Map<String, Object> getUserParams() { - Map<String, Object> userParams = new HashMap<>(); - userParams.put("lppCustomerId", "lppCustomerId"); - return userParams; - } - - private ServiceProxy buildServiceProxy(ServiceInstance serviceInstance) { - ServiceProxy serviceProxy = new ServiceProxy(); - serviceProxy.setServiceInstance(serviceInstance); - return serviceProxy; - } - - private Configuration getVRFConfiguration() { - Configuration vrfConfiguration = new Configuration(); - vrfConfiguration.setConfigurationId("ConfigurationId"); - vrfConfiguration.setConfigurationName("ConfigurationName"); - vrfConfiguration.setConfigurationSubType("ConfigurationSubType"); - vrfConfiguration.setConfigurationType("VRF-ENTRY"); - return vrfConfiguration; - } - - public Configuration getVNRConfiguration() { - Configuration vnrConfiguration = new Configuration(); - vnrConfiguration.setConfigurationId("ConfigurationId"); - vnrConfiguration.setConfigurationName("ConfigurationName"); - vnrConfiguration.setConfigurationSubType("ConfigurationSubType"); - vnrConfiguration.setConfigurationType("VNRConfiguration"); - L3Network l3Network = getL3Network(); - vnrConfiguration.setNetwork(l3Network); - return vnrConfiguration; - } - - public L3Network getL3Network() { - L3Network l3Network = new L3Network(); - l3Network.setNetworkId("l3NetworkId"); - Subnet ipv4subnet = getSubnet("ipv4CidrMask", "ipv4NetworkStartAddress", "IPV4"); - Subnet ipv6subnet = getSubnet("ipv6CidrMask", "ipv6NetworkStartAddress", "IPV6"); - l3Network.getSubnets().add(ipv4subnet); - l3Network.getSubnets().add(ipv6subnet); - return l3Network; - } - - private Subnet getSubnet(String ipv4CidrMask, String ipv4NetworkStartAddress, String ipv4) { - Subnet ipv4subnet = new Subnet(); - ipv4subnet.setCidrMask(ipv4CidrMask); - ipv4subnet.setNetworkStartAddress(ipv4NetworkStartAddress); - ipv4subnet.setIpVersion(ipv4); - return ipv4subnet; - } - - private ServiceInstance buildServiceInstance(GenericVnf vnf) { - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("ServiceInstanceId"); - List<GenericVnf> vnfs = serviceInstance.getVnfs(); - vnfs.add(vnf); - return serviceInstance; - } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java index 88a291e68b..92fc13b633 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; @@ -47,6 +47,7 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumerat import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java index 76e915781f..0952a35ab0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; @@ -38,6 +38,8 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java index f4006ab5d5..bd5c234e50 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; @@ -33,6 +33,8 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java index 2fd684e0f0..e064300ab7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; @@ -40,6 +40,8 @@ import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java index 00836176f0..a042289281 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc.mapper; +package org.onap.so.bpmn.infrastructure.sdnc.mapper; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -35,6 +35,8 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 1aa7640492..70b10c5195 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -400,6 +400,42 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void rollbackExecutionRollbackToCreatedWithFabricTest() { + execution.setVariable("isRollback", false); + execution.setVariable("handlingCode", "RollbackToCreated"); + execution.setVariable("requestAction", EMPTY_STRING); + execution.setVariable("resourceName", EMPTY_STRING); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); + flowsToExecute.add(ebb1); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); + flowsToExecute.add(ebb2); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); + flowsToExecute.add(ebb3); + + BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); + flowsToExecute.add(ebb4); + + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("gCurrentSequence", 4); + + workflowActionBBTasks.rollbackExecutionPath(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEquals(0, execution.getVariable("gCurrentSequence")); + assertEquals(2, ebbs.size()); + assertEquals("DeleteFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName()); + assertEquals("DeactivateVfModuleBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName()); + + } + + @Test public void rollbackExecutionRollbackToCreatedTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToCreated"); 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 cf8d98e86e..8f104566a4 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 @@ -3122,7 +3122,7 @@ public class WorkflowActionTest extends BaseTaskTest { ExecuteBuildingBlock result = null; try { result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, - false, null, null, null, false, null, null, true); + false, null, null, null, false, null, null, true, null); } catch (NullPointerException e) { fail("NullPointerException should not be thrown when 'resource' is null"); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java index 9049fe1965..3429a16f0b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java @@ -35,6 +35,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -45,7 +46,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCConfigurationResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java index 327bae5749..f86a712e33 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java @@ -32,6 +32,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -42,7 +43,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCNetworkResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java index ad05ac0072..4282b0d158 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java @@ -35,6 +35,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -42,7 +43,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCServiceInstanceResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java index 14e993281a..813c2f7cd4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java @@ -33,6 +33,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -43,8 +44,7 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation;; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCVfModuleResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java index 0ccf056ddc..f9c380bc84 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java @@ -39,6 +39,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -49,7 +50,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCVnfResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json index 957c603dc9..191e0ac40e 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json @@ -2,6 +2,7 @@ "ApplicationControllerTaskRequest": { "controllerType": "TEST-CONTROLLER-NAME", "action": "Lock", + "requestorId": "testRequestorId", "identityUrl": "IDENTITY-URL-TEST", "applicationControllerVnf": { "vnfId": "TEST-VNF-ID", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json index 040c680d1c..724f096a4e 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json @@ -2,6 +2,7 @@ "ApplicationControllerTaskRequest": { "controllerType": "APPC", "action": "ConfigModify", + "requestorId": "testRequestorId", "identityUrl": "IDENTITY-URL-TEST", "applicationControllerVnf": { "vnfId": "TEST-VNF-ID", diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java index c240957ae9..010e184618 100644 --- a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java @@ -11,6 +11,7 @@ public class ApplicationControllerTaskRequest implements Serializable { private static final long serialVersionUID = -3150320542857627682L; private Action action; + private String requestorId; private String controllerType; private String identityUrl; private String operationsTimeout; @@ -110,6 +111,14 @@ public class ApplicationControllerTaskRequest implements Serializable { this.newSoftwareVersion = newSoftwareVersion; } + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java b/common/src/main/java/org/onap/so/client/exception/MapperException.java index 354c669d62..354c669d62 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java +++ b/common/src/main/java/org/onap/so/client/exception/MapperException.java 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 7ae7de2ece..fff82ea5bc 100644 --- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java +++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java @@ -22,8 +22,16 @@ public class ExternalTaskServiceUtils { @Autowired public Environment env; - protected Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet(); + private static final long DEFAULT_LOCK_DURATION_LONG = 2700000; + private static final long DEFAULT_LOCK_DURATION_MEDIUM = 900000; + private static final long DEFAULT_LOCK_DURATION_SHORT = 300000; + + private static final String LOCK_DURATION_LONG = "mso.workflow.topics.lockDurationLong"; + private static final String LOCK_DURATION_MEDIUM = "mso.workflow.topics.lockDurationMedium"; + private static final String LOCK_DURATION_SHORT = "mso.workflow.topics.lockDurationShort"; + + protected Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet(); private static final Logger logger = LoggerFactory.getLogger(ExternalTaskServiceUtils.class); @@ -74,4 +82,16 @@ public class ExternalTaskServiceUtils { return taskClients; } + public long getLockDurationLong() { + return env.getProperty(LOCK_DURATION_LONG, Long.class, new Long(DEFAULT_LOCK_DURATION_LONG)); + } + + public long getLockDurationMedium() { + return env.getProperty(LOCK_DURATION_MEDIUM, Long.class, new Long(DEFAULT_LOCK_DURATION_MEDIUM)); + } + + public long getLockDurationShort() { + return env.getProperty(LOCK_DURATION_SHORT, Long.class, new Long(DEFAULT_LOCK_DURATION_SHORT)); + } + } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java index 1cd23614b5..1f747e6c8c 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java @@ -21,11 +21,13 @@ package org.onap.aaiclient.client.aai; import java.net.URI; +import java.util.HashMap; +import java.util.Map; import javax.ws.rs.NotFoundException; import javax.ws.rs.core.UriBuilder; -import org.onap.so.client.RestClient; import org.onap.aaiclient.client.graphinventory.GraphInventoryClient; import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException; +import org.onap.so.client.RestClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,11 +38,20 @@ public class AAIClient extends GraphInventoryClient { protected AAIVersion version; protected AAIClient() { - super(AAIProperties.class); + super(AAIProperties.class, new HashMap<String, String>()); } protected AAIClient(AAIVersion version) { - super(AAIProperties.class); + super(AAIProperties.class, new HashMap<String, String>()); + this.version = version; + } + + protected AAIClient(Map<String, String> additionalHeaders) { + super(AAIProperties.class, additionalHeaders); + } + + protected AAIClient(AAIVersion version, Map<String, String> additionalHeaders) { + super(AAIProperties.class, additionalHeaders); this.version = version; } @@ -54,7 +65,7 @@ public class AAIClient extends GraphInventoryClient { protected RestClient createClient(URI uri) { try { - return new AAIRestClient(getRestProperties(), constructPath(uri)); + return new AAIRestClient(getRestProperties(), constructPath(uri), additionalHeaders); } catch (GraphInventoryUriComputationException | NotFoundException e) { logger.debug("failed to construct A&AI uri", e); throw e; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java index 238e87392f..378db87d9b 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java @@ -26,16 +26,17 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.aaiclient.client.graphinventory.GraphInventoryQueryClient; import org.onap.aaiclient.client.graphinventory.entities.DSLQuery; import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri; +import com.google.common.collect.ImmutableMap; public class AAIDSLQueryClient extends GraphInventoryQueryClient<AAIDSLQueryClient, DSLQuery, AAIResultWrapper, AAIObjectType> { public AAIDSLQueryClient() { - super(new AAIClient()); + super(new AAIClient(ImmutableMap.of("X-DslApiVersion", "V2"))); } public AAIDSLQueryClient(AAIVersion version) { - super(new AAIClient(version)); + super(new AAIClient(version, ImmutableMap.of("X-DslApiVersion", "V2"))); } @Override @@ -53,5 +54,4 @@ public class AAIDSLQueryClient public AAIObjectType createType(String name, String uri) { return new AAIFluentTypeReverseLookup().fromName(name, uri); } - } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java index b3402fa221..2335a48d43 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java @@ -63,6 +63,7 @@ import org.onap.aai.domain.yang.ServiceSubscription; import org.onap.aai.domain.yang.SliceProfile; import org.onap.aai.domain.yang.SpPartner; import org.onap.aai.domain.yang.SriovPf; +import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.Subnet; import org.onap.aai.domain.yang.Tenant; import org.onap.aai.domain.yang.TunnelXconnect; @@ -184,6 +185,8 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S new AAIObjectType(AAINamespaceConstants.NETWORK, AggregateRoute.class); public static final AAIObjectType L_INTERFACE = new AAIObjectType(AAIObjectType.VSERVER.uriTemplate(), LInterface.class); + public static final AAIObjectType SRIOV_VF = + new AAIObjectType(AAIObjectType.L_INTERFACE.uriTemplate(), SriovVf.class); public static final AAIObjectType SUB_L_INTERFACE = new AAIObjectType(AAIObjectType.L_INTERFACE.uriTemplate(), "/l-interfaces/l-interface/{sub-interface-name}", "sub-l-interface"); public static final AAIObjectType IMAGE = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Image.class); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java index 9a8a2a53c0..0f69b0cc8f 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java @@ -23,18 +23,20 @@ package org.onap.aaiclient.client.aai; import java.net.URI; import java.util.Map; import java.util.Optional; -import org.onap.so.client.ResponseExceptionMapper; import org.onap.aaiclient.client.graphinventory.GraphInventoryPatchConverter; import org.onap.aaiclient.client.graphinventory.GraphInventoryRestClient; import org.onap.logging.filter.base.ONAPComponents; +import org.onap.so.client.ResponseExceptionMapper; public class AAIRestClient extends GraphInventoryRestClient { private final AAIProperties aaiProperties; + private final Map<String, String> additionalHeaders; - protected AAIRestClient(AAIProperties props, URI uri) { + protected AAIRestClient(AAIProperties props, URI uri, Map<String, String> additionalHeaders) { super(props, uri); this.aaiProperties = props; + this.additionalHeaders = additionalHeaders; } @Override @@ -46,6 +48,7 @@ public class AAIRestClient extends GraphInventoryRestClient { protected void initializeHeaderMap(Map<String, String> headerMap) { headerMap.put("X-FromAppId", aaiProperties.getSystemName()); headerMap.put("X-TransactionId", requestId); + headerMap.putAll(additionalHeaders); String auth = aaiProperties.getAuth(); String key = aaiProperties.getKey(); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java index a2bb8bc141..f8f977d117 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java @@ -21,20 +21,25 @@ package org.onap.aaiclient.client.graphinventory; import java.net.URI; +import java.util.Map; +import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri; +import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri; import org.onap.so.client.RestClient; import org.onap.so.client.RestProperties; import org.onap.so.client.RestPropertiesLoader; -import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri; -import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri; +import com.google.common.collect.ImmutableMap; public abstract class GraphInventoryClient { private RestProperties props; + protected final Map<String, String> additionalHeaders; - protected GraphInventoryClient(Class<? extends RestProperties> propertiesClass) { + protected GraphInventoryClient(Class<? extends RestProperties> propertiesClass, + Map<String, String> additionalHeaders) { RestProperties props = RestPropertiesLoader.getInstance().getNewImpl(propertiesClass); this.props = props; + this.additionalHeaders = additionalHeaders; } protected abstract URI constructPath(URI uri); @@ -64,4 +69,8 @@ public abstract class GraphInventoryClient { public abstract GraphInventoryVersion getVersion(); public abstract String getGraphDBName(); + + public Map<String, String> getAdditionalHeaders() { + return ImmutableMap.copyOf(this.additionalHeaders); + } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java index c749561e5f..a192e3828a 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java @@ -138,4 +138,8 @@ public abstract class GraphInventoryQueryClient<S, I, Wrapper extends GraphInven } return clone; } + + public GraphInventoryClient getClient() { + return this.client; + } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java index c071e24391..5c88e8e42e 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java @@ -22,13 +22,17 @@ package org.onap.aaiclient.client.graphinventory.entities; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; import java.util.List; +import java.util.stream.Collectors; import org.onap.aaiclient.client.aai.entities.QueryStep; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep { protected final String nodeName; + protected final Collection<String> fields; protected final List<DSLNodeKey> nodeKeys; protected final StringBuilder query; protected boolean output = false; @@ -37,6 +41,7 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep this.nodeName = ""; this.nodeKeys = new ArrayList<>(); this.query = new StringBuilder(); + this.fields = new LinkedHashSet<>(); } @@ -44,6 +49,7 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep this.nodeName = name.typeName(); this.nodeKeys = new ArrayList<>(); this.query = new StringBuilder(); + this.fields = new LinkedHashSet<>(); query.append(nodeName); } @@ -51,6 +57,7 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep this.nodeName = name.typeName(); this.nodeKeys = Arrays.asList(key); this.query = new StringBuilder(); + this.fields = new LinkedHashSet<>(); query.append(nodeName); } @@ -58,6 +65,7 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep this.nodeName = copy.nodeName; this.nodeKeys = copy.nodeKeys; this.query = new StringBuilder(copy.query); + this.fields = copy.fields; this.output = copy.output; } @@ -67,6 +75,12 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep return new DSLOutputNode(this); } + public DSLOutputNode output(String... fields) { + this.output = true; + this.fields.addAll(Arrays.asList(fields)); + return new DSLOutputNode(this); + } + public T and(DSLNodeKey... key) { this.nodeKeys.addAll(Arrays.asList(key)); @@ -77,7 +91,13 @@ public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep public String build() { StringBuilder result = new StringBuilder(query); if (output) { - result.append("*"); + if (fields.isEmpty()) { + result.append("*"); + } else { + String items = + fields.stream().map(item -> String.format("'%s'", item)).collect(Collectors.joining(", ")); + result.append("{").append(items).append("}"); + } } for (DSLNodeKey key : nodeKeys) { result.append(key.build()); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java index 762203258a..c56ce0bfee 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java @@ -24,6 +24,7 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.function.Consumer; import java.util.stream.Collectors; import org.onap.aaiclient.client.aai.entities.QueryStep; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; @@ -49,9 +50,20 @@ public class DSLQueryBuilder<S, E> { } public DSLQueryBuilder<S, Node> output() { + callOnLambda(item -> item.output()); + return (DSLQueryBuilder<S, Node>) this; + } + + public DSLQueryBuilder<S, Node> output(String... fields) { + callOnLambda(item -> item.output(fields)); + return (DSLQueryBuilder<S, Node>) this; + } + + protected void callOnLambda(Consumer<DSLNodeBase> consumer) { + Object obj = steps.get(steps.size() - 1); if (obj instanceof DSLNodeBase) { - ((DSLNodeBase) steps.get(steps.size() - 1)).output(); + consumer.accept((DSLNodeBase) steps.get(steps.size() - 1)); } else if (obj.getClass().getName().contains("$$Lambda$")) { // process lambda expressions for (Field f : obj.getClass().getDeclaredFields()) { @@ -60,7 +72,7 @@ public class DSLQueryBuilder<S, E> { try { o = f.get(obj); if (o instanceof DSLQueryBuilder && ((DSLQueryBuilder) o).steps.get(0) instanceof DSLNodeBase) { - ((DSLNodeBase) ((DSLQueryBuilder) o).steps.get(0)).output(); + consumer.accept(((DSLNodeBase) ((DSLQueryBuilder) o).steps.get(0))); } } catch (IllegalArgumentException | IllegalAccessException e) { } @@ -68,7 +80,6 @@ public class DSLQueryBuilder<S, E> { break; } } - return (DSLQueryBuilder<S, Node>) this; } @SafeVarargs diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java new file mode 100644 index 0000000000..36fc1db57c --- /dev/null +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java @@ -0,0 +1,17 @@ +package org.onap.aaiclient.client.aai; + +import static org.junit.Assert.assertEquals; +import java.net.URISyntaxException; +import org.junit.Test; + +public class AAIDSLQueryClientTest { + + + + @Test + public void verifyHeadersTest() throws URISyntaxException { + + AAIDSLQueryClient client = new AAIDSLQueryClient(); + assertEquals("V2", client.getClient().getAdditionalHeaders().get("X-DslApiVersion")); + } +} diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java index 86738beabb..b73454fe67 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java @@ -20,6 +20,13 @@ package org.onap.aaiclient.client.aai; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.matching; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.hamcrest.CoreMatchers.containsString; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -30,6 +37,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.net.URI; import java.net.URISyntaxException; +import java.util.HashMap; import javax.ws.rs.core.Response; import org.junit.Rule; import org.junit.Test; @@ -37,10 +45,12 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.so.client.RestClientSSL; +import org.onap.aaiclient.client.defaultproperties.DefaultAAIPropertiesImpl; import org.onap.aaiclient.client.graphinventory.GraphInventoryPatchConverter; import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import com.google.common.collect.ImmutableMap; @RunWith(MockitoJUnitRunner.class) public class AAIRestClientTest { @@ -53,9 +63,12 @@ public class AAIRestClientTest { @Rule public ExpectedException thrown = ExpectedException.none(); + @Rule + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); + @Test public void failPatchOnComplexObject() throws URISyntaxException { - AAIRestClient client = new AAIRestClient(props, new URI("")); + AAIRestClient client = new AAIRestClient(props, new URI(""), new HashMap<String, String>()); this.thrown.expect(GraphInventoryPatchDepthExceededException.class); this.thrown.expectMessage(containsString("Object exceeds allowed depth for update action")); client.patch( @@ -64,7 +77,7 @@ public class AAIRestClientTest { @Test public void verifyPatchValidation() throws URISyntaxException { - AAIRestClient client = new AAIRestClient(props, new URI("")); + AAIRestClient client = new AAIRestClient(props, new URI(""), new HashMap<String, String>()); AAIRestClient spy = spy(client); GraphInventoryPatchConverter patchValidatorMock = mock(GraphInventoryPatchConverter.class); doReturn(patchValidatorMock).when(spy).getPatchConverter(); @@ -73,4 +86,14 @@ public class AAIRestClientTest { spy.patch(payload); verify(patchValidatorMock, times(1)).convertPatchFormat(eq((Object) payload)); } + + @Test + public void verifyAdditionalHeadersTest() throws URISyntaxException { + AAIRestClient client = new AAIRestClient(new DefaultAAIPropertiesImpl(wireMockRule.port()), new URI("/test"), + ImmutableMap.of("test", "value")); + wireMockRule.stubFor(get(urlPathEqualTo("/test")).willReturn(aResponse().withStatus(200))); + client.get(); + wireMockRule.verify(getRequestedFor(urlPathEqualTo("/test")).withHeader("X-FromAppId", equalTo("MSO")) + .withHeader("X-TransactionId", matching(".*")).withHeader("test", equalTo("value"))); + } } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java index 965770c796..b0b0c6aca9 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java @@ -26,6 +26,7 @@ import org.junit.Test; import org.onap.aaiclient.client.graphinventory.entities.DSLNodeKey; import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder; import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode; +import org.onap.aaiclient.client.graphinventory.entities.Node; import org.onap.aaiclient.client.graphinventory.entities.Output; import org.onap.aaiclient.client.graphinventory.entities.Start; import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder; @@ -146,4 +147,23 @@ public class DSLQueryBuilderTest { "generic-vnf*('vnf-id', 'vnfId') > " + "[ pserver* > complex*, " + "vserver > pserver* > complex* ]", builder.build().get()); } + + @Test + public void selectOutputFilterTest() { + DSLQueryBuilder<Output, Output> builder = TraversalBuilder + .traversal(new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")) + .output("cloud-region-id", "a", "b")); + builder.to(__.node(AAIObjectType.PSERVER)).output("x", "y", "z"); + + assertEquals("cloud-region{'cloud-region-id', 'a', 'b'}('cloud-owner', 'CloudOwner') > pserver{'x', 'y', 'z'}", + builder.build().toString()); + } + + @Test + public void selectOutputFilterOnNodeTest() { + DSLStartNode node = new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")); + DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(node).output("cloud-region-id"); + + assertEquals("cloud-region{'cloud-region-id'}('cloud-owner', 'CloudOwner')", builder.build().toString()); + } } 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 23a1a812df..4a8b7d90c6 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 @@ -325,13 +325,8 @@ public class FluentGenerator { String value; String name; - if (params.group(2) != null) { - name = params.group(2); - } else { - name = params.group(1); - } value = params.group(1); - + name = params.group(2); name = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, name); classFields.add(FieldSpec.builder(String.class, name, Modifier.PUBLIC, Modifier.FINAL) diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java index 8be22e1dcc..d27794c127 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java @@ -7,5 +7,5 @@ public class Patterns { public static final Pattern pluralPattern = Pattern.compile(".*(?<partial>/(?<name>[^{]*$))"); public static final Pattern singularPattern = Pattern.compile(".*(?<partial>/(?<name>[^/{}]*)/\\{.*$)"); public static final Pattern topLevelPattern = Pattern.compile("^/([^/]+)/.*"); - public static final Pattern urlTemplatePattern = Pattern.compile("\\{([^}.]+(?:\\.([^}]+))?)\\}"); + public static final Pattern urlTemplatePattern = Pattern.compile("\\{((?:.+\\.)?([^}.]+))\\}"); } diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java index 42305488bc..ec09af8a4e 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java @@ -125,8 +125,6 @@ public class SwaggerConverter { } } - log.debug(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(output)); - for (Map.Entry<String, ObjectType> item : output.entrySet()) { if (item.getValue().getType().equals("plural")) { @@ -156,7 +154,7 @@ public class SwaggerConverter { Matcher templates = Patterns.urlTemplatePattern.matcher(item.getValue().getPartialUri()); List<String> localFields = new ArrayList<>(); while (templates.find()) { - localFields.add(templates.group(1)); + localFields.add(templates.group(2)); } item.getValue().setFields(item.getValue().getFields().stream() .filter(f -> localFields.contains(f.getName())).collect(Collectors.toList())); @@ -166,6 +164,8 @@ public class SwaggerConverter { output.values().stream().filter(item -> item.getType().equals("plural")) .forEach(item -> item.getChildren().clear()); + log.debug(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(output)); + return output; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java index f39a95e92c..b59f298022 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java @@ -9,6 +9,8 @@ * ================================================================================ * Modifications Copyright (c) 2020 Nokia * ================================================================================ + * Modifications Copyright (c) 2020 Nordix + * ================================================================================ * 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 @@ -25,7 +27,28 @@ package org.onap.so.apihandlerinfra; +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 java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +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.common.ErrorNumbers; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.exceptions.ApiException; @@ -39,35 +62,13 @@ import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.ModelType; -import org.onap.so.serviceinstancebeans.RequestReferences; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; -import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.transaction.Transactional; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -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 java.io.IOException; -import java.util.HashMap; -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; @Component @Path("/onap/so/infra/instanceManagement") @@ -75,8 +76,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; description = "Infrastructure API Requests for Instance Management")) public class InstanceManagement { - private static Logger logger = LoggerFactory.getLogger(InstanceManagement.class); - private static String uriPrefix = "/instanceManagement/"; + private static final Logger LOG = LoggerFactory.getLogger(InstanceManagement.class); + private static final String URI_PREFIX = "/instanceManagement/"; private static final String SAVE_TO_DB = "save instance to db"; @Autowired @@ -102,13 +103,13 @@ public class InstanceManagement { @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); + final String requestId = requestHandlerUtils.getRequestId(requestContext); + final Map<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); instanceIdMap.put("workflowUuid", workflowUuid); return processCustomWorkflowRequest(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, - requestContext); + requestContext, true); } @POST @@ -122,34 +123,61 @@ public class InstanceManagement { @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("pnfName") String pnfName, @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); + final String requestId = requestHandlerUtils.getRequestId(requestContext); + final Map<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("pnfName", pnfName); instanceIdMap.put("workflowUuid", workflowUuid); - return processPNFCustomWorkflowRequest(request, Action.forCustomWorkflow, instanceIdMap, version, requestId, - requestContext); + return processCustomWorkflowRequest(request, Action.forCustomWorkflow, instanceIdMap, version, requestId, + requestContext, false); + } + + @POST + @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/workflows/{workflowUuid}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Execute custom Service Level workflow", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Transactional + public Response executeServiceLevelCustomWorkflow(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("workflowUuid") String workflowUuid, + @Context ContainerRequestContext requestContext) throws ApiException { + final String requestId = requestHandlerUtils.getRequestId(requestContext); + final Map<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("workflowUuid", workflowUuid); + return processCustomWorkflowRequest(request, Action.forCustomWorkflow, instanceIdMap, version, requestId, + requestContext, false); } - private Response processCustomWorkflowRequest(String requestJSON, Actions action, - HashMap<String, String> instanceIdMap, String version, String requestId, - ContainerRequestContext requestContext) throws ApiException { - String serviceInstanceId; - boolean aLaCarte = true; - ServiceInstancesRequest sir; - String apiVersion = version.substring(1); + private Response processCustomWorkflowRequest(final String requestJSON, final Actions action, + final Map<String, String> instanceIdMap, final String version, final String requestId, + final ContainerRequestContext requestContext, final boolean aLaCarte) throws ApiException { + String pnfName = null; + String vnfType = null; + String workflowUuid = null; + String vnfInstanceId = null; + String svcInstanceId = null; + final String apiVersion = version.substring(1); - String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix); + if (instanceIdMap != null && !instanceIdMap.isEmpty()) { + pnfName = instanceIdMap.get("pnfName"); + workflowUuid = instanceIdMap.get("workflowUuid"); + vnfInstanceId = instanceIdMap.get("vnfInstanceId"); + svcInstanceId = instanceIdMap.get("serviceInstanceId"); + } - sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); - String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); - InfraActiveRequests currentActiveReq = - msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); + final String requestUri = requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX); + final ServiceInstancesRequest svcInsReq = + requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); + final String requestScope = requestHandlerUtils.deriveRequestScope(action, svcInsReq, requestUri); + InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(svcInsReq, action, requestId, + Status.IN_PROGRESS, requestJSON, requestScope); try { requestHandlerUtils.validateHeaders(requestContext); } catch (ValidationException e) { - logger.error("Exception occurred", e); + LOG.error("Exception occurred", e); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError) .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); @@ -160,42 +188,18 @@ public class InstanceManagement { throw validateException; } - requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, + requestHandlerUtils.parseRequest(svcInsReq, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq); requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); - String vnfType = msoRequest.getVnfType(sir, requestScope); - - if (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null) { + if (requestScope.equalsIgnoreCase(ModelType.vnf.name())) { + vnfType = msoRequest.getVnfType(svcInsReq, requestScope); currentActiveReq.setVnfType(vnfType); } checkDuplicateAndBuildError(action, instanceIdMap, requestScope, currentActiveReq); - - ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); - - RequestReferences referencesResponse = new RequestReferences(); - - referencesResponse.setRequestId(requestId); - - serviceResponse.setRequestReferences(referencesResponse); - boolean isBaseVfModule = false; - - String workflowUuid = null; - if (instanceIdMap != null) { - workflowUuid = instanceIdMap.get("workflowUuid"); - } - - RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid); - - String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, true); - - serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir); - String vnfId = ""; - - if (sir.getVnfInstanceId() != null) { - vnfId = sir.getVnfInstanceId(); - } + final RecipeLookupResult recipeLookupResult = + getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid); currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid); saveCurrentActiveRequest(currentActiveReq); @@ -203,11 +207,11 @@ public class InstanceManagement { RequestClientParameter requestClientParameter; try { requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId) - .setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(action.toString()).setServiceInstanceId(serviceInstanceId).setVnfId(vnfId) - .setServiceType(serviceInstanceType).setVnfType(vnfType) + .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString()) + .setServiceInstanceId(svcInstanceId).setVnfId(vnfInstanceId).setVnfType(vnfType) + .setPnfCorrelationId(pnfName).setApiVersion(apiVersion) .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, null, aLaCarte, action)) - .setApiVersion(apiVersion).setALaCarte(aLaCarte).setRequestUri(requestUri).build(); + .setALaCarte(aLaCarte).setRequestUri(requestUri).build(); } catch (IOException e) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) @@ -232,7 +236,7 @@ public class InstanceManagement { } } - private void checkDuplicateAndBuildError(Actions action, HashMap<String, String> instanceIdMap, String requestScope, + private void checkDuplicateAndBuildError(Actions action, Map<String, String> instanceIdMap, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException { InfraActiveRequests dup = @@ -248,74 +252,6 @@ public class InstanceManagement { } } - private Response processPNFCustomWorkflowRequest(String requestJSON, Actions action, - HashMap<String, String> instanceIdMap, String version, String requestId, - ContainerRequestContext requestContext) throws ApiException { - boolean aLaCarte = false; - ServiceInstancesRequest sir; - String apiVersion = version.substring(1); - - String serviceInstanceId = ""; - String pnfName = ""; - String workflowUuid = ""; - if (instanceIdMap != null) { - serviceInstanceId = instanceIdMap.get("serviceInstanceId"); - pnfName = instanceIdMap.get("pnfName"); - workflowUuid = instanceIdMap.get("workflowUuid"); - } - - String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix); - sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); - sir.setServiceInstanceId(serviceInstanceId); - sir.setPnfName(pnfName); - String requestScope = ModelType.pnf.name(); - InfraActiveRequests currentActiveReq = - msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); - - try { - requestHandlerUtils.validateHeaders(requestContext); - } catch (ValidationException e) { - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = - new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError) - .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = - new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, - ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); - requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); - throw validateException; - } - - requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, - currentActiveReq); - requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); - - checkDuplicateAndBuildError(action, instanceIdMap, requestScope, currentActiveReq); - - RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid); - - currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid); - saveCurrentActiveRequest(currentActiveReq); - - RequestClientParameter requestClientParameter; - try { - requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString()) - .setServiceInstanceId(serviceInstanceId).setPnfCorrelationId(pnfName) - .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, null, aLaCarte, action)) - .setApiVersion(apiVersion).setRequestUri(requestUri).build(); - } catch (IOException 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 requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, - recipeLookupResult.getOrchestrationURI(), requestScope); - } - private RecipeLookupResult getInstanceManagementWorkflowRecipe(InfraActiveRequests currentActiveReq, String workflowUuid) throws ApiException { RecipeLookupResult recipeLookupResult; 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 f3c3ec5ff1..4ac8b73698 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 @@ -154,9 +154,8 @@ public class MsoRequest { // Parse request JSON - public void parse(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, - String version, String originalRequestJSON, int reqVersion, Boolean aLaCarteFlag) - throws ValidationException, IOException { + public void parse(ServiceInstancesRequest sir, Map<String, String> instanceIdMap, Actions action, String version, + String originalRequestJSON, int reqVersion, Boolean aLaCarteFlag) throws ValidationException, IOException { logger.debug("Validating the Service Instance request"); List<ValidationRule> rules = new ArrayList<>(); 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 a61975f529..a68309f199 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 @@ -261,8 +261,8 @@ public class RequestHandlerUtils extends AbstractRestHandler { } } - public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, - String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException { + public InfraActiveRequests duplicateCheck(Actions action, Map<String, String> instanceIdMap, String instanceName, + String requestScope, InfraActiveRequests currentActiveReq) throws ApiException { InfraActiveRequests dup = null; try { if (!(instanceName == null && "service".equals(requestScope) && (action == Action.createInstance @@ -332,7 +332,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { } } - public void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, + public void parseRequest(ServiceInstancesRequest sir, Map<String, String> instanceIdMap, Actions action, String version, String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException { int reqVersion = Integer.parseInt(version.substring(1)); @@ -354,7 +354,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { } public void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, - HashMap<String, String> instanceIdMap, String instanceName, String requestScope, InfraActiveRequests dup) + Map<String, String> instanceIdMap, String instanceName, String requestScope, InfraActiveRequests dup) throws ApiException { String instance = null; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java index 357497591d..0f7cf5fc6a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java @@ -81,12 +81,13 @@ public class WorkflowSpecificationsHandler { @Transactional public Response queryWorkflowSpecifications(@QueryParam("vnfModelVersionId") String vnfModelVersionId, - @QueryParam("pnfModelVersionId") String pnfModelVersionId, @PathParam("version") String version) + @QueryParam("pnfModelVersionId") String pnfModelVersionId, + @QueryParam("resourceTarget") String resourceTarget, @PathParam("version") String version) throws Exception { String apiVersion = version.substring(1); List<Workflow> workflows = new ArrayList<>(); - if (vnfModelVersionId == null && pnfModelVersionId == null) { + if (vnfModelVersionId == null && pnfModelVersionId == null && resourceTarget == null) { workflows.addAll(queryWorkflowSpecificationsForAll()); } else { // 1. query workflow specifications for given vnfModelVersionId if need. @@ -106,6 +107,16 @@ public class WorkflowSpecificationsHandler { workflows.addAll(pnfWorkflows); } } + + // 3. query workflow specifications for given resourceTarget + if (resourceTarget != null) { + List<Workflow> workflowsForResourceTarget = queryWorkflowsForResourceTarget(resourceTarget); + logger.debug( + "Retrieved " + workflowsForResourceTarget.size() + " workflows for given resource target."); + if (workflowsForResourceTarget.size() > 0) { + workflows.addAll(workflowsForResourceTarget); + } + } } // Deduplication @@ -119,11 +130,16 @@ public class WorkflowSpecificationsHandler { apiVersion); } + /** + * @deprecated As of G release, workflows for all resource types (pnf,vnf,service) can be fetched using + * /workflowSpecifications/{version:[vV]1}/workflows?resourceTarget={resourceType} API + */ @Path("/{version:[vV]1}/pnfWorkflows") @GET @Operation(description = "Finds pnf workflow specifications", responses = @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) @Transactional + @Deprecated public Response getWorkflowsSpecForPnf(@PathParam("version") String version) throws Exception { final String pnf_resource = "pnf"; @@ -132,7 +148,7 @@ public class WorkflowSpecificationsHandler { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - List<Workflow> workflows = catalogDbClient.findWorkflowByResourceTarget(pnf_resource); + List<Workflow> workflows = queryWorkflowsForResourceTarget(pnf_resource); Optional<String> optional = getResponseByWorkflowSpec(workflows); return builder.buildResponse(HttpStatus.SC_OK, "", optional.isPresent() ? optional.get() : EMPTY_BODY, @@ -296,4 +312,11 @@ public class WorkflowSpecificationsHandler { List<Workflow> workflows = catalogDbClient.findWorkflowByPnfModelUUID(pnfModelVersionId); return workflows; } + + private List<Workflow> queryWorkflowsForResourceTarget(String resourceTarget) { + List<Workflow> workflows = catalogDbClient.findWorkflowByResourceTarget(resourceTarget); + return workflows; + } + + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java index 2cf01f9390..55a68ff7df 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java @@ -21,7 +21,7 @@ package org.onap.so.apihandlerinfra.validation; -import java.util.HashMap; +import java.util.Map; import org.onap.so.apihandler.common.CommonConstants; import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; @@ -31,6 +31,7 @@ public class InstanceIdMapValidation implements ValidationRule { private static final String Service_InstanceId = "serviceInstanceId"; private static final String Vnf_InstanceId = "vnfInstanceId"; + private static final String PNF_NAME = "pnfName"; private static final String vfModule_InstanceId = "vfModuleInstanceId"; private static final String volume_Group_InstanceId = "volumeGroupInstanceId"; @@ -39,7 +40,7 @@ public class InstanceIdMapValidation implements ValidationRule { @Override public ValidationInformation validate(ValidationInformation info) throws ValidationException { - HashMap<String, String> instanceIdMap = info.getInstanceIdMap(); + Map<String, String> instanceIdMap = info.getInstanceIdMap(); ServiceInstancesRequest sir = info.getSir(); if (instanceIdMap != null) { if (instanceIdMap.get(Service_InstanceId) != null) { @@ -90,6 +91,10 @@ public class InstanceIdMapValidation implements ValidationRule { } sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID)); } + + if (instanceIdMap.get(PNF_NAME) != null) { + sir.setPnfName(instanceIdMap.get(PNF_NAME)); + } } return info; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java index 68b2a78a85..ee4fde02eb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java @@ -21,7 +21,7 @@ package org.onap.so.apihandlerinfra.validation; -import java.util.HashMap; +import java.util.Map; import org.onap.so.apihandlerinfra.Actions; import org.onap.so.serviceinstancebeans.LineOfBusiness; import org.onap.so.serviceinstancebeans.OwningEntity; @@ -34,7 +34,7 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; public class ValidationInformation { ServiceInstancesRequest sir; - HashMap<String, String> instanceIdMap; + Map<String, String> instanceIdMap; Actions action; int reqVersion; String requestScope; @@ -53,7 +53,7 @@ public class ValidationInformation { OwningEntity owningEntity; Service userParams; - public ValidationInformation(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, + public ValidationInformation(ServiceInstancesRequest sir, Map<String, String> instanceIdMap, Actions action, int reqVersion, Boolean aLaCarteFlag, RequestParameters requestParameters) { this.sir = sir; this.instanceIdMap = instanceIdMap; @@ -71,11 +71,11 @@ public class ValidationInformation { this.sir = value; } - public HashMap<String, String> getInstanceIdMap() { + public Map<String, String> getInstanceIdMap() { return this.instanceIdMap; } - public void setInstanceIdMap(HashMap<String, String> value) { + public void setInstanceIdMap(Map<String, String> value) { this.instanceIdMap = value; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java index 081f235db1..33ed5fa700 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java @@ -29,10 +29,12 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID; -import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID; 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 com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; @@ -46,7 +48,6 @@ import org.junit.Before; import org.junit.Test; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.RequestReferences; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.springframework.beans.factory.annotation.Autowired; @@ -57,8 +58,6 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.util.ResourceUtils; import org.springframework.web.util.UriComponentsBuilder; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; public class InstanceManagementTest extends BaseTest { @@ -208,6 +207,35 @@ public class InstanceManagementTest extends BaseTest { } @Test + public void executeServiceLevelCustomWorkflow() throws IOException { + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/testingServiceLevelWorkflow")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching( + ".*/workflow/search/findByArtifactUUID[?]artifactUUID=81526781-e55c-4cb7-adb3-97e09d9c76bf")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("workflow_ServiceLevel_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + // expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + requestReferences.setRequestSelfLink(createExpectedSelfLink("v1", "32807a28-1a14-4b88-b7b3-2950918aa76d")); + expectedResponse.setRequestReferences(requestReferences); + uri = instanceManagementUri + "v1" + + "/serviceInstances/5df8b6de-2083-11e7-93ae-92361f002676/workflows/81526781-e55c-4cb7-adb3-97e09d9c76bf"; + ResponseEntity<String> response = + sendRequest(inputStream("/ExecuteServiceLevelCustomWorkflow.json"), uri, HttpMethod.POST, headers); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test public void workflowAndOperationNameTest() { wireMockServer.stubFor(get(urlMatching( ".*/workflow/search/findByArtifactUUID[?]artifactUUID=71526781-e55c-4cb7-adb3-97e09d9c76be")) diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java index 4ab88f40f6..1fa71cefc2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java @@ -58,6 +58,9 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { @Autowired WorkflowSpecificationsHandler workflowSpecificationsHandler; + @Autowired + ObjectMapper mapper; + @Value("${wiremock.server.port}") private String wiremockPort; @@ -152,7 +155,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); WorkflowSpecifications expectedResponse = mapper.readValue( @@ -306,7 +308,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { WorkflowSpecifications workflowSpecifications = workflowSpecificationsHandler.mapWorkflowsToWorkflowSpecifications(workflows); - ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); String workflowSpecificationsJson = mapper.writeValueAsString(workflowSpecifications); @@ -349,7 +350,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); WorkflowSpecifications expectedResponse = mapper.readValue( @@ -367,6 +367,52 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { } @Test + public void queryWorkflowSpecificationsByResourceTarget_Test_Success() throws JSONException, IOException { + + String URL_PATH = basePath + "/v1/workflows"; + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + String WORKFLOW_QUERY = "/workflow/search/findByResourceTarget[?]resourceTarget=service"; + String WORKFLOW_SPEC_QUERY = "/workflow/5/workflowActivitySpecSequence"; + String JSON_FILE_PATH = "src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json"; + String MOCK_RESP_FILE = "WorkflowSpecificationsForServiceWorkflows_Response.json"; + String MOCK_RESP_SPEC_FILE = "Empty_workflowActivitySpecSequence_Response.json"; + + wireMockServer.stubFor(get(urlMatching(WORKFLOW_QUERY)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb(MOCK_RESP_FILE)) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching(WORKFLOW_SPEC_QUERY)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb(MOCK_RESP_SPEC_FILE)) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + UriComponentsBuilder builder = + UriComponentsBuilder.fromHttpUrl(createURLWithPort(URL_PATH)).queryParam("resourceTarget", "service"); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + WorkflowSpecifications expectedResponse = mapper + .readValue(new String(Files.readAllBytes(Paths.get(JSON_FILE_PATH))), WorkflowSpecifications.class); + WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + assertThat(expectedResponse, sameBeanAs(realResponse)); + assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0)); + assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); + assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); + assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0)); + } + + @Test public void testWorkflowSpecificationsForPnf_Success() throws JSONException, IOException { final String urlPath = basePath + "/v1/pnfWorkflows"; @@ -397,7 +443,6 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); WorkflowSpecifications expectedResponse = mapper.readValue( diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json new file mode 100644 index 0000000000..e466ac08a3 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json @@ -0,0 +1,39 @@ +{ + "requestDetails":{ + "subscriberInfo":{ + "globalSubscriberId":"Test" + }, + "requestInfo":{ + "suppressRollback": false, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "demo", + "instanceName":"testInstanceName", + "source":"VID" + }, + "cloudConfiguration":{ + "lcpCloudRegionId": "RegionOne", + "tenantId": "7320ec4a5b9d4589ba7c4412ccfd290f", + "cloudOwner": "CloudOwner" + }, + "requestParameters":{ + "subscriptionServiceType": "test", + "userParams":[], + "aLaCarte": false, + "payload": "{\"k1\": \"v1\"}" + }, + "project":{ + "projectName": "PNFSWUProject" + }, + "owningEntity":{ + "owningEntityId":"67f2e84c-734d-4e90-a1e4-d2ffa2e75849", + "owningEntityName":"OE-Test" + }, + "modelInfo":{ + "modelVersion": "2.0", + "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b", + "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b", + "modelName": "Demo_svc", + "modelType": "service" + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json new file mode 100644 index 0000000000..aaaad17470 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForService.json @@ -0,0 +1,20 @@ +{ + "workflowSpecificationList": [ + { + "workflowSpecification": { + "artifactInfo": { + "artifactType": "workflow", + "artifactUuid": "a1fe8726-66d5-3e7f-2212-7e5h662e9255", + "artifactName": "DummyServiceWorkflow", + "artifactVersion": "1.0", + "artifactDescription": "Dummy Service Workflow to test custom Service workflow", + "workflowName": "Dummy Service Workflow", + "operationName": "DummyServiceWorkflow", + "workflowSource": "native", + "workflowResourceTarget": "service" + }, + "workflowInputParameters": [] + } + } + ] +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json new file mode 100644 index 0000000000..9a836e033b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForServiceWorkflows_Response.json @@ -0,0 +1,41 @@ +{ + "_embedded": { + "workflow": [ + { + "artifactChecksum": "MANUAL RECORD", + "artifactName": "DummyServiceWorkflow", + "artifactUUID": "a1fe8726-66d5-3e7f-2212-7e5h662e9255", + "body": null, + "created": "2020-06-29T08:28:15.000+0000", + "description": "Dummy Service Workflow to test custom Service workflow", + "id": 4, + "name": "Dummy Service Workflow", + "operationName": "DummyServiceWorkflow", + "pnfResourceWorkflow": null, + "resourceTarget": "service", + "source": "native", + "timeoutMinutes": null, + "version": 1.0, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findByResourceTarget?resourceTarget=service" + }, + "workflow": { + "href": "http://localhost:8090/workflow/5" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/5/workflowActivitySpecSequence" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findByResourceTarget?resourceTarget=service" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/5/workflowActivitySpecSequence" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json new file mode 100644 index 0000000000..133c724b43 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json @@ -0,0 +1,6 @@ +{ + "artifactUUID": "81526781-e55c-4cb7-adb3-97e09d9c76bf", + "artifactName": "testingServiceLevelWorkflow.bpmn", + "name": "testingServiceLevelWorkflow", + "operationName": "testServiceLevelOperation" +} @@ -30,6 +30,7 @@ <module>adapters</module> <module>asdc-controller</module> <module>so-optimization-clients</module> + <module>so-sdn-clients</module> <module>bpmn</module> <module>cloudify-client</module> <module>cxf-logging</module> @@ -73,7 +74,7 @@ <format.skipValidate>false</format.skipValidate> <format.skipExecute>true</format.skipExecute> <io.fabric8.version>0.33.0</io.fabric8.version> - <appc.client.version>1.7.1</appc.client.version> + <appc.client.version>1.8.0-SNAPSHOT</appc.client.version> <bowman.client.version>0.8.0</bowman.client.version> <aaf.cadi.version>2.1.15</aaf.cadi.version> </properties> diff --git a/so-sdn-clients/pom.xml b/so-sdn-clients/pom.xml new file mode 100644 index 0000000000..c9b417b230 --- /dev/null +++ b/so-sdn-clients/pom.xml @@ -0,0 +1,173 @@ +<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"> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>so</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>so-sdn-clients</artifactId> + <properties> + <sdnc.northbound.version>1.5.2</sdnc.northbound.version> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>default-test</id> + <goals> + <goal>test</goal> + </goals> + <configuration> + <includes> + <include>**/UnitTestSuite.java</include> + </includes> + </configuration> + </execution> + <execution> + <id>integration-test</id> + <goals> + <goal>test</goal> + </goals> + <configuration> + <includes> + <include>**/IntegrationTestSuite.java</include> + </includes> + </configuration> + </execution> + </executions> + <configuration> + <parallel>suites</parallel> + </configuration> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <versionRange>[1.0.0,)</versionRange> + <goals> + <goal>unpack</goal> + </goals> + </pluginExecutionFilter> + <action> + <execute /> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <dependencyManagement> + <dependencies> + <dependency> + <!-- Import dependency management from Spring Boot --> + <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.camunda.bpm.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter</artifactId> + <version>${camunda.springboot.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-contract-wiremock</artifactId> + <version>1.2.4.RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.onap.sdnc.northbound</groupId> + <artifactId>generic-resource-api-client</artifactId> + <version>${sdnc.northbound.version}</version> + <exclusions> + <exclusion> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + </exclusion> + <exclusion> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>io.swagger</groupId> + <artifactId>swagger-models</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>ch.vorburger.mariaDB4j</groupId> + <artifactId>mariaDB4j</artifactId> + <version>2.2.3</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-configuration-processor</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>aai-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.inject</groupId> + <artifactId>jersey-hk2</artifactId> + <version>2.26</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> + </dependency> + </dependencies> +</project> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index 7d2fc10d0b..7d2fc10d0b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SDNCClient.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java index 01ac675d83..01ac675d83 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java index 15076fa45a..15076fa45a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java index 2c8bdd931c..2c8bdd931c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java index d6216c509d..d6216c509d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java index 4edbf37bad..4edbf37bad 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java index ae9fe6ad70..ae9fe6ad70 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java index 9b857dc08c..9b857dc08c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidator.java index 83624dec63..d4af90267d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidator.java @@ -22,7 +22,6 @@ package org.onap.so.client.sdno; import java.io.IOException; import java.util.UUID; -import org.onap.aai.domain.yang.GenericVnf; public interface SDNOValidator { @@ -38,18 +37,4 @@ public interface SDNOValidator { */ public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception; - - /** - * Issues a health diagnostic request for a given GenericVnf to SDN-O - * - * @param genericVnf - * @param uuid - * @param requestingUserId - * @return diagnostic result - * @throws IOException - * @throws Exception - */ - public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) - throws IOException, Exception; - } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java index 9fc95a6f3f..d2a87db70a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java @@ -61,18 +61,6 @@ public class SDNOValidatorImpl implements SDNOValidator { return status; } - @Override - public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) - throws IOException, Exception { - - SDNO requestDiagnostic = buildRequestDiagnostic(genericVnf, uuid, requestingUserId); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(requestDiagnostic); - this.submitRequest(json); - boolean status = this.pollForResponse(uuid.toString()); - return status; - } - protected SDNO buildRequestDiagnostic(GenericVnf vnf, UUID uuid, String requestingUserId) { Optional<String> nfRole; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java index 7e98355b4d..7e98355b4d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Body.java index 8c40b749a6..8c40b749a6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Body.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Input.java index c8122c06f6..c8122c06f6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Input.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java index 485f64673f..485f64673f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java index b1b75ab412..b1b75ab412 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java index 8b84cf6659..8b84cf6659 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/SDNO.java index 46e2c1d1fc..46e2c1d1fc 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/SDNO.java diff --git a/so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java b/so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java new file mode 100644 index 0000000000..9c25b1f002 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java @@ -0,0 +1,60 @@ +/*- + * ============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; + +import java.io.IOException; +import java.io.InputStream; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.onap.so.client.sdnc.SDNCClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.SpyBean; +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; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration +@AutoConfigureWireMock(port = 0) +public abstract class BaseIntegrationTest { + + @Value("${wiremock.server.port}") + protected String wireMockPort; + + @SpyBean + protected SDNCClient SPY_sdncClient; + + @Autowired + protected WireMockServer wireMockServer; + + @Before + public void baseTestBefore() { + wireMockServer.resetAll(); + } + +} + + diff --git a/so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..62d9ecee44 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import javax.sql.DataSource; + +@Configuration +@Profile({"test"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + MariaDB4jSpringService service = new MariaDB4jSpringService(); + + + service.getConfiguration().addArg("--lower_case_table_names=1"); + return service; + } + + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + // Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword) + .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build(); + } +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java b/so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java new file mode 100644 index 0000000000..50bbc1845f --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + +import org.junit.runner.RunWith; +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({"**/*IT.class"}) +public class IntegrationTestSuite { + +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/TestApplication.java b/so-sdn-clients/src/test/java/org/onap/so/TestApplication.java new file mode 100644 index 0000000000..fe965b4444 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/TestApplication.java @@ -0,0 +1,43 @@ +package org.onap.so; +/*- + * ============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========================================================= + */ + + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Profile; + +@SpringBootApplication +@Profile("test") +@ComponentScan(basePackages = {"org.onap.so"}, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) +public class TestApplication { + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + + + } +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java b/so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java new file mode 100644 index 0000000000..890c81daeb --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + + +import org.junit.runner.RunWith; +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({"**/*Test.class"}) +public class UnitTestSuite { + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java index a8816e1b04..a8816e1b04 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java index 0b338bde1d..0b338bde1d 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java index 750e578558..7345b8161b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java @@ -33,7 +33,7 @@ public class SDNOHealthCheckClientTest { - private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/health-check/"; + private final String fileLocation = "src/test/resources/__files/sdno/health-check/"; private static final String userId = "test-user"; private static final Optional<String> clliCode = Optional.of("test-clli"); private static final String requestId = "test-request-id"; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java index b91f83c1b7..8d2993ec43 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java @@ -55,7 +55,7 @@ public class SDNOValidatorIT extends BaseIntegrationTest { @Mock private Consumer mrConsumer; private SDNOHealthCheckDmaapConsumer dmaapConsumer; - private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/"; + private final String fileLocation = "src/test/resources/__files/sdno/client/"; private final String uuid = "xyz123"; @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java index c2278c26f9..c2278c26f9 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json new file mode 100644 index 0000000000..9c50c2f11b --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json @@ -0,0 +1,7 @@ +{ + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json new file mode 100644 index 0000000000..91d64b98ca --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json @@ -0,0 +1,54 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : null, + "global-customer-id" : "globalCustomerId", + "service-instance-id" : null + }, + "network-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "network-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + } ] + }, + "network-name" : "TEST_NETWORK_NAME", + "network-instance-group-id" : "networkInstanceGroupId" + }, + "request-information" : { + "notification-url" : null, + "order-version" : null, + "request-action" : "CreateNetworkInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : null, + "svc-action" : "assign" + }, + "network-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : "modelCustomizationUUID", + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "from-preload": null, + "network-id" : "TEST_NETWORK_ID", + "network-type" : null + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json new file mode 100644 index 0000000000..95a2af3880 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json @@ -0,0 +1,53 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : null, + "global-customer-id" : "globalCustomerId", + "service-instance-id" : null + }, + "network-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "network-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + } ] + }, + "network-instance-group-id" : "networkInstanceGroupId" + }, + "request-information" : { + "notification-url" : null, + "order-version" : null, + "request-action" : "CreateNetworkInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : null, + "svc-action" : "assign" + }, + "network-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : "modelCustomizationUUID", + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "from-preload": null, + "network-id" : "TEST_NETWORK_ID", + "network-type" : null + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json new file mode 100644 index 0000000000..a7cf1e1434 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json @@ -0,0 +1,54 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : null, + "global-customer-id" : "globalCustomerId", + "service-instance-id" : null + }, + "network-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "network-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + } ] + }, + "network-name" : "TEST_NETWORK_NAME", + "network-instance-group-id" : "networkInstanceGroupId" + }, + "request-information" : { + "notification-url" : null, + "order-version" : null, + "request-action" : "DeleteNetworkInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : null, + "svc-action" : "unassign" + }, + "network-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : "modelCustomizationUUID", + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "from-preload": null, + "network-id" : "TEST_NETWORK_ID", + "network-type" : null + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json new file mode 100644 index 0000000000..53c1997126 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json @@ -0,0 +1,74 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "serviceModelName", + "model-version" : "serviceModelVersion", + "model-customization-uuid" : null, + "model-uuid" : "serviceModelUuid", + "model-invariant-uuid" : "serviceModelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : "serviceInstanceId", + "global-customer-id" : "globalCustomerId", + "service-instance-id" : "serviceInstanceId" + }, + "vf-module-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "vf-module-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + }, + { + "name" : "key2", + "value" : "value2" + }, + { + "name" : "volume-group-id", + "value" : "volumeGroupId" + } ] + }, + "vf-module-name" : "testVfModuleName" + }, + "request-information" : { + "request-action" : "CreateVfModuleInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null, + "order-version" : null, + "notification-url" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : "http://localhost:8080", + "svc-action" : "assign" + }, + "vf-module-information" : { + "onap-model-information" : { + "model-name" : "vfModuleModelName", + "model-version" : "vfModuleModelVersion", + "model-customization-uuid" : "vfModuleModelCustomizationUuid", + "model-uuid" : "vfModuleModelUuid", + "model-invariant-uuid" : "vfModuleModelInvariantUuid" + }, + "vf-module-id" : "testVfModuleId", + "from-preload" : true, + "vf-module-type": "vfModuleModelName" + + }, + "vnf-information" : { + "onap-model-information" : { + "model-name" : "vnfModelName", + "model-version" : "vnfModelVersion", + "model-customization-uuid" : "vnfModelCustomizationUuid", + "model-uuid" : "vnfModelUuid", + "model-invariant-uuid" : "vnfModelInvariantUuid" + }, + "vnf-id" : "testVnfId", + "vnf-type" : "testVnfType", + "vnf-name" : "testVnfName" + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json new file mode 100644 index 0000000000..9f93c0df1f --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json @@ -0,0 +1,31 @@ +{ + "service-information" : { + "service-instance-id" : "serviceInstanceId", + "service-id" : "serviceInstanceId" + }, + "vf-module-request-input" : { + "vf-module-name" : "testVfModuleName", + "vf-module-input-parameters" : {} + }, + "request-information" : { + "request-action" : "DeleteVfModuleInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null, + "order-version" : null, + "notification-url" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : "http://localhost:8080", + "svc-action" : "unassign" + }, + "vf-module-information" : { + "vf-module-id" : "testVfModuleId", + "from-preload": true + }, + "vnf-information" : { + "vnf-id" : "testVnfId", + "vnf-type" : "testVnfType" + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json b/so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json new file mode 100644 index 0000000000..a18b6aa54e --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json @@ -0,0 +1,27 @@ +{ + "vnf-topology": { + "tenant": "0422ffb57ba042c0800a29dc85ca70f8", + "vnf-topology-identifier-structure": { + "vnf-id": "66dac89b-2a5b-4cb9-b22e-a7e4488fb3db", + "vnf-type": "InfraMSO_vSAMP10a_Service/InfraMSO_vSAMP10a-2 0", + "vnf-name": "MSO-DEV-VNF-1806HF1-InfraMSO_vSAMP10a-1XXX-GR_21" + }, + "aic-clli": "AUSTTXGR", + "vnf-resource-assignments": { + "availability-zones": { + "availability-zone": [ + "AZ-MN02" + ], + "max-count": 1 + } + }, + "aic-cloud-region": "mtn6", + "onap-model-information": { + "model-customization-uuid": "034226ae-879a-46b5-855c-d02babcb6cb6", + "model-uuid": "cb79c25f-b30d-4d95-afb5-97be4021f3db", + "model-invariant-uuid": "e93d3a7a-446d-486b-ae48-d474a9156064", + "model-name": "InfraMSO_vSAMP10a-2", + "model-version": "1.0" + } + } +}
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json new file mode 100644 index 0000000000..0de25616e3 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json @@ -0,0 +1,127 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "extra_console", + "vnf-parameter-value": "ttyS1" + }, + { + "vnf-parameter-name": "vnfUsername", + "vnf-parameter-value": "vnf_user" + }, + { + "vnf-parameter-name": "additionalParams", + "vnf-parameter-value": "{\"image_id\": \"DUMMYVNF\",\"instance_type\": \"m1.small\",\"ftp_address\": \"ftp://0.0.0.0:2100/\"}" + }, + { + "vnf-parameter-name": "fsb_admin_gateway_ip_1", + "vnf-parameter-value": "0.0.0.0" + }, + { + "vnf-parameter-name": "availability_zone_1" + }, + { + "vnf-parameter-name": "fsb_admin_gateway_ip_2" + }, + { + "vnf-parameter-name": "fsb_admin_prefix_length", + "vnf-parameter-value": "28" + }, + { + "vnf-parameter-name": "ONAPMME_OMCN_vLC_P4_prefix_length", + "vnf-parameter-value": "28" + }, + { + "vnf-parameter-name": "gpbs", + "vnf-parameter-value": "2" + }, + { + "vnf-parameter-name": "fsb_admin_ip_2", + "vnf-parameter-value": "192.0.0.1" + }, + { + "vnf-parameter-name": "internal_mtu", + "vnf-parameter-value": "1500" + }, + { + "vnf-parameter-name": "storage_drbd_sync_rate", + "vnf-parameter-value": "0" + }, + { + "vnf-parameter-name": "ONAPMME_MEDIA_vLC_P3_net_id", + "vnf-parameter-value": "ONAPMME_MEDIA_vLC_P3" + }, + { + "vnf-parameter-name": "extVirtualLinks", + "vnf-parameter-value": "[{\"id\":\"ac1ed33d-8dc1-4800-8ce8-309b99c38eec\",\"tenant\":{\"cloudOwner\":\"CloudOwner\",\"regionName\":\"RegionOne\",\"tenantId\":\"80c26954-2536-4bca-9e20-10f8a2c9c2ad\"},\"resourceId\":\"8ef8cd54-75fd-4372-a6dd-2e05ea8fbd9b\",\"extCps\":[{\"cpdId\":\"f449292f-2f0f-4656-baa3-a18d86bac80f\",\"cpConfig\":[{\"cpInstanceId\":\"07876709-b66f-465c-99a7-0f4d026197f2\",\"linkPortId\":null,\"cpProtocolData\":null}]}],\"extLinkPorts\":null}]" + }, + { + "vnf-parameter-name": "vnfIpAddress", + "vnf-parameter-value": "127.0.0.0" + }, + { + "vnf-parameter-name": "node_type", + "vnf-parameter-value": "sgsnl" + }, + { + "vnf-parameter-name": "ONAPMME_SIG_vLC_P2_net_id", + "vnf-parameter-value": "ONAPMME_SIG_vLC_P2" + }, + { + "vnf-parameter-name": "updateOss", + "vnf-parameter-value": "false" + }, + { + "vnf-parameter-name": "tmo", + "vnf-parameter-value": "0" + }, + { + "vnf-parameter-name": "ss7", + "vnf-parameter-value": "Not_Applicable" + }, + { + "vnf-parameter-name": "ONAPMME_OMCN_vLC_P4_net_id", + "vnf-parameter-value": "ONAPMME_OMCN_vLC_P4" + }, + { + "vnf-parameter-name": "key_name" + }, + { + "vnf-parameter-name": "fsb_admin_dns_server_ip_2" + }, + { + "vnf-parameter-name": "time_zone", + "vnf-parameter-value": "GMT" + }, + { + "vnf-parameter-name": "enableRollback", + "vnf-parameter-value": "false" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json new file mode 100644 index 0000000000..c2cf2b2f28 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json @@ -0,0 +1,47 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "extra_console", + "vnf-parameter-value": "ttyS1" + }, + { + "vnf-parameter-name": "vnfUsername", + "vnf-parameter-value": "vnf_user" + }, + { + "vnf-parameter-name": "additionalParams", + "vnf-parameter-value": "[\"abc\"]" + }, + { + "vnf-parameter-name": "extVirtualLinks", + "vnf-parameter-value": "{\"def\":\"123\"}" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json new file mode 100644 index 0000000000..552adb9125 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json @@ -0,0 +1,39 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "extra_console", + "vnf-parameter-value": "ttyS1" + }, + { + "vnf-parameter-name": "vnfUsername", + "vnf-parameter-value": "vnf_user" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json new file mode 100644 index 0000000000..e19ad1c9d3 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json @@ -0,0 +1,34 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "hello": "world" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json new file mode 100644 index 0000000000..286ce4c844 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json @@ -0,0 +1,15 @@ +{ + "output": { + "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c", + "network-response-information": { + "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b", + "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/" + }, + "response-code": "200", + "service-response-information": { + "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a" + }, + "response-message": "", + "ack-final-indicator": "Y" + } +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json new file mode 100644 index 0000000000..deb4de0219 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json @@ -0,0 +1,15 @@ +{ + "output": { + "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c", + "network-response-information": { + "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b", + "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/" + }, + "response-code": "200", + "service-response-information": { + "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a" + }, + "response-message": "", + "ack-final-indicator": "N" + } +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json new file mode 100644 index 0000000000..cf0254886d --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json @@ -0,0 +1,8 @@ +{ + "output": { + "svc-request-id": "086a7a09-1470-4977-8b3e-307488b8811a", + "response-code": "404", + "response-message": "invalid input: the service-instance does not have any service data in SDNC", + "ack-final-indicator": "Y" + } +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json b/so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json new file mode 100644 index 0000000000..7e263b4465 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json @@ -0,0 +1,29 @@ +{ + "vnf-topology": { + "tenant": "0422ffb57ba042c0800a29dc85ca70f8", + "vnf-topology-identifier-structure": { + "vnf-id": "66dac89b-2a5b-4cb9-b22e-a7e4488fb3db", + "vnf-type": "InfraMSO_vSAMP10a_Service/InfraMSO_vSAMP10a-2 0", + "vnf-name": "MSO-DEV-VNF-1806HF1-InfraMSO_vSAMP10a-1XXX-GR_21" + }, + "aic-clli": "AUSTTXGR", + "vnf-resource-assignments": { + "availability-zones": { + "availability-zone": [ + { + "test":"AZ-MN02" + } + ], + "max-count": 1 + } + }, + "aic-cloud-region": "mtn6", + "onap-model-information": { + "model-customization-uuid": "034226ae-879a-46b5-855c-d02babcb6cb6", + "model-uuid": "cb79c25f-b30d-4d95-afb5-97be4021f3db", + "model-invariant-uuid": "e93d3a7a-446d-486b-ae48-d474a9156064", + "model-name": "InfraMSO_vSAMP10a-2", + "model-version": "1.0" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json b/so-sdn-clients/src/test/resources/__files/sdno/client/output-failure.json index 8cf0a820cd..8cf0a820cd 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/client/output-failure.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json b/so-sdn-clients/src/test/resources/__files/sdno/client/output-success.json index a6794327d8..a6794327d8 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/client/output-success.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json b/so-sdn-clients/src/test/resources/__files/sdno/client/response.json index 2355e86938..2355e86938 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/client/response.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-post-check-request.json index 2c46b5a8cb..2c46b5a8cb 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-post-check-request.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-pre-check-request.json index bf168b0028..bf168b0028 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-pre-check-request.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-post-check-request.json index 89e505e7d0..89e505e7d0 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-post-check-request.json diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-pre-check-request.json index 86897c8a1f..86897c8a1f 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-pre-check-request.json diff --git a/so-sdn-clients/src/test/resources/application-test.yaml b/so-sdn-clients/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..b64fc3318b --- /dev/null +++ b/so-sdn-clients/src/test/resources/application-test.yaml @@ -0,0 +1,231 @@ +aai: + auth: 5A1272FE739BECA4D4374A86B25C021DFE6745E3BB7BE6836BF64A6059B8220E586C21FD7567AF41DB42571EB7 + endpoint: http://localhost:${wiremock.server.port} + pnfEntryNotificationTimeout: P14D +appc: + client: + key: iaEMAfjsVsZnraBP + response: + timeout: '120000' + secret: wcivUjsjXzmGFBfxMmyJu9dz + poolMembers: localhost:3904 + service: ueb + topic: + read: + name: APPC-TEST-AMDOCS2 + timeout: '120000' + write: APPC-TEST-AMDOCS1-DEV3 + sdnc: + read: SDNC-LCM-READ + write: SDNC-LCM-WRITE +log: + debug: + CompleteMsoProcess: 'true' + CreateNetworkInstanceInfra: 'true' + CreateServiceInstanceInfra: 'true' + DeleteNetworkInstanceInfra: 'true' + FalloutHandler: 'true' + UpdateNetworkInstanceInfra: 'true' + VnfAdapterRestV1: 'true' + sdncAdapter: 'true' + vnfAdapterCreateV1: 'true' + vnfAdapterRestV1: 'true' +pnf: + dmaap: + host: hostTest + port: 1234 + protocol: http + uriPathPrefix: events + topicName: pnfReady + consumerGroup: consumerGroup + consumerId: consumerId + topicListenerDelayInSeconds: 5 +mso: + naming: + endpoint: http://localhost:${wiremock.server.port}/web/service/v1/genNetworkElementName + auth: Basic YnBlbDptc28tZGItMTUwNyE= + adapters: + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 + completemsoprocess: + endpoint: http://localhost:${wiremock.server.port}/CompleteMsoProcess + db: + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C + endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter + spring: + endpoint: http://localhost:${wiremock.server.port} + network: + endpoint: http://localhost:${wiremock.server.port}/networks/NetworkAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/networks/rest/v1/networks + openecomp: + db: + endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter + po: + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C + password: 3141634BF7E070AA289CF2892C986C0B + sdnc: + endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter/v1/sdnc + timeout: PT60S + tenant: + endpoint: http://localhost:${wiremock.server.port}/tenantAdapterMock + vnf: + endpoint: http://localhost:${wiremock.server.port}/vnfs/VnfAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs + volume-groups: + rest: + endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/volume-groups + vnf-async: + endpoint: http://localhost:${wiremock.server.port}/vnfs/VnfAdapterAsync + workflow: + message: + endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message + + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 + + bpmn: + optimisticlockingexception: + retrycount: '3' + cloudRegionIdsToSkipAddingVnfEdgesTo: test25Region1,test25Region2,test25Region99 + callbackRetryAttempts: '5' + catalog: + db: + endpoint: http://localhost:${wiremock.server.port}/ + spring: + endpoint: http://localhost:${wiremock.server.port} + correlation: + timeout: 60 + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + default: + adapter: + namespace: http://org.onap.so + healthcheck: + log: + debug: 'false' + infra: + customer: + id: testCustIdInfra + logPath: logs + msoKey: 07a7159d3bf51a0e53be7a8f89699be7 + po: + timeout: PT60S + request: + db: + endpoint: http://localhost:${wiremock.server.port}/ + rollback: 'true' + site-name: localDevEnv + workflow: + default: + aai: + cloud-region: + version: '9' + generic-vnf: + version: '9' + global: + default: + aai: + namespace: http://org.openecomp.aai.inventory/ + version: '8' + message: + endpoint: http://localhost:${wiremock.server.port}/mso/WorkflowMesssage + notification: + name: GenericNotificationService + sdncadapter: + callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService + vnfadapter: + create: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + delete: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + query: + callback: http://localhost:${wiremock.server.port}/mso/services/VNFAdapterQuerCallbackV1 + rollback: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + global: + dmaap: + username: dmaapUsername + password: dmaapPassword + host: http://localhost:28090 + publisher: + topic: com.att.mso.asyncStatusUpdate +policy: + auth: Basic dGVzdHBkcDphbHBoYTEyMw== + client: + auth: Basic bTAzNzQzOnBvbGljeVIwY2sk + endpoint: https://localhost:8081/pdp/api/ + environment: TEST +sdnc: + auth: Basic YWRtaW46YWRtaW4= + host: http://localhost:${wiremock.server.port} + path: /restconf/operations/GENERIC-RESOURCE-API +sniro: + conductor: + enabled: true + host: http://localhost:${wiremock.server.port} + uri: /v1/release-orders + headers.auth: Basic dGVzdDp0ZXN0cHdk + manager: + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri.v1: /sniro/api/v2/placement + uri.v2: /sniro/api/placement/v2 + headers.auth: Basic dGVzdDp0ZXN0cHdk + headers.patchVersion: 1 + headers.minorVersion: 1 + headers.latestVersion: 2 +oof: + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri: /api/oof/v1/placement + headers.auth: Basic dGVzdDp0ZXN0cHdk +org: + onap: + so: + cloud-owner: att-aic +spring: + datasource: + jdbc-url: jdbc:mariadb://localhost:3307/camundabpmn + username: root + password: password + 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 +sdno: + health-check: + dmaap: + password: password + publisher: + topic: sdno.test-health-diagnostic-v02 + subscriber: + topic: sdno.test-health-diagnostic-v02 + username: username +mariaDB4j: + dataDir: + port: 3307 + databaseName: camundabpmn +camunda: + bpm: + metrics: + enabled: false + db-reporter-activate: false +# CDSProcessingClient +cds: + endpoint: localhost + port: 11012 + auth: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + timeout: 60 diff --git a/so-sdn-clients/src/test/resources/dmaap.properties b/so-sdn-clients/src/test/resources/dmaap.properties new file mode 100644 index 0000000000..5593455da3 --- /dev/null +++ b/so-sdn-clients/src/test/resources/dmaap.properties @@ -0,0 +1,10 @@ +sdno.health-check.dmaap.username=testuser +sdno.health-check.dmaap.password=eHQ1cUJrOUc +sdno.health-check.dmaap.subscriber.topic=com.att.sdno.test-health-diagnostic-v02 +sdno.health-check.dmaap.publisher.topic=com.att.sdno.test-health-diagnostic-v02 +ruby.create-ticket-request.dmaap.username=testuser +ruby.create-ticket-request.dmaap.password=eHQ1cUJrOUc +ruby.create-ticket-request.publisher.topic=com.att.pdas.st1.msoCMFallout-v1 +ruby.create-ticket-request.dmaap.auth=81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 +sdno.health-check.dmaap.auth=81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 +mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7
\ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/schema.sql b/so-sdn-clients/src/test/resources/schema.sql new file mode 100644 index 0000000000..5ae6a2d972 --- /dev/null +++ b/so-sdn-clients/src/test/resources/schema.sql @@ -0,0 +1,1195 @@ + +USE `camundabpmn`; + + +create table ACT_GE_PROPERTY ( + NAME_ varchar(64), + VALUE_ varchar(300), + REV_ integer, + primary key (NAME_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + + +create table ACT_GE_BYTEARRAY ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + BYTES_ LONGBLOB, + GENERATED_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_DEPLOYMENT ( + ID_ varchar(64), + NAME_ varchar(255), + DEPLOY_TIME_ timestamp(3), + SOURCE_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXECUTION ( + ID_ varchar(64), + REV_ integer, + PROC_INST_ID_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + SUPER_EXEC_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + IS_ACTIVE_ TINYINT, + IS_CONCURRENT_ TINYINT, + IS_SCOPE_ TINYINT, + IS_EVENT_SCOPE_ TINYINT, + SUSPENSION_STATE_ integer, + CACHED_ENT_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOB ( + ID_ varchar(64) NOT NULL, + REV_ integer, + TYPE_ varchar(255) NOT NULL, + LOCK_EXP_TIME_ timestamp(3) NULL, + LOCK_OWNER_ varchar(255), + EXCLUSIVE_ boolean, + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + RETRIES_ integer, + EXCEPTION_STACK_ID_ varchar(64), + EXCEPTION_MSG_ varchar(4000), + DUEDATE_ timestamp(3) NULL, + REPEAT_ varchar(255), + HANDLER_TYPE_ varchar(255), + HANDLER_CFG_ varchar(4000), + DEPLOYMENT_ID_ varchar(64), + SUSPENSION_STATE_ integer NOT NULL DEFAULT 1, + JOB_DEF_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOBDEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + JOB_TYPE_ varchar(255) NOT NULL, + JOB_CONFIGURATION_ varchar(255), + SUSPENSION_STATE_ integer, + JOB_PRIORITY_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_PROCDEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + HAS_START_FORM_KEY_ TINYINT, + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + VERSION_TAG_ varchar(64), + HISTORY_TTL_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_TASK ( + ID_ varchar(64), + REV_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + TASK_DEF_KEY_ varchar(255), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + DELEGATION_ varchar(64), + PRIORITY_ integer, + CREATE_TIME_ timestamp(3), + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_IDENTITYLINK ( + ID_ varchar(64), + REV_ integer, + GROUP_ID_ varchar(255), + TYPE_ varchar(255), + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_VARIABLE ( + ID_ varchar(64) not null, + REV_ integer, + TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + TASK_ID_ varchar(64), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + VAR_SCOPE_ varchar(64) not null, + SEQUENCE_COUNTER_ bigint, + IS_CONCURRENT_LOCAL_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EVENT_SUBSCR ( + ID_ varchar(64) not null, + REV_ integer, + EVENT_TYPE_ varchar(255) not null, + EVENT_NAME_ varchar(255), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + CONFIGURATION_ varchar(255), + CREATED_ timestamp(3) not null, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_INCIDENT ( + ID_ varchar(64) not null, + REV_ integer not null, + INCIDENT_TIMESTAMP_ timestamp(3) not null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_AUTHORIZATION ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ integer not null, + GROUP_ID_ varchar(255), + USER_ID_ varchar(255), + RESOURCE_TYPE_ integer not null, + RESOURCE_ID_ varchar(255), + PERMS_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_FILTER ( + ID_ varchar(64) not null, + REV_ integer not null, + RESOURCE_TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + OWNER_ varchar(255), + QUERY_ LONGTEXT not null, + PROPERTIES_ LONGTEXT, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_METER_LOG ( + ID_ varchar(64) not null, + NAME_ varchar(64) not null, + REPORTER_ varchar(255), + VALUE_ bigint, + TIMESTAMP_ timestamp(3), + MILLISECONDS_ bigint DEFAULT 0, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXT_TASK ( + ID_ varchar(64) not null, + REV_ integer not null, + WORKER_ID_ varchar(255), + TOPIC_NAME_ varchar(255), + RETRIES_ integer, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + LOCK_EXP_TIME_ timestamp(3) NULL, + SUSPENSION_STATE_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + TENANT_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_BATCH ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_CREATED_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + SUSPENSION_STATE_ integer, + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_EXEC_BUSKEY on ACT_RU_EXECUTION(BUSINESS_KEY_); +create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_); +create index ACT_IDX_TASK_CREATE on ACT_RU_TASK(CREATE_TIME_); +create index ACT_IDX_TASK_ASSIGNEE on ACT_RU_TASK(ASSIGNEE_); +create index ACT_IDX_TASK_TENANT_ID on ACT_RU_TASK(TENANT_ID_); +create index ACT_IDX_IDENT_LNK_USER on ACT_RU_IDENTITYLINK(USER_ID_); +create index ACT_IDX_IDENT_LNK_GROUP on ACT_RU_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_EVENT_SUBSCR_CONFIG_ on ACT_RU_EVENT_SUBSCR(CONFIGURATION_); +create index ACT_IDX_EVENT_SUBSCR_TENANT_ID on ACT_RU_EVENT_SUBSCR(TENANT_ID_); +create index ACT_IDX_VARIABLE_TASK_ID on ACT_RU_VARIABLE(TASK_ID_); +create index ACT_IDX_VARIABLE_TENANT_ID on ACT_RU_VARIABLE(TENANT_ID_); +create index ACT_IDX_ATHRZ_PROCEDEF on ACT_RU_IDENTITYLINK(PROC_DEF_ID_); +create index ACT_IDX_INC_CONFIGURATION on ACT_RU_INCIDENT(CONFIGURATION_); +create index ACT_IDX_INC_TENANT_ID on ACT_RU_INCIDENT(TENANT_ID_); +-- CAM-5914 +create index ACT_IDX_JOB_EXECUTION_ID on ACT_RU_JOB(EXECUTION_ID_); +-- this index needs to be limited in mariadb see CAM-6938 +create index ACT_IDX_JOB_HANDLER on ACT_RU_JOB(HANDLER_TYPE_(100),HANDLER_CFG_(155)); +create index ACT_IDX_JOB_PROCINST on ACT_RU_JOB(PROCESS_INSTANCE_ID_); +create index ACT_IDX_JOB_TENANT_ID on ACT_RU_JOB(TENANT_ID_); +create index ACT_IDX_JOBDEF_TENANT_ID on ACT_RU_JOBDEF(TENANT_ID_); + +-- new metric milliseconds column +CREATE INDEX ACT_IDX_METER_LOG_MS ON ACT_RU_METER_LOG(MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_NAME_MS ON ACT_RU_METER_LOG(NAME_, MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_REPORT ON ACT_RU_METER_LOG(NAME_, REPORTER_, MILLISECONDS_); + +-- old metric timestamp column +CREATE INDEX ACT_IDX_METER_LOG_TIME ON ACT_RU_METER_LOG(TIMESTAMP_); +CREATE INDEX ACT_IDX_METER_LOG ON ACT_RU_METER_LOG(NAME_, TIMESTAMP_); + +create index ACT_IDX_EXT_TASK_TOPIC on ACT_RU_EXT_TASK(TOPIC_NAME_); +create index ACT_IDX_EXT_TASK_TENANT_ID on ACT_RU_EXT_TASK(TENANT_ID_); +create index ACT_IDX_EXT_TASK_PRIORITY ON ACT_RU_EXT_TASK(PRIORITY_); +create index ACT_IDX_EXT_TASK_ERR_DETAILS ON ACT_RU_EXT_TASK(ERROR_DETAILS_ID_); +create index ACT_IDX_AUTH_GROUP_ID ON ACT_RU_AUTHORIZATION(GROUP_ID_); +create index ACT_IDX_JOB_JOB_DEF_ID on ACT_RU_JOB(JOB_DEF_ID_); + +alter table ACT_GE_BYTEARRAY + add constraint ACT_FK_BYTEARR_DEPL + foreign key (DEPLOYMENT_ID_) + references ACT_RE_DEPLOYMENT (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_) on delete cascade on update cascade; + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_SUPER + foreign key (SUPER_EXEC_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_TSKASS_TASK + foreign key (TASK_ID_) + references ACT_RU_TASK (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_ATHRZ_PROCEDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_BYTEARRAY + foreign key (BYTEARRAY_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_JOB + add constraint ACT_FK_JOB_EXCEPTION + foreign key (EXCEPTION_STACK_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_EVENT_SUBSCR + add constraint ACT_FK_EVENT_EXEC + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_CAUSE + foreign key (CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_RCAUSE + foreign key (ROOT_CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_ERROR_DETAILS + foreign key (ERROR_DETAILS_ID_) + references ACT_GE_BYTEARRAY (ID_); + +create index ACT_IDX_INC_JOB_DEF on ACT_RU_INCIDENT(JOB_DEF_ID_); +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_JOB_DEF + foreign key (JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_USER + unique (USER_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_GROUP + unique (GROUP_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_UNIQ_VARIABLE + unique (VAR_SCOPE_, NAME_); + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_BATCH_SEED_JOB_DEF ON ACT_RU_BATCH(SEED_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_SEED_JOB_DEF + foreign key (SEED_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_MONITOR_JOB_DEF ON ACT_RU_BATCH(MONITOR_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_MONITOR_JOB_DEF + foreign key (MONITOR_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_JOB_DEF ON ACT_RU_BATCH(BATCH_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_JOB_DEF + foreign key (BATCH_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +-- indexes for deadlock problems - https://app.camunda.com/jira/browse/CAM-2567 -- +create index ACT_IDX_INC_CAUSEINCID on ACT_RU_INCIDENT(CAUSE_INCIDENT_ID_); +create index ACT_IDX_INC_EXID on ACT_RU_INCIDENT(EXECUTION_ID_); +create index ACT_IDX_INC_PROCDEFID on ACT_RU_INCIDENT(PROC_DEF_ID_); +create index ACT_IDX_INC_PROCINSTID on ACT_RU_INCIDENT(PROC_INST_ID_); +create index ACT_IDX_INC_ROOTCAUSEINCID on ACT_RU_INCIDENT(ROOT_CAUSE_INCIDENT_ID_); +-- index for deadlock problem - https://app.camunda.com/jira/browse/CAM-4440 -- +create index ACT_IDX_AUTH_RESOURCE_ID on ACT_RU_AUTHORIZATION(RESOURCE_ID_); +-- index to prevent deadlock on fk constraint - https://app.camunda.com/jira/browse/CAM-5440 -- +create index ACT_IDX_EXT_TASK_EXEC on ACT_RU_EXT_TASK(EXECUTION_ID_); + +-- indexes to improve deployment +create index ACT_IDX_BYTEARRAY_NAME on ACT_GE_BYTEARRAY(NAME_); +create index ACT_IDX_DEPLOYMENT_NAME on ACT_RE_DEPLOYMENT(NAME_); +create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_); +create index ACT_IDX_JOBDEF_PROC_DEF_ID ON ACT_RU_JOBDEF(PROC_DEF_ID_); +create index ACT_IDX_JOB_HANDLER_TYPE ON ACT_RU_JOB(HANDLER_TYPE_); +create index ACT_IDX_EVENT_SUBSCR_EVT_NAME ON ACT_RU_EVENT_SUBSCR(EVENT_NAME_); +create index ACT_IDX_PROCDEF_DEPLOYMENT_ID ON ACT_RE_PROCDEF(DEPLOYMENT_ID_); +create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_); +create index ACT_IDX_PROCDEF_VER_TAG ON ACT_RE_PROCDEF(VERSION_TAG_); +-- create case definition table -- +create table ACT_RE_CASE_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case execution table -- +create table ACT_RU_CASE_EXECUTION ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + SUPER_EXEC_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + ACT_ID_ varchar(255), + PREV_STATE_ integer, + CURRENT_STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case sentry part table -- + +create table ACT_RU_CASE_SENTRY_PART ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + CASE_EXEC_ID_ varchar(64), + SENTRY_ID_ varchar(255), + TYPE_ varchar(255), + SOURCE_CASE_EXEC_ID_ varchar(64), + STANDARD_EVENT_ varchar(255), + SOURCE_ varchar(255), + VARIABLE_EVENT_ varchar(255), + VARIABLE_NAME_ varchar(255), + SATISFIED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create index on business key -- +create index ACT_IDX_CASE_EXEC_BUSKEY on ACT_RU_CASE_EXECUTION(BUSINESS_KEY_); + +-- create foreign key constraints on ACT_RU_CASE_EXECUTION -- +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_) on delete cascade on update cascade; + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_VARIABLE -- +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +-- create foreign key constraints on ACT_RU_TASK -- +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_CASE_SENTRY_PART -- +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_EXEC + foreign key (CASE_EXEC_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_CASE_DEF_TENANT_ID on ACT_RE_CASE_DEF(TENANT_ID_); +create index ACT_IDX_CASE_EXEC_TENANT_ID on ACT_RU_CASE_EXECUTION(TENANT_ID_); +-- create decision definition table -- +create table ACT_RE_DECISION_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + VERSION_TAG_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create decision requirements definition table -- +create table ACT_RE_DECISION_REQ_DEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) NOT NULL, + VERSION_ integer NOT NULL, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_RE_DECISION_DEF + add constraint ACT_FK_DEC_REQ + foreign key (DEC_REQ_ID_) + references ACT_RE_DECISION_REQ_DEF(ID_); + +create index ACT_IDX_DEC_DEF_TENANT_ID on ACT_RE_DECISION_DEF(TENANT_ID_); +create index ACT_IDX_DEC_DEF_REQ_ID on ACT_RE_DECISION_DEF(DEC_REQ_ID_); +create index ACT_IDX_DEC_REQ_DEF_TENANT_ID on ACT_RE_DECISION_REQ_DEF(TENANT_ID_); +create table ACT_HI_PROCINST ( + ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + START_USER_ID_ varchar(255), + START_ACT_ID_ varchar(255), + END_ACT_ID_ varchar(255), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + SUPER_CASE_INSTANCE_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + DELETE_REASON_ varchar(4000), + TENANT_ID_ varchar(64), + STATE_ varchar(255), + primary key (ID_), + unique (PROC_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + EXECUTION_ID_ varchar(64) not null, + ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + ACT_NAME_ varchar(255), + ACT_TYPE_ varchar(255) not null, + ASSIGNEE_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + ACT_INST_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_TASKINST ( + ID_ varchar(64) not null, + TASK_DEF_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + DELETE_REASON_ varchar(4000), + PRIORITY_ integer, + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_VARINST ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(100), + REV_ integer, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + STATE_ varchar(20), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_DETAIL ( + ID_ varchar(64) not null, + TYPE_ varchar(255) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + VAR_INST_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(255), + REV_ integer, + TIME_ datetime(3) not null, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + OPERATION_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_IDENTITYLINK ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + TYPE_ varchar(255), + USER_ID_ varchar(255), + GROUP_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + OPERATION_TYPE_ varchar(64), + ASSIGNER_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_COMMENT ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TIME_ datetime(3) not null, + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTION_ varchar(255), + MESSAGE_ varchar(4000), + FULL_MSG_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ATTACHMENT ( + ID_ varchar(64) not null, + REV_ integer, + USER_ID_ varchar(255), + NAME_ varchar(255), + DESCRIPTION_ varchar(4000), + TYPE_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + URL_ varchar(4000), + CONTENT_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_OP_LOG ( + ID_ varchar(64) not null, + DEPLOYMENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + JOB_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + BATCH_ID_ varchar(64), + USER_ID_ varchar(255), + TIMESTAMP_ timestamp(3) not null, + OPERATION_TYPE_ varchar(64), + OPERATION_ID_ varchar(64), + ENTITY_TYPE_ varchar(30), + PROPERTY_ varchar(64), + ORG_VALUE_ varchar(4000), + NEW_VALUE_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_INCIDENT ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CREATE_TIME_ timestamp(3) not null, + END_TIME_ timestamp(3) null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + ACTIVITY_ID_ varchar(255), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + INCIDENT_STATE_ integer, + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_JOB_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + JOB_ID_ varchar(64) not null, + JOB_DUEDATE_ timestamp(3) NULL, + JOB_RETRIES_ integer, + JOB_PRIORITY_ bigint NOT NULL DEFAULT 0, + JOB_EXCEPTION_MSG_ varchar(4000), + JOB_EXCEPTION_STACK_ID_ varchar(64), + JOB_STATE_ integer, + JOB_DEF_ID_ varchar(64), + JOB_DEF_TYPE_ varchar(255), + JOB_DEF_CONFIGURATION_ varchar(255), + ACT_ID_ varchar(255), + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_BATCH ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_EXT_TASK_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + EXT_TASK_ID_ varchar(64) not null, + RETRIES_ integer, + TOPIC_NAME_ varchar(255), + WORKER_ID_ varchar(255), + PRIORITY_ bigint NOT NULL DEFAULT 0, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + STATE_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_PRO_INST_END on ACT_HI_PROCINST(END_TIME_); +create index ACT_IDX_HI_PRO_I_BUSKEY on ACT_HI_PROCINST(BUSINESS_KEY_); +create index ACT_IDX_HI_PRO_INST_TENANT_ID on ACT_HI_PROCINST(TENANT_ID_); +create index ACT_IDX_HI_PRO_INST_PROC_DEF_KEY on ACT_HI_PROCINST(PROC_DEF_KEY_); + +create index ACT_IDX_HI_ACT_INST_START on ACT_HI_ACTINST(START_TIME_); +create index ACT_IDX_HI_ACT_INST_END on ACT_HI_ACTINST(END_TIME_); +create index ACT_IDX_HI_ACT_INST_PROCINST on ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_); +create index ACT_IDX_HI_ACT_INST_COMP on ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_ACT_INST_STATS on ACT_HI_ACTINST(PROC_DEF_ID_, ACT_ID_, END_TIME_, ACT_INST_STATE_); +create index ACT_IDX_HI_ACT_INST_TENANT_ID on ACT_HI_ACTINST(TENANT_ID_); +create index ACT_IDX_HI_ACT_INST_PROC_DEF_KEY on ACT_HI_ACTINST(PROC_DEF_KEY_); + +create index ACT_IDX_HI_TASK_INST_TENANT_ID on ACT_HI_TASKINST(TENANT_ID_); +create index ACT_IDX_HI_TASK_INST_PROC_DEF_KEY on ACT_HI_TASKINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_TASKINST_PROCINST on ACT_HI_TASKINST(PROC_INST_ID_); +create index ACT_IDX_HI_TASKINSTID_PROCINST on ACT_HI_TASKINST(ID_,PROC_INST_ID_); + +create index ACT_IDX_HI_DETAIL_PROC_INST on ACT_HI_DETAIL(PROC_INST_ID_); +create index ACT_IDX_HI_DETAIL_ACT_INST on ACT_HI_DETAIL(ACT_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_INST on ACT_HI_DETAIL(CASE_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_EXEC on ACT_HI_DETAIL(CASE_EXECUTION_ID_); +create index ACT_IDX_HI_DETAIL_TIME on ACT_HI_DETAIL(TIME_); +create index ACT_IDX_HI_DETAIL_NAME on ACT_HI_DETAIL(NAME_); +create index ACT_IDX_HI_DETAIL_TASK_ID on ACT_HI_DETAIL(TASK_ID_); +create index ACT_IDX_HI_DETAIL_TENANT_ID on ACT_HI_DETAIL(TENANT_ID_); +create index ACT_IDX_HI_DETAIL_PROC_DEF_KEY on ACT_HI_DETAIL(PROC_DEF_KEY_); +create index ACT_IDX_HI_DETAIL_BYTEAR on ACT_HI_DETAIL(BYTEARRAY_ID_); + +create index ACT_IDX_HI_IDENT_LNK_USER on ACT_HI_IDENTITYLINK(USER_ID_); +create index ACT_IDX_HI_IDENT_LNK_GROUP on ACT_HI_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_HI_IDENT_LNK_TENANT_ID on ACT_HI_IDENTITYLINK(TENANT_ID_); +create index ACT_IDX_HI_IDENT_LNK_PROC_DEF_KEY on ACT_HI_IDENTITYLINK(PROC_DEF_KEY_); +create index ACT_IDX_HI_IDENT_LINK_TASK on ACT_HI_IDENTITYLINK(TASK_ID_); + +create index ACT_IDX_HI_PROCVAR_PROC_INST on ACT_HI_VARINST(PROC_INST_ID_); +create index ACT_IDX_HI_PROCVAR_NAME_TYPE on ACT_HI_VARINST(NAME_, VAR_TYPE_); +create index ACT_IDX_HI_CASEVAR_CASE_INST on ACT_HI_VARINST(CASE_INST_ID_); +create index ACT_IDX_HI_VAR_INST_TENANT_ID on ACT_HI_VARINST(TENANT_ID_); +create index ACT_IDX_HI_VAR_INST_PROC_DEF_KEY on ACT_HI_VARINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_VARINST_BYTEAR on ACT_HI_VARINST(BYTEARRAY_ID_); + +create index ACT_IDX_HI_INCIDENT_TENANT_ID on ACT_HI_INCIDENT(TENANT_ID_); +create index ACT_IDX_HI_INCIDENT_PROC_DEF_KEY on ACT_HI_INCIDENT(PROC_DEF_KEY_); +create index ACT_IDX_HI_INCIDENT_PROCINST on ACT_HI_INCIDENT(PROC_INST_ID_); + +create index ACT_IDX_HI_JOB_LOG_PROCINST on ACT_HI_JOB_LOG(PROCESS_INSTANCE_ID_); +create index ACT_IDX_HI_JOB_LOG_PROCDEF on ACT_HI_JOB_LOG(PROCESS_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_TENANT_ID on ACT_HI_JOB_LOG(TENANT_ID_); +create index ACT_IDX_HI_JOB_LOG_JOB_DEF_ID on ACT_HI_JOB_LOG(JOB_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_PROC_DEF_KEY on ACT_HI_JOB_LOG(PROCESS_DEF_KEY_); +create index ACT_IDX_HI_JOB_LOG_EX_STACK on ACT_HI_JOB_LOG(JOB_EXCEPTION_STACK_ID_); + +create index ACT_HI_EXT_TASK_LOG_PROCINST on ACT_HI_EXT_TASK_LOG(PROC_INST_ID_); +create index ACT_HI_EXT_TASK_LOG_PROCDEF on ACT_HI_EXT_TASK_LOG(PROC_DEF_ID_); +create index ACT_HI_EXT_TASK_LOG_PROC_DEF_KEY on ACT_HI_EXT_TASK_LOG(PROC_DEF_KEY_); +create index ACT_HI_EXT_TASK_LOG_TENANT_ID on ACT_HI_EXT_TASK_LOG(TENANT_ID_); +create index ACT_IDX_HI_EXTTASKLOG_ERRORDET on ACT_HI_EXT_TASK_LOG(ERROR_DETAILS_ID_); + +create index ACT_IDX_HI_OP_LOG_PROCINST on ACT_HI_OP_LOG(PROC_INST_ID_); +create index ACT_IDX_HI_OP_LOG_PROCDEF on ACT_HI_OP_LOG(PROC_DEF_ID_); + +create index ACT_IDX_HI_COMMENT_TASK on ACT_HI_COMMENT(TASK_ID_); +create index ACT_IDX_HI_COMMENT_PROCINST on ACT_HI_COMMENT(PROC_INST_ID_); + +create index ACT_IDX_HI_ATTACHMENT_CONTENT on ACT_HI_ATTACHMENT(CONTENT_ID_); +create index ACT_IDX_HI_ATTACHMENT_PROCINST on ACT_HI_ATTACHMENT(PROC_INST_ID_); +create index ACT_IDX_HI_ATTACHMENT_TASK on ACT_HI_ATTACHMENT(TASK_ID_); +create table ACT_HI_CASEINST ( + ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64) not null, + CREATE_TIME_ datetime(3) not null, + CLOSE_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + CREATE_USER_ID_ varchar(255), + SUPER_CASE_INSTANCE_ID_ varchar(64), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_), + unique (CASE_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_CASEACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + CASE_ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + CASE_ACT_NAME_ varchar(255), + CASE_ACT_TYPE_ varchar(255), + CREATE_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_CAS_I_CLOSE on ACT_HI_CASEINST(CLOSE_TIME_); +create index ACT_IDX_HI_CAS_I_BUSKEY on ACT_HI_CASEINST(BUSINESS_KEY_); +create index ACT_IDX_HI_CAS_I_TENANT_ID on ACT_HI_CASEINST(TENANT_ID_); +create index ACT_IDX_HI_CAS_A_I_CREATE on ACT_HI_CASEACTINST(CREATE_TIME_); +create index ACT_IDX_HI_CAS_A_I_END on ACT_HI_CASEACTINST(END_TIME_); +create index ACT_IDX_HI_CAS_A_I_COMP on ACT_HI_CASEACTINST(CASE_ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_CAS_A_I_CASEINST on ACT_HI_CASEACTINST(CASE_INST_ID_, CASE_ACT_ID_); +create index ACT_IDX_HI_CAS_A_I_TENANT_ID on ACT_HI_CASEACTINST(TENANT_ID_); +-- create history decision instance table -- +create table ACT_HI_DECINST ( + ID_ varchar(64) NOT NULL, + DEC_DEF_ID_ varchar(64) NOT NULL, + DEC_DEF_KEY_ varchar(255) NOT NULL, + DEC_DEF_NAME_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + EVAL_TIME_ datetime(3) not null, + COLLECT_VALUE_ double, + USER_ID_ varchar(255), + ROOT_DEC_INST_ID_ varchar(64), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision input table -- +create table ACT_HI_DEC_IN ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision output table -- +create table ACT_HI_DEC_OUT ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + RULE_ID_ varchar(64), + RULE_ORDER_ integer, + VAR_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + + +create index ACT_IDX_HI_DEC_INST_ID on ACT_HI_DECINST(DEC_DEF_ID_); +create index ACT_IDX_HI_DEC_INST_KEY on ACT_HI_DECINST(DEC_DEF_KEY_); +create index ACT_IDX_HI_DEC_INST_PI on ACT_HI_DECINST(PROC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_CI on ACT_HI_DECINST(CASE_INST_ID_); +create index ACT_IDX_HI_DEC_INST_ACT on ACT_HI_DECINST(ACT_ID_); +create index ACT_IDX_HI_DEC_INST_ACT_INST on ACT_HI_DECINST(ACT_INST_ID_); +create index ACT_IDX_HI_DEC_INST_TIME on ACT_HI_DECINST(EVAL_TIME_); +create index ACT_IDX_HI_DEC_INST_TENANT_ID on ACT_HI_DECINST(TENANT_ID_); +create index ACT_IDX_HI_DEC_INST_ROOT_ID on ACT_HI_DECINST(ROOT_DEC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_ID on ACT_HI_DECINST(DEC_REQ_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_KEY on ACT_HI_DECINST(DEC_REQ_KEY_); + + +create index ACT_IDX_HI_DEC_IN_INST on ACT_HI_DEC_IN(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_IN_CLAUSE on ACT_HI_DEC_IN(DEC_INST_ID_, CLAUSE_ID_); + +create index ACT_IDX_HI_DEC_OUT_INST on ACT_HI_DEC_OUT(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_OUT_RULE on ACT_HI_DEC_OUT(RULE_ORDER_, CLAUSE_ID_); + +-- mariadb_identity_7.8.0-ee + +create table ACT_ID_GROUP ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + TYPE_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_MEMBERSHIP ( + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (USER_ID_, GROUP_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_USER ( + ID_ varchar(64), + REV_ integer, + FIRST_ varchar(255), + LAST_ varchar(255), + EMAIL_ varchar(255), + PWD_ varchar(255), + SALT_ varchar(255), + PICTURE_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_INFO ( + ID_ varchar(64), + REV_ integer, + USER_ID_ varchar(64), + TYPE_ varchar(64), + KEY_ varchar(255), + VALUE_ varchar(255), + PASSWORD_ LONGBLOB, + PARENT_ID_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT_MEMBER ( + ID_ varchar(64) not null, + TENANT_ID_ varchar(64) not null, + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_USER + unique (TENANT_ID_, USER_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_GROUP + unique (TENANT_ID_, GROUP_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB + foreign key (TENANT_ID_) + references ACT_ID_TENANT (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +ALTER TABLE ACT_GE_BYTEARRAY + ADD TYPE_ integer; + +ALTER TABLE ACT_GE_BYTEARRAY + ADD CREATE_TIME_ datetime(3); + +ALTER TABLE ACT_RE_PROCDEF + ADD STARTABLE_ BOOLEAN NOT NULL DEFAULT TRUE;
\ No newline at end of file |