diff options
117 files changed, 2206 insertions, 1190 deletions
diff --git a/.gitignore b/.gitignore index 79d2c94622..c57b142a05 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/main-schemas/M **/bin/ /tattletale/ /.metadata/ +**/.sts4-cache +**/.java-version diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/aai/AaiPropertiesImpl.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/aai/AaiPropertiesImpl.java index b3b22e239d..9e08cda354 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/aai/AaiPropertiesImpl.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/aai/AaiPropertiesImpl.java @@ -32,13 +32,15 @@ public class AaiPropertiesImpl implements AAIProperties { private final String endpoint; private final String encryptedBasicAuth; private final String encrytptionKey; + private final String aaiVersion; public AaiPropertiesImpl() { - final ApplicationContext context = SpringContextHelper.getAppContext(); this.endpoint = context.getEnvironment().getProperty("aai.endpoint"); this.encryptedBasicAuth = context.getEnvironment().getProperty("aai.auth"); this.encrytptionKey = context.getEnvironment().getProperty("mso.key"); + this.aaiVersion = context.getEnvironment().getProperty("aai.version"); + } @Override @@ -53,6 +55,11 @@ public class AaiPropertiesImpl implements AAIProperties { @Override public AAIVersion getDefaultVersion() { + for (final AAIVersion version : AAIVersion.values()) { + if (version.toString().equalsIgnoreCase(this.aaiVersion)) { + return version; + } + } return AAIVersion.LATEST; } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java index a2af1a4580..4a8e95ff07 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java @@ -199,9 +199,9 @@ public class LifecycleManager { private String sendInstantiateRequestToVnfm(final EsrVnfm vnfm, final GenericVnf genericVnf, final CreateVnfRequest createVnfRequest) { - final InstantiateVnfRequest instantiateVnfRequest = - vnfmHelper.createInstantiateRequest(createVnfRequest.getTenant(), createVnfRequest, - packageProvider.getFlavourId(genericVnf.getModelVersionId())); + final String pkgId = getPackageId(createVnfRequest, genericVnf); + final InstantiateVnfRequest instantiateVnfRequest = vnfmHelper.createInstantiateRequest( + createVnfRequest.getTenant(), createVnfRequest, packageProvider.getFlavourId(pkgId)); final String jobId = vnfmServiceProvider.instantiateVnf(vnfm, genericVnf.getSelflink(), instantiateVnfRequest); logger.info("Instantiate VNF request successfully sent to " + genericVnf.getSelflink()); diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml index 8d79aff29d..aaf4949144 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml @@ -187,10 +187,5 @@ <artifactId>okhttp</artifactId> <version>${okhttp-version}</version> </dependency> - <dependency> - <groupId>com.squareup.okhttp</groupId> - <artifactId>logging-interceptor</artifactId> - <version>${okhttp-version}</version> - </dependency> </dependencies> </project> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml index f34fb61802..6554da3409 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml @@ -187,11 +187,6 @@ <artifactId>okhttp</artifactId> <version>${okhttp-version}</version> </dependency> - <dependency> - <groupId>com.squareup.okhttp</groupId> - <artifactId>logging-interceptor</artifactId> - <version>${okhttp-version}</version> - </dependency> </dependencies> </project> diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index 2453c18f1a..6c9c23a59b 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -124,17 +124,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-client</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-bindings-soap</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.onap.so</groupId> diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index c33160d255..a7c47f8f53 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -24,6 +24,7 @@ package org.onap.so.openstack.utils; import java.io.IOException; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -124,10 +125,8 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { // Properties names and variables (with default values) protected String createPollIntervalProp = "org.onap.so.adapters.po.pollInterval"; - private String pollingMultiplierProp = "org.onap.so.adapters.po.pollMultiplier"; protected static final String CREATE_POLL_INTERVAL_DEFAULT = "15"; - private static final String POLLING_MULTIPLIER_DEFAULT = "60"; private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); @@ -348,9 +347,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { String tenantId, boolean notFoundIsSuccess) throws MsoException { int pollingFrequency = Integer.parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT)); - int pollingMultiplier = - Integer.parseInt(this.environment.getProperty(pollingMultiplierProp, POLLING_MULTIPLIER_DEFAULT)); - int numberOfPollingAttempts = Math.floorDiv((timeoutMinutes * pollingMultiplier), pollingFrequency); + LocalDateTime stopPolling = LocalDateTime.now().plusMinutes(timeoutMinutes); + if (pollingFrequency > timeoutMinutes * 60) { + logger.debug("Will not poll. Poll interval {} sec is greater then timeout {} sec", pollingFrequency, + timeoutMinutes * 60); + stopPolling = LocalDateTime.now().minusMinutes(1); + } Heat heatClient = getHeatClient(cloudSiteId, tenantId); while (true) { String stackName = stack.getStackName() + "/" + stack.getId(); @@ -363,12 +365,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { } else if (latestStack != null) { statusHandler.updateStackStatus(latestStack); if (stackStatus.equals(latestStack.getStackStatus())) { - if (numberOfPollingAttempts <= 0) { + if (LocalDateTime.now().isAfter(stopPolling)) { logger.error("Polling of stack timed out with Status: {}", latestStack.getStackStatus()); return latestStack; } + logger.debug("Will poll again until {}", stopPolling); sleep(pollingFrequency * 1000L); - numberOfPollingAttempts -= 1; } else { return latestStack; } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java index 4938bff748..4f7fed7df4 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java @@ -36,6 +36,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -106,7 +107,6 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { @Before public void setup() { doReturn("15").when(env).getProperty("org.onap.so.adapters.po.pollInterval", "15"); - doReturn("1").when(env).getProperty("org.onap.so.adapters.po.pollMultiplier", "60"); } @Test @@ -130,9 +130,8 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { assertEquals(true, actual != null); } - @Test - public final void pollStackForStatus_Polling_Exhausted_Test() throws MsoException, IOException { + public final void pollStackForStatus_No_Polling_Test() throws MsoException, IOException { Stack stack = new Stack(); stack.setId("id"); stack.setStackName("stackName"); @@ -141,6 +140,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { doNothing().when(stackStatusHandler).updateStackStatus(stack); doReturn(stack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id")); doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId); + doReturn("61").when(env).getProperty("org.onap.so.adapters.po.pollInterval", "15"); Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false); Mockito.verify(stackStatusHandler, times(1)).updateStackStatus(stack); Mockito.verify(heatUtils, times(1)).queryHeatStack(isA(Heat.class), eq("stackName/id")); @@ -148,6 +148,22 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { } @Test + public final void pollStackForStatus_Polling_Exhausted_Test() throws MsoException, IOException { + Stack stack = new Stack(); + stack.setId("id"); + stack.setStackName("stackName"); + stack.setStackStatus("CREATE_IN_PROGRESS"); + stack.setStackStatusReason("Stack Finished"); + doNothing().when(stackStatusHandler).updateStackStatus(stack); + doReturn(stack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id")); + doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId); + Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false); + Mockito.verify(stackStatusHandler, times(5)).updateStackStatus(stack); + Mockito.verify(heatUtils, times(5)).queryHeatStack(isA(Heat.class), eq("stackName/id")); + assertEquals(true, actual != null); + } + + @Test public final void postProcessStackCreate_CREATE_IN_PROGRESS_Test() throws MsoException, IOException { Stack stack = new Stack(); stack.setId("id"); @@ -255,12 +271,9 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { CreateStackParam createStackParam = new CreateStackParam(); createStackParam.setStackName("stackName"); doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId); - doNothing().when(heatUtils).postProcessStackDelete(deletedStack); doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(mockDeleteStack); doReturn(stackResource).when(heatClient).getStacks(); doReturn(mockDeleteStack).when(stackResource).deleteByName("stackName/id"); - doReturn(deletedStack).when(heatUtils).pollStackForStatus(120, stack, "DELETE_IN_PROGRESS", cloudSiteId, - tenantId, true); heatUtils.handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId); Mockito.verify(heatUtils, times(1)).executeAndRecordOpenstackRequest(mockDeleteStack); diff --git a/adapters/mso-cnf-adapter/pom.xml b/adapters/mso-cnf-adapter/pom.xml index 0928da084e..8cfb2dc581 100644 --- a/adapters/mso-cnf-adapter/pom.xml +++ b/adapters/mso-cnf-adapter/pom.xml @@ -89,12 +89,10 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime --> <dependency> diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml index 45fe77eecc..0099bb3091 100644 --- a/adapters/mso-nssmf-adapter/pom.xml +++ b/adapters/mso-nssmf-adapter/pom.xml @@ -107,17 +107,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java index 442339d9fe..b972517338 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java @@ -59,8 +59,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { public EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId) { return aaiClientProvider.getAaiClient() .get(EsrSystemInfoList.class, - AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.externalSystem().esrThirdpartySdnc((sdncId)))) + AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.externalSystem().esrThirdpartySdnc((sdncId)).esrSystemInfoList())) .orElseGet(() -> { logger.debug("VNFM not found in AAI"); return null; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java index 97a4c5e889..2ccd88a358 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java @@ -141,7 +141,9 @@ public abstract class BaseNssmfManager implements NssmfManager { public RestResponse queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) throws ApplicationException { this.params.clear(); this.params.put("jobId", jobId); - this.params.put("responseId", jobReq.getResponseId()); + if (jobReq.getResponseId() != null) { + this.params.put("responseId", jobReq.getResponseId()); + } this.urlHandler(); /** diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java index d8a9088a42..0d0d896370 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java @@ -127,8 +127,8 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { return restUtil.send(nssmfUrl, this.httpMethod, content, header); } - private void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status, RestResponse rsp) - throws ApplicationException { + protected void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status, + RestResponse rsp) throws ApplicationException { switch (fromString(rspDesc.getStatus())) { case STARTED: diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java index bc7a3d0bb7..491da0aab4 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java @@ -30,6 +30,8 @@ import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; import org.onap.so.beans.nsmf.DeAllocateNssi; import org.onap.so.beans.nsmf.NssiResponse; import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest; +import org.onap.so.beans.nsmf.ResponseDescriptor; +import org.onap.so.beans.nsmf.JobStatusResponse; import org.onap.so.db.request.beans.ResourceOperationStatus; import java.util.HashMap; import java.util.Map; @@ -72,7 +74,7 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { restResponse = returnRsp; ResourceOperationStatus status = - new ResourceOperationStatus(serviceInfo.getNsiId(), nssiId, serviceInfo.getServiceUuid()); + new ResourceOperationStatus(serviceInfo.getNsiId(), resp.getJobId(), serviceInfo.getServiceUuid()); status.setResourceInstanceID(nssiId); updateDbStatus(status, restResponse.getStatus(), JobStatus.FINISHED, @@ -111,6 +113,25 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { } @Override + protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException { + ResponseDescriptor responseDescriptor = new ResponseDescriptor(); + responseDescriptor.setStatus(JobStatus.FINISHED.toString()); + responseDescriptor.setProgress(100); + responseDescriptor.setStatusDescription("Finished"); + + JobStatusResponse jobStatusResponse = new JobStatusResponse(); + jobStatusResponse.setResponseDescriptor(responseDescriptor); + + RestResponse restResponse = new RestResponse(); + restResponse.setStatus(200); + restResponse.setResponseContent(marshal(jobStatusResponse)); + + updateRequestDbJobStatus(responseDescriptor, status, restResponse); + + return restResponse; + } + + @Override protected SelectionType doQueryNSSISelectionCapability() { return SelectionType.NSSMF; } diff --git a/adapters/mso-oof-adapter/pom.xml b/adapters/mso-oof-adapter/pom.xml index 98150d39e0..a986052551 100644 --- a/adapters/mso-oof-adapter/pom.xml +++ b/adapters/mso-oof-adapter/pom.xml @@ -36,12 +36,10 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index eb6cba5510..7d5e8cc6fd 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -51,76 +51,6 @@ </execution> </executions> </plugin> - - <!-- run the following plugin only when there's a wsdl change and you need to recompile the java classes - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>jaxws-maven-plugin</artifactId> - <version>2.4.1</version> - <executions> - <execution> - <id>generate-network-async-stubs</id> - <phase>process-classes</phase> - <goals> - <goal>wsimport</goal> - </goals> - <configuration> - <vmArgs> - <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> - </vmArgs> - <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> - <wsdlFiles> - <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile> - </wsdlFiles> - <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation> - <packageName>org.onap.so.adapters.network.async.client</packageName> - <xnocompile>false</xnocompile> - <keep>true</keep> - </configuration> - </execution> - - <execution> - <id>generate-vnf-async-stubs</id> - <phase>process-classes</phase> - <goals> - <goal>wsimport</goal> - </goals> - <configuration> - <vmArgs> - <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> - </vmArgs> - <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> - <wsdlFiles> - <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile> - </wsdlFiles> - <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation> - <packageName>org.onap.so.adapters.vnf.async.client</packageName> - <xnocompile>false</xnocompile> - <keep>true</keep> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <id>add-source</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${project.build.directory}/generated-sources/wsimport/</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> @@ -228,17 +158,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> 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 7d30c87101..5cb870e0d7 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 @@ -46,6 +46,7 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.UriBuilder; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.validator.routines.InetAddressValidator; import org.onap.aai.domain.yang.Flavor; @@ -59,7 +60,6 @@ import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.SriovPf; -import org.onap.aai.domain.yang.SriovPfs; import org.onap.aai.domain.yang.Subnets; import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.VfModule; @@ -80,12 +80,12 @@ import org.onap.aaiclient.client.graphinventory.entities.DSLQuery; 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.Pathed; import org.onap.aaiclient.client.graphinventory.entities.Start; import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder; import org.onap.aaiclient.client.graphinventory.entities.__; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; -import org.onap.logging.filter.base.ErrorCode; import org.onap.so.cloud.resource.beans.NodeType; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.ServerType; @@ -95,8 +95,6 @@ import org.onap.so.heatbridge.helpers.AaiHelper; import org.onap.so.heatbridge.openstack.api.OpenstackClient; 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; @@ -582,69 +580,67 @@ public class HeatBridgeImpl implements HeatBridgeApi { * * @param port Openstack port object * @param lIf AAI l-interface object + * @throws HeatBridgeException */ - private void updateSriovPfToPserver(final Port port, final LInterface lIf) { + protected void updateSriovPfToPserver(final Port port, final LInterface lIf) throws HeatBridgeException { 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 { - AAIResourceUri pInterfaceUri = - AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() - .pserver(pserverHostName).pInterface(matchingPifName.get())) - .depth(Depth.ONE); - if (resourcesClient.exists(pInterfaceUri)) { - PInterface matchingPIf = resourcesClient.get(PInterface.class, pInterfaceUri).get(); - - String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); - - if (matchingPIf.getSriovPfs() == null - || CollectionUtils.isEmpty(matchingPIf.getSriovPfs().getSriovPf()) - || matchingPIf.getSriovPfs().getSriovPf().stream() - .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { - - SriovPf sriovPf = new SriovPf(); - sriovPf.setPfPciId(pfPciId); - - AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverHostName) - .pInterface(matchingPifName.get()).sriovPf(sriovPf.getPfPciId())); - - // TODO if it does exist, should check if relationship is there, if not then create? - if (!resourcesClient.exists(sriovPfUri)) { - transaction.create(sriovPfUri, sriovPf); - - AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder - .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId) - .vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).sriovVf( - port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString())); - transaction.connect(sriovPfUri, sriovVfUri); - } - } + + AAIResourceUri sriovVfUri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId) + .tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()) + .sriovVf(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString())); + + boolean relationshipExist = sriovVfHasSriovPfRelationship(sriovVfUri); + + String pserverHostName = port.getHostId(); + lIf.setInterfaceDescription("Attached to SR-IOV port: " + pserverHostName); + + if (!relationshipExist) { + AAIResourceUri pserverUri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverHostName)); + if (resourcesClient.exists(pserverUri)) { + String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PF_PCI_SLOT_KEY).toString(); + + DSLQueryBuilder<Start, Node> builder = TraversalBuilder + .fragment(new DSLStartNode(Types.PSERVER, __.key("hostname", pserverHostName))) + .to(__.node(Types.P_INTERFACE) + .to(__.node(Types.SRIOV_PF, __.key("pf-pci-id", pfPciId)).output())); + + List<Pathed> results = getAAIDSLClient().queryPathed(new DSLQuery(builder.build())); + + if (results.size() == 1) { + + AAIResourceUri sriovPfUri = AAIUriFactory.createResourceFromExistingURI(Types.SRIOV_PF, + UriBuilder.fromUri(results.get(0).getResourceLink()).build()); + + transaction.connect(sriovPfUri, sriovVfUri); + } else { - logger.warn( - "PInterface {} does not exist in AAI. Unable to build sriov-vf to sriov-pf relationship.", - matchingPifName.get()); + throw new HeatBridgeException("Unable to find sriov-pf related link " + pfPciId + + ". Unexpected results size" + results.size()); } - } 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); + } else { + logger.error("Pserver {} does not exist in AAI. Unable to build sriov-vf to sriov-pf relationship.", + pserverHostName); + throw new HeatBridgeException("Pserver " + pserverHostName + " does not exist in AAI"); + } + } + } + } + + protected boolean sriovVfHasSriovPfRelationship(AAIResourceUri sriovVfUri) { + boolean pfRelationshipsExist = false; + if (resourcesClient.exists(sriovVfUri)) { + Optional<Relationships> sriovVfRelationships = resourcesClient.get(sriovVfUri).getRelationships(); + + if (sriovVfRelationships.isPresent()) { + List<AAIResourceUri> sriovPfUris = sriovVfRelationships.get().getRelatedUris(Types.SRIOV_PF); + if (sriovPfUris.size() != 0) { + pfRelationshipsExist = true; } } } + return pfRelationshipsExist; } protected void updateLInterfaceIps(final Port port, final LInterface lIf) { diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java index 71c6a96cd6..c8a39a5795 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java @@ -43,6 +43,7 @@ public class HeatBridgeConstants { public static final String OS_NEUTRON_PROVIDERNET = "OS::Neutron::ProviderNet"; public static final String OS_SRIOV_PORT_TYPE = "direct"; public static final String OS_PCI_SLOT_KEY = "pci_slot"; + public static final String OS_PF_PCI_SLOT_KEY = "pf_pci_slot"; public static final String OS_PHYSICAL_NETWORK_KEY = "physical_network"; public static final String OS_PHYSICAL_INTERFACE_KEY = "physical-interface"; public static final String OS_VLAN_NETWORK_KEY = "vlan"; 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 a9c31128ad..531496cc8f 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,6 +42,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -49,9 +50,10 @@ import static org.mockito.Mockito.when; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -60,7 +62,6 @@ import java.util.Set; import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -75,9 +76,12 @@ import org.onap.aai.domain.yang.SriovPf; import org.onap.aaiclient.client.aai.AAIDSLQueryClient; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; +import org.onap.aaiclient.client.aai.entities.Results; 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.DSLQuery; +import org.onap.aaiclient.client.graphinventory.entities.Pathed; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; import org.onap.so.cloud.resource.beans.NodeType; import org.onap.so.db.catalog.beans.CloudIdentity; @@ -100,6 +104,7 @@ import org.openstack4j.openstack.heat.domain.HeatResource; import org.openstack4j.openstack.heat.domain.HeatResource.Resources; import org.springframework.core.env.Environment; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; @@ -133,6 +138,9 @@ public class HeatBridgeImplTest { @Mock private Server server; + @Mock + private AAIDSLQueryClient dSLQueryClient; + @Spy @InjectMocks private HeatBridgeImpl heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, @@ -342,11 +350,13 @@ public class HeatBridgeImplTest { } @Test - public void testUpdateVserverLInterfacesToAai() throws HeatBridgeException { + public void testUpdateVserverLInterfacesToAai() + throws HeatBridgeException, JsonParseException, JsonMappingException, IOException { // Arrange List<Resource> stackResources = (List<Resource>) extractTestStackResources(); Port port = mock(Port.class); when(port.getId()).thenReturn("test-port-id"); + when(port.getHostId()).thenReturn("pserverId"); 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"); @@ -357,7 +367,7 @@ public class HeatBridgeImplTest { when(server.getHypervisorHostname()).thenReturn("test.server.name"); 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")); + HeatBridgeConstants.OS_PF_PCI_SLOT_KEY, "testPfPciId")); IP ip = mock(IP.class); @@ -386,10 +396,14 @@ public class HeatBridgeImplTest { 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)); + + when(resourcesClient.exists(any(AAIResourceUri.class))).thenReturn(true); when(env.getProperty("mso.cloudOwner.included", "")).thenReturn("CloudOwner"); + doReturn(dSLQueryClient).when(heatbridge).getAAIDSLClient(); + List<Pathed> pathed = ((Results<Pathed>) MAPPER.readValue(getJson("pathed-sriov-pf.json"), + new TypeReference<Results<Pathed>>() {})).getResult(); + when(dSLQueryClient.queryPathed(any(DSLQuery.class))).thenReturn(pathed); + doReturn(false).when(heatbridge).sriovVfHasSriovPfRelationship(any()); // Act heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); @@ -399,6 +413,7 @@ public class HeatBridgeImplTest { verify(osClient, times(5)).getPortById(anyString()); verify(osClient, times(5)).getSubnetById("testSubnetId"); verify(osClient, times(10)).getNetworkById(anyString()); + verify(transaction, times(5)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class)); } @Test @@ -571,7 +586,8 @@ public class HeatBridgeImplTest { } @Test - public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException { + public void testUpdateVserverLInterfacesToAai_skipVlans() + throws HeatBridgeException, JsonParseException, JsonMappingException, IOException { // Arrange List<Resource> stackResources = (List<Resource>) extractTestStackResources(); Port port = mock(Port.class); @@ -597,11 +613,9 @@ public class HeatBridgeImplTest { 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)); + doNothing().when(heatbridge).updateSriovPfToPserver(any(), any()); // Act heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); @@ -636,5 +650,9 @@ public class HeatBridgeImplTest { return content; } + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + filename))); + } + } diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json b/adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json new file mode 100644 index 0000000000..cccad4c6d3 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json @@ -0,0 +1,8 @@ +{ + "results" : [ + { + "resource-type" : "sriov-pf", + "resource-link" : "/cloud-infrastructure/pservers/pserver/id1/p-interfaces/p-interface/id2/sriov-pfs/sriov-pf/id3" + } + ] +}
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml index ca13895848..66b9a6b993 100644 --- a/adapters/mso-requests-db-adapter/pom.xml +++ b/adapters/mso-requests-db-adapter/pom.xml @@ -25,17 +25,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -159,7 +156,7 @@ <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> - <version>2.4.0-b180725.0644</version> + <version>2.4.0-b180830.0438</version> </dependency> </dependencies> <executions> diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml index 808210389a..590121966e 100644 --- a/adapters/mso-sdnc-adapter/pom.xml +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -179,17 +179,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml index a86dc94cf2..eae6745866 100644 --- a/adapters/mso-vfc-adapter/pom.xml +++ b/adapters/mso-vfc-adapter/pom.xml @@ -66,17 +66,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java index c69800d640..c2b3ffddca 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java @@ -57,9 +57,11 @@ public class ASDCConfiguration implements IConfiguration { public static final String WORKFLOW = "WORKFLOW"; public static final String VF_MODULES_METADATA = "VF_MODULES_METADATA"; public static final String CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT = "CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT"; + public static final String HELM = "HELM"; + private static final String[] SUPPORTED_ARTIFACT_TYPES = {HEAT, HEAT_ARTIFACT, HEAT_ENV, HEAT_NESTED, HEAT_NET, - HEAT_VOL, OTHER, TOSCA_CSAR, VF_MODULES_METADATA, WORKFLOW, CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT}; + HEAT_VOL, OTHER, TOSCA_CSAR, VF_MODULES_METADATA, WORKFLOW, CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, HELM}; public static final List<String> SUPPORTED_ARTIFACT_TYPES_LIST = diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java index f5b0e17cf5..1b5463211c 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java @@ -119,6 +119,7 @@ public class VfResourceStructure extends ResourceStructure { case ASDCConfiguration.HEAT_NET: case ASDCConfiguration.OTHER: case ASDCConfiguration.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT: + case ASDCConfiguration.HELM: artifactsMapByUUID.put(artifactInfo.getArtifactUUID(), vfModuleArtifact); break; case ASDCConfiguration.VF_MODULES_METADATA: diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy index 669441c320..6377d77d19 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -304,6 +304,10 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { Boolean failOnCallbackError = execution.getVariable("failOnCallbackError") if(failOnCallbackError) { sdncAdapterBuildWorkflowException(execution, callback) + }else { + if(ackFinalIndicator.equals('Y')) { + sdncAdapterBuildWorkflowException(execution, callback) + } } } 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 4206596c94..3b84b150e0 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 @@ -213,7 +213,8 @@ public class ExecuteBuildingBlockRainyDay { String targetState = ""; if ("RollbackToAssigned".equalsIgnoreCase(handlingCode)) { targetState = Status.ROLLED_BACK_TO_ASSIGNED.toString(); - } else if ("RollbackToCreated".equalsIgnoreCase(handlingCode)) { + } else if ("RollbackToCreated".equalsIgnoreCase(handlingCode) + || "RollbackToCreatedNoConfiguration".equalsIgnoreCase(handlingCode)) { targetState = Status.ROLLED_BACK_TO_CREATED.toString(); } else { targetState = Status.ROLLED_BACK.toString(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index 843cca0848..43db27917e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -232,6 +232,20 @@ public class ExceptionBuilder { throw new BpmnError("MSOWorkflowException"); } + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage, + ONAPComponentsList extSystemErrorSource, String workStep) { + String processKey = getProcessKey(execution); + logger.info("Building a WorkflowException for Subflow"); + + WorkflowException exception = + new WorkflowException(processKey, errorCode, errorMessage, workStep, extSystemErrorSource); + execution.setVariable("WorkflowException", exception); + execution.setVariable("WorkflowExceptionErrorMessage", errorMessage); + logger.info("Outgoing WorkflowException is {}", exception); + logger.info("Throwing MSOWorkflowException"); + throw new BpmnError("MSOWorkflowException"); + } + public WorkflowException buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage, ONAPComponentsList extSystemErrorSource) { String processKey = getProcessKey(execution); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java index ee47b514d1..b34d9dce9c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayTest.java @@ -259,6 +259,35 @@ public class ExecuteBuildingBlockRainyDayTest extends BaseTest { assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), delegateExecution.getVariable("rollbackTargetState")); } + @Test + public void queryRainyDayTableRollbackToCreatedNoConfiguration() throws Exception { + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + vnf.setVnfType("vnft1"); + BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock); + delegateExecution.setVariable("buildingBlock", executeBuildingBlock); + delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AddFabricConfigurationBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("RollbackToCreatedNoConfiguration"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + rainyDayHandlerStatus.setSecondaryPolicy("Abort"); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AddFabricConfigurationBB", + "st1", "vnft1", "7000", "*", "errorMessage", "*"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); + + assertEquals("RollbackToCreatedNoConfiguration", delegateExecution.getVariable("handlingCode")); + assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), delegateExecution.getVariable("rollbackTargetState")); + } + @Test public void suppressRollbackTest() throws Exception { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java index 5baafbba67..b7e4dd98d8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java @@ -22,6 +22,7 @@ package org.onap.so.client.exception; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; @@ -39,6 +40,7 @@ import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.core.WorkflowException; import org.onap.logging.filter.base.ONAPComponents; @RunWith(MockitoJUnitRunner.class) @@ -95,4 +97,17 @@ public class ExceptionBuilderUnitTest { thrown.expect(BpmnError.class); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), ONAPComponents.SDNC); } + + @Test + public void buildAndThrowWorkflowExceptionWithWorkStepTest() { + doReturn("Process key").when(exceptionBuilder).getProcessKey(execution); + + try { + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), ONAPComponents.SDNC, + "WORKSTEP"); + } catch (BpmnError e) { + } + WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); + assertEquals("WORKSTEP", workflowException.getWorkStep()); + } } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index f2e0ce29ff..5fd9701880 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -95,7 +95,7 @@ </bpmn:serviceTask> </bpmn:subProcess> <bpmn:sequenceFlow id="SequenceFlow_0v588sm" name="Rollback = true" sourceRef="ExclusiveGateway_Finished" targetRef="Task_RollbackExecutionPath"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("handlingCode")=="Rollback"||execution.getVariable("handlingCode")=="RollbackToAssigned"||execution.getVariable("handlingCode")=="RollbackToCreated"}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("handlingCode")=="Rollback"||execution.getVariable("handlingCode")=="RollbackToAssigned"||execution.getVariable("handlingCode")=="RollbackToCreated"||execution.getVariable("handlingCode")=="RollbackToCreatedNoConfiguration"}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1atzsgn" sourceRef="Task_RollbackExecutionPath" targetRef="Task_SelectBB"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isRollbackNeeded")==true}</bpmn:conditionExpression> diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index 5dad9b8687..ebc0264c7e 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -143,17 +143,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>com.h2database</groupId> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy index c7fe7e36a6..eabe58488e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy @@ -32,150 +32,148 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class ActivateSliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="ActSS" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - RequestDBUtil requestDBUtil = new RequestDBUtil() - - private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class) - - @Override - void preProcessRequest(DelegateExecution execution) { - logger.debug(Prefix + "preProcessRequest Start") - execution.setVariable("prefix", Prefix) - execution.setVariable("startTime", System.currentTimeMillis()) - def msg - try { - // get request input - String subnetInstanceReq = execution.getVariable("bpmnRequest") - logger.debug(subnetInstanceReq) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //NSSI ID - String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") - if (isBlank(serviceInstanceID)) { - msg = "Input serviceInstanceID is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("serviceInstanceID", serviceInstanceID) - } - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - - //requestParameters, subscriptionServiceType is 5G - String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - //operationType = deactivateInstance/activateInstance - String operationType = execution.getVariable("requestAction") - if (isBlank(operationType)) { - msg = "Input operationType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("operationType", operationType) - } - - String jobId = UUID.randomUUID().toString() - execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) - - } catch(BpmnError e) { - throw e - } catch(Exception ex) { - msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "preProcessRequest Exit") - } - - - /** - * create operation status in request db - * - * Init the Operation Status - */ - def prepareInitOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareInitOperationStatus Start") - - String serviceId = execution.getVariable("serviceInstanceID") - String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - String operationType = execution.getVariable("operationType") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) - - ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType(operationType) - requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareInitOperationStatus Exit") - } - - - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" - .trim().replaceAll(" ", "") - - logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse) - sendWorkflowResponse(execution, 202, activateSyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } - + String Prefix="ActivateSliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI ID + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + //operationType = deactivateInstance/activateInstance + String operationType = execution.getVariable("requestAction") + if (isBlank(operationType)) { + msg = "Input operationType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("operationType", operationType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType(operationType) + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse) + sendWorkflowResponse(execution, 202, activateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy index 5a7722d679..9100f2773b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy @@ -33,158 +33,158 @@ import static org.apache.commons.lang3.StringUtils.isBlank class AllocateSliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="ASS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - RequestDBUtil requestDBUtil = new RequestDBUtil() - JsonUtils jsonUtil = new JsonUtils() - private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class) - - @Override - void preProcessRequest(DelegateExecution execution) { - logger.debug(Prefix + "preProcessRequest Start") - execution.setVariable("prefix", Prefix) - execution.setVariable("startTime", System.currentTimeMillis()) - def msg - try { - // get request input - String subnetInstanceReq = execution.getVariable("bpmnRequest") - logger.debug(subnetInstanceReq) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) - - //modelInfo - String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid") - if (isBlank(modelInvariantUuid)) { - msg = "Input modelInvariantUuid is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("modelInvariantUuid", modelInvariantUuid) - } - - logger.debug("modelInvariantUuid: " + modelInvariantUuid) - - String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid") - if (isBlank(modelUuid)) { - msg = "Input modelUuid is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("modelUuid", modelUuid) - } - - logger.debug("modelUuid: " + modelUuid) - - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - String dummyServiceId = new UUID(0,0).toString(); - execution.setVariable("dummyServiceId", dummyServiceId) - logger.debug("dummyServiceId: " + dummyServiceId) - String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") - execution.setVariable("servicename", servicename) - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - - //requestParameters, subscriptionServiceType is 5G - String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - String jobId = UUID.randomUUID().toString() - execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) - - } catch(BpmnError e) { - throw e - } catch(Exception ex) { - msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "preProcessRequest Exit") - } - - - /** - * create operation status in request db - * - * Init the Operation Status - */ - def prepareInitOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareInitOperationStatus Start") - - String serviceId = execution.getVariable("dummyServiceId") - String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) - - ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType("Allocate") - requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareInitOperationStatus Exit") - } - - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" - .trim().replaceAll(" ", "").trim().replaceAll(" ", "") - - logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse) - sendWorkflowResponse(execution, 202, allocateSyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } - + String Prefix="AllocateSliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //modelInfo + String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid") + if (isBlank(modelInvariantUuid)) { + msg = "Input modelInvariantUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + } + + logger.debug("modelInvariantUuid: " + modelInvariantUuid) + + String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid") + if (isBlank(modelUuid)) { + msg = "Input modelUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelUuid", modelUuid) + } + + logger.debug("modelUuid: " + modelUuid) + + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + String dummyServiceId = new UUID(0,0).toString(); + execution.setVariable("dummyServiceId", dummyServiceId) + logger.debug("dummyServiceId: " + dummyServiceId) + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("dummyServiceId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Allocate") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "").trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse) + sendWorkflowResponse(execution, 202, allocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy index 964baa7a9d..65885f3516 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy @@ -32,14 +32,13 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="DeASS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - RequestDBUtil requestDBUtil = new RequestDBUtil() - - private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class) - - @Override + String Prefix="DeAllocateSliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class) + + @Override void preProcessRequest(DelegateExecution execution) { logger.debug(Prefix + "preProcessRequest Start") execution.setVariable("prefix", Prefix) @@ -62,8 +61,8 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { } else { execution.setVariable("globalSubscriberId", globalSubscriberId) } - - //NSSI ID + + //NSSI ID String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") if (isBlank(serviceInstanceID)) { msg = "Input serviceInstanceID is null" @@ -73,27 +72,27 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { { execution.setVariable("serviceInstanceID", serviceInstanceID) } - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + //requestParameters, subscriptionServiceType is 5G String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") if (isBlank(subscriptionServiceType)) { @@ -106,9 +105,9 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { String jobId = UUID.randomUUID().toString() execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) } catch(BpmnError e) { throw e @@ -131,13 +130,13 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { String serviceId = execution.getVariable("serviceInstanceID") String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") + String nsiId = execution.getVariable("nsiId") logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) ResourceOperationStatus initStatus = new ResourceOperationStatus() initStatus.setServiceId(serviceId) initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) + initStatus.setResourceTemplateUUID(nsiId) initStatus.setOperType("Deallocate") requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) @@ -145,26 +144,26 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { } - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "") - - logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse) - sendWorkflowResponse(execution, 202, deAllocateSyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse) + sendWorkflowResponse(execution, 202, deAllocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index 0900863a62..e5c9514fa5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -158,7 +158,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index 88014e7b54..3e834fa7bb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.apache.commons.lang3.StringUtils import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.beans.nsmf.EsrInfo +import org.onap.so.beans.nsmf.JobStatusResponse import org.onap.so.beans.nsmf.NssiResponse import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest import org.onap.so.beans.nsmf.ResponseDescriptor @@ -17,7 +18,6 @@ import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.springframework.http.ResponseEntity class DoAllocateNSSI extends AbstractServiceTaskProcessor { @@ -34,7 +34,7 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { private static final NSSMF_ALLOCATE_URL = "/api/rest/provMns/v1/NSS/SliceProfiles" - private static final NSSMF_QUERY_JOB_STATUS_URL = "/NSS/jobs/%s" + private static final NSSMF_QUERY_JOB_STATUS_URL = "/api/rest/provMns/v1/NSS/jobs/%s" @Override void preProcessRequest(DelegateExecution execution) { @@ -64,11 +64,12 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { NssmfAdapterNBIRequest nbiRequest = execution.getVariable("nbiRequest") as NssmfAdapterNBIRequest String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, NSSMF_ALLOCATE_URL, objectMapper.writeValueAsString(nbiRequest)) - ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class) - String respBody = responseEntity.getBody() - NssiResponse result = objectMapper.readValue(respBody, NssiResponse.class) - //todo: if success - //todo: + + if (response != null) { + NssiResponse nssiResponse = objectMapper.readValue(response, NssiResponse.class) + execution.setVariable("nssiAllocateResult", nssiResponse) + } + execution.setVariable("serviceInfo", nbiRequest.getServiceInfo()) execution.setVariable("esrInfo", nbiRequest.getEsrInfo()) } @@ -96,13 +97,14 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, endpoint, objectMapper.writeValueAsString(nbiRequest)) - ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class) - String result = responseEntity.getBody() - //todo;if success - ResponseDescriptor responseDescriptor = objectMapper.readValue(result, ResponseDescriptor.class) + if (response != null) { + JobStatusResponse jobStatusResponse = objectMapper.readValue(response, JobStatusResponse.class) + execution.setVariable("nssiAllocateStatus", jobStatusResponse) - //todo: handle status - execution.setVariable("nssiAllocateResult", responseDescriptor) + if (jobStatusResponse.getResponseDescriptor().getProgress() == 100) { + execution.setVariable("jobFinished", true) + } + } } void prepareUpdateOrchestrationTask(DelegateExecution execution) { @@ -111,10 +113,10 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - ResponseDescriptor response = execution.getVariable("nssiAllocateResult") as ResponseDescriptor + JobStatusResponse jobStatusResponse = execution.getVariable("nssiAllocateStatus") as JobStatusResponse + ResponseDescriptor response = jobStatusResponse.getResponseDescriptor() SubnetType subnetType = execution.getVariable("subnetType") as SubnetType - SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo sliceTaskInfo.progress = response.getProgress() sliceTaskInfo.status = response.getStatus() @@ -127,6 +129,7 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { execution.setVariable("sliceTaskParams", sliceParams) execution.setVariable("sliceTaskInfo", sliceTaskInfo) + logger.debug("Finish prepareUpdateOrchestrationTask progress") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 8993127dbc..1d5232f3c5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -95,7 +95,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ List<TemplateInfo> nsstInfos = new ArrayList<>() ServiceDecomposition nstServiceDecomposition = execution.getVariable("nstServiceDecomposition") as ServiceDecomposition - //todo: + List<AllottedResource> allottedResources = nstServiceDecomposition.getAllottedResources() for (AllottedResource allottedResource : allottedResources) { TemplateInfo nsstInfo = new TemplateInfo() @@ -150,9 +150,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions) - - - int num = execution.getVariable("maxNsstIndex") as Integer int index = execution.getVariable("currentNsstIndex") as Integer @@ -180,8 +177,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ List<SubnetCapability> subnetCapabilities = new ArrayList<>() - - for (ServiceDecomposition serviceDecomposition : nsstServiceDecompositions) { SubnetCapability subnetCapability = new SubnetCapability() handleByType(execution, serviceDecomposition, sliceParams, subnetCapability) @@ -206,7 +201,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ sliceParams.tnBHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid() sliceParams.tnBHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid() sliceParams.tnBHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName() - break case SubnetType.TN_MH: sliceParams.tnMHSliceTaskInfo.vendor = vendor @@ -215,7 +209,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ sliceParams.tnMHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid() sliceParams.tnMHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid() sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName() - break case SubnetType.AN_NF: sliceParams.anSliceTaskInfo.vendor = vendor @@ -236,9 +229,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ default: subnetType = null break - - //todo - } if (null == subnetType) { def msg = "Get subnetType failed, modelUUId=" + modelInfo.getModelUuid() @@ -297,17 +287,16 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ private static String buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) { NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest() - List<String> subnetTypes = new ArrayList<>() - subnetTypes.add(subnetType.subnetType) +// List<String> subnetTypes = new ArrayList<>() +// subnetTypes.add(subnetType.subnetType) Map<String, Object> paramMap = new HashMap() - paramMap.put("subnetTypes", subnetTypes) + paramMap.put("subnetType", subnetType.subnetType) request.setSubnetCapabilityQuery(objectMapper.writeValueAsString(paramMap)) EsrInfo esrInfo = new EsrInfo() esrInfo.setVendor(vendor) esrInfo.setNetworkType(subnetType.networkType) - request.setEsrInfo(esrInfo) String strRequest = objectMapper.writeValueAsString(request) @@ -320,7 +309,8 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ * prepare select nsi request * @param execution */ - public void preNSIRequest(DelegateExecution execution, boolean preferReuse) { + public void preNSIRequest(DelegateExecution execution) { + boolean preferReuse = execution.getVariable("needQuerySliceProfile") ? false : true String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) @@ -378,8 +368,9 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ if (isSharable && solution.get("existingNSI")) { //sharedNSISolution processSharedNSI(solution, sliceTaskParams) + execution.setVariable("needQuerySliceProfile", true) } - else if(solution.containsKey("newNSISolution")) { + else { processNewNSI(solution, sliceTaskParams) } } @@ -395,6 +386,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ String nsiName = sharedNSISolution.get("NSIName") sliceParams.setSuggestNsiId(nsiId) sliceParams.setSuggestNsiName(nsiName) + } private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index 0f1bf0d8b4..7beafefc28 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -23,12 +23,10 @@ package org.onap.so.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.SliceProfile -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils @@ -38,6 +36,7 @@ import org.slf4j.LoggerFactory class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class); + final String AAI_VERSION = "v21" JsonUtils jsonUtil = new JsonUtils() TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -67,23 +66,26 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { void createSliceProfile(DelegateExecution execution) { - String sliceserviceInstanceId = execution.getVariable("sliceServiceInstanceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String sliceProfileStr = execution.getVariable("sliceProfile") String sliceProfileId = UUID.randomUUID().toString() SliceProfile sliceProfile = new SliceProfile(); sliceProfile.setProfileId(sliceProfileId) sliceProfile.setLatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) sliceProfile.setResourceSharingLevel(jsonUtil.getJsonValue(sliceProfileStr, "resourceSharingLevel")) - sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)) //TODO: should be list + //sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)) - sliceProfile.setE2ELatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) sliceProfile.setMaxBandwidth(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "maxBandwidth"))) - //TODO: new API - sliceProfile.setReliability(new Object()) + //sliceProfile.setReliability(new Object()) try { AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceserviceInstanceId).sliceProfile(sliceProfileId)) + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId) + .sliceProfile(sliceProfileId)) client.create(uri, sliceProfile) } catch (BpmnError e) { @@ -112,20 +114,25 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { ss.setOrchestrationStatus(serviceStatus) String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - ss.setModelInvariantId(modelInvariantUuid) - ss.setModelVersionId(modelUuid) + //TODO: need valid model ID from the caller, as AAI does not accept invalid IDs + //ss.setModelInvariantId(modelInvariantUuid) + //ss.setModelVersionId(modelUuid) String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) ss.setServiceInstanceLocationId(serviceInstanceLocationid) String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) ss.setEnvironmentContext(snssai) ss.setServiceRole(serviceRole) AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ssInstanceId)) + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId)) client.create(uri, ss) } catch (BpmnError e) { throw e } catch (Exception ex) { - String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance. " + ex.getMessage() + String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance: " + ex.getMessage() logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -133,17 +140,19 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { void createAllottedResource(DelegateExecution execution) { - String serviceInstanceId = execution.getVariable('sliceServiceInstanceId') - - AAIResourcesClient resourceClient = getAAIClient() - AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + String ssInstanceId = execution.getVariable('sliceServiceInstanceId') try { List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportSliceNetworks")) for (String networkStr : networkStrList) { String allottedResourceId = UUID.randomUUID().toString() - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("sliceserviceInstanceId")).allottedResource(allottedResourceId)) + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(execution.getVariable("sliceServiceInstanceId")) + .allottedResource(allottedResourceId)) execution.setVariable("allottedResourceUri", allottedResourceUri) String modelInvariantId = execution.getVariable("modelInvariantUuid") String modelVersionId = execution.getVariable("modelUuid") @@ -152,27 +161,37 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { resource.setId(allottedResourceId) resource.setType("TsciNetwork") resource.setAllottedResourceName("network_" + execution.getVariable("sliceServiceInstanceName")) - resource.setModelInvariantId(modelInvariantId) - resource.setModelVersionId(modelVersionId) getAAIClient().create(allottedResourceUri, resource) - //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build()) - //getAAIClient().connect(allottedResourceUri,ssServiceuri) - //execution.setVariable("aaiARPath", allottedResourceUri.build().toString()); String linkArrayStr = jsonUtil.getJsonValue(networkStr, "connectionLinks") - createLogicalLinksForAllocatedResource(execution, linkArrayStr, serviceInstanceId, allottedResourceId) + createLogicalLinksForAllocatedResource(execution, linkArrayStr, ssInstanceId, allottedResourceId) } - + } catch (BpmnError e) { + throw e } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage()) + String msg = "Exception in DoCreateTnNssiInstance.createAllottedResource: " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } void createLogicalLinksForAllocatedResource(DelegateExecution execution, - String linkArrayStr, String serviceInstanceId, + String linkArrayStr, String ssInstanceId, String allottedResourceId) { - try { + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId) + .allottedResource(allottedResourceId)) + + if (!getAAIClient().exists(allottedResourceUri)) { + logger.info("ERROR: createLogicalLinksForAllocatedResource: allottedResource not exist: uri={}", + allottedResourceUri) + return + } + List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) for (String linkStr : linkStrList) { @@ -186,15 +205,22 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { resource.setLinkId(logicalLinkId) resource.setLinkName(epA) resource.setLinkName2(epB) - resource.setModelInvariantId(modelInvariantId) - resource.setModelVersionId(modelVersionId) + resource.setLinkType("TsciConnectionLink") + resource.setInMaint(false) - AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId)) + //epA is link-name + AAIResourceUri logicalLinkUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA)) getAAIClient().create(logicalLinkUri, resource) + + tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, AAI_VERSION, allottedResourceUri, epA); } + } catch (BpmnError e) { + throw e } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, - "Exception in createLogicalLinksForAllocatedResource" + ex.getMessage()) + String msg = "Exception in DoCreateTnNssiInstance.createLogicalLinksForAllocatedResource: " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index 9d6c4a1b2a..75ef7d347c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -19,8 +19,8 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject 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 @@ -47,6 +47,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor private ExceptionUtil exceptionUtil = new ExceptionUtil() private JsonUtils jsonUtil = new JsonUtils() + ObjectMapper objectMapper = new ObjectMapper() private RequestDBUtil requestDBUtil = new RequestDBUtil() private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) @@ -133,10 +134,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor String nssiId = currentNSSI['nssiServiceInstanceId'] String nsiId = currentNSSI['nsiServiceInstanceId'] String scriptName = execution.getVariable("scriptName") - boolean modifyAction = execution.getVariable("terminateNSI") String serviceInvariantUuid = currentNSSI['modelInvariantId'] - String serviceUuid = currentNSSI['modelVersionId'] + String serviceUuid = currentNSSI['modelId'] String globalSubscriberId = currentNSSI['globalSubscriberId'] String subscriptionServiceType = execution.getVariable("serviceType") @@ -146,37 +146,37 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor deAllocateNssi.setTerminateNssiOption(0) deAllocateNssi.setSnssaiList(Arrays.asList(snssai)) deAllocateNssi.setScriptName(scriptName) - deAllocateNssi.setSliceProfileId(profileId) - deAllocateNssi.setModifyAction(modifyAction) ServiceInfo serviceInfo = new ServiceInfo() serviceInfo.setServiceInvariantUuid(serviceInvariantUuid) serviceInfo.setServiceUuid(serviceUuid) + serviceInfo.setNsiId(nsiId) serviceInfo.setGlobalSubscriberId(globalSubscriberId) serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + String serviceInfoString = objectMapper.writeValueAsString(serviceInfo) EsrInfo esrInfo = getEsrInfo(currentNSSI) + String esrInfoString = objectMapper.writeValueAsString(esrInfo) execution.setVariable("deAllocateNssi",deAllocateNssi) - execution.setVariable("esrInfo",esrInfo) - execution.setVariable("serviceInfo",serviceInfo) + execution.setVariable("esrInfo", esrInfoString) + execution.setVariable("serviceInfo", serviceInfoString) String nssmfRequest = """ { - "deAllocateNssi": "${execution.getVariable("deAllocateNssi") as JSONObject}", - "esrInfo": ${execution.getVariable("esrInfo") as JSONObject}, - "serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject} + "deAllocateNssi": ${objectMapper.writeValueAsString(deAllocateNssi)}, + "esrInfo": ${esrInfoString}, + "serviceInfo": ${serviceInfoString} } """ - String urlStr = String.format("/api/rest/provMns/v1/NSS/nssi/%s",nssiId) + String urlStr = String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s", profileId) NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, NssiResponse.class) if (nssmfResponse != null) { currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" currentNSSI['jobProgress'] = 0 execution.setVariable("currentNSSI", currentNSSI) - } - else { + } else { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") } LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****") @@ -190,32 +190,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor { def currentNSSI = execution.getVariable("currentNSSI") String jobId = currentNSSI['jobId'] - String nssiId = currentNSSI['nssiServiceInstanceId'] - String nsiId = currentNSSI['nsiServiceInstanceId'] - String serviceInvariantUuid = currentNSSI['modelInvariantId'] - String serviceUuid = currentNSSI['modelVersionId'] - String globalSubscriberId = currentNSSI['globalSubscriberId'] - String subscriptionServiceType = execution.getVariable("serviceType") - String sST = currentNSSI['sST'] - String PLMNIdList = currentNSSI['PLMNIdList'] - String nssiName = currentNSSI['nssiName'] - + execution.setVariable("responseId", "3") - execution.setVariable("esrInfo", getEsrInfo(currentNSSI)) execution.setVariable("jobId", jobId) - - Map<String, ?> serviceInfoMap = new HashMap<>() - serviceInfoMap.put("nssiId", nssiId) - serviceInfoMap.put("nsiId", nsiId) - serviceInfoMap.put("nssiName", nssiName) - serviceInfoMap.put("sST", sST) - serviceInfoMap.put("PLMNIdList", PLMNIdList) - serviceInfoMap.put("globalSubscriberId", globalSubscriberId) - serviceInfoMap.put("subscriptionServiceType", subscriptionServiceType) - serviceInfoMap.put("serviceInvariantUuid", serviceInvariantUuid) - serviceInfoMap.put("serviceUuid", serviceUuid) - - execution.setVariable("serviceInfo", serviceInfoMap) } @@ -238,8 +215,9 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor LOGGER.error("job progress is null or empty!") exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Job progress from NSSMF.") } + def currentNSSI = execution.getVariable("currentNSSI") int oldProgress = currentNSSI['jobProgress'] - int currentProgress = progress + int currentProgress = Integer.parseInt(progress) execution.setVariable("isNSSIDeAllocated", (currentProgress == 100)) execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress)) @@ -247,6 +225,8 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor currentNSSI['status'] = status currentNSSI['statusDescription'] = statusDescription + String nssiId = currentNSSI['nssiServiceInstanceId'] + String nsiId = currentNSSI['nsiServiceInstanceId'] LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" ) } else { @@ -256,7 +236,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } catch (any) { - String msg = "Received a Bad Response from NSSMF." cause-"+any.getCause()" + String msg = "Received a Bad Response from NSSMF. cause-"+any.getCause() LOGGER.error(any.printStackTrace()) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -309,7 +289,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor String nssiServiceInstanceId = currentNSSI['nssiServiceInstanceId'] String profileId = currentNSSI['profileId'] String globalSubscriberId = currentNSSI["globalSubscriberId"] - String serviceType = currentNSSI["serviceType"] + String serviceType = execution.getVariable("serviceType") try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index a410b93d16..baf0333a19 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -162,7 +162,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy index 03a726c52c..4ff15a58c5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -387,7 +387,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy index 47489b7b84..0465a433eb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy @@ -32,142 +32,142 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class ModifySliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="MSS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - RequestDBUtil requestDBUtil = new RequestDBUtil() - - private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class) - - @Override - void preProcessRequest(DelegateExecution execution) { - logger.debug(Prefix + "preProcessRequest Start") - execution.setVariable("prefix", Prefix) - execution.setVariable("startTime", System.currentTimeMillis()) - def msg - try { - // get request input - String subnetInstanceReq = execution.getVariable("bpmnRequest") - logger.debug(subnetInstanceReq) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //NSSI Info - String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") - if (isBlank(serviceInstanceID)) { - msg = "Input serviceInstanceID is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("serviceInstanceID", serviceInstanceID) - } - - String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") - execution.setVariable("servicename", servicename) - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - - //requestParameters, subscriptionServiceType is 5G - String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - String jobId = UUID.randomUUID().toString() - execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) - - } catch(BpmnError e) { - throw e - } catch(Exception ex) { - msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "preProcessRequest Exit") - } - - - /** - * create operation status in request db - * - * Init the Operation Status - */ - def prepareInitOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareInitOperationStatus Start") - - String serviceId = execution.getVariable("serviceInstanceID") - String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) - - ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType("Modify") - requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareInitOperationStatus Exit") - } - - - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}""" - .trim().replaceAll(" ", "") - logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse) - sendWorkflowResponse(execution, 202, modifySyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } + String Prefix="ModifySliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI Info + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Modify") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse) + sendWorkflowResponse(execution, 202, modifySyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 7d2e536af9..e856522fca 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -27,11 +27,9 @@ import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -155,7 +153,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { "modelUuid":"${modelUuid}", "modelVersion":"" }""" - execution.setVariable("ssServiceModelInfo", serviceModelInfo) + execution.setVariable("serviceModelInfo", serviceModelInfo) logger.debug("Finish prepareDecomposeService") } @@ -186,13 +184,14 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { if (maxIndex < 1) { String msg = "Exception in TN NSST processDecomposition. There is no NSST associated with TN NSST " logger.info(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } else { + execution.setVariable("tnNsstInfoList", nsstInfoList) + execution.setVariable("tnModelVersion", tnModelVersion) + execution.setVariable("tnModelName", tnModelName) + execution.setVariable("currentIndex", currentIndex) + execution.setVariable("maxIndex", maxIndex) } - execution.setVariable("tnNsstInfoList", nsstInfoList) - execution.setVariable("tnModelVersion", tnModelVersion) - execution.setVariable("tnModelName", tnModelName) - execution.setVariable("currentIndex", currentIndex) - execution.setVariable("maxIndex", maxIndex) logger.debug("End processDecomposition") } @@ -334,7 +333,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index a1b883c34e..1bb0e8aca7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -20,8 +20,11 @@ package org.onap.so.bpmn.infrastructure.scripts - +import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.Relationship +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils @@ -241,4 +244,40 @@ class TnNssmfUtils { return res } + + void createRelationShipInAAI(DelegateExecution execution, AAIResourceUri uri, Relationship relationship) { + logger.debug("createRelationShipInAAI Start") + String msg + AAIResourcesClient client = new AAIResourcesClient() + try { + if (!client.exists(uri)) { + logger.info("ERROR: createRelationShipInAAI: not exist: uri={}", uri) + return + } + AAIResourceUri from = ((AAIResourceUri) (uri.clone())).relationshipAPI() + client.create(from, relationship) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in createRelationShipInAAI. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("createRelationShipInAAI Exit") + } + + void attachLogicalLinkToAllottedResource(DelegateExecution execution, String aaiVersion, AAIResourceUri arUri, + String logicalLinkId) { + + + String toLink = "aai/${aaiVersion}/network/logical-links/logical-link/${logicalLinkId}" + + Relationship relationship = new Relationship() + relationship.setRelatedLink(toLink) + relationship.setRelatedTo("logical-link") + relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + + createRelationShipInAAI(execution, arUri, relationship) + } } diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml index e6eb284199..a8f35986e7 100644 --- a/bpmn/so-bpmn-infrastructure-flows/pom.xml +++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml @@ -195,17 +195,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>com.h2database</groupId> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn index 450faaebca..29f024991d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn @@ -91,13 +91,6 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_0ou7wr9" sourceRef="Activity_1hyt0pb" targetRef="Activity_1ydx2rx" /> <bpmn:sequenceFlow id="Flow_18cgkru" sourceRef="Activity_1ydx2rx" targetRef="Activity_0qlstj2" /> - <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI"> - <bpmn:extensionElements> - <camunda:in source="servicename" target="servicename" /> - </bpmn:extensionElements> - <bpmn:incoming>Flow_0g7721r</bpmn:incoming> - <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing> - </bpmn:callActivity> <bpmn:sequenceFlow id="Flow_189zwjw" sourceRef="CallDoAllocateTransportNSSI" targetRef="Event_18u424w" /> <bpmn:callActivity id="CallDoAllocateCoreNSSI" name="Call CNAllocateNSSI" calledElement="DoAllocateCoreNSSI"> <bpmn:extensionElements> @@ -118,6 +111,24 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> <bpmn:outgoing>Flow_1coedjo</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="Flow_1coedjo" sourceRef="CallDoAllocateCoreNSSI" targetRef="Event_18u424w" /> + <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="dummyServiceId" target="dummyServiceId" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0g7721r</bpmn:incoming> + <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing> + </bpmn:callActivity> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AllocateSliceSubnet"> @@ -126,8 +137,8 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> <di:waypoint x="1152" y="190" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_189zwjw_di" bpmnElement="Flow_189zwjw"> - <di:waypoint x="1080" y="300" /> - <di:waypoint x="1170" y="300" /> + <di:waypoint x="1080" y="290" /> + <di:waypoint x="1170" y="290" /> <di:waypoint x="1170" y="208" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_18cgkru_di" bpmnElement="Flow_18cgkru"> @@ -153,10 +164,10 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0g7721r_di" bpmnElement="Flow_0g7721r"> <di:waypoint x="890" y="215" /> - <di:waypoint x="890" y="300" /> - <di:waypoint x="980" y="300" /> + <di:waypoint x="890" y="290" /> + <di:waypoint x="980" y="290" /> <bpmndi:BPMNLabel> - <dc:Bounds x="912" y="273" width="36" height="14" /> + <dc:Bounds x="912" y="263" width="36" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1fij4ds_di" bpmnElement="Flow_1fij4ds"> @@ -208,12 +219,13 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> <bpmndi:BPMNShape id="Activity_1ydx2rx_di" bpmnElement="Activity_1ydx2rx"> <dc:Bounds x="380" y="150" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_008nbm9_di" bpmnElement="CallDoAllocateTransportNSSI"> - <dc:Bounds x="980" y="260" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_01669p4_di" bpmnElement="CallDoAllocateCoreNSSI"> <dc:Bounds x="980" y="150" width="100" height="80" /> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_00awuik_di" bpmnElement="CallDoAllocateTransportNSSI"> + <dc:Bounds x="980" y="250" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn index f4886322c2..12632dec72 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn @@ -68,12 +68,12 @@ ex.processJavaException(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0t094g7</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def rupScript = new TnAllocateNssi() +def runScript = new TnAllocateNssi() runScript.prepareUpdateJobStatus(execution,"progress","10","Allocate TN NSSI started")</bpmn:script> </bpmn:scriptTask> <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_1ex8ke9" name="Goto OOF TN NSSI Selection"> <bpmn:incoming>SequenceFlow_0jrclmc</bpmn:incoming> - <bpmn:linkEventDefinition id="LinkEventDefinition_0de65en" name="OofTnNssiSelect" /> + <bpmn:linkEventDefinition id="LinkEventDefinition_0de65en" name="TnAllocateNssi" /> </bpmn:intermediateThrowEvent> <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn index 1bda596c6a..7699e804b4 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn @@ -160,10 +160,11 @@ dcso.processNSIResp(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:scriptTask id="ScriptTask_0bgvphs" name="Prepare OOF Select NSI options request" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_1iawj3m</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1e7iqkm</bpmn:incoming> <bpmn:outgoing>SequenceFlow_14o0fxe</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcso = new DoCreateSliceServiceOption() -dcso.preNSIRequest(execution,true)</bpmn:script> +dcso.preNSIRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_00uke3g" name=" Select NSSI "> <bpmn:outgoing>SequenceFlow_1iawj3m</bpmn:outgoing> @@ -190,7 +191,7 @@ dcso.handleNssiSelect(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_103oxyw" sourceRef="CallActivity_0melx8d" targetRef="ParallelGateway_06a2n9u" /> <bpmn:sequenceFlow id="SequenceFlow_14rhmx9" sourceRef="CallActivity_1vzxvna" targetRef="ParallelGateway_06a2n9u" /> <bpmn:parallelGateway id="ParallelGateway_05zg916"> - <bpmn:incoming>SequenceFlow_1h3kdce</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0vfe8hp</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0il5j01</bpmn:outgoing> <bpmn:outgoing>SequenceFlow_0euwvgf</bpmn:outgoing> <bpmn:outgoing>SequenceFlow_05250mp</bpmn:outgoing> @@ -198,7 +199,7 @@ dcso.handleNssiSelect(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_0il5j01" sourceRef="ParallelGateway_05zg916" targetRef="CallActivity_0otry7e" /> <bpmn:sequenceFlow id="SequenceFlow_0euwvgf" sourceRef="ParallelGateway_05zg916" targetRef="CallActivity_0melx8d" /> <bpmn:sequenceFlow id="SequenceFlow_05250mp" sourceRef="ParallelGateway_05zg916" targetRef="CallActivity_1vzxvna" /> - <bpmn:sequenceFlow id="SequenceFlow_1h3kdce" sourceRef="ScriptTask_12t6v71" targetRef="ParallelGateway_05zg916" /> + <bpmn:sequenceFlow id="SequenceFlow_1h3kdce" sourceRef="ScriptTask_12t6v71" targetRef="ExclusiveGateway_015qbbq" /> <bpmn:sequenceFlow id="SequenceFlow_1tqg26p" sourceRef="CallActivity_0tzazs0" targetRef="Task_00nfg5x" /> <bpmn:sequenceFlow id="SequenceFlow_1tey3hz" sourceRef="Task_1jyj2vs" targetRef="ExclusiveGateway_0b52m39" /> <bpmn:sequenceFlow id="SequenceFlow_0abqxa1" sourceRef="Task_1m9qoo3" targetRef="CallActivity_0tzazs0" /> @@ -216,212 +217,234 @@ dcso.handleNssiSelect(execution)</bpmn:script> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_1nrfy6i" sourceRef="ExclusiveGateway_0b52m39" targetRef="EndEvent_0p0cjhl" /> <bpmn:sequenceFlow id="SequenceFlow_1ezi1oi" sourceRef="Task_00nfg5x" targetRef="ExclusiveGateway_0b52m39" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_015qbbq" default="SequenceFlow_0vfe8hp"> + <bpmn:incoming>SequenceFlow_1h3kdce</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0vfe8hp</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1e7iqkm</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0vfe8hp" sourceRef="ExclusiveGateway_015qbbq" targetRef="ParallelGateway_05zg916" /> + <bpmn:sequenceFlow id="SequenceFlow_1e7iqkm" sourceRef="ExclusiveGateway_015qbbq" targetRef="ScriptTask_0bgvphs"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("needQuerySliceProfile") == true}</bpmn:conditionExpression> + </bpmn:sequenceFlow> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateSliceServiceOption"> <bpmndi:BPMNShape id="ScriptTask_11rb2ju_di" bpmnElement="ScriptTask_11rb2ju"> - <dc:Bounds x="400" y="140" width="100" height="80" /> + <dc:Bounds x="470" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0c567r4_di" bpmnElement="CallActivity_0c567r4"> - <dc:Bounds x="560" y="140" width="100" height="80" /> + <dc:Bounds x="630" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0z0dwk2_di" bpmnElement="ScriptTask_0z0dwk2"> - <dc:Bounds x="710" y="140" width="100" height="80" /> + <dc:Bounds x="780" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1kzy63m_di" bpmnElement="SequenceFlow_1kzy63m"> - <di:waypoint x="500" y="180" /> - <di:waypoint x="560" y="180" /> + <di:waypoint x="570" y="180" /> + <di:waypoint x="630" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1t317y2_di" bpmnElement="SequenceFlow_1t317y2"> - <di:waypoint x="660" y="180" /> - <di:waypoint x="710" y="180" /> + <di:waypoint x="730" y="180" /> + <di:waypoint x="780" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0tzazs0_di" bpmnElement="CallActivity_0tzazs0"> - <dc:Bounds x="1410" y="320" width="100" height="80" /> + <dc:Bounds x="1560" y="320" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_0mwlirs_di" bpmnElement="StartEvent_0mwlirs"> - <dc:Bounds x="162" y="162" width="36" height="36" /> + <dc:Bounds x="232" y="162" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="169" y="198" width="25" height="14" /> + <dc:Bounds x="239" y="198" width="25" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0w34e57_di" bpmnElement="ScriptTask_0w34e57"> - <dc:Bounds x="230" y="140" width="100" height="80" /> + <dc:Bounds x="300" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1fuwy35_di" bpmnElement="SequenceFlow_1fuwy35"> - <di:waypoint x="198" y="180" /> - <di:waypoint x="230" y="180" /> + <di:waypoint x="268" y="180" /> + <di:waypoint x="300" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1anc3ln_di" bpmnElement="CallActivity_1vzxvna"> - <dc:Bounds x="740" y="320" width="100" height="80" /> + <dc:Bounds x="950" y="330" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1xgkaqi_di" bpmnElement="CallActivity_0melx8d"> - <dc:Bounds x="740" y="460" width="100" height="80" /> + <dc:Bounds x="950" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_11y7ba5_di" bpmnElement="CallActivity_0otry7e"> - <dc:Bounds x="740" y="580" width="100" height="80" /> + <dc:Bounds x="950" y="580" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1icyh1a_di" bpmnElement="Task_1m9qoo3"> - <dc:Bounds x="1410" y="460" width="100" height="80" /> + <dc:Bounds x="1560" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0aqbm7t_di" bpmnElement="Task_00nfg5x"> - <dc:Bounds x="1210" y="320" width="100" height="80" /> + <dc:Bounds x="1360" y="320" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_12sydez_di" bpmnElement="ScriptTask_12sydez"> - <dc:Bounds x="860" y="140" width="100" height="80" /> + <dc:Bounds x="930" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0hfiogq_di" bpmnElement="CallActivity_0hfiogq"> - <dc:Bounds x="1010" y="140" width="100" height="80" /> + <dc:Bounds x="1080" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_14j28c2_di" bpmnElement="ScriptTask_14j28c2"> - <dc:Bounds x="1170" y="140" width="100" height="80" /> + <dc:Bounds x="1240" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_12pvazb_di" bpmnElement="SequenceFlow_12pvazb"> - <di:waypoint x="960" y="180" /> - <di:waypoint x="1010" y="180" /> + <di:waypoint x="1030" y="180" /> + <di:waypoint x="1080" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1inonqp_di" bpmnElement="SequenceFlow_1inonqp"> - <di:waypoint x="1110" y="180" /> - <di:waypoint x="1170" y="180" /> + <di:waypoint x="1180" y="180" /> + <di:waypoint x="1240" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_1bxdugq_di" bpmnElement="IntermediateThrowEvent_1bxdugq"> - <dc:Bounds x="1482" y="162" width="36" height="36" /> + <dc:Bounds x="1552" y="162" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1459" y="205" width="87" height="14" /> + <dc:Bounds x="1529" y="205" width="87" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_067xdx1_di" bpmnElement="SequenceFlow_067xdx1"> - <di:waypoint x="330" y="180" /> <di:waypoint x="400" y="180" /> + <di:waypoint x="470" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_049glzl_di" bpmnElement="SequenceFlow_049glzl"> - <di:waypoint x="1270" y="180" /> - <di:waypoint x="1320" y="180" /> + <di:waypoint x="1340" y="180" /> + <di:waypoint x="1390" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0zglfyw_di" bpmnElement="SequenceFlow_0zglfyw"> - <di:waypoint x="1230" y="140" /> - <di:waypoint x="1230" y="80" /> - <di:waypoint x="910" y="80" /> - <di:waypoint x="910" y="140" /> + <di:waypoint x="1300" y="140" /> + <di:waypoint x="1300" y="80" /> + <di:waypoint x="980" y="80" /> + <di:waypoint x="980" y="140" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0t4gmix_di" bpmnElement="SequenceFlow_0t4gmix"> - <di:waypoint x="810" y="180" /> - <di:waypoint x="860" y="180" /> + <di:waypoint x="880" y="180" /> + <di:waypoint x="930" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1tx9eou_di" bpmnElement="Task_1xqjkqx"> - <dc:Bounds x="1320" y="140" width="100" height="80" /> + <dc:Bounds x="1390" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_16akt81_di" bpmnElement="SequenceFlow_16akt81"> - <di:waypoint x="1420" y="180" /> - <di:waypoint x="1482" y="180" /> + <di:waypoint x="1490" y="180" /> + <di:waypoint x="1552" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0vs5jgq_di" bpmnElement="CallActivity_0vs5jgq"> - <dc:Bounds x="360" y="460" width="100" height="80" /> + <dc:Bounds x="410" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_12t6v71_di" bpmnElement="ScriptTask_12t6v71"> - <dc:Bounds x="490" y="460" width="100" height="80" /> + <dc:Bounds x="580" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0bgvphs_di" bpmnElement="ScriptTask_0bgvphs"> - <dc:Bounds x="210" y="460" width="100" height="80" /> + <dc:Bounds x="250" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_00uke3g_di" bpmnElement="IntermediateCatchEvent_00uke3g"> - <dc:Bounds x="142" y="482" width="36" height="36" /> + <dc:Bounds x="162" y="482" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="135" y="525" width="60" height="14" /> + <dc:Bounds x="155" y="525" width="60" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_14o0fxe_di" bpmnElement="SequenceFlow_14o0fxe"> - <di:waypoint x="310" y="500" /> - <di:waypoint x="360" y="500" /> + <di:waypoint x="350" y="500" /> + <di:waypoint x="410" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0nwt0ci_di" bpmnElement="SequenceFlow_0nwt0ci"> - <di:waypoint x="460" y="500" /> - <di:waypoint x="490" y="500" /> + <di:waypoint x="510" y="500" /> + <di:waypoint x="580" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1iawj3m_di" bpmnElement="SequenceFlow_1iawj3m"> - <di:waypoint x="178" y="500" /> - <di:waypoint x="210" y="500" /> + <di:waypoint x="198" y="500" /> + <di:waypoint x="250" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0h3fsja_di" bpmnElement="Task_1jyj2vs"> - <dc:Bounds x="1010" y="460" width="100" height="80" /> + <dc:Bounds x="1220" y="460" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ParallelGateway_06a2n9u_di" bpmnElement="ParallelGateway_06a2n9u"> - <dc:Bounds x="905" y="475" width="50" height="50" /> + <dc:Bounds x="1105" y="475" width="50" height="50" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1tr3i9d_di" bpmnElement="SequenceFlow_1tr3i9d"> - <di:waypoint x="955" y="500" /> - <di:waypoint x="1010" y="500" /> + <di:waypoint x="1155" y="500" /> + <di:waypoint x="1220" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0aasemn_di" bpmnElement="SequenceFlow_0aasemn"> - <di:waypoint x="840" y="620" /> - <di:waypoint x="930" y="620" /> - <di:waypoint x="930" y="525" /> + <di:waypoint x="1050" y="620" /> + <di:waypoint x="1130" y="620" /> + <di:waypoint x="1130" y="525" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_103oxyw_di" bpmnElement="SequenceFlow_103oxyw"> - <di:waypoint x="840" y="500" /> - <di:waypoint x="905" y="500" /> + <di:waypoint x="1050" y="500" /> + <di:waypoint x="1105" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_14rhmx9_di" bpmnElement="SequenceFlow_14rhmx9"> - <di:waypoint x="840" y="360" /> - <di:waypoint x="930" y="360" /> - <di:waypoint x="930" y="475" /> + <di:waypoint x="1050" y="370" /> + <di:waypoint x="1130" y="370" /> + <di:waypoint x="1130" y="475" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ParallelGateway_05zg916_di" bpmnElement="ParallelGateway_05zg916"> - <dc:Bounds x="635" y="475" width="50" height="50" /> + <dc:Bounds x="825" y="475" width="50" height="50" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0il5j01_di" bpmnElement="SequenceFlow_0il5j01"> - <di:waypoint x="660" y="525" /> - <di:waypoint x="660" y="620" /> - <di:waypoint x="740" y="620" /> + <di:waypoint x="850" y="525" /> + <di:waypoint x="850" y="620" /> + <di:waypoint x="950" y="620" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0euwvgf_di" bpmnElement="SequenceFlow_0euwvgf"> - <di:waypoint x="685" y="500" /> - <di:waypoint x="740" y="500" /> + <di:waypoint x="875" y="500" /> + <di:waypoint x="950" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_05250mp_di" bpmnElement="SequenceFlow_05250mp"> - <di:waypoint x="660" y="475" /> - <di:waypoint x="660" y="360" /> - <di:waypoint x="740" y="360" /> + <di:waypoint x="850" y="475" /> + <di:waypoint x="850" y="370" /> + <di:waypoint x="950" y="370" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1h3kdce_di" bpmnElement="SequenceFlow_1h3kdce"> - <di:waypoint x="590" y="500" /> - <di:waypoint x="635" y="500" /> + <di:waypoint x="680" y="500" /> + <di:waypoint x="725" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1tqg26p_di" bpmnElement="SequenceFlow_1tqg26p"> - <di:waypoint x="1410" y="360" /> - <di:waypoint x="1310" y="360" /> + <di:waypoint x="1560" y="360" /> + <di:waypoint x="1460" y="360" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1tey3hz_di" bpmnElement="SequenceFlow_1tey3hz"> - <di:waypoint x="1110" y="500" /> - <di:waypoint x="1235" y="500" /> + <di:waypoint x="1320" y="500" /> + <di:waypoint x="1385" y="500" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0abqxa1_di" bpmnElement="SequenceFlow_0abqxa1"> - <di:waypoint x="1460" y="460" /> - <di:waypoint x="1460" y="400" /> + <di:waypoint x="1610" y="460" /> + <di:waypoint x="1610" y="400" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0b52m39_di" bpmnElement="ExclusiveGateway_0b52m39" isMarkerVisible="true"> - <dc:Bounds x="1235" y="475" width="50" height="50" /> + <dc:Bounds x="1385" y="475" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1218" y="463" width="85" height="14" /> + <dc:Bounds x="1367" y="535" width="86" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_126j77n_di" bpmnElement="SequenceFlow_126j77n"> - <di:waypoint x="1285" y="500" /> - <di:waypoint x="1410" y="500" /> + <di:waypoint x="1435" y="500" /> + <di:waypoint x="1560" y="500" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1339" y="482" width="17" height="14" /> + <dc:Bounds x="1489" y="482" width="17" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_0p0cjhl_di" bpmnElement="EndEvent_0p0cjhl"> - <dc:Bounds x="1242" y="632" width="36" height="36" /> + <dc:Bounds x="1392" y="632" width="36" height="36" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1nrfy6i_di" bpmnElement="SequenceFlow_1nrfy6i"> - <di:waypoint x="1260" y="525" /> - <di:waypoint x="1260" y="632" /> + <di:waypoint x="1410" y="525" /> + <di:waypoint x="1410" y="632" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1ezi1oi_di" bpmnElement="SequenceFlow_1ezi1oi"> - <di:waypoint x="1260" y="400" /> - <di:waypoint x="1260" y="475" /> + <di:waypoint x="1410" y="400" /> + <di:waypoint x="1410" y="475" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_015qbbq_di" bpmnElement="ExclusiveGateway_015qbbq" isMarkerVisible="true"> + <dc:Bounds x="725" y="475" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0vfe8hp_di" bpmnElement="SequenceFlow_0vfe8hp"> + <di:waypoint x="775" y="500" /> + <di:waypoint x="825" y="500" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1e7iqkm_di" bpmnElement="SequenceFlow_1e7iqkm"> + <di:waypoint x="750" y="525" /> + <di:waypoint x="750" y="620" /> + <di:waypoint x="300" y="620" /> + <di:waypoint x="300" y="540" /> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn index c107cfb53a..a745f7c50d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeallocateNSSI.bpmn @@ -99,10 +99,11 @@ dnssi.prepareUpdateOperationStatus(execution)</bpmn:script> <bpmn:callActivity id="Task_1x3et9h" name="Query Job Status" calledElement="QueryJobStatus"> <bpmn:extensionElements> <camunda:in source="msoRequestId" target="msoRequestId" /> - <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> - <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> - <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> - <camunda:out source="serviceDecompositionString" target="serviceDecompositionString" /> + <camunda:in source="esrInfo" target="esrInfo" /> + <camunda:in source="serviceInfo" target="serviceInfo" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="responseId" target="responseId" /> + <camunda:out source="responseDescriptor" target="responseDescriptor" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0w01l14</bpmn:incoming> <bpmn:outgoing>SequenceFlow_10nogqz</bpmn:outgoing> 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 5425b2a725..f0898ace81 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 @@ -75,6 +75,7 @@ public class WorkflowActionBBTasks { private static final String COMPLETED = "completed"; private static final String HANDLINGCODE = "handlingCode"; private static final String ROLLBACKTOCREATED = "RollbackToCreated"; + private static final String ROLLBACKTOCREATEDNOCONFIGURATION = "RollbackToCreatedNoConfiguration"; private static final String REPLACEINSTANCE = "replaceInstance"; private static final String VFMODULE = "VfModule"; protected String maxRetries = "mso.rainyDay.maxRetries"; @@ -334,14 +335,19 @@ public class WorkflowActionBBTasks { String handlingCode = (String) execution.getVariable(HANDLINGCODE); List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>(rollbackFlows); - if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode)) { + if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode) + || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)) { for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) { if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Unassign") && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) { rollbackFlowsFiltered.remove(rollbackFlow); } else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Delete") - && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") - && ROLLBACKTOCREATED.equals(handlingCode)) { + && ((!rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") + && (ROLLBACKTOCREATED.equals(handlingCode) + || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode))) + || (rollbackFlow.getBuildingBlock().getBpmnFlowName() + .contains("FabricConfiguration") + && ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)))) { rollbackFlowsFiltered.remove(rollbackFlow); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java index 682a0471ee..2119ced951 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java @@ -29,6 +29,7 @@ import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -48,6 +49,9 @@ public class SkipCDSBuildingBlockListener implements FlowManipulator { private Set<String> vFModuleAction = new HashSet<String>(Arrays.asList("VfModuleConfigAssign", "VfModuleConfigDeploy")); + private Set<String> pnfActions = + new HashSet<>(Arrays.asList("config-assign", "config-deploy", "PnfConfigAssign", "PnfConfigDeploy")); + @Override public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { @@ -95,9 +99,17 @@ public class SkipCDSBuildingBlockListener implements FlowManipulator { boolean skipVfModule = vfc.isSkipPostInstConf(); currentSequenceSkipCheck(execution, skipVfModule); } - } + } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("PNF") + && containsIgnoreCaseAction(currentBB, pnfActions)) { + PnfResourceCustomization pnfResourceCustomization = + catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(customizationUUID); + if (null != pnfResourceCustomization) { + boolean skipConfigPNF = pnfResourceCustomization.isSkipPostInstConf(); + currentSequenceSkipCheck(execution, skipConfigPNF); + } + } } private boolean containsIgnoreCaseAction(ExecuteBuildingBlock currentBB, Set<String> actions) { 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 a7ee89f073..3290bb3dce 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 @@ -436,6 +436,40 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void rollbackExecutionRollbackToCreatedNoConfigurationWithFabricTest() { + execution.setVariable("isRollback", false); + execution.setVariable("handlingCode", "RollbackToCreatedNoConfiguration"); + 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(1, ebbs.size()); + assertEquals("DeactivateVfModuleBB", ebbs.get(0).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/listeners/SkipCDSBuildingBlockListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java index fb162f857b..fdf4d36c89 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java @@ -36,6 +36,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -47,9 +48,11 @@ public class SkipCDSBuildingBlockListenerTest { private static final String VNF_SCOPE = "VNF"; private static final String VF_SCOPE = "VFModule"; + private static final String PNF_SCOPE = "pnf"; private static final String TEST_MODELUUID = "123456789"; private static final String VNF_TEST_ACTION = "VnfConfigAssign"; private static final String VFModule_TEST_ACTION = "VfModuleConfigAssign"; + private static final String PNFModule_TEST_ACTION = "config-assign"; private static final String MODELCUSTOMIZATIONUUID = "123456789"; private static final String BBNAME = "ControllerExecutionBB"; private static final boolean ISFIRST = true; @@ -63,6 +66,7 @@ public class SkipCDSBuildingBlockListenerTest { private BuildingBlockExecution buildingBlockExecution = new DelegateExecutionImpl(new DelegateExecutionFake()); private VnfResourceCustomization vnfCust = new VnfResourceCustomization(); private VfModuleCustomization vfCust = new VfModuleCustomization(); + private PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); private BuildingBlock buildingBlock = new BuildingBlock(); @InjectMocks @@ -166,6 +170,44 @@ public class SkipCDSBuildingBlockListenerTest { } + @Test + public void testProcessForPNFToSkipCDSBB() { + // given + setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, 0); + pnfResourceCustomization = getPnfResourceCustomization(true); + + when(catalogDbClient + .getPnfResourceCustomizationByModelCustomizationUUID(executeBuildingBlock.getBuildingBlock().getKey())) + .thenReturn(pnfResourceCustomization); + + // when + skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); + + // then + actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + assertEquals(1, actual); + + } + + @Test + public void testProcessForPNFNotToSkipCDSBB() { + // given + setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, 0); + pnfResourceCustomization = getPnfResourceCustomization(false); + + when(catalogDbClient + .getPnfResourceCustomizationByModelCustomizationUUID(executeBuildingBlock.getBuildingBlock().getKey())) + .thenReturn(pnfResourceCustomization); + + // when + skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); + + // then + actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + assertEquals(0, actual); + + } + /** * setting scope action in buildingBlock and BB current sequence in BuildingBlockExecution * @@ -199,4 +241,11 @@ public class SkipCDSBuildingBlockListenerTest { return vfModuleCustomizations; } + private PnfResourceCustomization getPnfResourceCustomization(boolean setSkippost) { + PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); + pnfResourceCustomization.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID); + pnfResourceCustomization.setSkipPostInstConf(setSkippost); + return pnfResourceCustomization; + } + } diff --git a/common/pom.xml b/common/pom.xml index ff13da4ee6..74e51805ad 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -71,7 +71,6 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-client</artifactId> - <version>${cxf.version}</version> <scope>test</scope> </dependency> <dependency> diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java index 27c5cf8e26..dc8e69121e 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java @@ -22,14 +22,16 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; +import java.io.Serializable; import java.util.Map; @JsonInclude(JsonInclude.Include.NON_NULL) @Data -public class AllocateAnNssi { +public class AllocateAnNssi implements Serializable { @Deprecated public final static String URL = "/api/rest/provMns/v1/an/NSS" + "/SliceProfiles"; + private static final long serialVersionUID = 4925129853421138442L; private String nsstId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java b/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java index 418f8a5065..e2c2e999ec 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class AnPerfReq { +public class AnPerfReq implements Serializable { + + private static final long serialVersionUID = -7415880702887244040L; private PerfReqEmbb perfReqEmbb; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java index e5eb3e0d21..eef0396205 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java @@ -24,12 +24,15 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.ToString; +import java.io.Serializable; import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) @Data @ToString -public class AnSliceProfile { +public class AnSliceProfile implements Serializable { + + private static final long serialVersionUID = -3057342171549542794L; @JsonProperty(value = "sliceProfileId", required = true) private String sliceProfileId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java index 399d51e894..10aaf26413 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java @@ -21,12 +21,14 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) -public class DeAllocateNssi { +public class DeAllocateNssi implements Serializable { @Deprecated public final static String URL = "/api/rest/provMns/v1/NSS" + "/SliceProfiles/%s"; + private static final long serialVersionUID = 8198187346132154044L; private String nsiId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java b/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java index 9259d51591..a0a9531c89 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class JobStatusResponse { +public class JobStatusResponse implements Serializable { + + private static final long serialVersionUID = -2039407266985403172L; private ResponseDescriptor responseDescriptor; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java index d1679c6dfa..3219846ec7 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class NsiInfo { +public class NsiInfo implements Serializable { + + private static final long serialVersionUID = -8432406430744875618L; private String nsiName; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java index 66368be6b8..92acdaa90d 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class NssiResponse { +public class NssiResponse implements Serializable { + + private static final long serialVersionUID = 2723440188640857903L; private String nssiId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java index bce0d56f9a..f6e945e368 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class PerfReqEmbb { +public class PerfReqEmbb implements Serializable { + + private static final long serialVersionUID = 8886635511695277599L; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int expDataRateDL; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java index 0b05d39bab..9e4b4edce3 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class PerfReqUrllc { +public class PerfReqUrllc implements Serializable { + + private static final long serialVersionUID = 3133479142915485943L; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int e2eLatency; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java b/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java index 146032c6fd..2456d540ce 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java @@ -22,11 +22,14 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; +import java.io.Serializable; import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) @Data -public class ResponseDescriptor { +public class ResponseDescriptor implements Serializable { + + private static final long serialVersionUID = 6330527958947215910L; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int progress; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java index 19e8b46314..f9848fca31 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java @@ -19,10 +19,11 @@ */ package org.onap.so.beans.nsmf; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import java.io.Serializable; -import java.util.List; +@JsonInclude(JsonInclude.Include.NON_NULL) @Data public class ServiceInfo implements Serializable { diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java index dd73fdb76b..8ea0eb6587 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.HashMap; +import java.io.Serializable; import java.util.Map; @@ -35,7 +36,8 @@ import java.util.Map; @AllArgsConstructor @ToString @Builder -public class SliceTaskParamsAdapter { +public class SliceTaskParamsAdapter implements Serializable { + private static final long serialVersionUID = -7785578865170503301L; private String serviceId; diff --git a/cxf-logging/pom.xml b/cxf-logging/pom.xml index cb0d126283..64cea6c8b3 100644 --- a/cxf-logging/pom.xml +++ b/cxf-logging/pom.xml @@ -13,17 +13,14 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-client</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-bindings-soap</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>javax.servlet</groupId> diff --git a/docs/developer_info/Docker-Config_Understanding.rst b/docs/developer_info/Docker-Config_Understanding.rst new file mode 100644 index 0000000000..e684c6c480 --- /dev/null +++ b/docs/developer_info/Docker-Config_Understanding.rst @@ -0,0 +1,364 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2020 Huawei Technologies Co., Ltd. + +Docker-config +============= + +In SO (Service Orchestration) every component running on docker engine and respective containers. here we can see how so is working with Dokcer. + +CA(Certificate Authority) +========================= + +Certificate Authorities/ CAs, issue Digital Certificates. Digital Certificates are verifiable small data files that contain identity credentials to help websites, people, and devices represent their authentic online identity (authentic because the CA has verified the identity). CAs play a critical role in how the Internet operates and how transparent, trusted transactions can take place online. CAs issue millions of Digital Certificates each year, and these certificates are used to protect information, encrypt billions of transactions, and enable secure communication. + +CA(file) + +/so/packages/docker/src/main/docker/docker-files/ca-certificates/onap-ca.crt + +Example CA cirtifiacte:- + +-----BEGIN CERTIFICATE----- +MIIEczCCA1ugAwIBAgIBADANBgkqhkiG9w0BAQQFAD..AkGA1UEBhMCR0Ix +EzARBgNVBAgTClNvbWUtU3RhdGUxFDASBgNVBAoTC0..0EgTHRkMTcwNQYD +VQQLEy5DbGFzcyAxIFB1YmxpYyBQcmltYXJ5IENlcn..XRpb24gQXV0aG9y +aXR5MRQwEgYDVQQDEwtCZXN0IENBIEx0ZDAeFw0wMD..TUwMTZaFw0wMTAy +MDQxOTUwMTZaMIGHMQswCQYDVQQGEwJHQjETMBEGA1..29tZS1TdGF0ZTEU +MBIGA1UEChMLQmVzdCBDQSBMdGQxNzA1BgNVBAsTLk..DEgUHVibGljIFBy +aW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxFD..AMTC0Jlc3QgQ0Eg +THRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCg..Tz2mr7SZiAMfQyu +vBjM9OiJjRazXBZ1BjP5CE/Wm/Rr500PRK+Lh9x5eJ../ANBE0sTK0ZsDGM +ak2m1g7oruI3dY3VHqIxFTz0Ta1d+NAjwnLe4nOb7/..k05ShhBrJGBKKxb +8n104o/5p8HAsZPdzbFMIyNjJzBM2o5y5A13wiLitE..fyYkQzaxCw0Awzl +kVHiIyCuaF4wj571pSzkv6sv+4IDMbT/XpCo8L6wTa..sh+etLD6FtTjYbb +rvZ8RQM1tlKdoMHg2qxraAV++HNBYmNWs0duEdjUbJ..XI9TtnS4o1Ckj7P +OfljiQIDAQABo4HnMIHkMB0GA1UdDgQWBBQ8urMCRL..5AkIp9NJHJw5TCB +tAYDVR0jBIGsMIGpgBQ8urMCRLYYMHUKU5AkIp9NJH..aSBijCBhzELMAkG +A1UEBhMCR0IxEzARBgNVBAgTClNvbWUtU3RhdGUxFD..AoTC0Jlc3QgQ0Eg +THRkMTcwNQYDVQQLEy5DbGFzcyAxIFB1YmxpYyBQcm..ENlcnRpZmljYXRp +b24gQXV0aG9yaXR5MRQwEgYDVQQDEwtCZXN0IENBIE..DAMBgNVHRMEBTAD +AQH/MA0GCSqGSIb3DQEBBAUAA4IBAQC1uYBcsSncwA..DCsQer772C2ucpX +xQUE/C0pWWm6gDkwd5D0DSMDJRqV/weoZ4wC6B73f5..bLhGYHaXJeSD6Kr +XcoOwLdSaGmJYslLKZB3ZIDEp0wYTGhgteb6JFiTtn..sf2xdrYfPCiIB7g +BMAV7Gzdc4VspS6ljrAhbiiawdBiQlQmsBeFz9JkF4..b3l8BoGN+qMa56Y +It8una2gY4l2O//on88r5IWJlm1L0oA8e4fR2yrBHX..adsGeFKkyNrwGi/ +7vQMfXdGsRrXNGRGnX+vWDZ3/zWI0joDtCkNnqEpVn..HoX +-----END CERTIFICATE----- + + +Configurations:- +================ + +Every component has its own over-ride yaml file. We can over-ride the file according the Configurations and Dependencies required for Deploying. + +Over-ride yaml for api-handler +============================== + +Path:- /docker-config/volumes/so/config/api-handler-infra/onapheat/override.yaml + +.. code-block:: bash + + server: + port: 8080 + tomcat: + max-threads: 50 + ssl-enable: false + + mso: + msoKey: 07a7159d3bf51a0e53be7a8f89699be7 + logPath: logs + site-name: onapheat + adapters: + requestDb: + endpoint: http://request-db-adapter:8083 + auth: Basic YnBlbDpwYXNzd29yZDEk + catalog: + db: + spring: + endpoint: http://catalog-db-adapter:8082 + db: + auth: Basic YnBlbDpwYXNzd29yZDEk + config: + path: /src/main/resources/ + infra: + default: + alacarte: + orchestrationUri: /mso/async/services/ALaCarteOrchestrator + recipeTimeout: 180 + testApi: VNF_API + service: + macro: + default: + testApi: GR_API + camundaURL: http://bpmn-infra:8081 + camundaAuth: AE2E9BE6EF9249085AF98689C4EE087736A5500629A72F35068FFB88813A023581DD6E765071F1C04075B36EA4213A + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 + sdc: + client: + auth: F3473596C526938329DF877495B494DC374D1C4198ED3AD305EA3ADCBBDA1862 + activate: + instanceid: test + userid: cs0008 + endpoint: http://c1.vm1.mso.simpledemo.onap.org:28090 + tenant: + isolation: + retry: + count: 3 + aai: + endpoint: https://aai.api.simpledemo.onap.org:8443 + auth: 2630606608347B7124C244AB0FE34F6F + extApi: + endpoint: http://nbi.onap:8080/nbi/api/v3 + so: + operational-environment: + dmaap: + username: testuser + password: VjR5NDcxSzA= + host: http://c1.vm1.mso.simpledemo.onap.org:28090 + auth: 51EA5414022D7BE536E7516C4D1A6361416921849B72C0D6FC1C7F262FD9F2BBC2AD124190A332D9845A188AD80955567A4F975C84C221EEA8243BFD92FFE6896CDD1EA16ADD34E1E3D47D4A + publisher: + topic: com.att.ecomp.mso.operationalEnvironmentEvent + + spring: + datasource: + hikari: + jdbcUrl: jdbc:mariadb://mariadb:3306/catalogdb + username: cataloguser + password: catalog123 + driver-class-name: org.mariadb.jdbc.Driver + pool-name: catdb-pool + registerMbeans: true + jpa: + show-sql: true + hibernate: + dialect: org.hibernate.dialect.MySQL5Dialect + ddl-auto: validate + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + jersey: + type: filter + + security: + usercredentials: + - + username: sitecontrol + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: SiteControl-Client + - + username: gui + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: GUI-Client + - + username: infraportal + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: InfraPortal-Client + - + username: InfraPortalClient + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: InfraPortal-Client + - + username: bpel + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: BPEL-Client + - + username: mso_admin + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: ACTUATOR + + request: + datasource: + hikari: + jdbcUrl: jdbc:mariadb://mariadb:3306/requestdb + username: requestuser + password: request123 + driver-class-name: org.mariadb.jdbc.Driver + pool-name: reqdb-pool + registerMbeans: true + org: + onap: + so: + cloud-owner: CloudOwner + adapters: + network: + encryptionKey: 07a7159d3bf51a0e53be7a8f89699be7 + + + +Start the container +======================= +cd /home/root1/docker-config/ + +CMD:- +=== + +sudo docker-compose up -d + +*Example Output:* + +root1@slave-node:~/docker-config$ sudo docker-compose up -d +docker-config_mariadb_1 is up-to-date +Starting docker-config_catalog-db-adapter_1 ... done +Starting docker-config_request-db-adapter_1 ... done +Starting docker-config_bpmn-infra_1 ... done +Starting docker-config_vfc-adapter_1 ... done +Starting docker-config_sdc-controller_1 ... done +Starting docker-config_sdnc-adapter_1 ... done +Starting docker-config_openstack-adapter_1 ... done +Starting docker-config_api-handler-infra_1 ... done +Starting docker-config_so-monitoring_1 ... done +Starting docker-config_nssmf-adapter_1 ... done + + +Example Output: +=============== + +docker ps + +*Example Output:* + +root1@slave-node:~/docker-config$ sudo docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +d930caf28508 nexus3.onap.org:10001/onap/so/openstack-adapter "/app/wait-for.sh -q…" 5 weeks ago Up 30 seconds 0.0.0.0:8087->8087/tcp docker-config_openstack-adapter_1 +599af283319e nexus3.onap.org:10001/onap/so/vfc-adapter "/app/wait-for.sh -q…" 5 weeks ago Up 30 seconds 0.0.0.0:8084->8084/tcp docker-config_vfc-adapter_1 +5549305c8dd6 nexus3.onap.org:10001/onap/so/api-handler-infra "/app/wait-for.sh -q…" 5 weeks ago Up 27 seconds 0.0.0.0:8080->8080/tcp docker-config_api-handler-infra_1 +59d3aa684ecb nexus3.onap.org:10001/onap/so/sdnc-adapter "/app/wait-for.sh -q…" 5 weeks ago Up 29 seconds 0.0.0.0:8086->8086/tcp docker-config_sdnc-adapter_1 +ade4cef97bd3 nexus3.onap.org:10001/onap/so/bpmn-infra "/app/wait-for.sh -q…" 5 weeks ago Up 29 seconds 0.0.0.0:8081->8081/tcp docker-config_bpmn-infra_1 +e9558560c4d7 nexus3.onap.org:10001/onap/so/sdc-controller "/app/wait-for.sh -q…" 5 weeks ago Up 25 seconds 0.0.0.0:8085->8085/tcp docker-config_sdc-controller_1 +ae27ec2f8b04 nexus3.onap.org:10001/onap/so/so-monitoring "/app/wait-for.sh -q…" 5 weeks ago Up 26 seconds 0.0.0.0:8088->8088/tcp docker-config_so-monitoring_1 +8d2c64d48f1a nexus3.onap.org:10001/onap/so/request-db-adapter "/app/wait-for.sh -q…" 5 weeks ago Up 32 seconds 0.0.0.0:8083->8083/tcp docker-config_request-db-adapter_1 +a126dd29c540 nexus3.onap.org:10001/mariadb:10.1.11 "/docker-entrypoint.…" 5 weeks ago Up 17 minutes 0.0.0.0:32768->3306/tcp docker-config_mariadb_1 + +Inspect a docker image +====================== +This command shows interesting information about the structure of the mso image. Note that an image is NOT a running container. It is the template that a container is created from. + +CMD:- +===== +sudo docker inspect onap/so/api-handler-infra + + +Example Output: + +.. code-block:: bash + + + [ + { + "Id": "sha256:2573165483e9ac87826da9c08984a9d0e1d93a90c681b22d9b4f90ed579350dc", + "RepoTags": [ + "onap/so/api-handler-infra:1.3.0-SNAPSHOT", + "onap/so/api-handler-infra:1.3.0-SNAPSHOT-20190213T0846", + "onap/so/api-handler-infra:1.3.0-SNAPSHOT-latest", + "onap/so/api-handler-infra:latest" + ], + "RepoDigests": [], + "Parent": "sha256:66b508441811ab4ed9968f8702a0d0a697f517bbc10d8d9076e5b98ae4437344", + "Comment": "", + "Created": "2019-02-13T09:37:33.770342225Z", + "Container": "8be46c735d21935631130f9017c3747779aab26eab54a9149b1edde122f7576d", + "ContainerConfig": { + "Hostname": "ac4a12e21390", + "Domainname": "", + "User": "", + "AttachStdin": false, + "AttachStdout": false, + "AttachStderr": false, + "Tty": false, + "OpenStdin": false, + "StdinOnce": false, + "Env": [ + "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin", + "LANG=C.UTF-8", + "JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk", + "JAVA_VERSION=8u191", + "JAVA_ALPINE_VERSION=8.191.12-r0", + "HTTP_PROXY=", + "HTTPS_PROXY=", + "http_proxy=", + "https_proxy=" + ], + "Cmd": [ + "/bin/sh", + "-c", + "#(nop) ", + "CMD [\"/app/start-app.sh\"]" + ], + "ArgsEscaped": true, + "Image": "sha256:66b508441811ab4ed9968f8702a0d0a697f517bbc10d8d9076e5b98ae4437344", + "Volumes": { + "/app/ca-certificates": {}, + "/app/config": {} + }, + "WorkingDir": "/app", + "Entrypoint": null, + "OnBuild": [], + "Labels": {} + }, + "DockerVersion": "17.05.0-ce", + "Author": "", + "Config": { + "Hostname": "ac4a12e21390", + "Domainname": "", + "User": "", + "AttachStdin": false, + "AttachStdout": false, + "AttachStderr": false, + "Tty": false, + "OpenStdin": false, + "StdinOnce": false, + "Env": [ + "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin", + "LANG=C.UTF-8", + "JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk", + "JAVA_VERSION=8u191", + "JAVA_ALPINE_VERSION=8.191.12-r0", + "HTTP_PROXY=", + "HTTPS_PROXY=", + "http_proxy=", + "https_proxy=" + ], + "Cmd": [ + "/app/start-app.sh" + ], + "ArgsEscaped": true, + "Image": "sha256:66b508441811ab4ed9968f8702a0d0a697f517bbc10d8d9076e5b98ae4437344", + "Volumes": { + "/app/ca-certificates": {}, + "/app/config": {} + }, + "WorkingDir": "/app", + "Entrypoint": null, + "OnBuild": [], + "Labels": {} + }, + "Architecture": "amd64", + "Os": "linux", + "Size": 245926705, + "VirtualSize": 245926705, + "GraphDriver": { + "Data": null, + "Name": "aufs" + }, + "RootFS": { + "Type": "layers", + "Layers": [ + "sha256:503e53e365f34399c4d58d8f4e23c161106cfbce4400e3d0a0357967bad69390", + "sha256:744b4cd8cf79c70508aace3697b6c3b46bee2c14f1c14b6ff09fd0ba5735c6d4", + "sha256:4c6899b75fdbea2f44efe5a2f8d9f5319c1cf7e87151de0de1014aba6ce71244", + "sha256:2e076d24f6d1277456e33e58fc8adcfd69dfd9c025f61aa7b98d500e7195beb2", + "sha256:bb67f2d5f8196c22137a9e98dd4190339a65c839822d16954070eeb0b2a17aa2", + "sha256:afbbd0cc43999d5c5b0ff54dfd82365a3feb826e5c857d9b4a7cf378001cd4b3", + "sha256:1920a7ca0f8ae38a79a1339ce742aaf3d7a095922d96e37074df67cf031d5035", + "sha256:1261fbaef67c5be677dae1c0f50394587832ea9d8c7dc105df2f3db6dfb92a3a", + "sha256:a33d8ee5c18908807458ffe643184228c21d3c5d5c5df1251f0f7dfce512f7e8", + "sha256:80704fca12eddb4cc638cee105637266e04ab5706b4e285d4fc6cac990e96d63", + "sha256:55abe39073a47f29aedba790a92c351501f21b3628414fa49a073c010ee747d1", + "sha256:cc4136c2c52ad522bd492545d4dd18265676ca690aa755994adf64943b119b28", + "sha256:2163a1f989859fdb3af6e253b74094e92a0fc1ee59f5eb959971f94eb1f98094" + ] + } + } + ] diff --git a/docs/developer_info/developer_information.rst b/docs/developer_info/developer_information.rst index a060da60b0..85e7010fcb 100644 --- a/docs/developer_info/developer_information.rst +++ b/docs/developer_info/developer_information.rst @@ -20,6 +20,7 @@ SO Developer Information BPMN_Subprocess_Process_Flows.rst BPMN_Project_Deployment_Strategy.rst BPMN-INFRA_Workflow_Understanding.rst + Docker-Config_Understanding.rst Mso_Openstack_Adapter.rst Cxf_Logging.rst instantiate/index.rst diff --git a/graph-inventory/fluent-builder-maven-plugin/pom.xml b/graph-inventory/fluent-builder-maven-plugin/pom.xml index 87f5138b4b..6e59d0d893 100644 --- a/graph-inventory/fluent-builder-maven-plugin/pom.xml +++ b/graph-inventory/fluent-builder-maven-plugin/pom.xml @@ -9,6 +9,36 @@ <artifactId>fluent-builder-maven-plugin</artifactId> <packaging>maven-plugin</packaging> <build> + <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-plugin-plugin</artifactId> + <goals> + <goal>descriptor</goal> + </goals> + <versionRange>[3.6.0,)</versionRange> + </pluginExecutionFilter> + <action> + <execute> + <runOnIncremental>false</runOnIncremental> + </execute> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index b09d676b57..7ed60384a5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -403,7 +403,7 @@ public class E2EServiceInstances { msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON, - null); + null, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -415,7 +415,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, - ModelType.service.name(), requestJSON, null); + ModelType.service.name(), requestJSON, null, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -493,7 +493,7 @@ public class E2EServiceInstances { msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON, - null); + null, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -505,7 +505,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, - ModelType.service.name(), requestJSON, null); + ModelType.service.name(), requestJSON, null, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -725,7 +725,7 @@ public class E2EServiceInstances { msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON, - null); + null, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -737,7 +737,7 @@ public class E2EServiceInstances { MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No recipe found in DB", action, - ModelType.service.name(), requestJSON, null); + ModelType.service.name(), requestJSON, null, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -958,7 +958,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, - ModelType.service.name(), requestJSON, null); + ModelType.service.name(), requestJSON, null, null); throw validateException; } 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 bf76cd3174..64c42a0498 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -451,7 +451,7 @@ public class MsoRequest { } public void createErrorRequestRecord(Status status, String requestId, String errorMessage, Actions action, - String requestScope, String requestJSON, String serviceInstanceId) { + String requestScope, String requestJSON, String serviceInstanceId, ServiceInstancesRequest sir) { try { InfraActiveRequests request = new InfraActiveRequests(requestId); Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); @@ -469,6 +469,17 @@ public class MsoRequest { Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); request.setEndTime(endTimeStamp); request.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); + if (sir != null) { + if (sir.getRequestDetails() != null && sir.getRequestDetails().getRequestInfo() != null) { + request.setRequestorId(sir.getRequestDetails().getRequestInfo().getRequestorId()); + request.setSource(sir.getRequestDetails().getRequestInfo().getSource()); + if (ModelType.service.name().equalsIgnoreCase(requestScope)) { + if (sir.getRequestDetails().getRequestInfo().getInstanceName() != null) { + request.setServiceInstanceName(sir.getRequestDetails().getRequestInfo().getInstanceName()); + } + } + } + } requestsDbClient.save(request); } catch (Exception e) { logger.error("Exception when updating record in DB", e); @@ -476,7 +487,6 @@ public class MsoRequest { } } - public Response buildResponse(int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { return buildResponseWithError(httpResponseCode, errorCode, inProgress, null); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java index 3f05c79dad..b1486c9686 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java @@ -88,9 +88,9 @@ import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; @Component -@Path("/onap/so/infra/onap3gppServiceInstances") -@OpenAPIDefinition(info = @Info(title = "/onap/so/infra/onap3gppServiceInstances", - description = "API Requests for 3GPP Service Instances")) +@Path("/onap/so/infra/3gppservices") +@OpenAPIDefinition( + info = @Info(title = "/onap/so/infra/3gppservices", description = "API Requests for 3GPP Service Instances")) public class Onap3gppServiceInstances { private static final Logger logger = LoggerFactory.getLogger(Onap3gppServiceInstances.class); @@ -101,7 +101,7 @@ public class Onap3gppServiceInstances { private static final String SAVE_TO_DB = "save instance to db"; - private static String uriPrefix = "/onap3gppServiceInstances/"; + private static final String URI_PREFIX = "/3gppservices/"; @Autowired private MsoRequest msoRequest; @@ -140,7 +140,7 @@ public class Onap3gppServiceInstances { @Context ContainerRequestContext requestContext) throws ApiException { String requestId = requestHandlerUtils.getRequestId(requestContext); return processServiceInstanceRequest(request, Action.createInstance, version, requestId, null, - requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX)); } /** @@ -161,7 +161,7 @@ public class Onap3gppServiceInstances { HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); return updateServiceInstances(request, Action.updateInstance, version, requestId, instanceIdMap, - requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX)); } /** @@ -183,7 +183,7 @@ public class Onap3gppServiceInstances { HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); return deleteServiceInstances(request, Action.deleteInstance, version, requestId, instanceIdMap, - requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX)); } /** @@ -204,7 +204,7 @@ public class Onap3gppServiceInstances { HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); return activateOrDeactivateServiceInstances(request, Action.activateInstance, version, requestId, instanceIdMap, - requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX)); } /** @@ -225,7 +225,7 @@ public class Onap3gppServiceInstances { HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", request.getServiceInstanceID()); return activateOrDeactivateServiceInstances(request, Action.deactivateInstance, version, requestId, - instanceIdMap, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + instanceIdMap, requestHandlerUtils.getRequestUri(requestContext, URI_PREFIX)); } /** 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 60e9c3b30a..cddb1ada31 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -326,7 +326,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { String requestScope = requestScopeFromUri(requestUri); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, - requestScope, requestJSON, null); + requestScope, requestJSON, null, null); throw validateException; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 2c8e92633c..7924ca304a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -830,7 +830,8 @@ public class ServiceInstances extends AbstractRestHandler { } catch (ApiException e) { msoRequest.createErrorRequestRecord(Status.FAILED, requestId, e.getMessage(), action, requestScope, requestJSON, requestHandlerUtils - .getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).orElse(null)); + .getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).orElse(null), + sir); throw e; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java index c3c92be013..95f00c3a39 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java @@ -55,9 +55,9 @@ import org.springframework.beans.factory.annotation.Autowired; public class Onap3gppServiceInstancesTest extends BaseTest { - private String onap3gppServicesUri = "/onap/so/infra/onap3gppServiceInstances/"; + private static final String ONAP3GPPSERVICES_URI = "/onap/so/infra/3gppservices/"; - private final ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper MAPPER = new ObjectMapper(); @Autowired private Onap3gppServiceInstances objUnderTest; @@ -74,11 +74,11 @@ public class Onap3gppServiceInstancesTest extends BaseTest { wireMockServer.stubFor(get(urlPathEqualTo("/service/search/findFirstByModelNameOrderByModelVersionDesc")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK))); + .withBody(MAPPER.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK))); wireMockServer.stubFor(get(urlPathEqualTo("/serviceRecipe/search/findFirstByServiceModelUUIDAndAction")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK))); + .withBody(MAPPER.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK))); wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK))); Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any()); @@ -107,7 +107,7 @@ public class Onap3gppServiceInstancesTest extends BaseTest { @Test public void createServiceInstanceTest() throws IOException { - String uri = onap3gppServicesUri + "v1/allocate"; + String uri = ONAP3GPPSERVICES_URI + "v1/allocate"; wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); @@ -123,7 +123,7 @@ public class Onap3gppServiceInstancesTest extends BaseTest { @Test public void updateServiceInstanceTest() throws IOException { - String uri = onap3gppServicesUri + "v1/modify"; + String uri = ONAP3GPPSERVICES_URI + "v1/modify"; wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); @@ -139,7 +139,7 @@ public class Onap3gppServiceInstancesTest extends BaseTest { @Test public void deleteServiceInstanceTest() throws IOException { - String uri = onap3gppServicesUri + "v1/deAllocate"; + String uri = ONAP3GPPSERVICES_URI + "v1/deAllocate"; wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); @@ -154,7 +154,7 @@ public class Onap3gppServiceInstancesTest extends BaseTest { @Test public void activateServiceInstanceTest() throws IOException { - String uri = onap3gppServicesUri + "v1/activate"; + String uri = ONAP3GPPSERVICES_URI + "v1/activate"; wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); @@ -169,7 +169,7 @@ public class Onap3gppServiceInstancesTest extends BaseTest { @Test public void deActivateServiceInstance() throws IOException { - String uri = onap3gppServicesUri + "v1/deActivate"; + String uri = ONAP3GPPSERVICES_URI + "v1/deActivate"; wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/commonNssmfTest")).willReturn( aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/BPMN_response.json") .withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); @@ -185,7 +185,7 @@ public class Onap3gppServiceInstancesTest extends BaseTest { @Test public void getSliceSubnetCapabilitiesTest() throws IOException, ApiException { String request = "{\"subnetTypes\":[\"AN\"]}"; - QuerySubnetCapability subnetCapabilityRequest = mapper.readValue(request, QuerySubnetCapability.class); + QuerySubnetCapability subnetCapabilityRequest = MAPPER.readValue(request, QuerySubnetCapability.class); String expectedResponse = "{\"AN\":{\"latency\":\"5\",\"maxNumberofUEs\":\"100\",\"maxThroughput\":\"150\",\"terminalDensity\":\"50\"}}"; Response response = objUnderTest.getSliceSubnetCapabilities(subnetCapabilityRequest, "v1"); diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 17b22ec216..9b42eacfc2 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -29,6 +29,7 @@ import javax.annotation.PostConstruct; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import org.apache.http.HttpStatus; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.db.request.beans.ArchivedInfraRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationStatus; @@ -42,6 +43,7 @@ import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus; import org.onap.so.db.request.beans.WatchdogDistributionStatus; import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup; import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; +import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Primary; @@ -297,17 +299,55 @@ public class RequestsDbClient { restTemplate.exchange(uri, HttpMethod.PATCH, entity, String.class); } + /** + * Required for groovy usage. Cannot use Spring Autowired variables + * + * @param requestId + * @param basicAuth + * @param host + * @return + */ public InfraActiveRequests getInfraActiveRequests(String requestId, String basicAuth, String host) { + RestTemplate template = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + headers.set(HttpHeaders.AUTHORIZATION, basicAuth); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); URI uri = getUri(host + "/infraActiveRequests/" + requestId); - - return getSingleResponse(uri, InfraActiveRequests.class); + try { + InfraActiveRequests infraActiveRequests = template + .exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), InfraActiveRequests.class).getBody(); + if (infraActiveRequests != null) { + infraActiveRequests.setRequestId(requestId); + } + return infraActiveRequests; + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return null; + } + throw e; + } } + /** + * Required for groovy usage. Cannot use Spring Autowired variables + * + * @param request + * @param basicAuth + * @param host + */ public void updateInfraActiveRequests(InfraActiveRequests request, String basicAuth, String host) { + RestTemplate template = new RestTemplate(); + template.getInterceptors().add(new SOSpringClientFilter()); + template.getInterceptors().add(new SpringClientPayloadFilter()); + HttpHeaders headers = new HttpHeaders(); + headers.set(HttpHeaders.AUTHORIZATION, basicAuth); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); URI uri = getUri(host + "/infraActiveRequests/" + request.getRequestId()); - HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, getHttpHeaders()); - restTemplate.put(uri, entity); + HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers); + template.put(uri, entity); } protected URI getUri(String uri) { diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java index d26ce84505..2e4623d25d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java @@ -83,7 +83,7 @@ public class PnfResourceCustomization implements Serializable { private String blueprintVersion; @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION") - private Boolean skipPostInstConf; + private boolean skipPostInstConf; @Column(name = "CONTROLLER_ACTOR") private String controllerActor; @@ -219,11 +219,11 @@ public class PnfResourceCustomization implements Serializable { this.blueprintVersion = blueprintVersion; } - public Boolean isSkipPostInstConf() { + public boolean isSkipPostInstConf() { return skipPostInstConf; } - public void setSkipPostInstConf(Boolean skipPostInstConf) { + public void setSkipPostInstConf(boolean skipPostInstConf) { this.skipPostInstConf = skipPostInstConf; } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java index f710890883..b39a85fb92 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java @@ -67,10 +67,10 @@ public class BeansTest { } private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new NoPrimitivesRule()) - .with(new NoNestedClassRule()).with(new NoStaticExceptFinalRule()) - .with(new SerializableMustHaveSerialVersionUIDRule()).with(new HasToStringRule()) - .with(new EqualsAndHashCodeTester()).with(new NoPublicFieldsExceptStaticFinalRule()) + Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new NoNestedClassRule()) + .with(new NoStaticExceptFinalRule()).with(new SerializableMustHaveSerialVersionUIDRule()) + .with(new HasToStringRule()).with(new EqualsAndHashCodeTester()) + .with(new NoPublicFieldsExceptStaticFinalRule()) .with(new CustomSetterMustExistRule() .exclude(allOf(hasAnnotationPropertyWithValue(Column.class, "updatable", equalTo(false)), hasAnnotation(GeneratedValue.class)), hasAnnotation(Temporal.class))) @@ -962,8 +962,74 @@ <dependency> <groupId>org.onap.aai.schema-service</groupId> <artifactId>aai-schema</artifactId> - <version>1.7.10-SNAPSHOT</version> + <version>1.7.10</version> </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-client</artifactId> + <version>${cxf.version}</version> + <exclusions> + <exclusion> + <groupId>org.jboss.spec.javax.rmi</groupId> + <artifactId>jboss-rmi-api_1.0_spec</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-bindings-soap</artifactId> + <version>${cxf.version}</version> + <exclusions> + <exclusion> + <groupId>org.jboss.spec.javax.rmi</groupId> + <artifactId>jboss-rmi-api_1.0_spec</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <version>${cxf.version}</version> + <exclusions> + <exclusion> + <groupId>org.jboss.spec.javax.rmi</groupId> + <artifactId>jboss-rmi-api_1.0_spec</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-spring-boot-starter-jaxws</artifactId> + <version>${cxf.version}</version> + <exclusions> + <exclusion> + <groupId>org.jboss.spec.javax.rmi</groupId> + <artifactId>jboss-rmi-api_1.0_spec</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> + <version>${cxf.version}</version> + <exclusions> + <exclusion> + <groupId>org.jboss.spec.javax.rmi</groupId> + <artifactId>jboss-rmi-api_1.0_spec</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-service-description-swagger</artifactId> + <version>${cxf.version}</version> + <exclusions> + <exclusion> + <groupId>org.jboss.spec.javax.rmi</groupId> + <artifactId>jboss-rmi-api_1.0_spec</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> </dependencyManagement> <profiles> diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/pom.xml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/pom.xml index a541117c93..272ac0c11a 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/pom.xml +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/pom.xml @@ -166,14 +166,8 @@ <version>${okhttp-version}</version> </dependency> <dependency> - <groupId>com.squareup.okhttp</groupId> - <artifactId>logging-interceptor</artifactId> - <version>${okhttp-version}</version> - </dependency> - <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> - <version>${jaxb-api}</version> </dependency> </dependencies> diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml index 1c13ecac25..3178b28502 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml @@ -102,5 +102,11 @@ <version>${hamcrest-version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>nl.jqno.equalsverifier</groupId> + <artifactId>equalsverifier</artifactId> + <version>${equalsverifier-version}</version> + <scope>test</scope> + </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java index 0dcadfd4d8..0901f077d2 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java @@ -31,10 +31,11 @@ import org.springframework.web.bind.annotation.ResponseStatus; public class NsRequestProcessingException extends RuntimeException { private static final long serialVersionUID = 66862444537194516L; - private InlineResponse400 problemDetails; + private final InlineResponse400 problemDetails; public NsRequestProcessingException(final String message) { super(message); + problemDetails = null; } public NsRequestProcessingException(final String message, final InlineResponse400 problemDetails) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java index 75dd7107a7..749e85e3db 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java @@ -25,7 +25,7 @@ import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model. import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.VnfPkgInfo; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.EtsiCatalogManagerRequestFailureException; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; -import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptorParser; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser.NetworkServiceDescriptorParser; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,9 +66,8 @@ public class EtsiCatalogPackageManagementServiceProviderImpl implements EtsiCata } return Optional.empty(); } catch (final Exception restProcessingException) { - logger.error("Caught exception while getting NS package model for: {}", nsdId, restProcessingException); - throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.", - restProcessingException); + final String message = "Caught exception while getting NS package model for: " + nsdId; + throw new EtsiCatalogManagerRequestFailureException(message, restProcessingException); } } @@ -82,9 +81,8 @@ public class EtsiCatalogPackageManagementServiceProviderImpl implements EtsiCata } return Optional.empty(); } catch (final Exception restProcessingException) { - logger.error("Caught exception while getting VNF package model for: {}", vnfPkgId, restProcessingException); - throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.", - restProcessingException); + final String message = "Caught exception while getting VNF package model for: " + vnfPkgId; + throw new EtsiCatalogManagerRequestFailureException(message, restProcessingException); } } @@ -101,9 +99,8 @@ public class EtsiCatalogPackageManagementServiceProviderImpl implements EtsiCata } return Optional.empty(); } catch (final Exception restProcessingException) { - logger.error("Caught exception while getting NS package content for: {}", nsdId, restProcessingException); - throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.", - restProcessingException); + final String message = "Caught exception while getting NS package content for: " + nsdId; + throw new EtsiCatalogManagerRequestFailureException(message, restProcessingException); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java index 8c6ea92428..7adf87adf4 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java @@ -69,11 +69,11 @@ import org.springframework.web.client.RestTemplate; @Configuration public class EtsiCatalogServiceProviderConfiguration { - public static final String ETSI_CATALOG_REST_TEMPLATE_BEAN = "etsiCatalogRestTemplate"; + private static final Logger LOGGER = LoggerFactory.getLogger(EtsiCatalogServiceProviderConfiguration.class); public static final String ETSI_CATALOG_SERVICE_PROVIDER_BEAN = "etsiCatalogServiceProvider"; - private final static Logger LOGGER = LoggerFactory.getLogger(EtsiCatalogServiceProviderConfiguration.class); + public static final String ETSI_CATALOG_REST_TEMPLATE_BEAN = "etsiCatalogRestTemplate"; private final HttpClientConnectionConfiguration clientConnectionConfiguration; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java index e3c159c7b0..54f6ad6543 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogUrlProvider.java @@ -33,8 +33,6 @@ public class EtsiCatalogUrlProvider { @Value("${etsi-catalog-manager.base.endpoint}") private String etsiCatalogManagerEndpoint; - public EtsiCatalogUrlProvider() {} - public String getNsPackageUrl(final String nsdId) { return etsiCatalogManagerEndpoint + "/nsd/v1/ns_descriptors/" + nsdId; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java index fe710ec00b..6776d8ba0b 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterConfiguration.java @@ -73,20 +73,20 @@ public class Sol003AdapterConfiguration { @Value("${rest.http.client.configuration.ssl.trustStorePassword:#{null}}") private String trustStorePassword; - @Value("so.adapters.sol003-adapter.auth:Basic dm5mbTpwYXNzd29yZDEk") + @Value("${so.adapters.sol003-adapter.auth:Basic dm5mbTpwYXNzd29yZDEk}") private String sol003AdapterBasicAuth; @Autowired private GsonProvider gsonProvider; - @Autowired - private HttpComponentsClientConfiguration httpComponentsClientConfiguration; - @Bean @Qualifier(SOL003_ADAPTER_REST_TEMPLATE_BEAN) - public RestTemplate sol003AdapterRestTemplate() { + public RestTemplate sol003AdapterRestTemplate( + @Autowired final HttpComponentsClientConfiguration httpComponentsClientConfiguration) { + final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = httpComponentsClientConfiguration.httpComponentsClientHttpRequestFactory(); + final RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(clientHttpRequestFactory)); restTemplate.getInterceptors().add(new SOSpringClientFilter()); @@ -114,7 +114,7 @@ public class Sol003AdapterConfiguration { final HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient); restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); - } catch (Exception exception) { + } catch (final Exception exception) { logger.error("Error reading truststore, TLS connection to VNFM will fail.", exception); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java index a0798f6e55..df3a0c2e31 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/vnfm/Sol003AdapterServiceProviderImpl.java @@ -22,6 +22,7 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm; import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterConfiguration.SOL003_ADAPTER_HTTP_REST_SERVICE_PROVIDER_BEAN; import java.util.Optional; +import org.apache.commons.lang3.StringUtils; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse; @@ -76,7 +77,7 @@ public class Sol003AdapterServiceProviderImpl implements Sol003AdapterServicePro final CreateVnfResponse createVnfResponse = response.getBody(); - if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) { + if (StringUtils.isBlank(createVnfResponse.getJobId())) { LOGGER.error("Received invalid instantiation response: {}", response); return Optional.empty(); } @@ -134,7 +135,7 @@ public class Sol003AdapterServiceProviderImpl implements Sol003AdapterServicePro } final DeleteVnfResponse deleteVnfResponse = response.getBody(); - if (deleteVnfResponse.getJobId() == null || deleteVnfResponse.getJobId().isEmpty()) { + if (StringUtils.isBlank(deleteVnfResponse.getJobId())) { LOGGER.error("Received invalid terminate response: {}", response); return Optional.empty(); } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java index 58ca2507bd..cfe5b94859 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java @@ -22,6 +22,7 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.Arrays; import java.util.Objects; /** @@ -82,7 +83,7 @@ public class FileEntry { @Override public int hashCode() { - return Objects.hash(isDirectory, filePath, fileContent); + return Objects.hash(isDirectory, filePath) + Arrays.hashCode(fileContent); } @Override @@ -90,7 +91,7 @@ public class FileEntry { if (obj instanceof FileEntry) { final FileEntry other = (FileEntry) obj; return Objects.equals(isDirectory, other.isDirectory) && Objects.equals(filePath, other.filePath) - && Objects.equals(fileContent, other.fileContent); + && Arrays.equals(fileContent, other.fileContent); } return false; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/FileParser.java index 9df5262302..2a37922e9b 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/FileParser.java @@ -17,9 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import java.util.Map; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; /** * @author Waqas Ikram (waqas.ikram@est.tech) diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParser.java index 33737f4c17..cc92234750 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParser.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -31,6 +31,10 @@ import java.util.Optional; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.apache.commons.io.IOUtils; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.ToscaMetadata; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.VirtualNetworkFunction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -79,7 +83,7 @@ public class NetworkServiceDescriptorParser { final Map<String, Object> nodeTemplates = getNodeTemplates(topologyTemplates); final Optional<NetworkServiceDescriptor> nsdOptional = - getNetworkServiceDescriptor(topologyTemplates);; + getNetworkServiceDescriptor(topologyTemplates); if (nsdOptional.isPresent()) { final NetworkServiceDescriptor networkServiceDescriptor = nsdOptional.get(); networkServiceDescriptor.setVnfs(getVirtualNetworkFunctions(nodeTemplates)); @@ -91,10 +95,10 @@ public class NetworkServiceDescriptorParser { } + logger.error("Unable to find {} file in {}", TOSCA_META_PATH_FILE_NAME, files); } catch (final Exception exception) { - logger.error("Unable to parser nsd zip content", exception); + logger.error("Unable to parse nsd zip content", exception); } - logger.error("Unable to parser nsd zip content"); return Optional.empty(); } @@ -104,7 +108,7 @@ public class NetworkServiceDescriptorParser { final Map<String, Object> substitutionMappings = (Map<String, Object>) topologyTemplates.get(SUBSTITUTION_MAPPINGS); final Object nodeType = substitutionMappings.get(NODE_TYPE); - if (substitutionMappings != null && nodeType != null && NS_NODE_TYPE.equals(nodeType)) { + if (substitutionMappings != null && NS_NODE_TYPE.equals(nodeType)) { final NetworkServiceDescriptor networkServiceDescriptor = new NetworkServiceDescriptor(); networkServiceDescriptor.setType(nodeType.toString()); networkServiceDescriptor.setProperties((Map<String, Object>) substitutionMappings.get(PROPERTIES)); @@ -191,7 +195,7 @@ public class NetworkServiceDescriptorParser { } return files; } catch (final Exception exception) { - logger.error("Unable to parser nsd zip content", exception); + logger.error("Unable to parse nsd zip content", exception); return Collections.emptyMap(); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadataParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/ToscaMetadataParser.java index fe23f5ef8d..746416c8e4 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadataParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/ToscaMetadataParser.java @@ -17,12 +17,15 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.util.List; import java.util.Optional; import org.apache.commons.io.IOUtils; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.ToscaMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -39,7 +42,7 @@ public class ToscaMetadataParser { public Optional<ToscaMetadata> parse(final FileEntry toscaMetaFile) { try { final ToscaMetadata toscaMetadata = new ToscaMetadata(); - final List<String> lines = IOUtils.readLines(toscaMetaFile.getFileContentAsStream(), "utf-8"); + final List<String> lines = IOUtils.readLines(toscaMetaFile.getFileContentAsStream(), UTF_8); for (final String line : lines) { final String trimmedLine = line.trim(); if (!trimmedLine.isEmpty() && trimmedLine.contains(ATTRIBUTE_VALUE_SEPARATOR)) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/YamlFileParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/YamlFileParser.java index ac8f782a99..eab6974252 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/YamlFileParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/YamlFileParser.java @@ -17,9 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import java.util.Map; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; import org.springframework.stereotype.Service; import org.yaml.snakeyaml.Yaml; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java index 5e5e51cee0..49118494cf 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/service/JobExecutorService.java @@ -164,7 +164,7 @@ public class JobExecutorService { final LocalDateTime currentDateTime = LocalDateTime.now(); final NsLcmOpOcc newNsLcmOpOcc = new NsLcmOpOcc().id(nsInstanceId).operation(NsLcmOpType.INSTANTIATE) .operationState(OperationStateEnum.PROCESSING).stateEnteredTime(currentDateTime) - .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInnovation(false) + .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInvocation(false) .isCancelPending(false).operationParams(gson.toJson(instantiateNsRequest)); databaseServiceProvider.addNSLcmOpOcc(newNsLcmOpOcc); logger.info("New NSLcmOpOcc created in database :\n{}", newNsLcmOpOcc); @@ -209,7 +209,7 @@ public class JobExecutorService { final LocalDateTime currentDateTime = LocalDateTime.now(); final NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc().id(nsInstanceId).operation(NsLcmOpType.TERMINATE) .operationState(OperationStateEnum.PROCESSING).stateEnteredTime(currentDateTime) - .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInnovation(false) + .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInvocation(false) .isCancelPending(false).operationParams(gson.toJson(terminateNsRequest)); databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc); logger.info("New NSLcmOpOcc created in database :\n{}", nsLcmOpOcc); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java index d23e81201c..e94b3de81e 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java @@ -48,10 +48,20 @@ public abstract class AbstractNetworkServiceTask { private final Logger logger = LoggerFactory.getLogger(getClass()); protected final DatabaseServiceProvider databaseServiceProvider; - public AbstractNetworkServiceTask(final DatabaseServiceProvider jobServiceProvider) { + protected AbstractNetworkServiceTask(final DatabaseServiceProvider jobServiceProvider) { this.databaseServiceProvider = jobServiceProvider; } + public void addJobStatus(final DelegateExecution execution, final JobStatusEnum jobStatus, + final String description) { + final NfvoJobStatus nfvoJobStatus = + new NfvoJobStatus().status(jobStatus).description(description).updatedTime(LocalDateTime.now()); + logger.info("Adding NfvoJobStatus {}", nfvoJobStatus); + final NfvoJob nfvoJob = getNfvoJob(execution); + nfvoJob.nfvoJobStatus(nfvoJobStatus); + databaseServiceProvider.addJob(nfvoJob); + } + public void setJobStatus(final DelegateExecution execution, final JobStatusEnum jobStatus, final String description) { logger.info("Setting Job Status to {}", jobStatus); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java index bfeaf49daa..600792acc0 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java @@ -47,6 +47,7 @@ import org.springframework.stereotype.Component; */ @Component public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { + private static final String CREATE_INSTANTIATE_REQUEST_PARAM_NAME = "request"; private static final Logger logger = LoggerFactory.getLogger(CreateInstantiateVnfTask.class); private static final String NF_INST_ID_PARAM_NAME = "NF_INST_ID"; public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse"; @@ -64,10 +65,11 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { public void checkIfNfInstanceExistsInDb(final DelegateExecution execution) { logger.info("Executing checkIfNfInstanceInDb"); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); - setJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NF Instance record exists in database for " + addJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NF Instance record exists in database for " + request.getNsInstId() + " and " + request.getVnfName()); if (!databaseServiceProvider.isNsInstExists(request.getNsInstId(), request.getVnfName())) { abortOperation(execution, @@ -79,10 +81,11 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { public void createNfInstanceInDb(final DelegateExecution execution) { logger.info("Executing createNfInstanceInDb"); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); - setJobStatus(execution, IN_PROGRESS, "Creating NF Instance record in database for " + request.getVnfName()); + addJobStatus(execution, IN_PROGRESS, "Creating NF Instance record in database for " + request.getVnfName()); final Optional<NfvoNsInst> optional = databaseServiceProvider.getNfvoNsInst(request.getNsInstId()); @@ -104,9 +107,10 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { public void createGenericVnfInAai(final DelegateExecution execution) { logger.info("Executing createGenericVnfInAai"); try { - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, "Creating GenericVnf record in AAI for " + request.getVnfName()); + addJobStatus(execution, IN_PROGRESS, "Creating GenericVnf record in AAI for " + request.getVnfName()); final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); @@ -140,10 +144,11 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing invokeCreateInstantiationRequest"); try { - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); - setJobStatus(execution, IN_PROGRESS, + addJobStatus(execution, IN_PROGRESS, "Invoking SOL003 adapter for creating and instantiating VNF: " + request.getVnfName()); final CreateVnfRequest vnfRequest = new CreateVnfRequest(); @@ -165,7 +170,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Vnf instantiation response: {}", vnfResponse); execution.setVariable(CREATE_VNF_RESPONSE_PARAM_NAME, vnfResponse); - setJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapater creating and instantiating VNF: " + addJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapater creating and instantiating VNF: " + request.getVnfName() + " CreaetVnfResponse Job Id: " + vnfResponse.getJobId()); logger.debug("Finished executing invokeCreateInstantiationRequest ..."); } catch (final Exception exception) { @@ -180,8 +185,9 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing updateNfInstanceStatusToInstantiated"); updateNfInstanceStatus(execution, State.INSTANTIATED); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); - setJobStatus(execution, FINISHED, "Successfully created and Instantiated VNF: " + request.getVnfName() + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); + addJobStatus(execution, FINISHED, "Successfully created and Instantiated VNF: " + request.getVnfName() + " will set status to " + State.INSTANTIATED); logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); @@ -192,8 +198,9 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing updateNfInstanceStatusToActive"); updateNfInstanceStatus(execution, State.FAILED); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); - setJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName() + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); + addJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName() + " will set status to " + State.FAILED); logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); @@ -202,14 +209,11 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) { final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); - final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(nfInstId); - if (!optional.isPresent()) { + if (optional.isEmpty()) { final String message = "Unable to find NfvoNfInst record in database using nfInstId: " + nfInstId; logger.error(message); - abortOperation(execution, message); - } final NfvoNfInst nfvoNfInst = optional.get(); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java index 1d9e09e74b..a6d35e301e 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java @@ -240,12 +240,20 @@ public class InstantiateNsTask extends AbstractNetworkServiceTask { final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId); - final String nsPackageId = nfvoNsInst.getNsPackageId(); - final NsdInfo nsdInfo = getNsdInfo(execution, nsPackageId); final Map<String, String> vnfdIdToVnfPkgIdMapping = new HashMap<>(); try { + final Optional<NsdInfo> nsdInfoOptional = + etsiCatalogPackageManagementServiceProvider.getNSPackageModel(nsPackageId); + + if (nsdInfoOptional.isEmpty()) { + final String message = "Unable to find NS package using NS package id: " + nsPackageId; + logger.error(message); + abortOperation(execution, message); + } + + final NsdInfo nsdInfo = nsdInfoOptional.get(); for (final String vnfPkgId : nsdInfo.getVnfPkgIds()) { final Optional<VnfPkgInfo> optional = etsiCatalogPackageManagementServiceProvider.getVnfPkgInfo(vnfPkgId); @@ -290,34 +298,8 @@ public class InstantiateNsTask extends AbstractNetworkServiceTask { setJobStatusToError(execution, "Instantiate NS workflow process failed"); } - private NsdInfo getNsdInfo(final DelegateExecution execution, final String nsPackageId) { - try { - final Optional<NsdInfo> optional = - etsiCatalogPackageManagementServiceProvider.getNSPackageModel(nsPackageId); - - if (optional.isPresent()) { - final NsdInfo packageModel = optional.get(); - logger.info("NS Package exists {}", packageModel); - return packageModel; - } - - } catch (final EtsiCatalogManagerRequestFailureException failureException) { - final String message = - "Unexpected exception occured while getting ns package using nsPackageId: " + nsPackageId; - logger.error(message, failureException); - - abortOperation(execution, message); - } - - final String message = "Unable to find NS package using NS package id: " + nsPackageId; - logger.error(message); - abortOperation(execution, message); - return null; - - } - private Optional<Tenant> getTenant(final Map<String, String> additionalParams) { - final String vimId = (String) additionalParams.get("vim_id"); + final String vimId = additionalParams.get("vim_id"); if (vimId != null) { final String[] splitString = vimId.split("_"); if (splitString.length == 3) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java index e4dc3d5e07..001c369801 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/MonitorSol003AdapterNodeTask.java @@ -37,7 +37,7 @@ public abstract class MonitorSol003AdapterNodeTask extends AbstractNetworkServic private static final Logger LOGGER = LoggerFactory.getLogger(MonitorSol003AdapterNodeTask.class); private final AaiServiceProvider aaiServiceProvider; - public MonitorSol003AdapterNodeTask(final DatabaseServiceProvider databaseServiceProvider, + protected MonitorSol003AdapterNodeTask(final DatabaseServiceProvider databaseServiceProvider, final AaiServiceProvider aaiServiceProvider) { super(databaseServiceProvider); this.aaiServiceProvider = aaiServiceProvider; @@ -56,7 +56,7 @@ public abstract class MonitorSol003AdapterNodeTask extends AbstractNetworkServic LOGGER.debug("Query A&AI for generic VNF using vnfID: {}", vnfId); final Optional<GenericVnf> aaiGenericVnfOptional = aaiServiceProvider.getGenericVnf(vnfId); - if (!aaiGenericVnfOptional.isPresent()) { + if (aaiGenericVnfOptional.isEmpty()) { abortOperation(execution, "Unable to find generic vnf in A&AI using vnfId" + vnfId); } final GenericVnf genericVnf = aaiGenericVnfOptional.get(); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java index 2baa2845a5..c0d1df8c50 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java @@ -109,9 +109,8 @@ public class TerminateNsTask extends AbstractNetworkServiceTask { final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); final List<NfvoNfInst> nfInstances = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId); if (nfInstances != null) { - nfInstances.stream().forEach(instance -> { - logger.info("Current status {} of vnf: {}", instance.getStatus(), instance.getName()); - }); + nfInstances.stream().forEach( + instance -> logger.info("Current status {} of vnf: {}", instance.getStatus(), instance.getName())); } } @@ -120,16 +119,14 @@ public class TerminateNsTask extends AbstractNetworkServiceTask { logger.info("Getting NfvoNfInstList using nsInstId: {}", nsInstId); final List<NfvoNfInst> nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId); - if (nfvoNfInstList.size() == 0) { + if (nfvoNfInstList == null || nfvoNfInstList.isEmpty()) { final String message = "Unable to find NF Instances in database using id: " + nsInstId; abortOperation(execution, message); } final List<String> vnfIdsList = new ArrayList<>(); - nfvoNfInstList.stream().forEach(nfvoNfInst -> { - vnfIdsList.add(nfvoNfInst.getNfInstId()); - }); + nfvoNfInstList.stream().forEach(nfvoNfInst -> vnfIdsList.add(nfvoNfInst.getNfInstId())); return vnfIdsList; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java index 15eee22dd2..049a6f38b0 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java @@ -19,6 +19,13 @@ */ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.DELETE_VNF_RESPONSE_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NF_INST_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.TERMINATE_VNF_VNFID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.ERROR; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS; +import java.util.Optional; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider; @@ -31,13 +38,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Optional; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NF_INST_ID_PARAM_NAME; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.DELETE_VNF_RESPONSE_PARAM_NAME; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.TERMINATE_VNF_VNFID_PARAM_NAME; -import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.ERROR; -import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED; -import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS; /** * @author Andrew Lamb (andrew.a.lamb@est.tech) @@ -63,7 +63,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { logger.info("vnfId: {}", vnfId); execution.setVariable(NF_INST_ID_PARAM_NAME, vnfId); - setJobStatus(execution, JobStatusEnum.IN_PROGRESS, + addJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if VNF Instance with id: " + vnfId + " exists in database."); if (!databaseServiceProvider.isNfInstExists(vnfId)) { abortOperation(execution, @@ -78,7 +78,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); try { - setJobStatus(execution, IN_PROGRESS, "Invoking SOL003 adapter for terminating VNF with vnfId: " + vnfId); + addJobStatus(execution, IN_PROGRESS, "Invoking SOL003 adapter for terminating VNF with vnfId: " + vnfId); final Optional<DeleteVnfResponse> optional = sol003AdapterServiceProvider.invokeTerminationRequest(vnfId); @@ -92,7 +92,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { logger.info("Vnf delete response: {}", vnfResponse); execution.setVariable(DELETE_VNF_RESPONSE_PARAM_NAME, vnfResponse); - setJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapter terminate VNF with vnfId: " + addJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapter terminate VNF with vnfId: " + vnfId + " DeleteVnfResponse Job Id: " + vnfResponse.getJobId()); logger.debug("Finished executing invokeTerminateRequest ..."); } catch (final Exception exception) { @@ -108,7 +108,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); try { - setJobStatus(execution, IN_PROGRESS, "Deleting GenericVnf record from AAI for vnfId: " + vnfId); + addJobStatus(execution, IN_PROGRESS, "Deleting GenericVnf record from AAI for vnfId: " + vnfId); aaiServiceProvider.deleteGenericVnf(vnfId); } catch (final Exception exception) { @@ -124,10 +124,10 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing deleteNfInstanceFromDb"); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, "Deleting NF Instance record from Database for vnfId: " + vnfId); + addJobStatus(execution, IN_PROGRESS, "Deleting NF Instance record from Database for vnfId: " + vnfId); databaseServiceProvider.deleteNfvoNfInst(vnfId); - setJobStatus(execution, FINISHED, "Successfully finished terminating VNF with vnfId: " + vnfId); + addJobStatus(execution, FINISHED, "Successfully finished terminating VNF with vnfId: " + vnfId); logger.info("Finished executing deleteNfInstanceFromDb ..."); } @@ -136,7 +136,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.TERMINATING); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, + addJobStatus(execution, IN_PROGRESS, "Terminating VNF with vnfId: " + vnfId + " will set status to " + State.TERMINATING); logger.info("Finished executing updateNfInstanceStatusToTerminating ..."); @@ -148,7 +148,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.NOT_INSTANTIATED); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, + addJobStatus(execution, IN_PROGRESS, "Successfully terminated VNF with vnfId: " + vnfId + " will set status to " + State.NOT_INSTANTIATED); logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); @@ -160,7 +160,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.FAILED); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, ERROR, + addJobStatus(execution, ERROR, "Failed to terminate VNF with vnfId: " + vnfId + " will set status to " + State.FAILED); logger.info("Finished executing updateNfInstanceStatusToFailed ..."); @@ -174,9 +174,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { if (optional.isEmpty()) { final String message = "Unable to find NfvoNfInst record in database using vnfId: " + vnfId; logger.error(message); - abortOperation(execution, message); - } final NfvoNfInst nfvoNfInst = optional.get(); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java index 34959ee0f0..9f21d2b449 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java @@ -24,6 +24,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; /** @@ -45,14 +46,14 @@ public class LocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> { @Override public LocalDateTime read(final JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - final String dateTime = in.nextString(); - return LocalDateTime.parse(dateTime, FORMATTER); + if (JsonToken.NULL == in.peek()) { + in.nextNull(); + return null; + } + final String dateTime = in.nextString(); + return LocalDateTime.parse(dateTime, FORMATTER); + } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/PojoClassesTests.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/PojoClassesTests.java new file mode 100644 index 0000000000..edfb20afd2 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/PojoClassesTests.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + +import java.util.Arrays; +import java.util.List; +import org.junit.Test; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.ToscaMetadata; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.VirtualNetworkFunction; +import org.onap.so.openpojo.rules.ToStringTester; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class PojoClassesTests { + + @Test + public void test_nsd_parser_pojo_classes() throws ClassNotFoundException { + + final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()) + .with(new ToStringTester()).build(); + validator.validate(FileEntry.class.getPackageName(), new FilterPackageInfo()); + } + + + @Test + public void test_nsd_parser_pojo_classes_equalAndHashMethod() throws ClassNotFoundException { + final List<Class<?>> classes = Arrays.asList(FileEntry.class, NetworkServiceDescriptor.class, + ToscaMetadata.class, VirtualNetworkFunction.class); + for (final Class<?> clazz : classes) { + EqualsVerifier.forClass(clazz).suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, + Warning.INHERITED_DIRECTLY_FROM_OBJECT).verify(); + } + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParserTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParserTest.java index 2bebf1c30a..4a8c715e5c 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParserTest.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParserTest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -31,6 +31,8 @@ import java.util.Optional; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.TestApplication; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser.NetworkServiceDescriptorParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/WebSecurityConfig.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/CancelModeType.java index dfb2b61978..627250535e 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/WebSecurityConfig.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/CancelModeType.java @@ -1,8 +1,6 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,23 +13,16 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ +package org.onap.so.etsi.nfvo.ns.lcm.database.beans; -package org.onap.so.adapters.nssmf.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@EnableWebSecurity -@Configuration -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable(); - } - +/** + * @author Andrew Lamb (andrew.a.lamb@est.tech) + * + */ +public enum CancelModeType { + GRACEFUL, FORCEFUL; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java index ce2487ea9d..60b06e1061 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java @@ -42,24 +42,24 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils; public class NfvoJob { @Id - @Column(name = "JOB_ID") + @Column(name = "JOB_ID", nullable = false) private String jobId; - @Column(name = "JOB_TYPE") + @Column(name = "JOB_TYPE", nullable = false) private String jobType; @Enumerated(EnumType.STRING) - @Column(name = "JOB_ACTION") + @Column(name = "JOB_ACTION", nullable = false) private JobAction jobAction; - @Column(name = "RESOURCE_ID") + @Column(name = "RESOURCE_ID", nullable = false) private String resourceId; @Column(name = "RESOURCE_NAME") private String resourceName; @Enumerated(EnumType.STRING) - @Column(name = "STATUS") + @Column(name = "STATUS", nullable = false) private JobStatusEnum status; @Column(name = "START_TIME") diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java index be673b47fa..66ae0e503c 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java @@ -44,17 +44,17 @@ public class NfvoJobStatus { private int id; @Enumerated(EnumType.STRING) - @Column(name = "STATUS") + @Column(name = "STATUS", nullable = false) private JobStatusEnum status; @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT") private String description; - @Column(name = "UPDATED_TIME") + @Column(name = "UPDATED_TIME", nullable = false) private LocalDateTime updatedTime; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "JOB_ID") + @JoinColumn(name = "JOB_ID", nullable = false) private NfvoJob nfvoJob; public int getId() { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java index e685781308..570355fb37 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java @@ -41,7 +41,7 @@ import javax.persistence.Table; public class NfvoNfInst { @Id - @Column(name = "NF_INST_ID") + @Column(name = "NF_INST_ID", nullable = false) private String nfInstId; @Column(name = "NAME") @@ -54,11 +54,11 @@ public class NfvoNfInst { private String packageId; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "NS_INST_ID") + @JoinColumn(name = "NS_INST_ID", nullable = false) private NfvoNsInst nsInst; @Enumerated(EnumType.STRING) - @Column(name = "STATUS") + @Column(name = "STATUS", nullable = false) private State status; @Column(name = "CREATE_TIME") diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java index 146e5512fc..04f988c2fc 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java @@ -44,29 +44,29 @@ import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndented public class NfvoNsInst { @Id - @Column(name = "NS_INST_ID") + @Column(name = "NS_INST_ID", nullable = false) private String nsInstId; - @Column(name = "NAME") + @Column(name = "NAME", nullable = false) private String name; @Column(name = "NS_PACKAGE_ID") private String nsPackageId; - @Column(name = "NSD_ID") + @Column(name = "NSD_ID", nullable = false) private String nsdId; - @Column(name = "NSD_INVARIANT_ID") + @Column(name = "NSD_INVARIANT_ID", nullable = false) private String nsdInvariantId; @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT") private String description; @Enumerated(EnumType.STRING) - @Column(name = "STATUS") + @Column(name = "STATUS", nullable = false) private State status; - @Column(name = "STATUS_UPDATED_TIME") + @Column(name = "STATUS_UPDATED_TIME", nullable = false) private LocalDateTime statusUpdatedTime; @Column(name = "GLOBAL_CUSTOMER_ID") diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java index 7668ed272d..4846e5a361 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java @@ -41,11 +41,11 @@ import javax.persistence.Table; public class NsLcmOpOcc { @Id - @Column(name = "ID") + @Column(name = "ID", nullable = false) private String id; @Enumerated(EnumType.STRING) - @Column(name = "OPERATION_STATE") + @Column(name = "OPERATION_STATE", nullable = false) private OperationStateEnum operationState; @Column(name = "STATE_ENTERED_TIME") @@ -55,22 +55,26 @@ public class NsLcmOpOcc { private LocalDateTime startTime; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "NS_INST_ID") + @JoinColumn(name = "NS_INST_ID", nullable = false) private NfvoNsInst nfvoNsInst; @Enumerated(EnumType.STRING) - @Column(name = "OPERATION") + @Column(name = "OPERATION", nullable = false) private NsLcmOpType operation; - @Column(name = "IS_AUTO_INNOVATION") - private boolean isAutoInnovation; + @Column(name = "IS_AUTO_INVOCATION", nullable = false) + private boolean isAutoInvocation; - @Column(name = "OPERATION_PARAMS", columnDefinition = "LONGTEXT") + @Column(name = "OPERATION_PARAMS", columnDefinition = "LONGTEXT", nullable = false) private String operationParams; - @Column(name = "IS_CANCEL_PENDING") + @Column(name = "IS_CANCEL_PENDING", nullable = false) private boolean isCancelPending; + @Enumerated(EnumType.STRING) + @Column(name = "CANCEL_MODE") + private CancelModeType cancelMode; + public NsLcmOpOcc() { this.id = UUID.randomUUID().toString(); } @@ -153,16 +157,29 @@ public class NsLcmOpOcc { return this; } - public boolean getIsAutoInnovation() { - return isAutoInnovation; + public boolean getIsAutoInvocation() { + return isAutoInvocation; + } + + public void setIsAutoInvocation(final boolean isAutoInvocation) { + this.isAutoInvocation = isAutoInvocation; + } + + public NsLcmOpOcc isAutoInvocation(final boolean isAutoInvocation) { + this.isAutoInvocation = isAutoInvocation; + return this; + } + + public CancelModeType getCancelMode() { + return cancelMode; } - public void setIsAutoInnovation(final boolean isAutoInnovation) { - this.isAutoInnovation = isAutoInnovation; + public void setCancelMode(final CancelModeType cancelMode) { + this.cancelMode = cancelMode; } - public NsLcmOpOcc isAutoInnovation(final boolean isAutoInnovation) { - this.isAutoInnovation = isAutoInnovation; + public NsLcmOpOcc cancelMode(final CancelModeType cancelMode) { + this.cancelMode = cancelMode; return this; } @@ -203,16 +220,16 @@ public class NsLcmOpOcc { && Objects.equals(stateEnteredTime, that.stateEnteredTime) && Objects.equals(startTime, that.startTime) && (nfvoNsInst == null ? that.nfvoNsInst == null : that.nfvoNsInst != null && Objects.equals(nfvoNsInst, that.nfvoNsInst)) - && Objects.equals(operation, that.operation) && Objects.equals(isAutoInnovation, that.isAutoInnovation) + && Objects.equals(operation, that.operation) && Objects.equals(isAutoInvocation, that.isAutoInvocation) && Objects.equals(operationParams, that.operationParams) - && Objects.equals(isCancelPending, that.isCancelPending); + && Objects.equals(isCancelPending, that.isCancelPending) && Objects.equals(cancelMode, that.cancelMode); } @Override public int hashCode() { return Objects.hash(id, operationState, stateEnteredTime, startTime, - nfvoNsInst != null ? nfvoNsInst.getNsInstId() : 0, operation, isAutoInnovation, operationParams, - isCancelPending); + nfvoNsInst != null ? nfvoNsInst.getNsInstId() : 0, operation, isAutoInvocation, operationParams, + isCancelPending, cancelMode); } @Override @@ -226,9 +243,10 @@ public class NsLcmOpOcc { sb.append(" nfvoNsInst: ").append(nfvoNsInst != null ? toIndentedString(nfvoNsInst.getNsInstId()) : null) .append("\n"); sb.append(" operation: ").append(toIndentedString(operation)).append("\n"); - sb.append(" isAutoInnovation: ").append(toIndentedString(isAutoInnovation)).append("\n"); + sb.append(" isAutoInvocation: ").append(toIndentedString(isAutoInvocation)).append("\n"); sb.append(" operationParams: ").append(toIndentedString(operationParams)).append("\n"); sb.append(" isCancelPending: ").append(toIndentedString(isCancelPending)).append("\n"); + sb.append(" cancelMode: ").append(toIndentedString(cancelMode)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql index f41a8206e0..85a732b83e 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql @@ -64,9 +64,10 @@ CREATE TABLE IF NOT EXISTS `NS_LCM_OP_OCCS` ( `START_TIME` DATETIME DEFAULT NULL, `NS_INST_ID` varchar(255) NOT NULL, `OPERATION` varchar(255) NOT NULL, - `IS_AUTO_INNOVATION` varchar(255) NOT NULL, + `IS_AUTO_INVOCATION` varchar(255) NOT NULL, `OPERATION_PARAMS` longtext NOT NULL, `IS_CANCEL_PENDING` varchar(255) NOT NULL, + `CANCEL_MODE` varchar(255) DEFAULT NULL, PRIMARY KEY (`ID`), FOREIGN KEY (NS_INST_ID) REFERENCES NS_INST(NS_INST_ID) diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java index 8070036791..fcf7f9c373 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java @@ -164,7 +164,7 @@ public class DatabaseServiceProviderTest { databaseServiceProvider.saveNfvoNsInst(nsInst); final NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc().nfvoNsInst(nsInst).operationState(OperationStateEnum.PROCESSING) - .isCancelPending(false).isAutoInnovation(false).operation(NsLcmOpType.INSTANTIATE) + .isCancelPending(false).isAutoInvocation(false).operation(NsLcmOpType.INSTANTIATE) .startTime(CURRENT_DATE_TIME).stateEnteredTime(CURRENT_DATE_TIME).operationParams(""); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLcmOperationOccurrenceManager.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLcmOperationOccurrenceManager.java new file mode 100644 index 0000000000..8a5cee6d75 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/lifecycle/NsLcmOperationOccurrenceManager.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.lifecycle; + +import static org.slf4j.LoggerFactory.getLogger; +import org.onap.so.etsi.nfvo.ns.lcm.EtsiSoNsLcmManagerUrlProvider; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstanceLinksSelf; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsLcmOpOccsNsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsLcmOpOccsNsLcmOpOccLinks; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.Optional; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * @author Andrew Lamb (andrew.a.lamb@est.tech) + * + */ +@Service +public class NsLcmOperationOccurrenceManager { + + private static final Logger logger = getLogger(NsLcmOperationOccurrenceManager.class); + + private final DatabaseServiceProvider databaseServiceProvider; + private final EtsiSoNsLcmManagerUrlProvider etsiSoNsLcmManagerUrlProvider; + + @Autowired + public NsLcmOperationOccurrenceManager(final DatabaseServiceProvider databaseServiceProvider, + final EtsiSoNsLcmManagerUrlProvider etsiSoNsLcmManagerUrlProvider) { + this.databaseServiceProvider = databaseServiceProvider; + this.etsiSoNsLcmManagerUrlProvider = etsiSoNsLcmManagerUrlProvider; + } + + public Optional<NsLcmOpOccsNsLcmOpOcc> getNsLcmOperationOccurrence(final String nsLcmOpOccId) { + logger.info("Getting NS LCM Operation Occurrence Operation for id: {}", nsLcmOpOccId); + final Optional<NsLcmOpOcc> optionalNsLcmOpOcc = databaseServiceProvider.getNsLcmOpOcc(nsLcmOpOccId); + + if (optionalNsLcmOpOcc.isEmpty()) { + logger.info("No NS LCM Operation Occurrence found for id: {}", nsLcmOpOccId); + return Optional.empty(); + } + + logger.info("Found NS LCM Operation Occurrence for id: {}", nsLcmOpOccId); + final NsLcmOpOcc nsLcmOpOcc = optionalNsLcmOpOcc.get(); + final NsLcmOpOccsNsLcmOpOcc nsLcmOpOccsNsLcmOpOcc = convertToNsLcmOpOccsNsLcmOpOcc(nsLcmOpOcc); + return Optional.of(nsLcmOpOccsNsLcmOpOcc); + } + + private NsLcmOpOccsNsLcmOpOcc convertToNsLcmOpOccsNsLcmOpOcc(final NsLcmOpOcc nsLcmOpOcc) { + logger.info("Converting Database NsLcmOpOcc to API NsLcmOpOcc... "); + final NsLcmOpOccsNsLcmOpOcc nsLcmOpOccsNsLcmOpOcc = + new NsLcmOpOccsNsLcmOpOcc().id(nsLcmOpOcc.getId()).statusEnteredTime(nsLcmOpOcc.getStateEnteredTime()) + .startTime(nsLcmOpOcc.getStartTime()).isAutomaticInvocation(nsLcmOpOcc.getIsAutoInvocation()) + .isCancelPending(nsLcmOpOcc.getIsCancelPending()); + + if (nsLcmOpOcc.getNfvoNsInst() != null) { + nsLcmOpOccsNsLcmOpOcc.setNsInstanceId(nsLcmOpOcc.getNfvoNsInst().getNsInstId()); + } + + if (nsLcmOpOcc.getOperationState() != null) { + nsLcmOpOccsNsLcmOpOcc.setOperationState( + NsLcmOpOccsNsLcmOpOcc.OperationStateEnum.fromValue(nsLcmOpOcc.getOperationState().toString())); + } + + if (nsLcmOpOcc.getOperation() != null) { + nsLcmOpOccsNsLcmOpOcc.setLcmOperationType( + NsLcmOpOccsNsLcmOpOcc.LcmOperationTypeEnum.fromValue(nsLcmOpOcc.getOperation().toString())); + } + + if (nsLcmOpOcc.getOperationParams() != null) { + nsLcmOpOccsNsLcmOpOcc.setOperationParams(nsLcmOpOcc.getOperationParams()); + } + + if (nsLcmOpOcc.getCancelMode() != null) { + nsLcmOpOccsNsLcmOpOcc.setCancelMode( + NsLcmOpOccsNsLcmOpOcc.CancelModeEnum.fromValue(nsLcmOpOcc.getCancelMode().toString())); + } + + nsLcmOpOccsNsLcmOpOcc.setLinks(generateLinks(nsLcmOpOcc)); + + logger.info("Database NsLcmOpOcc converted to API NsLcmOpOcc successfully... {}", nsLcmOpOccsNsLcmOpOcc); + return nsLcmOpOccsNsLcmOpOcc; + } + + private NsLcmOpOccsNsLcmOpOccLinks generateLinks(final NsLcmOpOcc nsLcmOpOcc) { + logger.info("Generating links..."); + final String nsLcmOpOccId = nsLcmOpOcc.getId(); + final NsInstancesNsInstanceLinksSelf linksSelfNsLcmOpOcc = new NsInstancesNsInstanceLinksSelf() + .href(etsiSoNsLcmManagerUrlProvider.getNsLcmOpOccUri(nsLcmOpOccId).toString()); + final NsLcmOpOccsNsLcmOpOccLinks links = new NsLcmOpOccsNsLcmOpOccLinks().self(linksSelfNsLcmOpOcc); + + if (nsLcmOpOcc.getNfvoNsInst() != null) { + final String nsInstId = nsLcmOpOcc.getNfvoNsInst().getNsInstId(); + final NsInstancesNsInstanceLinksSelf linksSelfNsInst = new NsInstancesNsInstanceLinksSelf() + .href(etsiSoNsLcmManagerUrlProvider.getCreatedNsResourceUri(nsInstId).toString()); + links.setNsInstance(linksSelfNsInst); + } + + return links; + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesController.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesController.java index ec79ce6329..207f0ff387 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesController.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesController.java @@ -22,20 +22,25 @@ package org.onap.so.etsi.nfvo.ns.lcm.rest; import static org.onap.so.etsi.nfvo.ns.lcm.Constants.NS_LIFE_CYCLE_MANAGEMENT_BASE_URL; import static org.slf4j.LoggerFactory.getLogger; import javax.ws.rs.core.MediaType; +import org.onap.so.etsi.nfvo.ns.lcm.lifecycle.NsLcmOperationOccurrenceManager; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; import org.onap.so.etsi.nfvo.ns.lcm.model.NsLcmOpOccsNsLcmOpOcc; import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; /** * Controller for handling NS lifecycle management operation occurrence requests see clause 6.4.9 and 6.4.10 in * https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/005/02.07.01_60/gs_NFV-SOL005v020701p.pdf * * @author Waqas Ikram (waqas.ikram@est.tech) + * @author Andrew Lamb (andrew.a.lamb@est.tech) * */ @Controller @@ -43,6 +48,12 @@ import org.springframework.web.bind.annotation.RequestMapping; public class NsLcmOperationOccurrencesController { private static final Logger logger = getLogger(NsLcmOperationOccurrencesController.class); + private final NsLcmOperationOccurrenceManager nsLcmOperationOccurrenceManager; + + @Autowired + public NsLcmOperationOccurrencesController(final NsLcmOperationOccurrenceManager nsLcmOperationOccurrenceManager) { + this.nsLcmOperationOccurrenceManager = nsLcmOperationOccurrenceManager; + } /** * The GET method to retrieve status information about a NS lifecycle management operation occurrence by reading an @@ -57,7 +68,18 @@ public class NsLcmOperationOccurrencesController { produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public ResponseEntity<?> getOperationStatus(@PathVariable("nsLcmOpOccId") final String nsLcmOpOccId) { logger.info("Received request to retrieve operation status for nsLcmOpOccId: {}", nsLcmOpOccId); - return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet"); + final Optional<NsLcmOpOccsNsLcmOpOcc> optionalNsLcmOpOccs = + nsLcmOperationOccurrenceManager.getNsLcmOperationOccurrence(nsLcmOpOccId); + + if (optionalNsLcmOpOccs.isPresent()) { + final NsLcmOpOccsNsLcmOpOcc nsLcmOpOcc = optionalNsLcmOpOccs.get(); + logger.info("Sending back NsLcmOpOcc: {}", nsLcmOpOcc); + return ResponseEntity.ok().body(nsLcmOpOcc); + } + + final String errorMessage = "Unable to retrieve operation occurrence status for nsLcmOpOccId: " + nsLcmOpOccId; + logger.error(errorMessage); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new InlineResponse400().detail(errorMessage)); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java index 78ab9e96cc..2390cef564 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java @@ -77,7 +77,7 @@ public class NsLifecycleManagementController { */ @PostMapping(value = "/ns_instances", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> createNs( + public ResponseEntity<NsInstancesNsInstance> createNs( @RequestHeader(value = HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME, required = true) final String globalCustomerId, @RequestHeader(value = HTTP_SERVICETYPE_HEADER_PARM_NAME, required = false, @@ -106,7 +106,7 @@ public class NsLifecycleManagementController { */ @DeleteMapping(value = "/ns_instances/{nsInstanceId}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> deleteNs(@PathVariable("nsInstanceId") final String nsInstanceId) { + public ResponseEntity<Void> deleteNs(@PathVariable("nsInstanceId") final String nsInstanceId) { logger.debug("Received delete NS request for nsInstanceId: {}", nsInstanceId); nsLifeCycleManager.deleteNs(nsInstanceId); logger.info("Successfully deleted NS for nsInstanceId: {}", nsInstanceId); @@ -124,7 +124,7 @@ public class NsLifecycleManagementController { @PostMapping(value = "/ns_instances/{nsInstanceId}/instantiate", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> instantiateNs(@PathVariable("nsInstanceId") final String nsInstanceId, + public ResponseEntity<Void> instantiateNs(@PathVariable("nsInstanceId") final String nsInstanceId, @RequestBody final InstantiateNsRequest instantiateNsRequest) { logger.debug("Received instantiate NS request: {}\n with nsInstanceId: {}", instantiateNsRequest, nsInstanceId); final URI resourceUri = nsLifeCycleManager.instantiateNs(nsInstanceId, instantiateNsRequest); @@ -144,7 +144,7 @@ public class NsLifecycleManagementController { @PostMapping(value = "/ns_instances/{nsInstanceId}/terminate", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> terminateNs(@PathVariable("nsInstanceId") final String nsInstanceId, + public ResponseEntity<Void> terminateNs(@PathVariable("nsInstanceId") final String nsInstanceId, @RequestBody final TerminateNsRequest terminateNsRequest) { logger.debug("Received terminate NS request: {}\n with nsInstanceId: {}", terminateNsRequest, nsInstanceId); final URI resourceUri = nsLifeCycleManager.terminateNs(nsInstanceId, terminateNsRequest); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesControllerTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesControllerTest.java index 9eace927d6..c5862569f2 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesControllerTest.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLcmOperationOccurrencesControllerTest.java @@ -20,13 +20,26 @@ package org.onap.so.etsi.nfvo.ns.lcm.rest; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import java.time.LocalDateTime; +import java.util.Optional; import java.util.UUID; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.etsi.nfvo.ns.lcm.Constants; -import org.onap.so.etsi.nfvo.ns.lcm.JSON; import org.onap.so.etsi.nfvo.ns.lcm.TestApplication; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpType; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; +import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; +import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400; +import org.onap.so.etsi.nfvo.ns.lcm.model.NsLcmOpOccsNsLcmOpOcc; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.web.client.RestTemplateBuilder; @@ -42,32 +55,75 @@ import org.springframework.test.context.junit4.SpringRunner; import com.google.gson.Gson; /** - * * @author Waqas Ikram (waqas.ikram@est.tech) + * @author Andrew Lamb (andrew.a.lamb@est.tech) + * */ @RunWith(SpringRunner.class) @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class NsLcmOperationOccurrencesControllerTest { + + private static final String NS_LCM_OP_OCCS = "/ns_lcm_op_occs/"; + @LocalServerPort private int port; + + @Autowired + private DatabaseServiceProvider databaseServiceProvider; + + @Autowired + private GsonProvider gsonProvider; + private TestRestTemplate testRestTemplate; @Before public void setUp() { - final Gson gson = JSON.createGson().create(); + final Gson gson = gsonProvider.getGson(); testRestTemplate = new TestRestTemplate( new RestTemplateBuilder().additionalMessageConverters(new GsonHttpMessageConverter(gson))); } @Test - public void testGetOperationStatusS_ValidNsLcmOpOccId() { - final String baseUrl = getNsLcmBaseUrl() + "/ns_lcm_op_occs/" + UUID.randomUUID().toString(); + public void testGetOperationStatus_validNsLcmOpOccId_returnsNsLcmOpOcc() { + final String nsLcmOpOccId = addDummyNsLcmOpOccToDatabase(); + final String baseUrl = getNsLcmBaseUrl() + NS_LCM_OP_OCCS + nsLcmOpOccId; final HttpEntity<?> request = new HttpEntity<>(new HttpHeaders()); - final ResponseEntity<Void> responseEntity = - testRestTemplate.exchange(baseUrl, HttpMethod.GET, request, Void.class); - assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + final ResponseEntity<NsLcmOpOccsNsLcmOpOcc> responseEntity = + testRestTemplate.exchange(baseUrl, HttpMethod.GET, request, NsLcmOpOccsNsLcmOpOcc.class); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + assertTrue(responseEntity.hasBody()); + assertNotNull(responseEntity.getBody()); + } + + @Test + public void testGetOperationStatus_nsLcmOpOccIdNotFound_returnsInlineResponse400() { + final String nsLcmOpOccId = UUID.randomUUID().toString(); + final Optional<NsLcmOpOcc> optionalNsLcmOpOcc = databaseServiceProvider.getNsLcmOpOcc(nsLcmOpOccId); + assertTrue(optionalNsLcmOpOcc.isEmpty()); + final String baseUrl = getNsLcmBaseUrl() + NS_LCM_OP_OCCS + nsLcmOpOccId; + final HttpEntity<?> request = new HttpEntity<>(new HttpHeaders()); + final ResponseEntity<InlineResponse400> responseEntity = + testRestTemplate.exchange(baseUrl, HttpMethod.GET, request, InlineResponse400.class); + assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); + assertTrue(responseEntity.hasBody()); + assertNotNull(responseEntity.getBody()); + } + + private String addDummyNsLcmOpOccToDatabase() { + final LocalDateTime currentDateTime = LocalDateTime.now(); + + final NfvoNsInst nsInst = new NfvoNsInst().name("name").nsdId("id").status(State.NOT_INSTANTIATED) + .nsdInvariantId("id").statusUpdatedTime(currentDateTime); + databaseServiceProvider.saveNfvoNsInst(nsInst); + + final NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc().nfvoNsInst(nsInst).operationState(OperationStateEnum.PROCESSING) + .isCancelPending(false).isAutoInvocation(false).operation(NsLcmOpType.INSTANTIATE) + .startTime(currentDateTime).stateEnteredTime(currentDateTime).operationParams(""); + databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc); + + return nsLcmOpOcc.getId(); } private String getNsLcmBaseUrl() { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml index 44acda20a4..6f2b4d26c5 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml @@ -29,11 +29,13 @@ spring: pool-name: ns-lcm-nfvo-pool registerMbeans: true jpa: + generate-ddl: true hibernate: - ddl-auto: none + ddl-auto: create logging: level: org.reflections.Reflections: ERROR + etsi-catalog-manager: base: - endpoint: http://modeling-etsicatalog.onap:8806/api
\ No newline at end of file + endpoint: http://modeling-etsicatalog.onap:8806/api |