aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/pom.xml5
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java26
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java1
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java128
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java76
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/manual/Migrate_Distrobution_Status.sql11
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.6.6__Add_Column_For_Distrobution_Status.sql1
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java134
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java1
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json52
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application.yaml4
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/GetResources.json2
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/application-test.yaml2
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql2
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.7__Add_OpenStack_Request_Information.sql13
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java25
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java17
-rw-r--r--adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml17
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java46
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java11
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java7
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java75
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java7
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java30
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java3
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java25
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java2
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java14
-rw-r--r--asdc-controller/src/test/resources/schema.sql1
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceLevel.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java228
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java17
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java116
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json206
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json1
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy7
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/CloudRequestData.java59
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/Request.java15
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java36
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java98
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json62
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql15
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql17
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/CloudApiRequests.java138
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java19
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java4
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java16
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java19
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java2
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatEnvironment.java160
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatFile.java115
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatTemplate.java147
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatTemplateParam.java73
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Service.java165
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/VfModule.java196
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Vnf.java218
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java3
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql1
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java14
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java22
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/InstantiateOperationProgressor.java123
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java119
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java33
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/TerminateOperationProgressor.java74
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java10
70 files changed, 2925 insertions, 381 deletions
diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml
index 7918072323..aa9a1cea9e 100644
--- a/adapters/mso-adapter-utils/pom.xml
+++ b/adapters/mso-adapter-utils/pom.xml
@@ -147,5 +147,10 @@
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>mso-requests-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
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 3dba412237..8093f045eb 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
@@ -23,6 +23,7 @@
package org.onap.so.openstack.utils;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.woorea.openstack.base.client.OpenStackConnectException;
@@ -47,6 +48,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vdu.CloudInfo;
import org.onap.so.adapters.vdu.PluginAction;
import org.onap.so.adapters.vdu.VduArtifact;
@@ -67,6 +69,9 @@ import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.HeatTemplate;
import org.onap.so.db.catalog.beans.HeatTemplateParam;
import org.onap.so.db.catalog.beans.ServerType;
+import org.onap.so.db.request.beans.CloudApiRequests;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.onap.so.openstack.beans.HeatStatus;
@@ -82,6 +87,7 @@ import org.onap.so.openstack.mappers.StackInfoMapper;
import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
@@ -121,6 +127,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
@Autowired
private KeystoneV3Authentication keystoneV3Authentication;
+ @Autowired
+ RequestsDbClient requestDBClient;
+
private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class);
// Properties names and variables (with default values)
@@ -241,6 +250,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
Stack heatStack = null;
try {
OpenStackRequest<Stack> request = heatClient.getStacks().create(stack);
+ saveStackRequest(request, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID), stackName);
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
request.header("X-Auth-User", cloudIdentity.getMsoId());
request.header("X-Auth-Key", CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass()));
@@ -276,6 +286,22 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
return new StackInfoMapper(heatStack).map();
}
+ private void saveStackRequest(OpenStackRequest<Stack> request, String requestId, String stackName) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ InfraActiveRequests foundRequest = requestDBClient.getInfraActiveRequestbyRequestId(requestId);
+ String stackRequest = mapper.writeValueAsString(request.entity());
+ CloudApiRequests cloudReq = new CloudApiRequests();
+ cloudReq.setCloudIdentifier(stackName);
+ cloudReq.setRequestBody(stackRequest);
+ cloudReq.setRequestId(requestId);
+ foundRequest.getCloudApiRequests().add(cloudReq);
+ requestDBClient.updateInfraActiveRequests(foundRequest);
+ } catch (Exception e) {
+ logger.error("Error updating in flight request with Openstack Create Request", e);
+ }
+ }
+
private Stack pollStackForCompletion(String cloudSiteId, String tenantId, String stackName, int timeoutMinutes,
boolean backout, Heat heatClient, Stack heatStack, String canonicalName)
throws MsoException, MsoOpenstackException {
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
index db73d4afec..0e526e59fb 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
@@ -24,6 +24,7 @@ import javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import org.onap.so.adapters.catalogdb.rest.CatalogDbAdapterRest;
+import org.onap.so.adapters.catalogdb.rest.ServiceRestImpl;
import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
import org.springframework.context.annotation.Configuration;
import io.swagger.jaxrs.config.BeanConfig;
@@ -40,6 +41,7 @@ public class JerseyConfiguration extends ResourceConfig {
register(ApiListingResource.class);
register(SwaggerSerializers.class);
register(JaxRsFilterLogging.class);
+ register(ServiceRestImpl.class);
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.2");
beanConfig.setSchemes(new String[] {"http"});
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
index 6cc53e6ec9..589f119337 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
@@ -279,6 +279,7 @@ public class CatalogDbAdapterRest {
@QueryParam("serviceModelUuid") String modelUUID,
@QueryParam("serviceModelInvariantUuid") String modelInvariantUUID,
@QueryParam("serviceModelVersion") String modelVersion) {
+
QueryServiceMacroHolder qryResp;
int respStatus = HttpStatus.SC_OK;
String uuid = "";
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java
new file mode 100644
index 0000000000..dd18767762
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.so.db.catalog.beans.HeatEnvironment;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.rest.catalog.beans.Service;
+import org.onap.so.rest.catalog.beans.VfModule;
+import org.onap.so.rest.catalog.beans.Vnf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class ServiceMapper {
+ private static final Logger logger = LoggerFactory.getLogger(ServiceMapper.class);
+
+ public Service mapService(org.onap.so.db.catalog.beans.Service service, int depth) {
+ Service restService = new Service();
+ restService.setCategory(service.getCategory());
+ restService.setCreated(service.getCreated());
+ restService.setDescription(service.getDescription());
+ restService.setDistrobutionStatus(service.getDistrobutionStatus());
+ restService.setEnvironmentContext(service.getEnvironmentContext());
+ restService.setModelInvariantId(service.getModelInvariantUUID());
+ restService.setModelName(service.getModelName());
+ restService.setModelVersionId(service.getModelUUID());
+ restService.setModelVersion(service.getModelVersion());
+ restService.setServiceRole(service.getServiceRole());
+ restService.setServiceType(service.getServiceType());
+ restService.setWorkloadContext(service.getWorkloadContext());
+ if (depth > 0)
+ restService.setVnf(mapVnfs(service, depth));
+ return restService;
+ }
+
+ private List<Vnf> mapVnfs(org.onap.so.db.catalog.beans.Service service, int depth) {
+ List<Vnf> vnfs = new ArrayList<>();
+ logger.info("Vnf Count : {}", service.getVnfCustomizations().size());
+ service.getVnfCustomizations().parallelStream().forEach(vnf -> vnfs.add(mapVnf(vnf, depth)));
+ return vnfs;
+ }
+
+ private Vnf mapVnf(org.onap.so.db.catalog.beans.VnfResourceCustomization vnfResourceCustomization, int depth) {
+ Vnf vnf = new Vnf();
+ vnf.setAvailabilityZoneMaxCount(vnfResourceCustomization.getAvailabilityZoneMaxCount());
+ vnf.setCategory(vnfResourceCustomization.getVnfResources().getCategory());
+ vnf.setCloudVersionMax(vnfResourceCustomization.getVnfResources().getAicVersionMax());
+ vnf.setCloudVersionMin(vnfResourceCustomization.getVnfResources().getAicVersionMin());
+ vnf.setMaxInstances(vnfResourceCustomization.getMaxInstances());
+ vnf.setMinInstances(vnfResourceCustomization.getMinInstances());
+ vnf.setModelCustomizationId(vnfResourceCustomization.getModelCustomizationUUID());
+ vnf.setModelInstanceName(vnfResourceCustomization.getModelInstanceName());
+ vnf.setModelInvariantId(vnfResourceCustomization.getVnfResources().getModelInvariantId());
+ vnf.setModelName(vnfResourceCustomization.getVnfResources().getModelName());
+ vnf.setModelVersionId(vnfResourceCustomization.getVnfResources().getModelUUID());
+ vnf.setModelVersion(vnfResourceCustomization.getVnfResources().getModelVersion());
+ vnf.setMultiStageDesign(vnfResourceCustomization.getMultiStageDesign());
+ vnf.setNfFunction(vnfResourceCustomization.getNfFunction());
+ vnf.setNfNamingCode(vnfResourceCustomization.getNfNamingCode());
+ vnf.setNfRole(vnfResourceCustomization.getNfRole());
+ vnf.setOrchestrationMode(vnfResourceCustomization.getVnfResources().getOrchestrationMode());
+ vnf.setSubCategory(vnfResourceCustomization.getVnfResources().getSubCategory());
+ vnf.setToscaNodeType(vnfResourceCustomization.getVnfResources().getToscaNodeType());
+ if (depth > 1) {
+ vnf.setVfModule(mapVfModules(vnfResourceCustomization, depth));
+ }
+ return vnf;
+ }
+
+ private List<VfModule> mapVfModules(VnfResourceCustomization vnfResourceCustomization, int depth) {
+ List<VfModule> vfModules = new ArrayList<>();
+ vnfResourceCustomization.getVfModuleCustomizations().parallelStream()
+ .forEach(vfModule -> vfModules.add(mapVfModule(vfModule)));
+ return vfModules;
+ }
+
+ private VfModule mapVfModule(VfModuleCustomization vfModuleCust) {
+ VfModule vfModule = new VfModule();
+ vfModule.setAvailabilityZoneCount(vfModuleCust.getAvailabilityZoneCount());
+ vfModule.setCreated(vfModuleCust.getCreated());
+ vfModule.setDescription(vfModuleCust.getVfModule().getDescription());
+ vfModule.setInitialCount(vfModuleCust.getInitialCount());
+ vfModule.setIsBase(vfModuleCust.getVfModule().getIsBase());
+ vfModule.setIsVolumeGroup(getIsVolumeGroup(vfModuleCust));
+ vfModule.setMaxInstances(vfModuleCust.getMaxInstances());
+ vfModule.setMinInstances(vfModuleCust.getMinInstances());
+ vfModule.setLabel(vfModuleCust.getLabel());
+ vfModule.setModelCustomizationId(vfModuleCust.getModelCustomizationUUID());
+ vfModule.setModelInvariantId(vfModuleCust.getVfModule().getModelInvariantUUID());
+ vfModule.setModelName(vfModuleCust.getVfModule().getModelName());
+ vfModule.setModelVersionId(vfModuleCust.getVfModule().getModelUUID());
+ vfModule.setModelVersion(vfModuleCust.getVfModule().getModelVersion());
+ return vfModule;
+ }
+
+ private boolean getIsVolumeGroup(VfModuleCustomization vfModuleCust) {
+ boolean isVolumeGroup = false;
+ HeatEnvironment envt = vfModuleCust.getVolumeHeatEnv();
+ if (envt != null) {
+ isVolumeGroup = true;
+ }
+ return isVolumeGroup;
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
new file mode 100644
index 0000000000..1ca8998396
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.rest.catalog.beans.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.google.common.base.Strings;
+import io.swagger.annotations.ApiOperation;
+
+@Path("/v1/")
+@Component
+public class ServiceRestImpl {
+
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Autowired
+ private ServiceMapper serviceMapper;
+
+ @GET
+ @Path("/services/{modelUUID}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @Transactional(readOnly = true)
+ public Service findService(@PathParam("modelUUID") String modelUUID, @QueryParam("depth") int depth) {
+ org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(modelUUID);
+ return serviceMapper.mapService(service, depth);
+ }
+
+ @GET
+ @Path("/services")
+ @ApiOperation(value = "Find Service Models", response = Service.class, responseContainer = "List")
+ @Produces({MediaType.APPLICATION_JSON})
+ @Transactional(readOnly = true)
+ public List<Service> queryServices(@QueryParam("modelName") String modelName,
+ @QueryParam("distributionStatus") String distributionStatus, @QueryParam("depth") int depth) {
+ List<Service> services = new ArrayList<>();
+ List<org.onap.so.db.catalog.beans.Service> serviceFromDB = new ArrayList<>();
+ if (!Strings.isNullOrEmpty(modelName) && !Strings.isNullOrEmpty(distributionStatus)) {
+ serviceFromDB = serviceRepo.findByModelNameAndDistrobutionStatus(modelName, distributionStatus);
+ } else if (!Strings.isNullOrEmpty(modelName)) {
+ serviceFromDB = serviceRepo.findByModelName(modelName);
+ }
+ serviceFromDB.stream().forEach(serviceDB -> services.add(serviceMapper.mapService(serviceDB, depth)));
+ return services;
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/manual/Migrate_Distrobution_Status.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/manual/Migrate_Distrobution_Status.sql
new file mode 100644
index 0000000000..4a9c2cce9f
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/manual/Migrate_Distrobution_Status.sql
@@ -0,0 +1,11 @@
+
+UPDATE catalogdb.service serv SET OVERALL_DISTRIBUTION_STATUS =(
+SELECT wds.DISTRIBUTION_ID_STATUS
+FROM requestdb.watchdog_distributionid_status wds
+INNER JOIN requestdb.watchdog_service_mod_ver_id_lookup wdlook
+ON wds.DISTRIBUTION_ID = wdlook.DISTRIBUTION_ID
+WHERE wdlook.SERVICE_MODEL_VERSION_ID = serv.MODEL_UUID
+ORDER BY wdlook.MODIFY_TIME DESC LIMIT 1);
+
+UPDATE catalogdb.service SET OVERALL_DISTRIBUTION_STATUS = 'DISTRIBUTION_COMPLETE_OK'
+WHERE service.OVERALL_DISTRIBUTION_STATUS = NULL; \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.6.6__Add_Column_For_Distrobution_Status.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.6.6__Add_Column_For_Distrobution_Status.sql
new file mode 100644
index 0000000000..ae416ffbfe
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.6.6__Add_Column_For_Distrobution_Status.sql
@@ -0,0 +1 @@
+ALTER TABLE catalogdb.service ADD COLUMN IF NOT EXISTS OVERALL_DISTRIBUTION_STATUS varchar(45); \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java
new file mode 100644
index 0000000000..b8161de6b2
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java
@@ -0,0 +1,134 @@
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.junit.Test;
+import org.onap.so.adapters.catalogdb.rest.ServiceMapper;
+import org.onap.so.db.catalog.beans.HeatTemplate;
+import org.onap.so.db.catalog.beans.HeatTemplateParam;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.rest.catalog.beans.Service;
+import wiremock.com.fasterxml.jackson.core.JsonParseException;
+import wiremock.com.fasterxml.jackson.databind.JsonMappingException;
+import wiremock.com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ServiceMapperTest {
+
+ private ServiceMapper serviceMapper = new ServiceMapper();
+
+ @Test
+ public void service_map_test() throws JsonParseException, JsonMappingException, IOException {
+ Service actual = serviceMapper.mapService(getTestService(), 2);
+ assertThat(actual, sameBeanAs(getExpectedService()));
+ }
+
+ private Service getExpectedService() throws JsonParseException, JsonMappingException, IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ return mapper.readValue(getJson("ExpectedService.json"), Service.class);
+ }
+
+
+ private org.onap.so.db.catalog.beans.Service getTestService() {
+ org.onap.so.db.catalog.beans.Service testService = new org.onap.so.db.catalog.beans.Service();
+ testService.setCategory("category");
+ testService.setDescription("description");
+ testService.setDistrobutionStatus("distrobutionStatus");
+ testService.setEnvironmentContext("environmentContext");
+ testService.setModelInvariantUUID("modelInvariantUUID");
+ testService.setModelName("modelName");
+ testService.setModelUUID("modelUUID");
+ testService.setModelVersion("modelVersion");
+ testService.setServiceType("serviceType");
+ testService.setServiceRole("serviceRole");
+ testService.getVnfCustomizations().add(getTestVnfCustomization());
+ return testService;
+ }
+
+ private org.onap.so.db.catalog.beans.VnfResourceCustomization getTestVnfCustomization() {
+ org.onap.so.db.catalog.beans.VnfResourceCustomization test =
+ new org.onap.so.db.catalog.beans.VnfResourceCustomization();
+ test.setId(1);
+ test.setAvailabilityZoneMaxCount(11);
+ test.setMaxInstances(3);
+ test.setMinInstances(1);
+ test.setModelCustomizationUUID("modelCustomizationUUID");
+ test.setModelInstanceName("modelInstanceName");
+ test.setMultiStageDesign("multiStageDesign");
+ test.setNfFunction("nfFunction");
+ test.setNfNamingCode("nfNamingCode");
+ test.setNfRole("nfRole");
+ test.setNfType("nfType");
+ test.setService(new org.onap.so.db.catalog.beans.Service());
+ test.setVnfResources(getTestVnfResource());
+ test.setVfModuleCustomizations(getTestVfModuleCust());
+ return test;
+ }
+
+ private List<VfModuleCustomization> getTestVfModuleCust() {
+ List<VfModuleCustomization> test = new ArrayList<>();
+ VfModuleCustomization testVfMod = new VfModuleCustomization();
+ testVfMod.setAvailabilityZoneCount(10);
+ testVfMod.setInitialCount(1);
+ testVfMod.setLabel("label");
+ testVfMod.setMaxInstances(3);
+ testVfMod.setMinInstances(1);
+ testVfMod.setModelCustomizationUUID("modelCustomizationUUID");
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ vfModule.setDescription("description");
+ vfModule.setIsBase(false);
+ vfModule.setModelInvariantUUID("modelInvariantUUID");
+ vfModule.setModelName("modelName");
+ vfModule.setModelUUID("modelUUID");
+ vfModule.setModelVersion("modelVersion");
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ moduleHeatTemplate.setArtifactChecksum("artifactChecksum");
+ moduleHeatTemplate.setArtifactUuid("artifactUuid");
+ List<HeatTemplate> childTemplates;
+ // moduleHeatTemplate.setChildTemplates(childTemplates);
+ moduleHeatTemplate.setDescription("description");
+ Set<HeatTemplateParam> parameters = new HashSet<>();
+ HeatTemplateParam heatParam = new HeatTemplateParam();
+ heatParam.setHeatTemplateArtifactUuid("heatTemplateArtifactUuid");
+ heatParam.setParamAlias("paramAlias");
+ heatParam.setParamName("paramName");
+ heatParam.setParamType("paramType");
+ heatParam.setRequired(false);
+ parameters.add(heatParam);
+ moduleHeatTemplate.setParameters(parameters);
+ moduleHeatTemplate.setTemplateBody("templateBody");
+ moduleHeatTemplate.setTemplateName("templateName");
+ moduleHeatTemplate.setTimeoutMinutes(1000);
+ moduleHeatTemplate.setVersion("version");
+ vfModule.setModuleHeatTemplate(moduleHeatTemplate);
+ testVfMod.setVfModule(vfModule);
+ test.add(testVfMod);
+ return test;
+ }
+
+ private org.onap.so.db.catalog.beans.VnfResource getTestVnfResource() {
+ org.onap.so.db.catalog.beans.VnfResource test = new org.onap.so.db.catalog.beans.VnfResource();
+ test.setCategory("category");
+ test.setDescription("description");
+ test.setModelInvariantUUID("modelInvariantUUID");
+ test.setModelName("modelName");
+ test.setModelUUID("modelUUID");
+ test.setModelVersion("modelVersion");
+ test.setAicVersionMax("cloudVersionMax");
+ test.setAicVersionMin("cloudVersionMin");
+ test.setOrchestrationMode("orchestrationMode");
+ test.setSubCategory("subCategory");
+ test.setToscaNodeType("toscaNodeType");
+ return test;
+ }
+
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename)));
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index 51b44b0d3a..4127d07c5f 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -289,7 +289,6 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
Assert.assertNotNull(vnfResource.getModelInvariantId());
Assert.assertNotNull(vnfResource.getModelVersion());
Assert.assertNotNull(vnfResource.getHeatTemplates());
- Assert.assertNotNull(vnfResource.getVnfResourceCustomizations());
Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
}
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json
new file mode 100644
index 0000000000..cc5145f0e3
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json
@@ -0,0 +1,52 @@
+{
+ "modelName": "modelName",
+ "description": "description",
+ "modelVersionId": "modelUUID",
+ "modelInvariantId": "modelInvariantUUID",
+ "modelVersion": "modelVersion",
+ "serviceType": "serviceType",
+ "serviceRole": "serviceRole",
+ "environmentContext": "environmentContext",
+ "category": "category",
+ "distrobutionStatus": "distrobutionStatus",
+ "vnf": [
+ {
+ "modelName": "modelName",
+ "modelVersionId": "modelUUID",
+ "modelInvariantId": "modelInvariantUUID",
+ "modelVersion": "modelVersion",
+ "modelCustomizationId": "modelCustomizationUUID",
+ "modelInstanceName": "modelInstanceName",
+ "minInstances": 1,
+ "maxInstances": 3,
+ "availabilityZoneMaxCount": 11,
+ "toscaNodeType": "toscaNodeType",
+ "nfFunction": "nfFunction",
+ "nfRole": "nfRole",
+ "nfNamingCode": "nfNamingCode",
+ "multiStageDesign": "multiStageDesign",
+ "orchestrationMode": "orchestrationMode",
+ "cloudVersionMin": "cloudVersionMin",
+ "cloudVersionMax": "cloudVersionMax",
+ "category": "category",
+ "subCategory": "subCategory",
+ "vfModule": [
+ {
+ "modelVersionId": "modelUUID",
+ "modelInvariantId": "modelInvariantUUID",
+ "modelName": "modelName",
+ "modelVersion": "modelVersion",
+ "description": "description",
+ "isBase": false,
+ "modelCustomizationId": "modelCustomizationUUID",
+ "label": "label",
+ "minInstances": 1,
+ "maxInstances": 3,
+ "initialCount": "1",
+ "availabilityZoneCount": 10,
+ "isVolumeGroup": false
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
index f66d77db48..1982961ae7 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
@@ -25,10 +25,10 @@ spring:
driver-class-name: org.mariadb.jdbc.Driver
initialization-mode: never
jpa:
- show-sql: true
+ show-sql: false
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
- ddl-auto: validate
+ ddl-auto: none
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
enable-lazy-load-no-trans: true
org:
diff --git a/adapters/mso-openstack-adapters/src/test/resources/GetResources.json b/adapters/mso-openstack-adapters/src/test/resources/GetResources.json
index 0d403a62b5..d4e84fb3c9 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/GetResources.json
+++ b/adapters/mso-openstack-adapters/src/test/resources/GetResources.json
@@ -90,7 +90,7 @@
"resource_status_reason": "state changed",
"resource_type": "OS::Heat::ResourceGroup",
"updated_time": "2019-01-23T19:34:15Z"
- },
+ },
{
"links": [
{
diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
index 058c1d2627..ce576f00e1 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
+++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
@@ -92,7 +92,7 @@ spring:
generate-ddl: false
show-sql: false
hibernate:
- ddl-auto: validate
+ ddl-auto: none
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
security:
usercredentials:
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index c700e78868..83023e53db 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -717,7 +717,6 @@ CREATE TABLE `northbound_request_ref_lookup` (
`MAX_API_VERSION` double DEFAULT NULL,
`IS_TOPLEVELFLOW` tinyint(1) DEFAULT NULL,
`CLOUD_OWNER` varchar(200) NOT NULL,
- `service_type` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_northbound_request_ref_lookup` (`MIN_API_VERSION`,`REQUEST_SCOPE`,`ACTION`,`IS_ALACARTE`,`MACRO_ACTION`,`CLOUD_OWNER`)
) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=latin1;
@@ -804,6 +803,7 @@ CREATE TABLE `service` (
`WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL,
`SERVICE_CATEGORY` varchar(200) DEFAULT NULL,
`RESOURCE_ORDER` varchar(200) default NULL,
+ OVERALL_DISTRIBUTION_STATUS varchar(45),
PRIMARY KEY (`MODEL_UUID`),
KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`),
CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.7__Add_OpenStack_Request_Information.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.7__Add_OpenStack_Request_Information.sql
new file mode 100644
index 0000000000..5635a1eb80
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.7__Add_OpenStack_Request_Information.sql
@@ -0,0 +1,13 @@
+use requestdb;
+
+CREATE TABLE IF NOT EXISTS cloud_api_requests(
+`ID` INT(13) NOT NULL AUTO_INCREMENT,
+`REQUEST_BODY` LONGTEXT NOT NULL,
+`CLOUD_IDENTIFIER` VARCHAR(200) NULL,
+`SO_REQUEST_ID` VARCHAR(45) NOT NULL,
+`CREATE_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (`ID`),
+CONSTRAINT fk_cloud_api_req_infra_requests
+ FOREIGN KEY (SO_REQUEST_ID)
+ REFERENCES infra_active_requests (REQUEST_ID))
+ENGINE = InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java
index 514e5ad923..9faba0df67 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java
@@ -50,35 +50,10 @@ public class HealthCheckHandlerTest extends RequestsAdapterBase {
@Test
public void testHealthcheck() throws JSONException {
- TestAppender.events.clear();
HttpEntity<String> entity = new HttpEntity<String>(null, headers);
-
ResponseEntity<String> response =
restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
-
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- for (ILoggingEvent logEvent : TestAppender.events)
- if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor")
- && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
- Map<String, String> mdc = logEvent.getMDCPropertyMap();
- assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
- assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
- assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
- assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
- assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- } else if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor")
- && logEvent.getMarker() != null && logEvent.getMarker() != null
- && logEvent.getMarker().getName().equals("EXIT")) {
- Map<String, String> mdc = logEvent.getMDCPropertyMap();
- assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
- assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- assertEquals("200", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
- assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
- assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
- assertEquals("COMPLETED", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- }
- TestAppender.events.clear();
}
private String createURLWithPort(String uri) {
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
index 3b737c6768..03df115574 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
@@ -25,6 +25,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.requestsdb.RequestsAdapterBase;
import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
+import org.onap.so.db.request.beans.CloudApiRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
@@ -41,9 +42,9 @@ import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertFalse;
@@ -87,6 +88,14 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
infraActiveRequests.setRequestAction("someaction");
infraActiveRequests
.setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
+ List<CloudApiRequests> cloudApiRequests = new ArrayList<>();
+ CloudApiRequests cloudRequest = new CloudApiRequests();
+ cloudRequest.setCloudIdentifier("heatstackanme/id");
+ cloudRequest.setId(1);
+ cloudRequest.setRequestBody("requestBody");
+ cloudRequest.setRequestId(infraActiveRequests.getRequestId());
+ cloudApiRequests.add(cloudRequest);
+ infraActiveRequests.setCloudApiRequests(cloudApiRequests);
requestsDbClient.save(infraActiveRequests);
}
@@ -96,7 +105,8 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
private void verifyInfraActiveRequests(InfraActiveRequests infraActiveRequestsResponse) {
- assertThat(infraActiveRequestsResponse, sameBeanAs(infraActiveRequests).ignoring("modifyTime").ignoring("log"));
+ assertThat(infraActiveRequestsResponse, sameBeanAs(infraActiveRequests).ignoring("modifyTime").ignoring("log")
+ .ignoring("cloudApiRequests.created").ignoring("cloudApiRequests.id"));
}
@Test
@@ -113,7 +123,6 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
verifyInfraActiveRequests(infraActiveRequestsResponse);
}
-
@Test
public void checkVnfIdStatusTest() {
InfraActiveRequests infraActiveRequestsResponse =
@@ -182,7 +191,7 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
public void getInfraActiveRequestbyRequestIdWhereRequestUrlNullTest() {
// requestUrl setup to null and save
infraActiveRequests.setRequestUrl(null);
- requestsDbClient.save(infraActiveRequests);
+ requestsDbClient.updateInfraActiveRequests(infraActiveRequests);
InfraActiveRequests infraActiveRequestsResponse =
requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId());
verifyInfraActiveRequests(infraActiveRequestsResponse);
diff --git a/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml
index d1596cd374..a63bd27378 100644
--- a/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml
+++ b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml
@@ -1,18 +1,7 @@
<configuration>
- <property name="p_tim" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}"/>
- <property name="p_lvl" value="%level"/>
- <property name="p_log" value="%logger"/>
- <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/>
- <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/>
- <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/>
- <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/>
- <property name="p_thr" value="%thread"/>
- <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/>
-
-
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
- <pattern>${pattern}</pattern>
+ <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern>
</encoder>
</appender>
@@ -44,6 +33,10 @@
<logger name="ch.vorburger" level="WARN" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
+
+ <logger name="org.hibernate" level="DEBUG" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
<root level="WARN">
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
index 867b6522f5..1374e89a19 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
@@ -22,6 +22,7 @@ package org.onap.so.adapters.vnfmadapter.extclients.aai;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
@@ -110,7 +111,7 @@ public class AaiHelper {
*/
public String getIdOfAssignedVnfm(final GenericVnf vnf) {
final Relationship relationship = getRelationship(vnf, "esr-vnfm");
- return getRelationshipKey(relationship, "esr-vnfm.vnfm-id");
+ return getRelationshipData(relationship, "esr-vnfm.vnfm-id");
}
/**
@@ -121,9 +122,9 @@ public class AaiHelper {
*/
public Tenant getAssignedTenant(final GenericVnf vnf) {
final Relationship relationship = getRelationship(vnf, "tenant");
- final String cloudOwner = getRelationshipKey(relationship, "cloud-region.cloud-owner");
- final String cloudRegion = getRelationshipKey(relationship, "cloud-region.cloud-region-id");
- final String tenantId = getRelationshipKey(relationship, "tenant.tenant-id");
+ final String cloudOwner = getRelationshipData(relationship, "cloud-region.cloud-owner");
+ final String cloudRegion = getRelationshipData(relationship, "cloud-region.cloud-region-id");
+ final String tenantId = getRelationshipData(relationship, "tenant.tenant-id");
if (cloudOwner == null || cloudRegion == null || tenantId == null) {
throw new TenantNotFoundException("No matching Tenant found in AAI. VNFID: " + vnf.getVnfId());
} else {
@@ -141,10 +142,17 @@ public class AaiHelper {
return null;
}
- private String getRelationshipKey(final Relationship relationship, final String relationshipKey) {
+ /**
+ * Get the value of the relationship data with the given key in the given relationship.
+ *
+ * @param relationship the relationship
+ * @param relationshipDataKey the key for the relationship data
+ * @return the value of the relationship data for the given key
+ */
+ public String getRelationshipData(final Relationship relationship, final String relationshipDataKey) {
if (relationship != null) {
for (final RelationshipData relationshipData : relationship.getRelationshipData()) {
- if (relationshipData.getRelationshipKey().equals(relationshipKey)) {
+ if (relationshipData.getRelationshipKey().equals(relationshipDataKey)) {
return relationshipData.getRelationshipValue();
}
}
@@ -153,6 +161,32 @@ public class AaiHelper {
}
/**
+ * Delete from the given VNF the relationship matching the given criteria.
+ *
+ * @param vnf the VNF
+ * @param relationshipRelatedToValue the related-to value for the relationship
+ * @param dataKey the relationship data key to match on
+ * @param dataValue the value the relationship data with the given key must match
+ * @return the deleted relationship or <code>null</code> if none found matching the given criteria
+ */
+ public Relationship deleteRelationshipWithDataValue(final GenericVnf vnf, final String relationshipRelatedToValue,
+ final String dataKey, final String dataValue) {
+ final Iterator<Relationship> relationships =
+ vnf.getRelationshipList() == null ? Collections.<Relationship>emptyList().iterator()
+ : vnf.getRelationshipList().getRelationship().iterator();
+
+ while (relationships.hasNext()) {
+ final Relationship relationship = relationships.next();
+ if (relationship.getRelatedTo().equals(relationshipRelatedToValue)
+ && dataValue.equals(getRelationshipData(relationship, dataKey))) {
+ relationships.remove();
+ return relationship;
+ }
+ }
+ return null;
+ }
+
+ /**
* Select a VNFM to use for the given generic VNF. Should only be used when no VNFM has already been assigned to the
* VNF.
*
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
index 645f37e72f..e66f86b66f 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
@@ -133,7 +133,7 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
public void deleteVnf(final String vnfSelfLink) {
logger.debug("Sending delete request to : " + vnfSelfLink);
final ResponseEntity<Void> response = httpServiceProvider.deleteHttpRequest(vnfSelfLink, Void.class);
- if (response.getStatusCode() != HttpStatus.OK) {
+ if (response.getStatusCode() != HttpStatus.NO_CONTENT) {
throw new VnfmRequestFailureException(
"Delete request to " + vnfSelfLink + " return status code: " + response.getStatusCode());
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
index e61bf860b3..345ff5119a 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
@@ -20,8 +20,11 @@
package org.onap.so.adapters.vnfmadapter.jobmanagement;
+import static org.slf4j.LoggerFactory.getLogger;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
+import java.util.Map;
+import java.util.UUID;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.JobNotFoundException;
@@ -32,9 +35,6 @@ import org.onap.vnfmadapter.v1.model.QueryJobResponse;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.Map;
-import java.util.UUID;
-import static org.slf4j.LoggerFactory.getLogger;
/**
* Manages jobs enabling the status of jobs to be queried. A job is associated with an operation on a VNFM.
@@ -123,12 +123,15 @@ public class JobManager {
public void notificationProcessedForOperation(final String operationId,
final boolean notificationProcessingWasSuccessful) {
+ logger.debug("Notification processed for operation ID {} success?: {}", operationId,
+ notificationProcessingWasSuccessful);
final java.util.Optional<VnfmOperation> relatedOperation = mapOfJobIdToVnfmOperation.values().stream()
.filter(operation -> operation.getOperationId().equals(operationId)).findFirst();
if (relatedOperation.isPresent()) {
relatedOperation.get().setNotificationProcessed(notificationProcessingWasSuccessful);
+ } else {
+ logger.debug("No operation found for operation ID " + operationId);
}
- logger.debug("No operation found for operation ID " + operationId);
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java
index 3ed66ad713..7ce08df52f 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java
@@ -94,4 +94,11 @@ public class VnfmOperation {
NOTIFICATION_PROCESSING_FAILED;
}
+ @Override
+ public String toString() {
+ return "VnfmOperation [vnfmId=" + vnfmId + ", operationId=" + operationId + ", notificationStatus="
+ + notificationStatus + "]";
+ }
+
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
index d39a2cb761..c09aa0cd48 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
@@ -27,6 +27,7 @@ import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
@@ -34,6 +35,7 @@ import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource;
import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
@@ -100,8 +102,7 @@ public class NotificationHandler implements Runnable {
aaiServiceProvider.invokePutGenericVnf(genericVnf);
- updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
- vnfInstance.getVimConnectionInfo());
+ addVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(), vnfInstance.getVimConnectionInfo());
logger.debug("Finished handling notification for vnfm: " + vnfInstance.getId());
}
@@ -114,16 +115,17 @@ public class NotificationHandler implements Runnable {
}
if (oamIpAddressSource.getType().equals(OamIpAddressType.LITERAL)) {
genericVnf.setIpv4OamAddress(oamIpAddressSource.getValue());
- }
- try {
- logger.debug("ConfigurableProperties: " + vnfInstance.getVnfConfigurableProperties());
- if (vnfInstance.getVnfConfigurableProperties() == null) {
- logger.warn("No ConfigurableProperties, cannot set OAM IP Address");
+ } else {
+ try {
+ logger.debug("ConfigurableProperties: " + vnfInstance.getVnfConfigurableProperties());
+ if (vnfInstance.getVnfConfigurableProperties() == null) {
+ logger.warn("No ConfigurableProperties, cannot set OAM IP Address");
+ }
+ final JSONObject properties = new JSONObject((Map) vnfInstance.getVnfConfigurableProperties());
+ genericVnf.setIpv4OamAddress(properties.get(oamIpAddressSource.getValue()).toString());
+ } catch (final JSONException jsonException) {
+ logger.error("Error getting vnfIpAddress", jsonException);
}
- final JSONObject properties = new JSONObject((Map) vnfInstance.getVnfConfigurableProperties());
- genericVnf.setIpv4OamAddress(properties.get(oamIpAddressSource.getValue()).toString());
- } catch (final JSONException jsonException) {
- logger.error("Error getting vnfIpAddress", jsonException);
}
}
@@ -143,30 +145,29 @@ public class NotificationHandler implements Runnable {
private void handleVnfTerminateFailed() {
final GenericVnf genericVnf = aaiServiceProvider
.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
- updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
- vnfInstance.getVimConnectionInfo());
- jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getId(), false);
+ deleteVservers(vnfLcmOperationOccurrenceNotification, genericVnf);
+ jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(), false);
}
private void handleVnfTerminateCompleted() {
final GenericVnf genericVnf = aaiServiceProvider
.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
- updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
- vnfInstance.getVimConnectionInfo());
+ deleteVservers(vnfLcmOperationOccurrenceNotification, genericVnf);
boolean deleteSuccessful = false;
try {
vnfmServiceProvider.deleteVnf(genericVnf.getSelflink());
deleteSuccessful = true;
} finally {
- jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getId(),
+ jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(),
deleteSuccessful);
genericVnf.setOrchestrationStatus("Assigned");
+ genericVnf.setSelflink("");
aaiServiceProvider.invokePutGenericVnf(genericVnf);
}
}
- private void updateVservers(final VnfLcmOperationOccurrenceNotification notification, final String vnfId,
+ private void addVservers(final VnfLcmOperationOccurrenceNotification notification, final String vnfId,
final List<InlineResponse201VimConnectionInfo> vnfInstancesVimConnectionInfo) {
final Map<String, InlineResponse201VimConnectionInfo> vimConnectionIdToVimConnectionInfo = new HashMap<>();
for (final InlineResponse201VimConnectionInfo vimConnectionInfo : vnfInstancesVimConnectionInfo) {
@@ -176,22 +177,28 @@ public class NotificationHandler implements Runnable {
for (final LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs vnfc : notification.getAffectedVnfcs()) {
final InlineResponse201VimConnectionInfo vimConnectionInfo =
getVimConnectionInfo(vimConnectionIdToVimConnectionInfo, vnfc);
- switch (vnfc.getChangeType()) {
- case ADDED:
- final Vserver vserver = aaiHelper.createVserver(vnfc);
- aaiHelper.addRelationshipFromVserverVnfToGenericVnf(vserver, vnfId);
-
- aaiServiceProvider.invokePutVserver(getCloudOwner(vimConnectionInfo),
- getCloudRegion(vimConnectionInfo), getTenant(vimConnectionInfo), vserver);
- break;
- case REMOVED:
- aaiServiceProvider.invokeDeleteVserver(getCloudOwner(vimConnectionInfo),
- getCloudRegion(vimConnectionInfo), getTenant(vimConnectionInfo),
- vnfc.getComputeResource().getResourceId());
- break;
- case MODIFIED:
- case TEMPORARY:
- default:
+ if (ChangeTypeEnum.ADDED.equals(vnfc.getChangeType())) {
+ final Vserver vserver = aaiHelper.createVserver(vnfc);
+ aaiHelper.addRelationshipFromVserverVnfToGenericVnf(vserver, vnfId);
+
+ aaiServiceProvider.invokePutVserver(getCloudOwner(vimConnectionInfo), getCloudRegion(vimConnectionInfo),
+ getTenant(vimConnectionInfo), vserver);
+ }
+ }
+ }
+
+ private void deleteVservers(final VnfLcmOperationOccurrenceNotification notification, final GenericVnf vnf) {
+ for (final LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs vnfc : notification.getAffectedVnfcs()) {
+ if (ChangeTypeEnum.REMOVED.equals(vnfc.getChangeType())) {
+
+ final Relationship relationshipToVserver = aaiHelper.deleteRelationshipWithDataValue(vnf, "vserver",
+ "vserver.vserver-id", vnfc.getComputeResource().getResourceId());
+
+ aaiServiceProvider.invokeDeleteVserver(
+ aaiHelper.getRelationshipData(relationshipToVserver, "cloud-region.cloud-owner"),
+ aaiHelper.getRelationshipData(relationshipToVserver, "cloud-region.cloud-region-id"),
+ aaiHelper.getRelationshipData(relationshipToVserver, "tenant.tenant-id"),
+ vnfc.getComputeResource().getResourceId());
}
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
index e241d0de7e..3ead98fce2 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
@@ -97,7 +97,7 @@ public class Sol003GrantController {
if (grantRequest.getOperation().equals(GrantRequest.OperationEnum.INSTANTIATE)) {
grantResponse.addResources(getResources(grantRequest.getAddResources(), vimConnectionId));
} else if (grantRequest.getOperation().equals(GrantRequest.OperationEnum.TERMINATE)) {
- grantResponse.addResources(getResources(grantRequest.getRemoveResources(), vimConnectionId));
+ grantResponse.removeResources(getResources(grantRequest.getRemoveResources(), vimConnectionId));
}
return grantResponse;
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
index 4af0da1485..69223d7922 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
@@ -22,6 +22,7 @@ package org.onap.so.adapters.vnfmadapter.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
@@ -102,6 +103,7 @@ public class Sol003GrantControllerTest {
final ResponseEntity<InlineResponse201> response = controller.grantsPost(grantRequest);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
assertEquals(1, response.getBody().getAddResources().size());
+ assertNull(response.getBody().getRemoveResources());
assertEquals(vimConnectionId, response.getBody().getAddResources().get(0).getVimConnectionId());
assertEquals("myTestVnfIdOnVnfm", response.getBody().getVnfInstanceId());
@@ -128,8 +130,9 @@ public class Sol003GrantControllerTest {
final ResponseEntity<InlineResponse201> response = controller.grantsPost(grantRequest);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
- assertEquals(1, response.getBody().getAddResources().size());
- assertEquals(vimConnectionId, response.getBody().getAddResources().get(0).getVimConnectionId());
+ assertNull(response.getBody().getAddResources());
+ assertEquals(1, response.getBody().getRemoveResources().size());
+ assertEquals(vimConnectionId, response.getBody().getRemoveResources().get(0).getVimConnectionId());
assertEquals("myTestVnfIdOnVnfm", response.getBody().getVnfInstanceId());
assertEquals("123456", response.getBody().getVnfLcmOpOccId());
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
index 822201ea1c..aeb7cd3540 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
@@ -49,6 +49,8 @@ import org.mockito.hamcrest.MockitoHamcrest;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
+import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
@@ -221,7 +223,7 @@ public class Sol003LcnControllerTest {
.andRespond(withSuccess(gson.toJson(vnfInstance), MediaType.APPLICATION_JSON));
mockRestServer.expect(requestTo(new URI("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm")))
- .andRespond(withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON));
+ .andRespond(withStatus(HttpStatus.NO_CONTENT).contentType(MediaType.APPLICATION_JSON));
final GenericVnf genericVnf = createGenericVnf("vnfmType1");
genericVnf.setSelflink("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm");
@@ -229,6 +231,7 @@ public class Sol003LcnControllerTest {
listOfGenericVnfs.add(genericVnf);
final GenericVnfs genericVnfs = new GenericVnfs();
genericVnfs.getGenericVnf().addAll(listOfGenericVnfs);
+ addRelationshipFromGenericVnfToVserver(genericVnf, "myVnfc1");
doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher(
@@ -320,6 +323,31 @@ public class Sol003LcnControllerTest {
return genericVnf;
}
+ private void addRelationshipFromGenericVnfToVserver(final GenericVnf genericVnf, final String vserverId) {
+ final Relationship relationshipToVserver = new Relationship();
+ relationshipToVserver.setRelatedTo("vserver");
+ final RelationshipData relationshipData1 = new RelationshipData();
+ relationshipData1.setRelationshipKey("vserver.vserver-id");
+ relationshipData1.setRelationshipValue(vserverId);
+ relationshipToVserver.getRelationshipData().add(relationshipData1);
+ final RelationshipData relationshipData2 = new RelationshipData();
+ relationshipData2.setRelationshipKey("cloud-region.cloud-owner");
+ relationshipData2.setRelationshipValue(CLOUD_OWNER);
+ relationshipToVserver.getRelationshipData().add(relationshipData2);
+ final RelationshipData relationshipData3 = new RelationshipData();
+ relationshipData3.setRelationshipKey("cloud-region.cloud-region-id");
+ relationshipData3.setRelationshipValue(REGION);
+ relationshipToVserver.getRelationshipData().add(relationshipData3);
+ final RelationshipData relationshipData4 = new RelationshipData();
+ relationshipData4.setRelationshipKey("tenant.tenant-id");
+ relationshipData4.setRelationshipValue(TENANT_ID);
+ relationshipToVserver.getRelationshipData().add(relationshipData4);
+
+ final RelationshipList relationshipList = new RelationshipList();
+ relationshipList.getRelationship().add(relationshipToVserver);
+ genericVnf.setRelationshipList(relationshipList);
+ }
+
private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> {
final String uriAsString;
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index fc0197dc52..dd159c0b38 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -599,6 +599,8 @@ public class ASDCController {
}
}
+ wd.updateCatalogDBStatus(iNotif.getServiceInvariantUUID(), overallStatus);
+
if (isDeploySuccess && watchdogError == null) {
sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK,
null);
@@ -613,7 +615,6 @@ public class ASDCController {
wdsRepo.save(wds);
}
-
} catch (ObjectOptimisticLockingFailureException e) {
logger.debug(
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java
index 46ec34e8d3..6a9c1aa848 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java
@@ -50,13 +50,12 @@ import org.springframework.stereotype.Component;
* This is a TEST only rest interface. It is not used in production, it is used to aid in testing the ASDC service on
* jboss without the need to be connected to the ASDC service broker. It starts the test at the treatNotification step
* and simulates both the notification step as well as the artifact download step.
- *
+ * <p>
* i.e. http://localhost:8080/asdc/treatNotification/v1
- *
+ * <p>
* i.e. http://localhost:8080/asdc/statusData/v1
- *
- * @author jm5423
*
+ * @author jm5423
*/
@Path("/")
@@ -64,10 +63,6 @@ import org.springframework.stereotype.Component;
@Profile("test")
public class ASDCRestInterface {
- private static DistributionClientEmulator distributionClientEmulator;
-
- private static JsonStatusData statusData;
-
private static final Logger logger = LoggerFactory.getLogger(ASDCRestInterface.class);
@Autowired
@@ -83,7 +78,7 @@ public class ASDCRestInterface {
public Response invokeASDCService(NotificationDataImpl request,
@HeaderParam("resource-location") String resourceLocation)
throws ASDCControllerException, ASDCParametersException, IOException {
- distributionClientEmulator = new DistributionClientEmulator(resourceLocation);
+ DistributionClientEmulator distributionClientEmulator = new DistributionClientEmulator(resourceLocation);
asdcController.setControllerName("asdc-controller1");
asdcController.setDistributionClient(distributionClientEmulator);
@@ -100,22 +95,24 @@ public class ASDCRestInterface {
public Response invokeASDCStatusData(String request) {
try {
- distributionClientEmulator = new DistributionClientEmulator("resource-examples/");
- statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
+ DistributionClientEmulator distributionClientEmulator =
+ new DistributionClientEmulator("resource-examples/");
+ JsonStatusData statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
ASDCController controller = new ASDCController("asdc-controller1", distributionClientEmulator);
controller.initASDC();
toscaInstaller.installTheComponentStatus(statusData);
controller.closeASDC();
+
+ logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), statusData.getDistributionID(),
+ "ASDC", "ASDC Updates Are Complete");
} catch (Exception e) {
logger.info("Error caught " + e.getMessage());
logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION.toString(),
"Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService",
ErrorCode.BusinessProcesssError.getValue(), "Exception in invokeASDCService", e);
}
- logger.info("ASDC Updates are complete");
- logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), statusData.getDistributionID(),
- "ASDC", "ASDC Updates Are Complete");
+
return null;
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index ddf1f3d84b..fce8c5655b 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -2271,7 +2271,7 @@ public class ToscaResourceInstaller {
// setting resource input for vnf customization
vnfResourceCustomization.setResourceInput(
getResourceInput(toscaResourceStructure, vnfResourceCustomization.getModelCustomizationUUID()));
- vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
+ service.getVnfCustomizations().add(vnfResourceCustomization);
}
return vnfResourceCustomization;
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java
index 3659ceed12..0128078a59 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java
@@ -30,6 +30,7 @@ import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
@@ -140,7 +141,6 @@ public class WatchdogDistribution {
logger.debug("Updating overall DistributionStatus to: {} for distributionId: ", status,
distributionId);
- watchdogDistributionStatus.setDistributionIdStatus(status);
watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
} else {
logger.debug("Components Size Didn't match with the WatchdogComponentDistributionStatus results.");
@@ -181,6 +181,8 @@ public class WatchdogDistribution {
throw new Exception(error);
}
+
+
AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, serviceModelInvariantUUID,
serviceModelVersionId);
aaiUri.depth(Depth.ZERO); // Do not return relationships if any
@@ -198,6 +200,16 @@ public class WatchdogDistribution {
}
}
+ public void updateCatalogDBStatus(String serviceModelVersionId, String status) {
+ try {
+ Service foundService = serviceRepo.findOneByModelUUID(serviceModelVersionId);
+ foundService.setDistrobutionStatus(status);
+ serviceRepo.save(foundService);
+ } catch (Exception e) {
+ logger.error("Error updating CatalogDBStatus", e);
+ }
+ }
+
public AAIResourcesClient getAaiClient() {
if (aaiClient == null) {
aaiClient = new AAIResourcesClient();
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index bdd906d870..0e8024da0a 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -806,6 +806,7 @@ CREATE TABLE `service` (
`WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL,
`SERVICE_CATEGORY` varchar(200) DEFAULT NULL,
`RESOURCE_ORDER` varchar(200) default NULL,
+ OVERALL_DISTRIBUTION_STATUS varchar(45),
PRIMARY KEY (`MODEL_UUID`),
KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`),
CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceLevel.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceLevel.java
new file mode 100644
index 0000000000..a3c75dbd41
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceLevel.java
@@ -0,0 +1,5 @@
+package org.onap.so.bpmn.common.resource;
+
+public enum ResourceLevel {
+ FIRST, SECOND
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
index 0dbf2c2a75..58f775ce0b 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +22,9 @@
package org.onap.so.bpmn.common.resource;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
@@ -31,6 +34,7 @@ import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
+import org.apache.commons.lang.StringUtils;
import org.camunda.bpm.engine.runtime.Execution;
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.bpmn.core.json.JsonUtils;
@@ -82,20 +86,20 @@ public class ResourceRequestBuilder {
* "requestInputs":{K,V} } <br>
*
* @param execution Execution context
- *
+ *
* @param serviceUuid The service template uuid
- *
+ *
* @param resourceCustomizationUuid The resource customization uuid
- *
+ *
* @param serviceParameters the service parameters passed from the API
- *
+ *
* @return the resource instantiate parameters
- *
+ *
* @since ONAP Beijing Release
*/
@SuppressWarnings("unchecked")
public static String buildResourceRequestParameters(Execution execution, String serviceUuid,
- String resourceCustomizationUuid, String serviceParameters) {
+ String resourceCustomizationUuid, String serviceParameters, Map<String, Object> currentVFData) {
List<String> resourceList =
jsonUtil.StringArrayToList(execution, (String) JsonUtils.getJsonValue(serviceParameters, "resources"));
// Get the right location str for resource. default is an empty array.
@@ -126,7 +130,7 @@ public class ResourceRequestBuilder {
}
Map<String, Object> resourceInputsFromServiceDeclaredLevel =
- buildResouceRequest(serviceUuid, resourceCustomizationUuid, serviceInput);
+ buildResouceRequest(serviceUuid, resourceCustomizationUuid, serviceInput, currentVFData);
resourceInputsFromUuiMap.putAll(resourceInputsFromServiceDeclaredLevel);
String resourceInputsStr = getJsonString(resourceInputsFromUuiMap);
String result = "{\n" + "\"locationConstraints\":" + locationConstraints + ",\n" + "\"requestInputs\":"
@@ -136,7 +140,7 @@ public class ResourceRequestBuilder {
@SuppressWarnings("unchecked")
public static Map<String, Object> buildResouceRequest(String serviceUuid, String resourceCustomizationUuid,
- Map<String, Object> serviceInputs) {
+ Map<String, Object> serviceInputs, Map<String, Object> currentVFData) {
try {
Map<String, Object> serviceInstnace = getServiceInstnace(serviceUuid);
// find match of customization uuid in vnf
@@ -144,24 +148,27 @@ public class ResourceRequestBuilder {
(Map<String, Map<String, Object>>) serviceInstnace.get("serviceResources");
List<Map<String, Object>> serviceVnfCust = (List<Map<String, Object>>) serviceResources.get("serviceVnfs");
- String resourceInputStr = getResourceInputStr(serviceVnfCust, resourceCustomizationUuid);
+ Map<String, String> resourceInputData = getResourceInputStr(serviceVnfCust, resourceCustomizationUuid);
// find match in network resource
- if (resourceInputStr == null) {
+ if (resourceInputData.size() == 0) {
List<Map<String, Object>> serviceNetworkCust =
(List<Map<String, Object>>) serviceResources.get("serviceNetworks");
- resourceInputStr = getResourceInputStr(serviceNetworkCust, resourceCustomizationUuid);
+ resourceInputData = getResourceInputStr(serviceNetworkCust, resourceCustomizationUuid);
// find match in AR resource
- if (resourceInputStr == null) {
+ if (resourceInputData == null) {
List<Map<String, Object>> serviceArCust =
(List<Map<String, Object>>) serviceResources.get("serviceAllottedResources");
- resourceInputStr = getResourceInputStr(serviceArCust, resourceCustomizationUuid);
+ resourceInputData = getResourceInputStr(serviceArCust, resourceCustomizationUuid);
}
}
+ String resourceInputStr = resourceInputData.get("resourceInput");
+ ResourceLevel resourceLevel = ResourceLevel.valueOf(resourceInputData.get("nodeType"));
+
if (resourceInputStr != null && !resourceInputStr.isEmpty()) {
- return getResourceInput(resourceInputStr, serviceInputs);
+ return getResourceInput(resourceInputStr, serviceInputs, resourceLevel, currentVFData);
}
} catch (Exception e) {
@@ -170,47 +177,220 @@ public class ResourceRequestBuilder {
return new HashMap();
}
- private static String getResourceInputStr(List<Map<String, Object>> resources, String resCustomizationUuid) {
+ private static Map<String, String> getResourceInputStr(List<Map<String, Object>> resources,
+ String resCustomizationUuid) {
+ Map<String, String> resourceInputMap = new HashMap<>(2);
for (Map<String, Object> resource : resources) {
Map<String, String> modelInfo = (Map<String, String>) resource.get("modelInfo");
if (modelInfo.get("modelCustomizationUuid").equalsIgnoreCase(resCustomizationUuid)) {
- return (String) resource.get("resourceInput");
+ resourceInputMap.put("resourceInput", (String) resource.get("resourceInput"));
+ String nodeType = ResourceLevel.FIRST.toString();
+ if (((String) resource.get("toscaNodeType")).contains(".vf.")) {
+ nodeType = ResourceLevel.FIRST.toString();
+ } else if (((String) resource.get("toscaNodeType")).contains(".vfc.")) {
+ nodeType = ResourceLevel.SECOND.toString();
+ }
+ resourceInputMap.put("nodeType", nodeType);
+ return resourceInputMap;
}
}
return null;
}
// this method combines resource input with service input
- private static Map<String, Object> getResourceInput(String resourceInputStr, Map<String, Object> serviceInputs) {
+ private static Map<String, Object> getResourceInput(String resourceInputStr, Map<String, Object> serviceInputs,
+ ResourceLevel resourceLevel, Map<String, Object> currentVFData) {
Gson gson = new Gson();
Type type = new TypeToken<Map<String, String>>() {}.getType();
Map<String, Object> resourceInput = gson.fromJson(resourceInputStr, type);
+ JsonParser parser = new JsonParser();
+
+ Map<String, Object> uuiServiceInput = serviceInputs;
+
+ int firstLevelIndex = 0;
+ int secondLevelIndex = 0;
+ String firstLevelKey = null;
+ String secondLevelKey = null;
+ boolean levelKeyNameUpdated = false;
+ int indexToPick = 0;
+
+ if (null != currentVFData) {
+ firstLevelIndex = getIntValue(currentVFData.get("currentFirstLevelIndex"), 0);
+ secondLevelIndex = getIntValue(currentVFData.get("currentSecondLevelIndex"), 0);
+ final String lastFirstLevelKey = firstLevelKey = (String) currentVFData.get("currentFirstLevelKey");
+ final String lastSecondLevelKey = secondLevelKey = (String) currentVFData.get("currentSecondLevelKey");
+
+ if (null != currentVFData.get("lastNodeTypeProcessed")) {
+ ResourceLevel lastResourceLevel =
+ ResourceLevel.valueOf(currentVFData.get("lastNodeTypeProcessed").toString());
+ switch (resourceLevel) {
+ case FIRST:
+ // if it is next request for same group then increment first level index
+ switch (lastResourceLevel) {
+ case FIRST:
+ boolean isSameLevelRequest = resourceInput.values().stream().anyMatch(item -> {
+ JsonElement tree = parser.parse(((String) item).split("\\|")[0]);
+ return tree.isJsonArray() && tree.getAsJsonArray().get(0).getAsString()
+ .equalsIgnoreCase(lastFirstLevelKey);
+ });
+ if (isSameLevelRequest) {
+ firstLevelIndex++;
+ }
+ break;
+ case SECOND:
+ firstLevelIndex = 0;
+ secondLevelKey = null;
+ break;
+
+ }
+ indexToPick = firstLevelIndex;
+ break;
+ case SECOND:
+ // if it is next request for same group then increment second level index
+ switch (lastResourceLevel) {
+ case FIRST:
+ secondLevelIndex = 0;
+ break;
+ case SECOND:
+ boolean isSameLevelRequest = resourceInput.values().stream().anyMatch(item -> {
+ JsonElement tree = parser.parse(((String) item).split("\\|")[0]);
+ return tree.isJsonArray() && tree.getAsJsonArray().get(0).getAsString()
+ .equalsIgnoreCase(lastSecondLevelKey);
+ });
+ if (isSameLevelRequest) {
+ secondLevelIndex++;
+ }
+ break;
+ }
+ // get actual parent object to search for second level objects
+ if (null != lastFirstLevelKey) {
+ Object currentObject = serviceInputs.get(lastFirstLevelKey);
+ if ((null != currentObject) && (currentObject instanceof List)) {
+ List currentFirstLevelList = (List) currentObject;
+ if (currentFirstLevelList.size() > firstLevelIndex) {
+ uuiServiceInput = (Map<String, Object>) currentFirstLevelList.get(firstLevelIndex);
+ }
+
+ }
+ }
+ indexToPick = secondLevelIndex;
+ break;
+
+ }
+ }
+
+
+ }
// replace value if key is available in service input
for (String key : resourceInput.keySet()) {
String value = (String) resourceInput.get(key);
if (value.contains("|")) {
+
+ // check which level
+
// node it type of getinput
String[] split = value.split("\\|");
String tmpKey = split[0];
- if (serviceInputs.containsKey(tmpKey)) {
- value = (String) serviceInputs.get(tmpKey);
+
+ JsonElement jsonTree = parser.parse(tmpKey);
+
+ // check if it is a list type
+ if (jsonTree.isJsonArray()) {
+ JsonArray jsonArray = jsonTree.getAsJsonArray();
+ boolean matchFound = false;
+ if (jsonArray.size() == 3) {
+ String keyName = jsonArray.get(0).getAsString();
+ String keyType = jsonArray.get(2).getAsString();
+ if (!levelKeyNameUpdated) {
+ switch (resourceLevel) {
+ case FIRST:
+ firstLevelKey = keyName;
+ break;
+ case SECOND:
+ secondLevelKey = keyName;
+ break;
+ }
+ levelKeyNameUpdated = true;
+ }
+
+ if (uuiServiceInput.containsKey(keyName)) {
+ Object vfcLevelObject = uuiServiceInput.get(keyName);
+ // it will be always list
+ if (vfcLevelObject instanceof List) {
+ List vfcObject = (List) vfcLevelObject;
+ if (vfcObject.size() > indexToPick) {
+ Map<String, Object> vfMap = (Map<String, Object>) vfcObject.get(indexToPick);
+ if (vfMap.containsKey(keyType)) {
+ if (vfMap.get(keyType) instanceof String) {
+ value = (String) vfMap.get(keyType);
+ } else {
+ value = getJsonString(vfMap.get(keyType));
+ }
+ matchFound = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (!matchFound) {
+ if (split.length == 1) { // means value is empty e.g. "a":"key1|"
+ value = "";
+ } else {
+ value = split[1];
+ }
+ }
+
} else {
- if (split.length == 1) { // means value is empty e.g. "a":"key1|"
- value = "";
+
+ // if not a list type
+ if (uuiServiceInput.containsKey(tmpKey)) {
+ value = (String) uuiServiceInput.get(tmpKey);
} else {
- value = split[1];
+ if (split.length == 1) { // means value is empty e.g. "a":"key1|"
+ value = "";
+ } else {
+ value = split[1];
+ }
}
}
+
}
resourceInput.put(key, value);
}
+ // store current processed details into map
+ if (null != currentVFData) {
+ currentVFData.put("currentFirstLevelKey", firstLevelKey);
+ currentVFData.put("currentFirstLevelIndex", firstLevelIndex);
+ currentVFData.put("currentSecondLevelKey", secondLevelKey);
+ currentVFData.put("currentSecondLevelIndex", secondLevelIndex);
+ currentVFData.put("lastNodeTypeProcessed", resourceLevel.toString());
+ }
+
return resourceInput;
}
+ private static int getIntValue(Object inputObj, int defaultValue) {
+ if (null != inputObj) {
+ if (inputObj instanceof Integer) {
+ return ((Integer) inputObj).intValue();
+ }
+ if (StringUtils.isNotEmpty(inputObj.toString())) {
+ try {
+ int val = Integer.parseInt(inputObj.toString());
+ return val;
+ } catch (NumberFormatException e) {
+ logger.warn("Unable to parse to int", e.getMessage());
+ }
+ }
+ }
+ return defaultValue;
+ }
+
public static Map<String, Object> getServiceInstnace(String uuid) throws Exception {
String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint");
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java
new file mode 100644
index 0000000000..84cf491355
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java
@@ -0,0 +1,17 @@
+package org.onap.so.client.exception;
+
+
+public class UnexpectedDataException extends Exception {
+
+ public UnexpectedDataException() {}
+
+ public UnexpectedDataException(String message, String system) {
+ super("Unexpected data found in " + system + ". " + message);
+ }
+
+ public UnexpectedDataException(String message) {
+ super("Unexpected data found. " + message);
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
index c7c181744f..adfee796f2 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
@@ -19,19 +19,53 @@
*/
package org.onap.so.bpmn.common.resource;
+import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.onap.so.BaseTest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.bpmn.mock.FileUtil;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
-
+import static org.junit.Assert.assertTrue;
public class ResourceRequestBuilderTest extends BaseTest {
+ private Map<String, Object> userInputMap = null;
+
+ private String serviceInput = null;
+
+ @Before
+ public void initializeMockObjects() {
+
+ if (null == this.userInputMap) {
+ ObjectMapper mapper = new ObjectMapper();
+
+ try {
+ String serviceInputRequest = FileUtil.readResourceFile("__files/UUI-SO-REQ.json");
+ this.userInputMap = mapper.readValue(serviceInputRequest, new TypeReference<Map<String, Object>>() {});
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ if (null == this.serviceInput) {
+
+ try {
+ this.serviceInput = FileUtil.readResourceFile("__files/SERVICE-SO-REQ-INPUT.json");
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ }
+
@Test
public void getResourceInputTest() throws Exception {
@@ -102,7 +136,7 @@ public class ResourceRequestBuilderTest extends BaseTest {
HashMap serviceInput = new HashMap();
serviceInput.put("key", "value");
Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null);
assertEquals(stringObjectMap.get("a"), "value");
}
@@ -173,7 +207,7 @@ public class ResourceRequestBuilderTest extends BaseTest {
HashMap serviceInput = new HashMap();
serviceInput.put("key1", "value");
Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null);
assertEquals(stringObjectMap.get("a"), "default_value");
}
@@ -244,7 +278,7 @@ public class ResourceRequestBuilderTest extends BaseTest {
HashMap serviceInput = new HashMap();
serviceInput.put("key1", "value");
Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null);
assertEquals(stringObjectMap.get("a"), "value");
}
@@ -337,7 +371,7 @@ public class ResourceRequestBuilderTest extends BaseTest {
HashMap serviceInput = new HashMap();
serviceInput.put("key1", "value");
Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null);
assertEquals(0, stringObjectMap.size());
}
@@ -382,8 +416,78 @@ public class ResourceRequestBuilderTest extends BaseTest {
HashMap serviceInput = new HashMap();
serviceInput.put("key2", "value");
Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", serviceInput);
+ "c3954379-4efe-431c-8258-f84905b158e5", "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", serviceInput, null);
assertEquals(stringObjectMap.get("a"), "");
}
+ @Test
+ public void getListResourceInputTest() throws Exception {
+
+
+
+ wireMockServer.stubFor(get(urlEqualTo(
+ "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok(this.serviceInput)));
+
+ // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+
+ // VF level request
+ Map<String, Object> currentVFData = new HashMap<>();
+ Map<String, Object> stringObjectMap =
+ ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
+ "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", this.userInputMap, currentVFData);
+ assertEquals("b", stringObjectMap.get("a"));
+ assertEquals("hub_spoke", stringObjectMap.get("topology"));
+ assertEquals("defaultvpn", stringObjectMap.get("name"));
+ assertTrue(((String) stringObjectMap.get("sitelist")).contains("["));
+
+ // vfc level request
+ stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
+ "e776449e-2b10-45c5-9217-2775c88ca1a0", this.userInputMap, currentVFData);
+ assertEquals("", stringObjectMap.get("a"));
+ assertEquals("layer3-port", stringObjectMap.get("portswitch"));
+ assertEquals("192.168.10.1", stringObjectMap.get("ipAddress"));
+ assertEquals("vCPE", stringObjectMap.get("deviceName"));
+
+ // vfc level request
+ stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
+ "e776449e-2b10-45c5-9217-2775c88ca1a1", this.userInputMap, currentVFData);
+ assertEquals("", stringObjectMap.get("a"));
+ assertEquals("layer2-port", stringObjectMap.get("portswitch"));
+ assertEquals("192.168.11.1", stringObjectMap.get("ipAddress"));
+ assertEquals("CPE_Beijing", stringObjectMap.get("deviceName"));
+
+ // VF level request
+ stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
+ "e776449e-2b10-45c5-9217-2775c88ca1c1", this.userInputMap, currentVFData);
+ assertEquals("Huawei Private Cloud", stringObjectMap.get("address"));
+ assertEquals("dsvpn_hub1", stringObjectMap.get("role"));
+ assertTrue(((String) stringObjectMap.get("wanlist")).contains("["));
+ assertTrue(((String) stringObjectMap.get("devlist")).contains("["));
+
+ // VFC request
+ stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
+ "e776449e-2b10-45c5-9217-2775c88cb1a1", this.userInputMap, currentVFData);
+ assertEquals("Huawei Private Cloud", stringObjectMap.get("address"));
+ assertEquals("20000", stringObjectMap.get("postcode"));
+ assertEquals("single_gateway", stringObjectMap.get("type"));
+ assertEquals("vCPE", stringObjectMap.get("deviceName"));
+ assertEquals("20.20.20.1", stringObjectMap.get("systemip"));
+ assertEquals("default_ipv6", stringObjectMap.get("systemipv6"));
+
+
+ // VFC request again
+ /*
+ * stringObjectMap = ResourceRequestBuilder.buildResouceRequest( "c3954379-4efe-431c-8258-f84905b158e5",
+ * "e776449e-2b10-45c5-9217-2775c88cb1f1", this.userInputMap, currentVFData);
+ * assertEquals("Huawei Public Cloud", stringObjectMap.get("address")); assertEquals("20001",
+ * stringObjectMap.get("postcode")); assertEquals("multiple_gateway", stringObjectMap.get("type"));
+ * assertEquals("CPE_Beijing", stringObjectMap.get("deviceName")); assertEquals("20.20.20.2",
+ * stringObjectMap.get("systemip"));
+ */
+
+
+ }
+
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json
new file mode 100644
index 0000000000..938b45e5a4
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json
@@ -0,0 +1,206 @@
+{
+ "serviceResources": {
+ "modelInfo": {
+ "modelName": "demoVFWCL",
+ "modelUuid": "c3954379-4efe-431c-8258-f84905b158e5",
+ "modelInvariantUuid": "0cbff61e-3b0a-4eed-97ce-b1b4faa03493",
+ "modelVersion": "1.0"
+ },
+ "serviceType": "",
+ "serviceRole": "",
+ "environmentContext": null,
+ "resourceOrder": "res1,res2",
+ "workloadContext": "Production",
+ "serviceVnfs": [
+
+ {
+ "modelInfo": {
+ "modelName": "15968a6e-2fe5-41bf-a481",
+ "modelUuid": "808abda3-2023-4105-92d2-e62644b61d53",
+ "modelInvariantUuid": "6e4ffc7c-497e-4a77-970d-af966e642d31",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "a00404d5-d7eb-4c46-b6b6-9cf2d087e545",
+ "modelInstanceName": "15968a6e-2fe5-41bf-a481 0"
+ },
+ "toscaNodeType": "org.openecomp.resource.vf.15968a6e2fe541bfA481",
+ "nfFunction": null,
+ "resourceInput": "{\"a\":\"b\",\"topology\":\"[sdwanvpnresource_list,INDEX,sdwanvpn_topology]|default_topo\",\"name\":\"[sdwanvpnresource_list,INDEX,sdwanvpn_name]|default_name\",\"sitelist\":\"[sdwanvpnresource_list,INDEX,sdwansitelan_list]|default_sitelist\"}",
+ "nfType": null,
+ "nfRole": null,
+ "nfNamingCode": null,
+ "multiStageDesign": "false",
+ "vfModules": [{
+ "modelInfo": {
+ "modelName": "15968a6e2fe541bfA481..base_vfw..module-0",
+ "modelUuid": "ec7fadde-1e5a-42f7-8255-cb19e475ff45",
+ "modelInvariantUuid": "61ab8b64-a014-4cf3-8a5a-b5ef388f8819",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "123aff6b-854f-4026-ae1e-cc74a3924576"
+ },
+ "isBase": true,
+ "vfModuleLabel": "base_vfw",
+ "initialCount": 1,
+ "hasVolumeGroup": true
+ }]
+ },
+
+ {
+ "modelInfo": {
+ "modelName": "f971106a-248f-4202-9d1f",
+ "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add7e",
+ "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f3",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1a0",
+ "modelInstanceName": "f971106a-248f-4202-9d1f 0"
+ },
+ "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f",
+ "nfFunction": null,
+ "nfType": null,
+ "nfRole": null,
+ "resourceInput": "{\"a\":\"b|\",\"portswitch\":\"[sdwansitelan_list,INDEX,portSwitch]|default_portswitch\",\"ipAddress\":\"[sdwansitelan_list,INDEX,ipAddress]|default_ipAddress\",\"deviceName\":\"[sdwansitelan_list,INDEX,deviceName]|default_deviceName\"}",
+ "nfNamingCode": null,
+ "multiStageDesign": "false",
+ "vfModules": [{
+ "modelInfo": {
+ "modelName": "F971106a248f42029d1f..base_vpkg..module-0",
+ "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35",
+ "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc"
+ },
+ "isBase": true,
+ "vfModuleLabel": "base_vpkg",
+ "initialCount": 1,
+ "hasVolumeGroup": true
+ }]
+ },
+
+ {
+ "modelInfo": {
+ "modelName": "f971106a-248f-4202-9d1e",
+ "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add7d",
+ "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f2",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1a1",
+ "modelInstanceName": "f971106a-248f-4202-9d1e 0"
+ },
+ "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f",
+ "nfFunction": null,
+ "nfType": null,
+ "nfRole": null,
+ "resourceInput": "{\"a\":\"b|\",\"portswitch\":\"[sdwansitelan_list,INDEX,portSwitch]|default_portswitch\",\"ipAddress\":\"[sdwansitelan_list,INDEX,ipAddress]|default_ipAddress\",\"deviceName\":\"[sdwansitelan_list,INDEX,deviceName]|default_deviceName\"}",
+ "nfNamingCode": null,
+ "multiStageDesign": "false",
+ "vfModules": [{
+ "modelInfo": {
+ "modelName": "F971106a248f42029d1f..base_vpkg..module-0",
+ "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35",
+ "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc"
+ },
+ "isBase": true,
+ "vfModuleLabel": "base_vpkg",
+ "initialCount": 1,
+ "hasVolumeGroup": true
+ }]
+ },
+
+ {
+ "modelInfo": {
+ "modelName": "f971106a-248f-4202-9d2e",
+ "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add8d",
+ "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89c2",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1c1",
+ "modelInstanceName": "f971106a-248f-4202-9d2e 0"
+ },
+ "toscaNodeType": "org.openecomp.resource.vf.F971106a248f42029d1f",
+ "nfFunction": null,
+ "nfType": null,
+ "nfRole": null,
+ "resourceInput": "{\"address\":\"[sdwansiteresource_list,INDEX,sdwansite_address]|default_address\",\"role\":\"[sdwansiteresource_list,INDEX,sdwansite_role]|default_role\",\"wanlist\":\"[sdwansiteresource_list,INDEX,sdwansitewan_list]|default_wanlist\",\"devlist\":\"[sdwansiteresource_list,INDEX,sdwandevice_list]|default_devlist\"}",
+ "nfNamingCode": null,
+ "multiStageDesign": "false",
+ "vfModules": [{
+ "modelInfo": {
+ "modelName": "F971106a248f42029d1f..base_vpkg..module-0",
+ "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35",
+ "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc"
+ },
+ "isBase": true,
+ "vfModuleLabel": "base_vpkg",
+ "initialCount": 1,
+ "hasVolumeGroup": true
+ }]
+ },
+
+ {
+ "modelInfo": {
+ "modelName": "f971106a-248f-4202-9d3e",
+ "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add9d",
+ "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f3",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88cb1a1",
+ "modelInstanceName": "f971106a-248f-4202-9d3e 0"
+ },
+ "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f",
+ "nfFunction": null,
+ "nfType": null,
+ "nfRole": null,
+ "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"deviceName\":\"[sdwansitewan_list,INDEX,deviceName]|default_deviceName\",\"systemip\":\"[sdwandevice_list,INDEX,systemIp]|default_systemip\", \"systemipv6\":\"[sdwandevice_list,INDEX,systemIpv6]|default_ipv6\"}",
+ "nfNamingCode": null,
+ "multiStageDesign": "false",
+ "vfModules": [{
+ "modelInfo": {
+ "modelName": "F971106a248f42029d1f..base_vpkg..module-0",
+ "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35",
+ "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc"
+ },
+ "isBase": true,
+ "vfModuleLabel": "base_vpkg",
+ "initialCount": 1,
+ "hasVolumeGroup": true
+ }]
+ },
+
+ {
+ "modelInfo": {
+ "modelName": "f971106a-248f-4202-9d5e",
+ "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add3d",
+ "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe8393",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88cb1f1",
+ "modelInstanceName": "f971106a-248f-4202-9d5e 0"
+ },
+ "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d3f",
+ "nfFunction": null,
+ "nfType": null,
+ "nfRole": null,
+ "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"deviceName\":\"[sdwansitewan_list,INDEX,deviceName]|default_deviceName\",\"systemip\":\"[sdwandevice_list,INDEX,systemIp]|default_systemip\"}",
+ "nfNamingCode": null,
+ "multiStageDesign": "false",
+ "vfModules": [{
+ "modelInfo": {
+ "modelName": "F971106a248f42029d1f..base_vpkg..module-0",
+ "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35",
+ "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc"
+ },
+ "isBase": true,
+ "vfModuleLabel": "base_vpkg",
+ "initialCount": 1,
+ "hasVolumeGroup": true
+ }]
+ }
+
+ ],
+ "serviceNetworks": [],
+ "serviceAllottedResources": []
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json
new file mode 100644
index 0000000000..e6161862ae
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json
@@ -0,0 +1 @@
+{ "sdwanvpnresource_list":[ { "sdwanvpn_topology":"hub_spoke", "sdwanvpn_name":"defaultvpn", "sdwansitelan_list":[ { "role":"Hub", "portType":"GE", "portSwitch":"layer3-port", "vlanId":"", "ipAddress":"192.168.10.1", "deviceName":"vCPE", "portNumer":"0/0/1" }, { "role":"Hub", "portType":"GE", "portSwitch":"layer2-port", "vlanId":"55", "ipAddress":"192.168.11.1", "deviceName":"CPE_Beijing", "portNumer":"0/0/1" } ] } ], "sdwansiteresource_list":[ { "sdwansite_emails":"chenchuanyu@huawei.com", "sdwansite_address":"Huawei Private Cloud", "sdwansite_description":"DC Site", "sdwansite_role":"dsvpn_hub1", "sdwansite_postcode":"20000", "sdwansite_type":"single_gateway", "sdwansite_latitude":"", "sdwansite_controlPoint":"", "sdwansite_longitude":"", "sdwansitewan_list":[ { "providerIpAddress":"", "portType":"GE", "inputBandwidth":"1000", "ipAddress":"", "name":"10000", "transportNetworkName":"internet", "outputBandwidth":"10000", "deviceName":"vCPE", "portNumber":"0/0/0", "ipMode":"DHCP", "publicIP":"119.3.7.113" } ], "sdwandevice_list":[ { "esn":"XXXXXXX", "vendor":"Huawei", "name":"vCPE", "type":"AR1000V", "version":"1.0", "class":"VNF", "systemIp":"20.20.20.1" } ] }, { "sdwansite_emails":"chenchuanyu@huawei.com", "sdwansite_address":"Huawei Public Cloud", "sdwansite_description":"DC Site", "sdwansite_role":"dsvpn_hub", "sdwansite_postcode":"20001", "sdwansite_type":"multiple_gateway", "sdwansite_latitude":"", "sdwansite_controlPoint":"", "sdwansite_longitude":"", "sdwansitewan_list":[ { "providerIpAddress":"", "portType":"GE", "inputBandwidth":"1000", "ipAddress":"172.18.1.2/24", "name":"10000", "transportNetworkName":"internet", "outputBandwidth":"10000", "deviceName":"CPE_Beijing", "portNumber":"0/0/0", "ipMode":"Static", "publicIP":"" } ], "sdwandevice_list":[ { "esn":"XXXXXXX", "vendor":"Huawei", "name":"CPE_Beijing", "type":"AR161", "version":"1.0", "class":"PNF", "systemIp":"20.20.20.2" } ] } ] } \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
index 7ad929b1c2..c99c702af0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
@@ -184,7 +184,7 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce
rmodel.setResourceCustomizationUuid(resourceCustomizationUuid)
addedResourceList.add(rmodel)
- Map<String, Object> resourceParameters = ResourceRequestBuilder.buildResouceRequest(serviceModelUuid, resourceCustomizationUuid, null)
+ Map<String, Object> resourceParameters = ResourceRequestBuilder.buildResouceRequest(serviceModelUuid, resourceCustomizationUuid, null, null)
requestInputs.addAll(resourceParameters.keySet())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
index 973d8a156c..0240beab9a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
@@ -260,11 +260,16 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{
//set the requestInputs from tempalte To Be Done
String serviceModelUuid = jsonUtil.getJsonValue(incomingRequest,"service.serviceUuid")
String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters")
- String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters)
+ Map<String, Object> currentVFData = (Map) execution.getVariable("currentVFData");
+ if (null == currentVFData) {
+ currentVFData = new HashMap<>();
+ }
+ String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters, currentVFData)
resourceInput.setResourceParameters(resourceParameters)
resourceInput.setRequestsInputs(incomingRequest)
execution.setVariable("resourceInput", resourceInput.toString())
execution.setVariable("resourceModelUUID", resourceInput.getResourceModelInfo().getModelUuid())
+ execution.setVariable("currentVFData",currentVFData);
logger.trace("COMPLETED prepareResourceRecipeRequest Process ")
}
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/CloudRequestData.java b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudRequestData.java
new file mode 100644
index 0000000000..abaef26562
--- /dev/null
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudRequestData.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.so.serviceinstancebeans;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+public class CloudRequestData {
+
+ Object cloudRequest;
+ String cloudIdentifier;
+
+ public CloudRequestData() {}
+
+ public CloudRequestData(Object cloudRequest, String cloudIdentifier) {
+ this.cloudRequest = cloudRequest;
+ this.cloudIdentifier = cloudIdentifier;
+ }
+
+ public Object getCloudRequest() {
+ return cloudRequest;
+ }
+
+ public void setCloudRequest(Object cloudRequest) {
+ this.cloudRequest = cloudRequest;
+ }
+
+ public String getCloudIdentifier() {
+ return cloudIdentifier;
+ }
+
+ public void setCloudIdentifier(String cloudIdentifier) {
+ this.cloudIdentifier = cloudIdentifier;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("cloudRequest", cloudRequest).append("cloudIdentifier", cloudIdentifier)
+ .toString();
+ }
+}
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java
index 8635af5b94..fbdb27c0ec 100644
--- a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java
@@ -20,7 +20,9 @@
package org.onap.so.serviceinstancebeans;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -38,6 +40,7 @@ public class Request {
protected InstanceReferences instanceReferences;
protected RequestStatus requestStatus;
protected List<RequestProcessingData> requestProcessingData;
+ protected List<CloudRequestData> cloudRequestData = new ArrayList<>();
public String getRequestId() {
@@ -112,12 +115,22 @@ public class Request {
this.requestProcessingData = requestProcessingData;
}
+
+ public List<CloudRequestData> getCloudRequestData() {
+ return cloudRequestData;
+ }
+
+ public void setCloudRequestData(List<CloudRequestData> cloudRequestData) {
+ this.cloudRequestData = cloudRequestData;
+ }
+
@Override
public String toString() {
return new ToStringBuilder(this).append("requestId", requestId).append("startTime", startTime)
.append("finishTime", finishTime).append("requestScope", requestScope)
.append("requestType", requestType).append("requestDetails", requestDetails)
.append("instanceReferences", instanceReferences).append("requestStatus", requestStatus)
- .append("requestProcessingData", requestProcessingData).toString();
+ .append("requestProcessingData", requestProcessingData).append("cloudRequestData", cloudRequestData)
+ .toString();
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index 34dcd4b0c4..1bbe858859 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -35,12 +35,14 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.http.HttpStatus;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandler.common.ResponseBuilder;
@@ -53,6 +55,7 @@ import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
+import org.onap.so.serviceinstancebeans.CloudRequestData;
import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
import org.onap.so.serviceinstancebeans.InstanceReferences;
@@ -65,6 +68,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -92,7 +97,9 @@ public class OrchestrationRequests {
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response getOrchestrationRequest(@PathParam("requestId") String requestId,
- @PathParam("version") String version) throws ApiException {
+ @PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest)
+ throws ApiException {
+
String apiVersion = version.substring(1);
GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse();
@@ -135,7 +142,7 @@ public class OrchestrationRequests {
throw validateException;
}
- Request request = mapInfraActiveRequestToRequest(infraActiveRequest);
+ Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest);
if (!requestProcessingData.isEmpty()) {
request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData));
}
@@ -150,8 +157,8 @@ public class OrchestrationRequests {
@ApiOperation(value = "Find Orchestrated Requests for a URI Information", response = Response.class)
@Produces(MediaType.APPLICATION_JSON)
@Transactional
- public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version)
- throws ApiException {
+ public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version,
+ @QueryParam("includeCloudRequest") boolean includeCloudRequest) throws ApiException {
long startTime = System.currentTimeMillis();
@@ -188,7 +195,7 @@ public class OrchestrationRequests {
List<RequestProcessingData> requestProcessingData =
requestsDbClient.getRequestProcessingDataBySoRequestId(infraActive.getRequestId());
RequestList requestList = new RequestList();
- Request request = mapInfraActiveRequestToRequest(infraActive);
+ Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest);
if (!requestProcessingData.isEmpty()) {
request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData));
}
@@ -286,8 +293,8 @@ public class OrchestrationRequests {
return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build();
}
- private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar) throws ApiException {
-
+ private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest)
+ throws ApiException {
String requestBody = iar.getRequestBody();
Request request = new Request();
@@ -329,8 +336,6 @@ public class OrchestrationRequests {
if (iar.getInstanceGroupName() != null)
ir.setInstanceGroupName(iar.getInstanceGroupName());
-
-
request.setInstanceReferences(ir);
RequestDetails requestDetails = null;
@@ -410,8 +415,19 @@ public class OrchestrationRequests {
status.setPercentProgress(iar.getProgress().intValue());
}
- request.setRequestStatus(status);
+ if (iar.getCloudApiRequests() != null && !iar.getCloudApiRequests().isEmpty() && includeCloudRequest) {
+ iar.getCloudApiRequests().stream().forEach(cloudRequest -> {
+ try {
+ request.getCloudRequestData()
+ .add(new CloudRequestData(mapper.readValue(cloudRequest.getRequestBody(), Object.class),
+ cloudRequest.getCloudIdentifier()));
+ } catch (Exception e) {
+ logger.error("Error reading Cloud Request", e);
+ }
+ });
+ }
+ request.setRequestStatus(status);
return request;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index 321ea3ac7d..c678fab03e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -48,6 +48,7 @@ import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.CloudRequestData;
import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
import org.onap.so.serviceinstancebeans.Request;
@@ -64,6 +65,7 @@ import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public class OrchestrationRequestsTest extends BaseTest {
@@ -149,13 +151,24 @@ public class OrchestrationRequestsTest extends BaseTest {
}
@Test
- public void testGetOrchestrationRequestRequestDetails() throws Exception {
- setupTestGetOrchestrationRequestRequestDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
+ public void testGetOrchestrationRequestWithOpenstackDetails() throws Exception {
+ setupTestGetOrchestrationRequestOpenstackDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
// Test request with modelInfo request body
GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
Request request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
+ List<CloudRequestData> cloudRequestData = new ArrayList<>();
+ CloudRequestData cloudData = new CloudRequestData();
+ cloudData.setCloudIdentifier("heatstackName/123123");
+ ObjectMapper mapper = new ObjectMapper();
+ Object reqData = mapper.readValue(
+ "{\r\n \"test\": \"00032ab7-3fb3-42e5-965d-8ea592502016\",\r\n \"test2\": \"deleteInstance\",\r\n \"test3\": \"COMPLETE\",\r\n \"test4\": \"Vf Module has been deleted successfully.\",\r\n \"test5\": 100\r\n}",
+ Object.class);
+ cloudData.setCloudRequest(reqData);
+ cloudRequestData.add(cloudData);
+ request.setCloudRequestData(cloudRequestData);
testResponse.setRequest(request);
+
String testRequestId = request.getRequestId();
HttpHeaders headers = new HttpHeaders();
@@ -163,15 +176,17 @@ public class OrchestrationRequestsTest extends BaseTest {
headers.set("Content-Type", MediaType.APPLICATION_JSON);
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
+ "/onap/so/infra/orchestrationRequests/v7/" + testRequestId + "?includeCloudRequest=true"));
ResponseEntity<GetOrchestrationResponse> response =
restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
+ System.out.println("Response :" + response.getBody().toString());
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
.ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
+
assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
@@ -323,70 +338,7 @@ public class OrchestrationRequestsTest extends BaseTest {
// properly called to update.
}
- @Ignore // What is this testing?
- @Test
- public void testGetOrchestrationRequestRequestDetailsWhiteSpace() throws Exception {
- InfraActiveRequests requests = new InfraActiveRequests();
- requests.setAction("create");
- requests.setRequestBody(" ");
- requests.setRequestId("requestId");
- requests.setRequestScope("service");
- requests.setRequestType("createInstance");
- ObjectMapper mapper = new ObjectMapper();
- String json = mapper.writeValueAsString(requests);
-
- requestsDbClient.save(requests);
- HttpHeaders headers = new HttpHeaders();
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
-
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
-
- ResponseEntity<GetOrchestrationResponse> response =
- restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
- }
-
- @Ignore // What is this testing?
- @Test
- public void testGetOrchestrationRequestRequestDetailsAlaCarte() throws IOException {
- InfraActiveRequests requests = new InfraActiveRequests();
-
- String requestJSON = new String(
- Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/AlaCarteRequest.json")));
-
- requests.setAction("create");
- requests.setRequestBody(requestJSON);
- requests.setRequestId("requestId");
- requests.setRequestScope("service");
- requests.setRequestType("createInstance");
- // iar.save(requests);
- HttpHeaders headers = new HttpHeaders();
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
-
- ResponseEntity<GetOrchestrationResponse> response =
- restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
- }
@Test
public void mapRequestProcessingDataTest() throws JsonParseException, JsonMappingException, IOException {
@@ -461,6 +413,15 @@ public class OrchestrationRequestsTest extends BaseTest {
.withStatus(HttpStatus.SC_OK)));
}
+
+ private void setupTestGetOrchestrationRequestOpenstackDetails(String requestId, String status) throws Exception {
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse()
+ .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(new String(Files.readAllBytes(Paths
+ .get("src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json"))))
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
private void setupTestUnlockOrchestrationRequest(String requestId, String status) {
wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId)))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
@@ -473,7 +434,6 @@ public class OrchestrationRequestsTest extends BaseTest {
private void setupTestUnlockOrchestrationRequest_invalid_Json() {
wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(INVALID_REQUEST_ID))).willReturn(aResponse()
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
-
}
private void setupTestUnlockOrchestrationRequest_Valid_Status(String requestID, String status) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json
new file mode 100644
index 0000000000..41d7e4d706
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json
@@ -0,0 +1,62 @@
+{
+ "clientRequestId": "00032ab7-3fb3-42e5-965d-8ea592502016",
+ "action": "deleteInstance",
+ "requestStatus": "COMPLETE",
+ "statusMessage": "Vf Module has been deleted successfully.",
+ "progress": 100,
+ "startTime": "2016-12-22T13:29:54.000+0000",
+ "endTime": "2016-12-22T13:30:28.000+0000",
+ "source": "VID",
+ "vnfId": "b92f60c8-8de3-46c1-8dc1-e4390ac2b005",
+ "vnfName": null,
+ "vnfType": null,
+ "serviceType": null,
+ "aicNodeClli": null,
+ "tenantId": "6accefef3cb442ff9e644d589fb04107",
+ "provStatus": null,
+ "vnfParams": null,
+ "vnfOutputs": null,
+ "requestBody": "{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"test::base::module-0\"},\"requestInfo\":{\"source\":\"VID\"},\"cloudConfiguration\":{\"tenantId\":\"6accefef3cb442ff9e644d589fb04107\",\"lcpCloudRegionId\":\"n6\"}}",
+ "responseBody": null,
+ "lastModifiedBy": "BPMN",
+ "modifyTime": "2016-12-22T13:30:28.000+0000",
+ "requestType": null,
+ "volumeGroupId": null,
+ "volumeGroupName": null,
+ "vfModuleId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992",
+ "vfModuleName": null,
+ "vfModuleModelName": "test::base::module-0",
+ "aaiServiceId": null,
+ "aicCloudRegion": "n6",
+ "callBackUrl": null,
+ "correlator": null,
+ "serviceInstanceId": "e3b5744d-2ad1-4cdd-8390-c999a38829bc",
+ "serviceInstanceName": null,
+ "requestScope": "vfModule",
+ "requestAction": "deleteInstance",
+ "networkId": null,
+ "networkName": null,
+ "networkType": null,
+ "requestorId": null,
+ "configurationId": null,
+ "configurationName": null,
+ "operationalEnvId": null,
+ "operationalEnvName": null,
+ "cloudApiRequests":[
+ {
+ "id": 1,
+ "cloudIdentifier": "heatstackName/123123",
+ "requestBody":"{\r\n \"test\": \"00032ab7-3fb3-42e5-965d-8ea592502016\",\r\n \"test2\": \"deleteInstance\",\r\n \"test3\": \"COMPLETE\",\r\n \"test4\": \"Vf Module has been deleted successfully.\",\r\n \"test5\": 100\r\n}",
+ "created": "2016-12-22T13:29:54.000+0000"
+ }
+ ],
+ "requestURI": "00032ab7-3fb3-42e5-965d-8ea592502017",
+ "_links": {
+ "self": {
+ "href": "http://localhost:8087/infraActiveRequests/00032ab7-3fb3-42e5-965d-8ea592502017"
+ },
+ "infraActiveRequests": {
+ "href": "http://localhost:8087/infraActiveRequests/00032ab7-3fb3-42e5-965d-8ea592502017"
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
index 712fbf54ca..2e1c6a9bdc 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
@@ -83,6 +83,8 @@ mso:
spring:
+ jersey:
+ type: filter
datasource:
jdbcUrl: jdbc:mariadb://localhost:3307/catalogdb
username: root
@@ -97,11 +99,10 @@ spring:
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
enable-lazy-load-no-trans: true
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
- jersey:
- type: filter
+
security:
usercredentials:
- -
+ -
username: test
password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
role: InfraPortal-Client
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
index 765740e864..c2eb21b18e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
@@ -1463,6 +1463,16 @@ create table if not exists model (
FOREIGN KEY (`RECIPE`) REFERENCES `model_recipe` (`MODEL_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+CREATE TABLE IF NOT EXISTS `requestdb`.`cloud_api_requests` (
+`ID` INT(13) NOT NULL AUTO_INCREMENT,
+`REQUEST_BODY` LONGTEXT NOT NULL,
+`CLOUD_IDENTIFIER` VARCHAR(200) NULL,
+`SO_REQUEST_ID` VARCHAR(45) NOT NULL,
+`CREATE_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (`ID`),
+INDEX `fk_cloud_api_requests__so_request_id_idx` (`SO_REQUEST_ID` ASC))
+ENGINE = InnoDB DEFAULT CHARSET=latin1;
+
CREATE TABLE IF NOT EXISTS `workflow` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`ARTIFACT_UUID` varchar(200) NOT NULL,
@@ -1480,8 +1490,3 @@ CREATE TABLE IF NOT EXISTS `workflow` (
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_workflow` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`SOURCE`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
-
-
-
-
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
index 2bd9936b3a..65372b7b48 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
@@ -1,5 +1,5 @@
-create table ACTIVATE_OPERATIONAL_ENV_SERVICE_MODEL_DISTRIBUTION_STATUS (
+create table IF NOT EXISTS ACTIVATE_OPERATIONAL_ENV_SERVICE_MODEL_DISTRIBUTION_STATUS (
REQUEST_ID varchar(255) not null,
OPERATIONAL_ENV_ID varchar(255) not null,
SERVICE_MODEL_VERSION_ID varchar(255) not null,
@@ -13,7 +13,7 @@ create table ACTIVATE_OPERATIONAL_ENV_SERVICE_MODEL_DISTRIBUTION_STATUS (
primary key (REQUEST_ID,OPERATIONAL_ENV_ID, SERVICE_MODEL_VERSION_ID)
);
-create table OPERATION_STATUS (
+create table IF NOT EXISTS OPERATION_STATUS (
SERVICE_ID varchar(255) not null,
OPERATION_ID varchar(255) not null,
SERVICE_NAME varchar(255),
@@ -46,7 +46,7 @@ INSERT INTO PUBLIC.OPERATION_STATUS(SERVICE_ID, OPERATION_ID, OPERATION_TYPE, US
primary key (SERVICE_ID,OPERATION_ID,RESOURCE_TEMPLATE_UUID)
);
-CREATE CACHED TABLE PUBLIC.INFRA_ACTIVE_REQUESTS(
+CREATE TABLE IF NOT EXISTS PUBLIC.INFRA_ACTIVE_REQUESTS(
REQUEST_ID VARCHAR NOT NULL SELECTIVITY 100,
CLIENT_REQUEST_ID VARCHAR SELECTIVITY 6,
ACTION VARCHAR SELECTIVITY 1,
@@ -168,6 +168,17 @@ CREATE CACHED TABLE PUBLIC.ARCHIVED_INFRA_REQUESTS(
REQUEST_URL VARCHAR SELECTIVITY 1
);
+CREATE TABLE IF NOT EXISTS cloud_api_requests(
+`ID` INT(13) NOT NULL AUTO_INCREMENT,
+`REQUEST_BODY` LONGTEXT NOT NULL,
+`CLOUD_IDENTIFIER` VARCHAR(200) NULL,
+`SO_REQUEST_ID` VARCHAR(45) NOT NULL,
+`CREATE_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (`ID`),
+CONSTRAINT fk_cloud_api_req_infra_requests
+ FOREIGN KEY (SO_REQUEST_ID)
+ REFERENCES infra_active_requests (REQUEST_ID));
+
CREATE CACHED TABLE PUBLIC.SITE_STATUS(
SITE_NAME VARCHAR NOT NULL,
STATUS VARCHAR,
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/CloudApiRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/CloudApiRequests.java
new file mode 100644
index 0000000000..690d0ffbaf
--- /dev/null
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/CloudApiRequests.java
@@ -0,0 +1,138 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.so.db.request.beans;
+
+import java.io.Serializable;
+import java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.openpojo.business.annotation.BusinessKey;
+
+
+@Entity
+@JsonInclude(Include.NON_NULL)
+@Table(name = "cloud_api_requests")
+public class CloudApiRequests implements Serializable {
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4686890103198488984L;
+
+ @JsonIgnore
+ @Id
+ @BusinessKey
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "ID")
+ private Integer id;
+
+
+ @Column(name = "SO_REQUEST_ID")
+ private String requestId;
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ @Column(name = "CLOUD_IDENTIFIER")
+ private String cloudIdentifier;
+
+ @Column(name = "REQUEST_BODY", columnDefinition = "LONGTEXT")
+ private String requestBody;
+
+ @Column(name = "CREATE_TIME", insertable = false, updatable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date created = null;
+
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof CloudApiRequests)) {
+ return false;
+ }
+ CloudApiRequests castOther = (CloudApiRequests) other;
+ return new EqualsBuilder().append(id, castOther.id).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(id).toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("id", id).append("cloudIdentifier", cloudIdentifier)
+ .append("requestBody", requestBody).append("created", created).toString();
+ }
+
+ @PrePersist
+ protected void createdAt() {
+ this.created = new Date();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getCloudIdentifier() {
+ return cloudIdentifier;
+ }
+
+ public void setCloudIdentifier(String cloudIdentifier) {
+ this.cloudIdentifier = cloudIdentifier;
+ }
+
+
+ public String getRequestBody() {
+ return requestBody;
+ }
+
+ public void setRequestBody(String requestBody) {
+ this.requestBody = requestBody;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
index a1010a349c..7c58c6171e 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
@@ -23,10 +23,15 @@ package org.onap.so.db.request.beans;
import java.net.URI;
import java.sql.Timestamp;
import java.util.Date;
+import java.util.List;
import java.util.Objects;
+import javax.persistence.CascadeType;
import javax.persistence.Column;
+import javax.persistence.FetchType;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
import javax.persistence.MappedSuperclass;
+import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
@@ -34,6 +39,7 @@ import javax.persistence.TemporalType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.onap.so.requestsdb.TimestampXMLAdapter;
+import uk.co.blackpepper.bowman.annotation.LinkedResource;
import uk.co.blackpepper.bowman.annotation.ResourceId;
@MappedSuperclass
@@ -147,6 +153,10 @@ public abstract class InfraRequests implements java.io.Serializable {
@Column(name = "REQUEST_URL", length = 500)
private String requestUrl;
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ @JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID")
+ private List<CloudApiRequests> cloudApiRequests;
+
@ResourceId
public URI getRequestURI() {
return URI.create(this.requestId);
@@ -458,6 +468,15 @@ public abstract class InfraRequests implements java.io.Serializable {
return requestAction;
}
+ @LinkedResource
+ public List<CloudApiRequests> getCloudApiRequests() {
+ return cloudApiRequests;
+ }
+
+ public void setCloudApiRequests(List<CloudApiRequests> cloudApiRequests) {
+ this.cloudApiRequests = cloudApiRequests;
+ }
+
public void setRequestAction(String requestAction) {
this.requestAction = requestAction;
}
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 f2ff6fac00..103410701c 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
@@ -72,10 +72,10 @@ public class RequestsDbClient {
private static final String SERVICE_MODEL_VERSION_ID = "SERVICE_MODEL_VERSION_ID";
- @Value("${mso.adapters.requestDb.endpoint}")
+ @Value("${mso.adapters.requestDb.endpoint:#{null}}")
protected String endpoint;
- @Value("${mso.adapters.requestDb.auth}")
+ @Value("${mso.adapters.requestDb.auth:#{null}}")
private String msoAdaptersAuth;
private String getOrchestrationFilterURI = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive/";
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
index ffcc8e9717..3b57ae0f72 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
@@ -25,11 +25,9 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
@@ -93,6 +91,9 @@ public class Service implements Serializable {
@Column(name = "RESOURCE_ORDER")
private String resourceOrder;
+ @Column(name = "OVERALL_DISTRIBUTION_STATUS")
+ private String distrobutionStatus;
+
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "network_resource_customization_to_service",
joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
@@ -135,6 +136,7 @@ public class Service implements Serializable {
@JoinColumn(name = "TOSCA_CSAR_ARTIFACT_UUID")
private ToscaCsar csar;
+
@Override
public String toString() {
return new ToStringBuilder(this).append("modelName", modelName).append("description", description)
@@ -367,4 +369,14 @@ public class Service implements Serializable {
public void setResourceOrder(String resourceOrder) {
this.resourceOrder = resourceOrder;
}
+
+
+ public String getDistrobutionStatus() {
+ return distrobutionStatus;
+ }
+
+ public void setDistrobutionStatus(String distrobutionStatus) {
+ this.distrobutionStatus = distrobutionStatus;
+ }
+
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java
index 5d9deb6c89..fb54449d5f 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java
@@ -38,9 +38,9 @@ import javax.persistence.TemporalType;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.openpojo.business.annotation.BusinessKey;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
+import com.openpojo.business.annotation.BusinessKey;
import uk.co.blackpepper.bowman.annotation.LinkedResource;
@Entity
@@ -93,9 +93,6 @@ public class VnfResource implements Serializable {
@JoinColumn(name = "HEAT_TEMPLATE_ARTIFACT_UUID")
private HeatTemplate heatTemplates;
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResources")
- private List<VnfResourceCustomization> vnfResourceCustomizations;
-
@OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResource")
private List<VnfResourceWorkflow> vnfResourceWorkflow;
@@ -111,8 +108,7 @@ public class VnfResource implements Serializable {
.append("toscaNodeType", toscaNodeType).append("description", description)
.append("orchestrationMode", orchestrationMode).append("aicVersionMin", aicVersionMin)
.append("aicVersionMax", aicVersionMax).append("created", created)
- .append("heatTemplates", heatTemplates).append("vnfResourceCustomizations", vnfResourceCustomizations)
- .append("vnfResourceWorkflow", vnfResourceWorkflow).toString();
+ .append("heatTemplates", heatTemplates).append("vnfResourceWorkflow", vnfResourceWorkflow).toString();
}
@Override
@@ -230,17 +226,6 @@ public class VnfResource implements Serializable {
}
@LinkedResource
- public List<VnfResourceCustomization> getVnfResourceCustomizations() {
- if (vnfResourceCustomizations == null)
- vnfResourceCustomizations = new ArrayList<>();
- return vnfResourceCustomizations;
- }
-
- public void setVnfResourceCustomizations(List<VnfResourceCustomization> vnfResourceCustomizations) {
- this.vnfResourceCustomizations = vnfResourceCustomizations;
- }
-
- @LinkedResource
public HeatTemplate getHeatTemplates() {
return heatTemplates;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java
index c107192060..b456beaeff 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java
@@ -30,6 +30,8 @@ import java.util.List;
public interface ServiceRepository extends JpaRepository<Service, String> {
List<Service> findByModelName(String modelName);
+ List<Service> findByModelNameAndDistrobutionStatus(String modelName, String distrobutionStatus);
+
Service findOneByModelName(String modelName);
/**
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatEnvironment.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatEnvironment.java
new file mode 100644
index 0000000000..97f67a5438
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatEnvironment.java
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.rest.catalog.beans;
+
+import java.io.Serializable;
+import java.text.DateFormat;
+import java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import com.openpojo.business.annotation.BusinessKey;
+
+@Entity
+@Table(name = "heat_environment")
+public class HeatEnvironment implements Serializable {
+
+ private static final long serialVersionUID = 768026109321305392L;
+
+ @BusinessKey
+ @Id
+ @Column(name = "ARTIFACT_UUID")
+ private String artifactUuid;
+
+ @Column(name = "NAME")
+ private String name = null;
+
+ @Column(name = "DESCRIPTION")
+ private String description = null;
+
+ @Lob
+ @Column(name = "BODY", columnDefinition = "LONGTEXT")
+ private String environment = null;
+
+ @Column(name = "ARTIFACT_CHECKSUM")
+ private String artifactChecksum;
+
+ @Column(name = "CREATION_TIMESTAMP", updatable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date created;
+
+ @BusinessKey
+ @Column(name = "VERSION")
+ private String version;
+
+ @PrePersist
+ protected void onCreate() {
+ this.created = new Date();
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof HeatEnvironment)) {
+ return false;
+ }
+ HeatEnvironment castOther = (HeatEnvironment) other;
+ return new EqualsBuilder().append(artifactUuid, castOther.artifactUuid).append(version, castOther.version)
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(artifactUuid).append(version).toHashCode();
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getArtifactUuid() {
+ return this.artifactUuid;
+ }
+
+ public void setArtifactUuid(String artifactUuid) {
+ this.artifactUuid = artifactUuid;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getEnvironment() {
+ return this.environment;
+ }
+
+ public void setEnvironment(String environment) {
+ this.environment = environment;
+ }
+
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Artifact UUID=" + this.artifactUuid);
+ sb.append(", name=");
+ sb.append(name);
+ sb.append(", version=");
+ sb.append(version);
+ sb.append(", description=");
+ sb.append(this.description == null ? "null" : this.description);
+ sb.append(", body=");
+ sb.append(this.environment == null ? "null" : this.environment);
+ if (this.created != null) {
+ sb.append(",creationTimestamp=");
+ sb.append(DateFormat.getInstance().format(this.created));
+ }
+ return sb.toString();
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatFile.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatFile.java
new file mode 100644
index 0000000000..94f61d30e3
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatFile.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.rest.catalog.beans;
+
+import java.io.Serializable;
+import java.util.Date;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+
+public class HeatFile implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3280125018687060890L;
+
+ private String artifactUuid;
+
+ private String description = null;
+
+ private String fileName;
+
+ private String fileBody;
+
+ private Date created;
+
+ private String artifactChecksum;
+
+ private String version;
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("artifactUuid", artifactUuid).append("description", description)
+ .append("fileName", fileName).append("fileBody", fileBody).append("created", created)
+ .append("artifactChecksum", artifactChecksum).toString();
+ }
+
+ public String getArtifactUuid() {
+ return this.artifactUuid;
+ }
+
+ public void setArtifactUuid(String artifactUuid) {
+ this.artifactUuid = artifactUuid;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getFileName() {
+ return this.fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getFileBody() {
+ return this.fileBody;
+ }
+
+ public void setFileBody(String fileBody) {
+ this.fileBody = fileBody;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public String getAsdcUuid() {
+ return this.artifactUuid;
+ }
+
+ public void setAsdcUuid(String artifactUuid) {
+ this.artifactUuid = artifactUuid;
+ }
+
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatTemplate.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatTemplate.java
new file mode 100644
index 0000000000..cb346e4167
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatTemplate.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.rest.catalog.beans;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+
+public class HeatTemplate implements Serializable {
+
+
+ private String artifactUuid;
+
+ private String templateName;
+
+ private String templateBody = null;
+
+ private Integer timeoutMinutes;
+
+ private String version;
+
+ private String description;
+
+ private String artifactChecksum;
+
+ private Date created;
+
+ private Set<HeatTemplateParam> parameters;
+
+ private List<HeatTemplate> childTemplates;
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("artifactUuid", artifactUuid).append("templateName", templateName)
+ .append("templateBody", templateBody).append("timeoutMinutes", timeoutMinutes)
+ .append("version", version).append("description", description)
+ .append("artifactChecksum", artifactChecksum).append("created", created)
+ .append("parameters", parameters).append("childTemplates", childTemplates).toString();
+ }
+
+ public List<HeatTemplate> getChildTemplates() {
+ if (childTemplates == null)
+ childTemplates = new ArrayList<>();
+ return childTemplates;
+ }
+
+ public void setChildTemplates(List<HeatTemplate> childTemplates) {
+ this.childTemplates = childTemplates;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getArtifactUuid() {
+ return this.artifactUuid;
+ }
+
+ public void setArtifactUuid(String artifactUuid) {
+ this.artifactUuid = artifactUuid;
+ }
+
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ public void setTemplateName(String templateName) {
+ this.templateName = templateName;
+ }
+
+ public String getTemplateBody() {
+ return templateBody;
+ }
+
+ public void setTemplateBody(String templateBody) {
+ this.templateBody = templateBody;
+ }
+
+ public Integer getTimeoutMinutes() {
+ return timeoutMinutes;
+ }
+
+ public void setTimeoutMinutes(Integer timeout) {
+ this.timeoutMinutes = timeout;
+ }
+
+ public Set<HeatTemplateParam> getParameters() {
+ if (parameters == null)
+ parameters = new HashSet<>();
+ return parameters;
+ }
+
+ public void setParameters(Set<HeatTemplateParam> parameters) {
+ this.parameters = parameters;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getHeatTemplate() {
+ return this.templateBody;
+ }
+
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatTemplateParam.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatTemplateParam.java
new file mode 100644
index 0000000000..a79ec962f8
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/HeatTemplateParam.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.rest.catalog.beans;
+
+import java.io.Serializable;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+
+public class HeatTemplateParam implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8251042980747916191L;
+
+ private String paramName;
+
+ private Boolean required;
+
+ private String paramType;
+
+ private String paramAlias;
+
+ public String getParamName() {
+ return paramName;
+ }
+
+ public void setParamName(String paramName) {
+ this.paramName = paramName;
+ }
+
+ public Boolean isRequired() {
+ return required;
+ }
+
+ public void setRequired(Boolean required) {
+ this.required = required;
+ }
+
+ public String getParamAlias() {
+ return paramAlias;
+ }
+
+ public void setParamAlias(String paramAlias) {
+ this.paramAlias = paramAlias;
+ }
+
+ public String getParamType() {
+ return paramType;
+ }
+
+ public void setParamType(String paramType) {
+ this.paramType = paramType;
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Service.java
new file mode 100644
index 0000000000..1620058e1e
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Service.java
@@ -0,0 +1,165 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.rest.catalog.beans;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+@JsonInclude(Include.NON_DEFAULT)
+public class Service implements Serializable {
+
+ private static final long serialVersionUID = 768026109321305392L;
+
+ private String modelName;
+
+ private String description;
+
+ private String modelVersionId;
+
+ private String modelInvariantId;
+
+ private Date created;
+
+ private String modelVersion;
+
+ private String serviceType;
+
+ private String serviceRole;
+
+ private String environmentContext;
+
+ private String workloadContext;
+
+ private String category;
+
+ private String distrobutionStatus;
+
+ private List<Vnf> vnf = new ArrayList<>();
+
+ public List<Vnf> getVnf() {
+ return vnf;
+ }
+
+ public void setVnf(List<Vnf> vnf) {
+ this.vnf = vnf;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getServiceRole() {
+ return serviceRole;
+ }
+
+ public void setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ }
+
+ public String getEnvironmentContext() {
+ return environmentContext;
+ }
+
+ public void setEnvironmentContext(String environmentContext) {
+ this.environmentContext = environmentContext;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getDistrobutionStatus() {
+ return distrobutionStatus;
+ }
+
+ public void setDistrobutionStatus(String distrobutionStatus) {
+ this.distrobutionStatus = distrobutionStatus;
+ }
+
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/VfModule.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/VfModule.java
new file mode 100644
index 0000000000..8e18f94faf
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/VfModule.java
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.rest.catalog.beans;
+
+import java.util.Date;
+import java.util.List;
+import org.onap.so.db.catalog.beans.HeatEnvironment;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+@JsonInclude(Include.NON_DEFAULT)
+public class VfModule {
+
+ // VfModule
+ private String modelVersionId;
+ private String modelInvariantId;
+ private String modelName;
+ private String modelVersion;
+ private String description;
+ private Boolean isBase;
+ private HeatTemplate heatTemplate;
+ private Date created;
+ private List<HeatFile> heatFile;
+
+ // Customization
+ private String modelCustomizationId;
+ private String label;
+ private Integer minInstances;
+ private Integer maxInstances;
+ private Integer initialCount;
+ private Integer availabilityZoneCount;
+ private HeatEnvironment heatEnv;
+ private Boolean isVolumeGroup;
+
+
+ // Add in cvnfcCustomization
+
+
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Boolean getIsBase() {
+ return isBase;
+ }
+
+ public void setIsBase(Boolean isBase) {
+ this.isBase = isBase;
+ }
+
+ public HeatTemplate getHeatTemplate() {
+ return heatTemplate;
+ }
+
+ public void setHeatTemplate(HeatTemplate heatTemplate) {
+ this.heatTemplate = heatTemplate;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ public List<HeatFile> getHeatFile() {
+ return heatFile;
+ }
+
+ public void setHeatFile(List<HeatFile> heatFile) {
+ this.heatFile = heatFile;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public Integer getMinInstances() {
+ return minInstances;
+ }
+
+ public void setMinInstances(Integer minInstances) {
+ this.minInstances = minInstances;
+ }
+
+ public Integer getMaxInstances() {
+ return maxInstances;
+ }
+
+ public void setMaxInstances(Integer maxInstances) {
+ this.maxInstances = maxInstances;
+ }
+
+ public Integer getInitialCount() {
+ return initialCount;
+ }
+
+ public void setInitialCount(Integer integer) {
+ this.initialCount = integer;
+ }
+
+ public Integer getAvailabilityZoneCount() {
+ return availabilityZoneCount;
+ }
+
+ public void setAvailabilityZoneCount(Integer availabilityZoneCount) {
+ this.availabilityZoneCount = availabilityZoneCount;
+ }
+
+ public HeatEnvironment getHeatEnv() {
+ return heatEnv;
+ }
+
+ public void setHeatEnv(HeatEnvironment heatEnv) {
+ this.heatEnv = heatEnv;
+ }
+
+ public Boolean getIsVolumeGroup() {
+ return isVolumeGroup;
+ }
+
+ public void setIsVolumeGroup(Boolean isVolumeGroup) {
+ this.isVolumeGroup = isVolumeGroup;
+ }
+
+
+
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Vnf.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Vnf.java
new file mode 100644
index 0000000000..40d701c3c5
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Vnf.java
@@ -0,0 +1,218 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.rest.catalog.beans;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+@JsonInclude(Include.NON_DEFAULT)
+public class Vnf implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2956199674955504834L;
+
+ private String modelName;
+ private String modelVersionId;
+ private String modelInvariantId;
+ private String modelVersion;
+ private String modelCustomizationId;
+ private String modelInstanceName;
+ private Integer minInstances;
+ private Integer maxInstances;
+ private Integer availabilityZoneMaxCount;
+ private String toscaNodeType;
+ private String nfFunction;
+ private String nfRole;
+ private String nfNamingCode;
+ private String multiStageDesign;
+ private String orchestrationMode;
+ private String cloudVersionMin;
+ private String cloudVersionMax;
+ private String category;
+ private String subCategory;
+ private List<VfModule> vfModule = new ArrayList<>();
+
+ public List<VfModule> getVfModule() {
+ return vfModule;
+ }
+
+ public void setVfModule(List<VfModule> vfModule) {
+ this.vfModule = vfModule;
+ }
+
+ public Integer getAvailabilityZoneMaxCount() {
+ return availabilityZoneMaxCount;
+ }
+
+ public void setAvailabilityZoneMaxCount(Integer availabilityZoneMaxCount) {
+ this.availabilityZoneMaxCount = availabilityZoneMaxCount;
+ }
+
+ public Integer getMinInstances() {
+ return minInstances;
+ }
+
+ public void setMinInstances(Integer minInstances) {
+ this.minInstances = minInstances;
+ }
+
+ public Integer getMaxInstances() {
+ return maxInstances;
+ }
+
+ public void setMaxInstances(Integer maxInstances) {
+ this.maxInstances = maxInstances;
+ }
+
+ public String getCloudVersionMin() {
+ return cloudVersionMin;
+ }
+
+ public void setCloudVersionMin(String cloudVersionMin) {
+ this.cloudVersionMin = cloudVersionMin;
+ }
+
+ public String getCloudVersionMax() {
+ return cloudVersionMax;
+ }
+
+ public void setCloudVersionMax(String cloudVersionMax) {
+ this.cloudVersionMax = cloudVersionMax;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getSubCategory() {
+ return subCategory;
+ }
+
+ public void setSubCategory(String subCategory) {
+ this.subCategory = subCategory;
+ }
+
+ public String getOrchestrationMode() {
+ return orchestrationMode;
+ }
+
+ public void setOrchestrationMode(String orchestrationMode) {
+ this.orchestrationMode = orchestrationMode;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+
+ public String getModelInstanceName() {
+ return modelInstanceName;
+ }
+
+ public void setModelInstanceName(String modelInstanceName) {
+ this.modelInstanceName = modelInstanceName;
+ }
+
+ public String getToscaNodeType() {
+ return toscaNodeType;
+ }
+
+ public void setToscaNodeType(String toscaNodeType) {
+ this.toscaNodeType = toscaNodeType;
+ }
+
+ public String getNfFunction() {
+ return nfFunction;
+ }
+
+ public void setNfFunction(String nfFunction) {
+ this.nfFunction = nfFunction;
+ }
+
+ public String getNfRole() {
+ return nfRole;
+ }
+
+ public void setNfRole(String nfRole) {
+ this.nfRole = nfRole;
+ }
+
+ public String getNfNamingCode() {
+ return nfNamingCode;
+ }
+
+ public void setNfNamingCode(String nfNamingCode) {
+ this.nfNamingCode = nfNamingCode;
+ }
+
+ public String getMultiStageDesign() {
+ return multiStageDesign;
+ }
+
+ public void setMultiStageDesign(String multiStepDesign) {
+ this.multiStageDesign = multiStepDesign;
+ }
+}
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java
index 371a9c13e0..e8addc4aa8 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java
@@ -74,7 +74,6 @@ public class CvnfcCustomizationRepositoryTest extends BaseTest {
List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
vnfResourceCustomizations.add(vnfResourceCustomization);
- vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations);
vnfResourceCustomization.setVnfResources(vnfResource);
@@ -123,7 +122,6 @@ public class CvnfcCustomizationRepositoryTest extends BaseTest {
List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
vnfResourceCustomizations.add(vnfResourceCustomization);
- vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations);
vnfResourceCustomization.setVnfResources(vnfResource);
@@ -177,7 +175,6 @@ public class CvnfcCustomizationRepositoryTest extends BaseTest {
List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList();
vnfResourceCustomizations.add(vnfResourceCustomization);
- vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations);
vnfResourceCustomization.setVnfResources(vnfResource);
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index 34340f1357..0856a4cbe2 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -803,6 +803,7 @@ CREATE TABLE `service` (
`WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL,
`SERVICE_CATEGORY` varchar(200) DEFAULT NULL,
`RESOURCE_ORDER` varchar(200) default NULL,
+ OVERALL_DISTRIBUTION_STATUS varchar(45),
PRIMARY KEY (`MODEL_UUID`),
KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`),
CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
index e6bc06374c..9c3a02d4e6 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
@@ -119,9 +119,12 @@ public class SvnfmController {
*/
@DeleteMapping(value = "/vnf_instances/{vnfInstanceId}")
@ResponseStatus(code = HttpStatus.OK)
- public InlineResponse201 deleteVnf(@PathVariable("vnfInstanceId") final String vnfId) {
+ public ResponseEntity<Void> deleteVnf(@PathVariable("vnfInstanceId") final String vnfId) {
LOGGER.info("Start deleting Vnf------");
- return vnfmCacheRepository.deleteVnf(vnfId);
+ vnfmCacheRepository.deleteVnf(vnfId);
+ final HttpHeaders headers = new HttpHeaders();
+ headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ return new ResponseEntity<>(headers, HttpStatus.NO_CONTENT);
}
/**
@@ -132,10 +135,11 @@ public class SvnfmController {
*/
@PostMapping(value = "/vnf_instances/{vnfInstanceId}/terminate")
public ResponseEntity<Object> terminateVnf(@PathVariable("vnfInstanceId") final String vnfId) {
- LOGGER.info("Start terminateVNFRequest");
+ LOGGER.info("Start terminateVNFRequest {}", vnfId);
final HttpHeaders headers = new HttpHeaders();
- headers.add("Content-Type", MediaType.APPLICATION_JSON);
- return new ResponseEntity<>(svnfmService.terminateVnf(vnfId), headers, HttpStatus.ACCEPTED);
+ headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.add(HttpHeaders.LOCATION, svnfmService.terminateVnf(vnfId));
+ return new ResponseEntity<>(headers, HttpStatus.ACCEPTED);
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java
index 030b073da4..fbdbf744d0 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/repository/VnfmCacheRepository.java
@@ -20,16 +20,12 @@
package org.onap.svnfm.simulator.repository;
-import java.util.List;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfo;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
import org.onap.svnfm.simulator.constants.Constant;
import org.onap.svnfm.simulator.services.SvnfmService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;
@@ -49,15 +45,7 @@ public class VnfmCacheRepository {
return svnfmService.createVnf(createVnfRequest, id);
}
- @CachePut(value = Constant.IN_LINE_RESPONSE_201_CACHE, key = "#id")
- public InlineResponse201 updateVnf(final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo, final String id,
- final List<InlineResponse201VimConnectionInfo> vimConnectionInfo) {
- final InlineResponse201 vnf = getVnf(id);
- vnf.setInstantiatedVnfInfo(instantiatedVnfInfo);
- vnf.setInstantiationState(InstantiationStateEnum.INSTANTIATED);
- vnf.setVimConnectionInfo(vimConnectionInfo);
- return vnf;
- }
+
public InlineResponse201 getVnf(final String id) {
return svnfmService.getVnf(id);
@@ -67,8 +55,6 @@ public class VnfmCacheRepository {
* @param vnfId
* @return
*/
- public InlineResponse201 deleteVnf(final String vnfId) {
- // TODO
- return null;
- }
+ @CacheEvict(value = Constant.IN_LINE_RESPONSE_201_CACHE, key = "#id")
+ public void deleteVnf(final String id) {}
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/InstantiateOperationProgressor.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/InstantiateOperationProgressor.java
new file mode 100644
index 0000000000..020fa0390d
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/InstantiateOperationProgressor.java
@@ -0,0 +1,123 @@
+package org.onap.svnfm.simulator.services;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.modelmapper.ModelMapper;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources.TypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201AddResources;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoResourceHandle;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoVnfcResourceInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
+import org.onap.svnfm.simulator.config.ApplicationConfig;
+import org.onap.svnfm.simulator.model.VnfOperation;
+import org.onap.svnfm.simulator.model.Vnfds;
+import org.onap.svnfm.simulator.model.Vnfds.Vnfc;
+import org.onap.svnfm.simulator.model.Vnfds.Vnfd;
+import org.onap.svnfm.simulator.repository.VnfOperationRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class InstantiateOperationProgressor extends OperationProgressor {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(InstantiateOperationProgressor.class);
+
+ public InstantiateOperationProgressor(final VnfOperation operation, final SvnfmService svnfmService,
+ final VnfOperationRepository vnfOperationRepository, final ApplicationConfig applicationConfig,
+ final Vnfds vnfds, final SubscriptionService subscriptionService) {
+ super(operation, svnfmService, vnfOperationRepository, applicationConfig, vnfds, subscriptionService);
+ }
+
+ @Override
+ protected List<GrantsAddResources> getAddResources(final String vnfdId) {
+ final List<GrantsAddResources> resources = new ArrayList<>();
+
+ for (final Vnfd vnfd : vnfds.getVnfdList()) {
+ if (vnfd.getVnfdId().equals(vnfdId)) {
+ for (final Vnfc vnfc : vnfd.getVnfcList()) {
+ final GrantsAddResources addResource = new GrantsAddResources();
+ vnfc.setGrantResourceId(UUID.randomUUID().toString());
+ addResource.setId(vnfc.getGrantResourceId());
+ addResource.setType(TypeEnum.fromValue(vnfc.getType()));
+ addResource.setResourceTemplateId(vnfc.getResourceTemplateId());
+ addResource.setVduId(vnfc.getVduId());
+ resources.add(addResource);
+ }
+ }
+ }
+ return resources;
+ }
+
+ @Override
+ protected List<GrantsAddResources> getRemoveResources(final String vnfdId) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ protected List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> handleGrantResponse(
+ final InlineResponse201 grantResponse) {
+ final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo = createInstantiatedVnfInfo(grantResponse);
+ svnfmService.updateVnf(InstantiationStateEnum.INSTANTIATED, instantiatedVnfInfo, operation.getVnfInstanceId(),
+ getVimConnections(grantResponse));
+ return instantiatedVnfInfo.getVnfcResourceInfo();
+ }
+
+ private InlineResponse201InstantiatedVnfInfo createInstantiatedVnfInfo(final InlineResponse201 grantResponse) {
+ final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo = new InlineResponse201InstantiatedVnfInfo();
+
+ final Map<String, String> mapOfGrantResourceIdToVimConnectionId = new HashMap<>();
+ for (final InlineResponse201AddResources addResource : grantResponse.getAddResources()) {
+ mapOfGrantResourceIdToVimConnectionId.put(addResource.getResourceDefinitionId(),
+ addResource.getVimConnectionId());
+ }
+ LOGGER.info("VIM connections in grant response: {}", mapOfGrantResourceIdToVimConnectionId);
+
+ for (final Vnfd vnfd : vnfds.getVnfdList()) {
+ if (vnfd.getVnfdId().equals(svnfmService.getVnf(operation.getVnfInstanceId()).getVnfdId())) {
+ for (final Vnfc vnfc : vnfd.getVnfcList()) {
+ final InlineResponse201InstantiatedVnfInfoVnfcResourceInfo vnfcResourceInfoItem =
+ new InlineResponse201InstantiatedVnfInfoVnfcResourceInfo();
+ vnfcResourceInfoItem.setId(vnfc.getVnfcId());
+ vnfcResourceInfoItem.setVduId(vnfc.getVduId());
+ final InlineResponse201InstantiatedVnfInfoResourceHandle computeResource =
+ new InlineResponse201InstantiatedVnfInfoResourceHandle();
+ computeResource.setResourceId(UUID.randomUUID().toString());
+ LOGGER.info("Checking for VIM connection id for : {}", vnfc.getGrantResourceId());
+ computeResource
+ .setVimConnectionId(mapOfGrantResourceIdToVimConnectionId.get(vnfc.getGrantResourceId()));
+
+ computeResource.setVimLevelResourceType("OS::Nova::Server");
+ vnfcResourceInfoItem.setComputeResource(computeResource);
+ instantiatedVnfInfo.addVnfcResourceInfoItem(vnfcResourceInfoItem);
+ }
+ }
+ }
+
+ return instantiatedVnfInfo;
+ }
+
+
+ private List<InlineResponse201VimConnectionInfo> getVimConnections(final InlineResponse201 grantResponse) {
+ final List<InlineResponse201VimConnectionInfo> vimConnectionInfo = new ArrayList<>();
+ for (final InlineResponse201VimConnections vimConnection : grantResponse.getVimConnections()) {
+ final ModelMapper modelMapper = new ModelMapper();
+ vimConnectionInfo.add(modelMapper.map(vimConnection, InlineResponse201VimConnectionInfo.class));
+ }
+ return vimConnectionInfo;
+ }
+
+ @Override
+ protected ChangeTypeEnum getVnfcChangeType() {
+ return ChangeTypeEnum.ADDED;
+ }
+
+}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java
index d231e1b098..1e31ab2fdb 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/OperationProgressor.java
@@ -2,9 +2,7 @@ package org.onap.svnfm.simulator.services;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
import javax.ws.rs.core.MediaType;
import org.apache.commons.codec.binary.Base64;
@@ -12,12 +10,9 @@ import org.modelmapper.ModelMapper;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.ApiResponse;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources.TypeEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinks;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinksVnfLcmOpOcc;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201AddResources;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.ApiClient;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.ApiException;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.api.DefaultApi;
@@ -31,38 +26,32 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperatio
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfo;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoResourceHandle;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoVnfcResourceInfo;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic;
import org.onap.svnfm.simulator.config.ApplicationConfig;
import org.onap.svnfm.simulator.model.VnfOperation;
import org.onap.svnfm.simulator.model.Vnfds;
-import org.onap.svnfm.simulator.model.Vnfds.Vnfc;
-import org.onap.svnfm.simulator.model.Vnfds.Vnfd;
import org.onap.svnfm.simulator.repository.VnfOperationRepository;
-import org.onap.svnfm.simulator.repository.VnfmCacheRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class OperationProgressor implements Runnable {
+public abstract class OperationProgressor implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(OperationProgressor.class);
- private final VnfOperation operation;
- private final VnfmCacheRepository vnfRepository;
+ protected final VnfOperation operation;
+ protected final SvnfmService svnfmService;
private final VnfOperationRepository vnfOperationRepository;
private final ApplicationConfig applicationConfig;
- private final Vnfds vnfds;
+ protected final Vnfds vnfds;
private final SubscriptionService subscriptionService;
private final DefaultApi notificationClient;
private final org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.api.DefaultApi grantClient;
- public OperationProgressor(final VnfOperation operation, final VnfmCacheRepository vnfRepository,
+ public OperationProgressor(final VnfOperation operation, final SvnfmService svnfmService,
final VnfOperationRepository vnfOperationRepository, final ApplicationConfig applicationConfig,
final Vnfds vnfds, final SubscriptionService subscriptionService) {
this.operation = operation;
- this.vnfRepository = vnfRepository;
+ this.svnfmService = svnfmService;
this.vnfOperationRepository = vnfOperationRepository;
this.applicationConfig = applicationConfig;
this.vnfds = vnfds;
@@ -96,15 +85,15 @@ public class OperationProgressor implements Runnable {
final GrantRequest grantRequest = buildGrantRequest();
final InlineResponse201 grantResponse = sendGrantRequest(grantRequest);
- final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo = createInstantiatedVnfInfo(grantResponse);
- vnfRepository.updateVnf(instantiatedVnfInfo, operation.getVnfInstanceId(),
- getVimConnections(grantResponse));
+ final List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> vnfcs = handleGrantResponse(grantResponse);
+
+ svnfmService.getVnf(operation.getVnfInstanceId()).getInstantiatedVnfInfo();
sleep(10000);
setState(InlineResponse200.OperationStateEnum.COMPLETED);
final VnfLcmOperationOccurrenceNotification notificationOfCompleted =
buildNotification(NotificationStatusEnum.RESULT, OperationStateEnum.COMPLETED);
- notificationOfCompleted.setAffectedVnfcs(getVnfcs(instantiatedVnfInfo.getVnfcResourceInfo()));
+ notificationOfCompleted.setAffectedVnfcs(getVnfcs(vnfcs));
sendNotification(notificationOfCompleted);
} catch (final Exception exception) {
@@ -136,6 +125,7 @@ public class OperationProgressor implements Runnable {
notification.setOperationState(operationState);
notification.setOperation(OperationEnum.fromValue(operation.getOperation().toString()));
notification.setVnfInstanceId(operation.getVnfInstanceId());
+ notification.setVnfLcmOpOccId(operation.getId());
final LcnVnfLcmOperationOccurrenceNotificationLinks links = new LcnVnfLcmOperationOccurrenceNotificationLinks();
final LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance vnfInstanceLink =
@@ -157,14 +147,16 @@ public class OperationProgressor implements Runnable {
private List<LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs> getVnfcs(
final List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> instantiatedVnfcs) {
final List<LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs> vnfcs = new ArrayList<>();
- for (final InlineResponse201InstantiatedVnfInfoVnfcResourceInfo instantiatedVnfc : instantiatedVnfcs) {
- LOGGER.info("VNFC TO BE CONVERTED: {}", instantiatedVnfc);
- final ModelMapper mapper = new ModelMapper();
- final LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs vnfc =
- mapper.map(instantiatedVnfc, LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.class);
- LOGGER.info("VNFC FROM CONVERSION: {}", vnfc);
- vnfc.setChangeType(ChangeTypeEnum.ADDED);
- vnfcs.add(vnfc);
+ if (instantiatedVnfcs != null) {
+ for (final InlineResponse201InstantiatedVnfInfoVnfcResourceInfo instantiatedVnfc : instantiatedVnfcs) {
+ LOGGER.info("VNFC TO BE CONVERTED: {}", instantiatedVnfc);
+ final ModelMapper mapper = new ModelMapper();
+ final LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs vnfc =
+ mapper.map(instantiatedVnfc, LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.class);
+ LOGGER.info("VNFC FROM CONVERSION: {}", vnfc);
+ vnfc.setChangeType(getVnfcChangeType());
+ vnfcs.add(vnfc);
+ }
}
return vnfcs;
}
@@ -189,9 +181,10 @@ public class OperationProgressor implements Runnable {
public GrantRequest buildGrantRequest() {
final GrantRequest grantRequest = new GrantRequest();
grantRequest.setVnfInstanceId(operation.getVnfInstanceId());
- final String vnfdId = vnfRepository.getVnf(operation.getVnfInstanceId()).getVnfdId();
+ final String vnfdId = svnfmService.getVnf(operation.getVnfInstanceId()).getVnfdId();
grantRequest.setVnfdId(vnfdId);
grantRequest.setAddResources(getAddResources(vnfdId));
+ grantRequest.setRemoveResources(getRemoveResources(vnfdId));
grantRequest.setVnfLcmOpOccId(operation.getId());
grantRequest
.setOperation(org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest.OperationEnum
@@ -209,24 +202,14 @@ public class OperationProgressor implements Runnable {
return grantRequest;
}
- private List<GrantsAddResources> getAddResources(final String vnfdId) {
- final List<GrantsAddResources> resources = new ArrayList<>();
-
- for (final Vnfd vnfd : vnfds.getVnfdList()) {
- if (vnfd.getVnfdId().equals(vnfdId)) {
- for (final Vnfc vnfc : vnfd.getVnfcList()) {
- final GrantsAddResources addResource = new GrantsAddResources();
- vnfc.setGrantResourceId(UUID.randomUUID().toString());
- addResource.setId(vnfc.getGrantResourceId());
- addResource.setType(TypeEnum.fromValue(vnfc.getType()));
- addResource.setResourceTemplateId(vnfc.getResourceTemplateId());
- addResource.setVduId(vnfc.getVduId());
- resources.add(addResource);
- }
- }
- }
- return resources;
- }
+ protected abstract List<GrantsAddResources> getAddResources(final String vnfdId);
+
+ protected abstract List<GrantsAddResources> getRemoveResources(final String vnfdId);
+
+ protected abstract List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> handleGrantResponse(
+ InlineResponse201 grantResponse);
+
+ protected abstract ChangeTypeEnum getVnfcChangeType();
private InlineResponse201 sendGrantRequest(final GrantRequest grantRequest) {
LOGGER.info("Sending grant request: {}", grantRequest);
@@ -241,46 +224,6 @@ public class OperationProgressor implements Runnable {
}
}
- private InlineResponse201InstantiatedVnfInfo createInstantiatedVnfInfo(final InlineResponse201 grantResponse) {
- final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo = new InlineResponse201InstantiatedVnfInfo();
-
- final Map<String, String> mapOfGrantResourceIdToVimConnectionId = new HashMap<>();
- for (final InlineResponse201AddResources addResource : grantResponse.getAddResources()) {
- mapOfGrantResourceIdToVimConnectionId.put(addResource.getResourceDefinitionId(),
- addResource.getVimConnectionId());
- }
-
- for (final Vnfd vnfd : vnfds.getVnfdList()) {
- if (vnfd.getVnfdId().equals(vnfRepository.getVnf(operation.getVnfInstanceId()).getVnfdId())) {
- for (final Vnfc vnfc : vnfd.getVnfcList()) {
- final InlineResponse201InstantiatedVnfInfoVnfcResourceInfo vnfcResourceInfoItem =
- new InlineResponse201InstantiatedVnfInfoVnfcResourceInfo();
- vnfcResourceInfoItem.setId(vnfc.getVnfcId());
- vnfcResourceInfoItem.setVduId(vnfc.getVduId());
- final InlineResponse201InstantiatedVnfInfoResourceHandle computeResource =
- new InlineResponse201InstantiatedVnfInfoResourceHandle();
- computeResource.setResourceId(UUID.randomUUID().toString());
- computeResource
- .setVimConnectionId(mapOfGrantResourceIdToVimConnectionId.get(vnfc.getGrantResourceId()));
- computeResource.setVimLevelResourceType("OS::Nova::Server");
- vnfcResourceInfoItem.setComputeResource(computeResource);
- instantiatedVnfInfo.addVnfcResourceInfoItem(vnfcResourceInfoItem);
- }
- }
- }
-
- return instantiatedVnfInfo;
- }
-
- private List<InlineResponse201VimConnectionInfo> getVimConnections(final InlineResponse201 grantResponse) {
- final List<InlineResponse201VimConnectionInfo> vimConnectionInfo = new ArrayList<>();
- for (final InlineResponse201VimConnections vimConnection : grantResponse.getVimConnections()) {
- final ModelMapper modelMapper = new ModelMapper();
- vimConnectionInfo.add(modelMapper.map(vimConnection, InlineResponse201VimConnectionInfo.class));
- }
- return vimConnectionInfo;
- }
-
private String getVnfLink() {
return getLinkBaseUrl() + "/vnf_instances/" + operation.getVnfInstanceId();
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
index cac5075682..21bb00dba7 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
@@ -21,6 +21,7 @@
package org.onap.svnfm.simulator.services;
import java.lang.reflect.InvocationTargetException;
+import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -28,6 +29,9 @@ import org.modelmapper.ModelMapper;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
import org.onap.svnfm.simulator.config.ApplicationConfig;
@@ -38,13 +42,13 @@ import org.onap.svnfm.simulator.model.Vnfds;
import org.onap.svnfm.simulator.notifications.VnfInstantiationNotification;
import org.onap.svnfm.simulator.notifications.VnfmAdapterCreationNotification;
import org.onap.svnfm.simulator.repository.VnfOperationRepository;
-import org.onap.svnfm.simulator.repository.VnfmCacheRepository;
import org.onap.svnfm.simulator.repository.VnfmRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.stereotype.Service;
@@ -60,9 +64,6 @@ public class SvnfmService {
VnfmRepository vnfmRepository;
@Autowired
- VnfmCacheRepository vnfRepository;
-
- @Autowired
VnfOperationRepository vnfOperationRepository;
@Autowired
@@ -104,6 +105,17 @@ public class SvnfmService {
return inlineResponse201;
}
+ @CachePut(value = Constant.IN_LINE_RESPONSE_201_CACHE, key = "#id")
+ public InlineResponse201 updateVnf(final InstantiationStateEnum instantiationState,
+ final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo, final String id,
+ final List<InlineResponse201VimConnectionInfo> vimConnectionInfo) {
+ final InlineResponse201 vnf = getVnf(id);
+ vnf.setInstantiatedVnfInfo(instantiatedVnfInfo);
+ vnf.setInstantiationState(instantiationState);
+ vnf.setVimConnectionInfo(vimConnectionInfo);
+ return vnf;
+ }
+
/**
*
* @param vnfId
@@ -114,8 +126,8 @@ public class SvnfmService {
public String instantiateVnf(final String vnfId, final InstantiateVnfRequest instantiateVNFRequest) {
final VnfOperation vnfOperation = buildVnfOperation(InlineResponse200.OperationEnum.INSTANTIATE, vnfId);
vnfOperationRepository.save(vnfOperation);
- executor.submit(new OperationProgressor(vnfOperation, vnfRepository, vnfOperationRepository, applicationConfig,
- vnfds, subscriptionService));
+ executor.submit(new InstantiateOperationProgressor(vnfOperation, this, vnfOperationRepository,
+ applicationConfig, vnfds, subscriptionService));
return vnfOperation.getId();
}
@@ -173,9 +185,12 @@ public class SvnfmService {
* @param vnfId
* @return
*/
- public Object terminateVnf(final String vnfId) {
- // TODO
- return null;
+ public String terminateVnf(final String vnfId) {
+ final VnfOperation vnfOperation = buildVnfOperation(InlineResponse200.OperationEnum.TERMINATE, vnfId);
+ vnfOperationRepository.save(vnfOperation);
+ executor.submit(new TerminateOperationProgressor(vnfOperation, this, vnfOperationRepository, applicationConfig,
+ vnfds, subscriptionService));
+ return vnfOperation.getId();
}
public void registerSubscription(final LccnSubscriptionRequest subscription) {
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/TerminateOperationProgressor.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/TerminateOperationProgressor.java
new file mode 100644
index 0000000000..c829be9a4f
--- /dev/null
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/TerminateOperationProgressor.java
@@ -0,0 +1,74 @@
+package org.onap.svnfm.simulator.services;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources.TypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsResource;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoResourceHandle;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoVnfcResourceInfo;
+import org.onap.svnfm.simulator.config.ApplicationConfig;
+import org.onap.svnfm.simulator.model.VnfOperation;
+import org.onap.svnfm.simulator.model.Vnfds;
+import org.onap.svnfm.simulator.repository.VnfOperationRepository;
+
+public class TerminateOperationProgressor extends OperationProgressor {
+
+ public TerminateOperationProgressor(final VnfOperation operation, final SvnfmService svnfmService,
+ final VnfOperationRepository vnfOperationRepository, final ApplicationConfig applicationConfig,
+ final Vnfds vnfds, final SubscriptionService subscriptionService) {
+ super(operation, svnfmService, vnfOperationRepository, applicationConfig, vnfds, subscriptionService);
+ }
+
+ @Override
+ protected List<GrantsAddResources> getAddResources(final String vnfdId) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ protected List<GrantsAddResources> getRemoveResources(final String vnfdId) {
+ final List<GrantsAddResources> resources = new ArrayList<>();
+
+ final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201 vnf =
+ svnfmService.getVnf(operation.getVnfInstanceId());
+ for (final InlineResponse201InstantiatedVnfInfoVnfcResourceInfo vnfc : vnf.getInstantiatedVnfInfo()
+ .getVnfcResourceInfo()) {
+ final GrantsAddResources addResource = new GrantsAddResources();
+ addResource.setId(UUID.randomUUID().toString());
+ addResource.setType(TypeEnum.COMPUTE);
+ addResource.setVduId(vnfc.getVduId());
+ final GrantsResource resource = new GrantsResource();
+
+ final InlineResponse201InstantiatedVnfInfoResourceHandle computeResource = vnfc.getComputeResource();
+ resource.setResourceId(computeResource.getResourceId());
+ resource.setVimConnectionId(computeResource.getVimConnectionId());
+ resource.setVimLevelResourceType(computeResource.getVimLevelResourceType());
+ addResource.setResource(resource);
+ resources.add(addResource);
+
+ }
+ return resources;
+ }
+
+ @Override
+ protected List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> handleGrantResponse(
+ final InlineResponse201 grantResponse) {
+ final List<InlineResponse201InstantiatedVnfInfoVnfcResourceInfo> vnfcs =
+ svnfmService.getVnf(operation.getVnfInstanceId()).getInstantiatedVnfInfo().getVnfcResourceInfo();
+ svnfmService.updateVnf(InstantiationStateEnum.NOT_INSTANTIATED, null, operation.getVnfInstanceId(), null);
+ return vnfcs;
+ }
+
+ @Override
+ protected ChangeTypeEnum getVnfcChangeType() {
+ return ChangeTypeEnum.REMOVED;
+ }
+
+
+
+}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java
index 7c038b823f..60b251c4d4 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java
@@ -21,6 +21,8 @@
package org.onap.svnfm.simulator.services;
import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
@@ -74,11 +76,17 @@ public class VnfmHelper {
inlineResponse201.setVnfdVersion(Constant.VNFD_VERSION);
inlineResponse201.setVnfSoftwareVersion(Constant.VNF_SOFTWARE_VERSION);
inlineResponse201.setInstantiationState(InstantiationStateEnum.NOT_INSTANTIATED);
- inlineResponse201.setVnfConfigurableProperties(Constant.VNF_CONFIG_PROPERTIES);
+ inlineResponse201.setVnfConfigurableProperties(getConfigProperties());
addAdditionalPRopertyInlineResponse201(inlineResponse201);
return inlineResponse201;
}
+ private Map<String, String> getConfigProperties() {
+ final Map<String, String> configProperties = new HashMap<>();
+ configProperties.put("ipAddress", "10.11.12.13");
+ return configProperties;
+ }
+
private void addAdditionalPRopertyInlineResponse201(final InlineResponse201 inlineResponse201) {
final InlineResponse201LinksSelf VnfInstancesLinksSelf = new InlineResponse201LinksSelf();
VnfInstancesLinksSelf