Create based CSIT test for SO-CNFM - Simulator Changes. 24/133124/10
authornadeeshani.jayathilake <nadeeshani.jayathilake@est.tech>
Wed, 1 Feb 2023 10:21:43 +0000 (10:21 +0000)
committernadeeshani.jayathilake <nadeeshani.jayathilake@est.tech>
Tue, 7 Feb 2023 21:00:37 +0000 (21:00 +0000)
Issue-ID: SO-4067
Signed-off-by: nadeeshani.jayathilake <nadeeshani.jayathilake@est.tech>
Change-Id: If787d96873e234cf3409e1847408b0d50517ee43

20 files changed:
plans/so/integration-etsi-testing/so-simulators/aai-simulator/pom.xml
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/BusinessController.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/14dbe730-b3b9-4b51-9983-76a96233228c.csar [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/14dbe730-b3b9-4b51-9983-76a96233228c.json [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/8839a41e-8644-46c0-a08f-206d8b0edff2.csar [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/8839a41e-8644-46c0-a08f-206d8b0edff2.json [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/controller/CatalogControllerTest.java
prepare-csit.sh
run-csit.sh

index c51cae1..649ef55 100644 (file)
@@ -8,7 +8,7 @@
     </parent>
     <artifactId>aai-simulator</artifactId>
     <properties>
-        <version.aai.schema>1.8.1</version.aai.schema>
+        <version.aai.schema>1.9.2</version.aai.schema>
     </properties>
     <dependencies>
         <dependency>
index 1221bea..7b569bd 100644 (file)
@@ -306,7 +306,7 @@ public class BusinessController {
             @RequestBody final Relationship relationship, final HttpServletRequest request) {
 
         LOGGER.info(
-                "Will add {} relationship for 'global customer id': {}, 'service type': {} and 'service instance id: '{} ...",
+                "Will add {} bi-directional relationship for 'global customer id': {}, 'service type': {} and 'service instance id: '{} ...",
                 relationship.getRelatedTo(), globalCustomerId, serviceType, serviceInstanceId);
         final Optional<Relationship> optional = cacheServiceProvider.addRelationShip(globalCustomerId, serviceType,
                 serviceInstanceId, relationship, request.getRequestURI());
index 8e007de..d6c0a42 100644 (file)
@@ -34,6 +34,7 @@ import javax.ws.rs.core.MediaType;
 import org.onap.aai.domain.yang.CloudRegion;
 import org.onap.aai.domain.yang.EsrSystemInfo;
 import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.K8SResource;
 import org.onap.aai.domain.yang.Relationship;
 import org.onap.aai.domain.yang.Tenant;
 import org.onap.aai.domain.yang.Vserver;
@@ -44,6 +45,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -117,7 +119,7 @@ public class CloudRegionsController {
     public ResponseEntity<?> putRelationShip(@PathVariable("cloud-owner") final String cloudOwner,
             @PathVariable("cloud-region-id") final String cloudRegionId, @RequestBody final Relationship relationship,
             final HttpServletRequest request) {
-        LOGGER.info("Will add {} relationship to : {} ...", relationship.getRelatedTo());
+        LOGGER.info("Will add {} bi-directional relationship to : {} ...", relationship.getRelatedTo());
 
         final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
 
@@ -188,9 +190,11 @@ public class CloudRegionsController {
             @PathVariable("tenant-id") final String tenantId, final HttpServletRequest request) {
 
         final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
-        LOGGER.info("Will put RelationShip for key : {} and tenant-id:{} ...", key, tenantId);
+        LOGGER.info("Will add {} relationship for key : {} and tenant-id:{} ...", relationship.getRelatedLink(), key,
+                tenantId);
 
         if (relationship.getRelatedLink() != null) {
+
             final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
             final HttpHeaders incomingHeader = getHeaders(request);
             final boolean result = cacheServiceProvider.addRelationShip(incomingHeader, targetBaseUrl,
@@ -352,7 +356,9 @@ public class CloudRegionsController {
             @PathVariable("tenant-id") final String tenantId, @PathVariable("vserver-id") final String vServerId,
             @RequestBody final Relationship relationship, final HttpServletRequest request) {
         final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
-        LOGGER.info("Will add {} relationship to : {} ...", relationship.getRelatedTo());
+
+        LOGGER.info("Will add {} relationship for key : {}, tenant-id: {} and vserver-id: {}...",
+                relationship.getRelatedLink(), key, tenantId, vServerId);
 
         if (relationship.getRelatedLink() != null) {
             final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
@@ -364,7 +370,7 @@ public class CloudRegionsController {
                 return ResponseEntity.accepted().build();
             }
         }
-        LOGGER.error("Couldn't add {} relationship for 'key': {} ...", relationship.getRelatedTo(), key);
+        LOGGER.error("Couldn't add {} relationship for 'key': {} ...", relationship.getRelatedLink(), key);
         return getRequestErrorResponseEntity(request, CLOUD_REGION);
 
     }
@@ -379,7 +385,7 @@ public class CloudRegionsController {
             @PathVariable("tenant-id") final String tenantId, @PathVariable("vserver-id") final String vServerId,
             @RequestBody final Relationship relationship, final HttpServletRequest request) {
         final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
-        LOGGER.info("Will add {} relationship to : {} ...", relationship.getRelatedTo());
+        LOGGER.info("Will add {} bi-directional relationship to : {} ...", relationship.getRelatedTo());
 
         final Optional<Relationship> optional = cacheServiceProvider.addvServerRelationShip(key, tenantId, vServerId,
                 relationship, request.getRequestURI());
@@ -393,4 +399,101 @@ public class CloudRegionsController {
         return getRequestErrorResponseEntity(request, CLOUD_REGION);
 
     }
+
+
+    @PutMapping(value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/k8s-resources/k8s-resource/{id}",
+            consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+            produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public ResponseEntity<?> putK8sResource(@RequestBody final K8SResource k8sResource,
+            @PathVariable("cloud-owner") final String cloudOwner,
+            @PathVariable("cloud-region-id") final String cloudRegionId,
+            @PathVariable("tenant-id") final String tenantId, @PathVariable("id") final String id,
+            final HttpServletRequest request) {
+
+        final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+
+        if (key.isValid()) {
+            LOGGER.info("Will add K8s Resource to cache with key 'key': {} ....", key);
+            if (k8sResource.getResourceVersion() == null || k8sResource.getResourceVersion().isEmpty()) {
+                k8sResource.setResourceVersion(getResourceVersion());
+            }
+            if (cacheServiceProvider.putK8sResource(key, tenantId, id, k8sResource)) {
+                return ResponseEntity.accepted().build();
+            }
+        }
+
+        LOGGER.error("Unable to add K8s Resource in cache using key {}", key);
+        return getRequestErrorResponseEntity(request, CLOUD_REGION);
+    }
+
+    @GetMapping(value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/k8s-resources/k8s-resource/{id}",
+            produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public ResponseEntity<?> getK8sResource(@PathVariable("cloud-owner") final String cloudOwner,
+            @PathVariable("cloud-region-id") final String cloudRegionId,
+            @PathVariable("tenant-id") final String tenantId, @PathVariable("id") final String id,
+            final HttpServletRequest request) {
+        final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+        LOGGER.info("Retrieving K8SResource using key : {}, tenant-id:{} and id: {}...", key, tenantId, id);
+        if (key.isValid()) {
+            final Optional<K8SResource> optional = cacheServiceProvider.getK8sResource(key, tenantId, id);
+            if (optional.isPresent()) {
+                final K8SResource tenant = optional.get();
+                LOGGER.info("found K8SResource {} in cache", tenant);
+                return ResponseEntity.ok(tenant);
+            }
+        }
+        LOGGER.error("Unable to find K8SResource in cache key : {},tenant-id:{} and id: {}...", key, tenantId, id);
+        return getRequestErrorResponseEntity(request, CLOUD_REGION);
+    }
+
+    @PutMapping(
+            value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/k8s-resources/k8s-resource/{id}"
+                    + RELATIONSHIP_LIST_RELATIONSHIP_URL,
+            consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+            produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public ResponseEntity<?> putK8sResourceRelationShip(@PathVariable("cloud-owner") final String cloudOwner,
+            @PathVariable("cloud-region-id") final String cloudRegionId,
+            @PathVariable("tenant-id") final String tenantId, @PathVariable("id") final String id,
+            @RequestBody final Relationship relationship, final HttpServletRequest request) {
+        final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+        LOGGER.info("Will add {} relationship for key : {}, tenant-id: {} and id: {}...", relationship.getRelatedLink(),
+                key, tenantId, id);
+
+        if (relationship.getRelatedLink() != null) {
+            final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
+            final HttpHeaders incomingHeader = getHeaders(request);
+            final boolean result = cacheServiceProvider.addK8sResourceRelationShip(incomingHeader, targetBaseUrl,
+                    request.getRequestURI(), key, tenantId, id, relationship);
+            if (result) {
+                LOGGER.info("added created bi directional relationship with {}", relationship.getRelatedLink());
+                return ResponseEntity.accepted().build();
+            }
+        }
+        LOGGER.error("Couldn't add {} relationship for 'key': {} ...", relationship.getRelatedLink(), key);
+        return getRequestErrorResponseEntity(request, CLOUD_REGION);
+
+    }
+
+    @DeleteMapping(value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/k8s-resources/k8s-resource/{id}",
+        produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public ResponseEntity<?> deleteK8sResource(@PathVariable("cloud-owner") final String cloudOwner,
+                                               @PathVariable("cloud-region-id") final String cloudRegionId,
+                                               @PathVariable("tenant-id") final String tenantId, @PathVariable("id") final String id,
+                                               @RequestParam(name = "resource-version") final String resourceVersion,
+                                               final HttpServletRequest request) {
+        final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+        LOGGER.info("Removing K8SResource using key : {}, tenant-id:{} and id: {}...", key, tenantId, id);
+        if (key.isValid()) {
+            final boolean result = cacheServiceProvider.deleteK8sResource(key, tenantId, id, resourceVersion);
+            if (result) {
+                LOGGER.info("Deleted K8SResource from cache related to tenant ID: {}", tenantId);
+                return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
+            }  else {
+                return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
+            }
+        }
+        LOGGER.error("Unable to find K8SResource in cache key : {},tenant-id:{} and id: {}...", key, tenantId, id);
+        return getRequestErrorResponseEntity(request, CLOUD_REGION);
+    }
+
 }
index 297c2eb..fc3c25a 100644 (file)
@@ -156,7 +156,7 @@ public class ExternalSystemEsrController {
             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
     public ResponseEntity<?> putEsrVnfmRelationShip(@RequestBody final Relationship relationship,
             @PathVariable("vnfm-id") final String vnfmId, final HttpServletRequest request) {
-        LOGGER.info("Will put RelationShip for 'vnfm-id': {} ...", vnfmId);
+        LOGGER.info("Will add {} relationship for for 'vnfm-id': {}...", relationship.getRelatedLink(), vnfmId);
 
         if (relationship.getRelatedLink() != null) {
             final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
index 22209fc..7b543a7 100644 (file)
@@ -22,9 +22,9 @@ package org.onap.so.aaisimulator.controller;
 import static org.onap.so.aaisimulator.utils.Constants.APPLICATION_MERGE_PATCH_JSON;
 import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
 import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF;
-import static org.onap.so.aaisimulator.utils.Constants.VF_MODULE;
 import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNFS_URL;
 import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
+import static org.onap.so.aaisimulator.utils.Constants.VF_MODULE;
 import static org.onap.so.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
 import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getHeaders;
 import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
@@ -37,7 +37,6 @@ 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.VfModule;
-import org.onap.aai.domain.yang.VfModules;
 import org.onap.so.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
 import org.onap.so.aaisimulator.utils.HttpServiceUtils;
 import org.onap.so.aaisimulator.utils.RequestErrorResponseUtils;
@@ -46,11 +45,11 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PatchMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
@@ -122,7 +121,7 @@ public class GenericVnfsController {
             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
     public ResponseEntity<?> putGenericVnfRelationShip(@RequestBody final Relationship relationship,
             @PathVariable("vnf-id") final String vnfId, final HttpServletRequest request) {
-        LOGGER.info("Will put RelationShip for 'vnf-id': {} ...", vnfId);
+        LOGGER.info("Will add {} relationship for for 'vnf-id': {}...", relationship.getRelatedLink(), vnfId);
 
         if (relationship.getRelatedLink() != null) {
             final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
@@ -143,7 +142,7 @@ public class GenericVnfsController {
             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
     public ResponseEntity<?> putBiDirectionalRelationShip(@RequestBody final Relationship relationship,
             @PathVariable("vnf-id") final String vnfId, final HttpServletRequest request) {
-        LOGGER.info("Will put RelationShip for 'vnf-id': {} ...", vnfId);
+        LOGGER.info("Will put bi-directional relationship for 'vnf-id': {} ...", vnfId);
 
         final Optional<Relationship> optional =
                 cacheServiceProvider.addRelationShip(vnfId, relationship, request.getRequestURI());
@@ -182,16 +181,9 @@ public class GenericVnfsController {
     }
 
     @GetMapping(produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    public ResponseEntity<?> getGenericVnfs(@RequestParam(name = "selflink") final String selflink,
-            final HttpServletRequest request) {
-        LOGGER.info("will retrieve GenericVnfs using selflink: {}", selflink);
-
-        final List<GenericVnf> genericVnfList = cacheServiceProvider.getGenericVnfs(selflink);
-
-        if (genericVnfList.isEmpty()) {
-            LOGGER.error("No matching generic vnfs found using selflink: {}", selflink);
-            return getRequestErrorResponseEntity(request, GENERIC_VNF);
-        }
+    public ResponseEntity<?> getAllGenericVnfs(final HttpServletRequest request) {
+        LOGGER.info("will retrieve all GenericVnfs");
+        final List<GenericVnf> genericVnfList = cacheServiceProvider.getGenericVnfs();
 
         LOGGER.info("found {} GenericVnfs in cache", genericVnfList.size());
         final GenericVnfs genericVnfs = new GenericVnfs();
@@ -215,10 +207,11 @@ public class GenericVnfsController {
         return getRequestErrorResponseEntity(request, GENERIC_VNF);
 
     }
-    
-    
-    @GetMapping(value = "/generic-vnf/{vnf-id}/vf-modules/vf-module/{vf-module-id}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    public ResponseEntity<?> getVfModule(@PathVariable("vnf-id") final String vnfId, @PathVariable("vf-module-id") final String vfModuleId,
+
+    @GetMapping(value = "/generic-vnf/{vnf-id}/vf-modules/vf-module/{vf-module-id}",
+            produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public ResponseEntity<?> getVfModule(@PathVariable("vnf-id") final String vnfId,
+            @PathVariable("vf-module-id") final String vfModuleId,
             @RequestParam(name = "depth", required = false) final Integer depth,
             @RequestParam(name = "resultIndex", required = false) final Integer resultIndex,
             @RequestParam(name = "resultSize", required = false) final Integer resultSize,
@@ -243,16 +236,20 @@ public class GenericVnfsController {
     }
 
 
-    @PutMapping(value = "/generic-vnf/{vnf-id}/vf-modules/vf-module/{vf-module-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+    @PutMapping(value = "/generic-vnf/{vnf-id}/vf-modules/vf-module/{vf-module-id}",
+            consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
     public ResponseEntity<?> putVfModule(@RequestBody final VfModule vfModule,
-            @PathVariable("vnf-id") final String vnfId, @PathVariable("vf-module-id") final String vfModuleId, final HttpServletRequest request) {
+            @PathVariable("vnf-id") final String vnfId, @PathVariable("vf-module-id") final String vfModuleId,
+            final HttpServletRequest request) {
         LOGGER.info("Will add VfModule to cache with 'vf-module-id': {} ...", vfModuleId);
-
+        if (vfModule.getResourceVersion() == null || vfModule.getResourceVersion().isEmpty()) {
+            vfModule.setResourceVersion(getResourceVersion());
+        }
         cacheServiceProvider.putVfModule(vnfId, vfModuleId, vfModule);
         return ResponseEntity.accepted().build();
     }
-    
+
     @PostMapping(value = "/generic-vnf/{vnf-id}/vf-modules/vf-module/{vf-module-id}",
             consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, APPLICATION_MERGE_PATCH_JSON},
             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@@ -261,9 +258,9 @@ public class GenericVnfsController {
             @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String xHttpHeaderOverride,
             final HttpServletRequest request) {
 
-        LOGGER.info("Will post VfModule to cache with 'vf-module-id': {} and '{}': {} ...", vfModuleId, X_HTTP_METHOD_OVERRIDE,
-                xHttpHeaderOverride);
-        
+        LOGGER.info("Will post VfModule to cache with 'vf-module-id': {} and '{}': {} ...", vfModuleId,
+                X_HTTP_METHOD_OVERRIDE, xHttpHeaderOverride);
+
         if (HttpMethod.PATCH.toString().equalsIgnoreCase(xHttpHeaderOverride)) {
             if (cacheServiceProvider.patchVfModule(vnfId, vfModuleId, vfModule)) {
                 return ResponseEntity.accepted().build();
@@ -276,4 +273,42 @@ public class GenericVnfsController {
         return getRequestErrorResponseEntity(request, VF_MODULE);
     }
 
+
+    @PutMapping(
+            value = "/generic-vnf/{vnf-id}/vf-modules/vf-module/{vf-module-id}" + BI_DIRECTIONAL_RELATIONSHIP_LIST_URL,
+            consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+            produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public ResponseEntity<?> putBiDirectionalVfModuleRelationShip(@RequestBody final Relationship relationship,
+            @PathVariable("vnf-id") final String vnfId, @PathVariable("vf-module-id") final String vfModuleId,
+            final HttpServletRequest request) {
+        LOGGER.info("Will add {} bi-directional relationship to : {} ...", relationship.getRelatedTo());
+
+        final Optional<Relationship> optional =
+                cacheServiceProvider.addRelationShip(vnfId, vfModuleId, relationship, request.getRequestURI());
+
+        if (optional.isPresent()) {
+            final Relationship resultantRelationship = optional.get();
+            LOGGER.info("Relationship add, sending resultant relationship: {} in response ...", resultantRelationship);
+            return ResponseEntity.accepted().body(resultantRelationship);
+        }
+
+        LOGGER.error("Unable to add relationship for related link: {}", relationship.getRelatedLink());
+        return RequestErrorResponseUtils.getRequestErrorResponseEntity(request, GENERIC_VNF);
+    }
+
+    @DeleteMapping(value = "/generic-vnf/{vnf-id}/vf-modules/vf-module/{vf-module-id}",
+        produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public ResponseEntity<?> deleteVfModule(@PathVariable("vnf-id") final String vnfId,
+                                            @PathVariable("vf-module-id") final String vfModuleId,
+                                            @RequestParam(name = "resource-version") final String resourceVersion,
+                                            final HttpServletRequest request) {
+        LOGGER.info("Deleting VfModule from cache with 'vf-module-id': {} ...", vfModuleId);
+
+        boolean response = cacheServiceProvider.deleteVfModule(vnfId, vfModuleId, resourceVersion);
+        if(response){
+            return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
+        } else {
+            return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
+        }
+    }
 }
index b3438d2..e3a9d42 100644 (file)
@@ -117,7 +117,7 @@ public class LinesOfBusinessController {
             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
     public ResponseEntity<?> putRelationShip(@PathVariable("line-of-business-name") final String lineOfBusinessName,
             @RequestBody final Relationship relationship, final HttpServletRequest request) {
-        LOGGER.info("Will add {} relationship to : {} ...", relationship.getRelatedTo());
+        LOGGER.info("Will add {} bi-directional relationship to : {} ...", relationship.getRelatedTo());
 
         final Optional<Relationship> optional =
                 cacheServiceProvider.addRelationShip(lineOfBusinessName, relationship, request.getRequestURI());
index 39e3594..97278bb 100644 (file)
@@ -114,7 +114,7 @@ public class PlatformController {
             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
     public ResponseEntity<?> putRelationShip(@PathVariable("platform-name") final String platformName,
             @RequestBody final Relationship relationship, final HttpServletRequest request) {
-        LOGGER.info("Will add {} relationship to : {} ...", relationship.getRelatedTo());
+        LOGGER.info("Will add {} bi-directional relationship to : {} ...", relationship.getRelatedTo());
 
         final Optional<Relationship> optional =
                 cacheServiceProvider.addRelationShip(platformName, relationship, request.getRequestURI());
index 490982a..b049121 100644 (file)
@@ -116,7 +116,8 @@ public class ProjectController {
     public ResponseEntity<?> putProjectRelationShip(@RequestBody final Relationship relationship,
             @PathVariable("project-name") final String projectName, final HttpServletRequest request) {
 
-        LOGGER.info("adding relationship for project-name: {} ...", projectName);
+        LOGGER.info("Will add {} relationship for for 'project-name': {}...", relationship.getRelatedLink(),
+                projectName);
 
         if (relationship.getRelatedLink() != null) {
             final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
index 6facac8..e4d6cb7 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Optional;
 import org.onap.aai.domain.yang.CloudRegion;
 import org.onap.aai.domain.yang.EsrSystemInfo;
 import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.K8SResource;
 import org.onap.aai.domain.yang.Relationship;
 import org.onap.aai.domain.yang.Tenant;
 import org.onap.aai.domain.yang.Vserver;
@@ -63,7 +64,20 @@ public interface CloudRegionCacheServiceProvider extends Clearable {
     Optional<Relationship> addvServerRelationShip(final CloudRegionKey key, final String tenantId,
             final String vServerId, final Relationship relationship, final String requestUri);
 
-    boolean addVServerRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl, final String requestURI, final CloudRegionKey key,
-            final String tenantId, final String vServerId, final Relationship relationship);
+    boolean addVServerRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl,
+            final String requestURI, final CloudRegionKey key, final String tenantId, final String vServerId,
+            final Relationship relationship);
+
+    boolean putK8sResource(final CloudRegionKey key, final String tenantId, final String id,
+            final K8SResource k8sResource);
+
+    Optional<K8SResource> getK8sResource(final CloudRegionKey key, final String tenantId, final String id);
+
+    boolean addK8sResourceRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl,
+            final String requestURI, final CloudRegionKey key, final String tenantId, final String id,
+            final Relationship relationship);
+
+    boolean deleteK8sResource(final CloudRegionKey key, final String tenantId, final String id,
+                              final String resourceVersion);
 
 }
index f1f782a..f15b389 100644 (file)
@@ -26,10 +26,14 @@ import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGION_CLOUD_OWNER;
 import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGION_CLOUD_REGION_ID;
 import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGION_OWNER_DEFINED_TYPE;
 import static org.onap.so.aaisimulator.utils.Constants.HOSTED_ON;
+import static org.onap.so.aaisimulator.utils.Constants.K8S_RESOURCE;
+import static org.onap.so.aaisimulator.utils.Constants.K8S_RESOURCE_ID;
+import static org.onap.so.aaisimulator.utils.Constants.K8S_RESOURCE_NAME;
 import static org.onap.so.aaisimulator.utils.Constants.LOCATED_IN;
 import static org.onap.so.aaisimulator.utils.Constants.TENANT;
 import static org.onap.so.aaisimulator.utils.Constants.TENANT_TENANT_ID;
 import static org.onap.so.aaisimulator.utils.Constants.TENANT_TENANT_NAME;
+import static org.onap.so.aaisimulator.utils.Constants.USES;
 import static org.onap.so.aaisimulator.utils.Constants.VSERVER;
 import static org.onap.so.aaisimulator.utils.Constants.VSERVER_VSERVER_ID;
 import static org.onap.so.aaisimulator.utils.Constants.VSERVER_VSERVER_NAME;
@@ -41,6 +45,8 @@ import java.util.Optional;
 import org.onap.aai.domain.yang.CloudRegion;
 import org.onap.aai.domain.yang.EsrSystemInfo;
 import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.K8SResource;
+import org.onap.aai.domain.yang.K8SResources;
 import org.onap.aai.domain.yang.RelatedToProperty;
 import org.onap.aai.domain.yang.Relationship;
 import org.onap.aai.domain.yang.RelationshipData;
@@ -67,8 +73,6 @@ import org.springframework.stereotype.Service;
 public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServiceProvider
         implements CloudRegionCacheServiceProvider {
 
-
-
     private static final Logger LOGGER = LoggerFactory.getLogger(CloudRegionCacheServiceProviderImpl.class);
 
     private final HttpRestServiceProvider httpRestServiceProvider;
@@ -331,6 +335,112 @@ public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServicePro
         return false;
     }
 
+    @Override
+    public boolean putK8sResource(final CloudRegionKey key, final String tenantId, final String id,
+            final K8SResource k8sResource) {
+        final Optional<Tenant> optional = getTenant(key, tenantId);
+        if (optional.isPresent()) {
+            final Tenant tenant = optional.get();
+            K8SResources k8sResources = tenant.getK8SResources();
+            if (k8sResources == null) {
+                k8sResources = new K8SResources();
+                tenant.setK8SResources(k8sResources);
+            }
+
+
+            final Optional<K8SResource> existingK8sResource = k8sResources.getK8SResource().stream()
+                    .filter(entry -> entry.getId() != null && entry.getId().equalsIgnoreCase(id)).findFirst();
+
+            if (existingK8sResource.isEmpty()) {
+                LOGGER.info("Adding k8sResources to cache...");
+                return k8sResources.getK8SResource().add(k8sResource);
+            }
+
+            LOGGER.warn("K8SResource already exists existingK8sResource: {}...", existingK8sResource.get());
+            return false;
+        }
+
+        LOGGER.error("Unable to add K8s Resource using key: {}, tenantId: {} and id: {}...", key, tenantId, id);
+        return false;
+    }
+
+    @Override
+    public Optional<K8SResource> getK8sResource(final CloudRegionKey key, final String tenantId, final String id) {
+        final Optional<Tenant> optional = getTenant(key, tenantId);
+
+        if (optional.isPresent()) {
+
+            final Tenant tenant = optional.get();
+            final K8SResources k8sResources = tenant.getK8SResources();
+            if (k8sResources != null) {
+                return k8sResources.getK8SResource().stream()
+                        .filter(entry -> entry.getId() != null && entry.getId().equalsIgnoreCase(id)).findFirst();
+            }
+
+        }
+        LOGGER.error("Unable to find K8sResource using key: {}, tenantId: {} and id: {}...", key, tenantId, id);
+        return Optional.empty();
+    }
+
+    @Override
+    public boolean addK8sResourceRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl,
+            final String requestUriString, final CloudRegionKey key, final String tenantId, final String id,
+            final Relationship relationship) {
+        try {
+            final Optional<K8SResource> optional = getK8sResource(key, tenantId, id);
+            if (optional.isPresent()) {
+                final K8SResource k8sResource = optional.get();
+                final String targetUrl = getTargetUrl(targetBaseUrl, relationship.getRelatedLink());
+                final Relationship outGoingRelationShip =
+                        getRelationship(key, tenantId, k8sResource, getRelationShipListRelatedLink(requestUriString));
+                final Optional<Relationship> optionalRelationship = httpRestServiceProvider.put(incomingHeader,
+                        outGoingRelationShip, targetUrl, Relationship.class);
+
+                if (optionalRelationship.isPresent()) {
+                    final Relationship resultantRelationship = optionalRelationship.get();
+
+                    RelationshipList relationshipList = k8sResource.getRelationshipList();
+                    if (relationshipList == null) {
+                        relationshipList = new RelationshipList();
+                        k8sResource.setRelationshipList(relationshipList);
+                    }
+                    if (relationshipList.getRelationship().add(resultantRelationship)) {
+                        LOGGER.info("added relationship {} in cache successfully", resultantRelationship);
+                        return true;
+                    }
+                }
+
+            }
+        } catch (final Exception exception) {
+            LOGGER.error("Unable to add two-way relationship for key: {}, tenantId: {} and id: {}", key, tenantId, id,
+                    exception);
+        }
+        LOGGER.error("Unable to add K8sResource relationship for key: {}, tenantId: {} and id: {}...", key, tenantId,
+                id);
+        return false;
+    }
+
+    private Relationship getRelationship(final CloudRegionKey key, final String tenantId, final K8SResource k8sResource,
+            final String relatedLink) {
+        final Relationship relationShip = new Relationship();
+        relationShip.setRelatedTo(K8S_RESOURCE);
+        relationShip.setRelationshipLabel(USES);
+        relationShip.setRelatedLink(relatedLink);
+
+        final List<RelationshipData> relationshipDataList = relationShip.getRelationshipData();
+        relationshipDataList.add(getRelationshipData(CLOUD_REGION_CLOUD_OWNER, key.getCloudOwner()));
+        relationshipDataList.add(getRelationshipData(CLOUD_REGION_CLOUD_REGION_ID, key.getCloudRegionId()));
+        relationshipDataList.add(getRelationshipData(TENANT_TENANT_ID, tenantId));
+        relationshipDataList.add(getRelationshipData(K8S_RESOURCE_ID, k8sResource.getId()));
+
+        final RelatedToProperty relatedToProperty = new RelatedToProperty();
+        relatedToProperty.setPropertyKey(K8S_RESOURCE_NAME);
+        relatedToProperty.setPropertyValue(k8sResource.getName());
+        relationShip.getRelatedToProperty().add(relatedToProperty);
+
+        return relationShip;
+    }
+
     @Override
     public Optional<Relationship> addvServerRelationShip(final CloudRegionKey key, final String tenantId,
             final String vServerId, final Relationship relationship, final String requestUri) {
@@ -468,4 +578,29 @@ public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServicePro
 
     }
 
+    @Override
+    public boolean deleteK8sResource(final CloudRegionKey key, final String tenantId, final String id,
+                                     final String resourceVersion) {
+        final Optional<Tenant> optional = getTenant(key, tenantId);
+        if (optional.isPresent()) {
+            final Tenant tenant = optional.get();
+            K8SResources k8sResources = tenant.getK8SResources();
+            if (k8sResources != null) {
+                final Optional<K8SResource> existingK8sResource = k8sResources.getK8SResource().stream()
+                    .filter(entry -> entry.getId() != null && entry.getId().equalsIgnoreCase(id)).findFirst();
+
+                if (existingK8sResource.isPresent()
+                    && existingK8sResource.get().getResourceVersion().equals(resourceVersion)) {
+                    LOGGER.info("k8sResources found in cache and removing the same.");
+                    return k8sResources.getK8SResource().remove(existingK8sResource.get());
+                }
+            }
+            else {
+                return true;
+            }
+        }
+
+        LOGGER.error("Unable to add K8s Resource using key: {}, tenantId: {} and id: {}...", key, tenantId, id);
+        return false;
+    }
 }
index 5570381..14b823c 100644 (file)
@@ -46,7 +46,7 @@ public interface GenericVnfCacheServiceProvider extends Clearable {
 
     boolean patchGenericVnf(final String vnfId, final GenericVnf genericVnf);
 
-    List<GenericVnf> getGenericVnfs(final String selflink);
+    List<GenericVnf> getGenericVnfs();
 
     boolean deleteGenericVnf(final String vnfId, final String resourceVersion);
 
@@ -55,4 +55,9 @@ public interface GenericVnfCacheServiceProvider extends Clearable {
     Optional<VfModule> getVfModule(final String vnfId, final String vfModuleId);
 
     boolean patchVfModule(final String vnfId, final String vfModuleId, final VfModule vfModule);
+
+    Optional<Relationship> addRelationShip(String vnfId, String vfModuleId, Relationship relationship,
+            String requestURI);
+
+    boolean deleteVfModule(final String vnfId, final String vfModuleId, final String resourceVersion);
 }
index 24544a6..0a26648 100644 (file)
@@ -24,6 +24,9 @@ import static org.onap.so.aaisimulator.utils.Constants.COMPOSED_OF;
 import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF;
 import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_ID;
 import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_NAME;
+import static org.onap.so.aaisimulator.utils.Constants.USES;
+import static org.onap.so.aaisimulator.utils.Constants.VF_MODULE;
+import static org.onap.so.aaisimulator.utils.Constants.VF_MODULE_VF_MODULE_ID;
 import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getBiDirectionalRelationShipListRelatedLink;
 import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getRelationShipListRelatedLink;
 import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getTargetUrl;
@@ -186,34 +189,27 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
     }
 
     @Override
-    public List<GenericVnf> getGenericVnfs(final String selflink) {
+    public List<GenericVnf> getGenericVnfs() {
         final Cache cache = getCache(GENERIC_VNF_CACHE.getName());
         if (cache != null) {
             final Object nativeCache = cache.getNativeCache();
             if (nativeCache instanceof ConcurrentHashMap) {
                 @SuppressWarnings("unchecked")
                 final ConcurrentHashMap<Object, Object> concurrentHashMap =
-                        (ConcurrentHashMap<Object, Object>) nativeCache;
+                    (ConcurrentHashMap<Object, Object>) nativeCache;
                 final List<GenericVnf> result = new ArrayList<>();
 
-                concurrentHashMap.keySet().stream().forEach(key -> {
+                concurrentHashMap.keySet().forEach(key -> {
                     final Optional<GenericVnf> optional = getGenericVnf(key.toString());
                     if (optional.isPresent()) {
                         final GenericVnf genericVnf = optional.get();
-                        final String genericVnfSelfLink = genericVnf.getSelflink();
-                        final String genericVnfId = genericVnf.getSelflink();
-
-                        if (genericVnfSelfLink != null && genericVnfSelfLink.equals(selflink)) {
-                            LOGGER.info("Found matching vnf for selflink: {}, vnf-id: {}", genericVnfSelfLink,
-                                    genericVnfId);
-                            result.add(genericVnf);
-                        }
+                        result.add(genericVnf);
                     }
                 });
                 return result;
             }
         }
-        LOGGER.error("No match found for selflink: {}", selflink);
+        LOGGER.error("No match found");
         return Collections.emptyList();
     }
 
@@ -259,14 +255,13 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
 
     @Override
     public Optional<VfModule> getVfModule(final String vnfId, final String vfModuleId) {
-        LOGGER.info("Getting vfModule from cache for vnfId: {} and vfModuleId: {}",
-                vnfId, vfModuleId);
+        LOGGER.info("Getting vfModule from cache for vnfId: {} and vfModuleId: {}", vnfId, vfModuleId);
         final Optional<GenericVnf> genericVnfOptional = getGenericVnf(vnfId);
         final GenericVnf value = genericVnfOptional.get();
         final VfModules vfmodules = value.getVfModules();
         if (vfmodules != null) {
-            for (VfModule vfModule : vfmodules.getVfModule()) {
-                 if (vfModule.getVfModuleId().equalsIgnoreCase(vfModuleId)){
+            for (final VfModule vfModule : vfmodules.getVfModule()) {
+                if (vfModule.getVfModuleId().equalsIgnoreCase(vfModuleId)) {
                     return Optional.of(vfModule);
                 }
             }
@@ -277,14 +272,13 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
 
     @Override
     public void putVfModule(final String vnfId, final String vfModuleId, final VfModule vfModule) {
-        LOGGER.info("Adding vfModule for vnfId: {} and vfModuleId: {}",
-                vnfId, vfModuleId);
+        LOGGER.info("Adding vfModule for vnfId: {} and vfModuleId: {}", vnfId, vfModuleId);
         final Optional<GenericVnf> genericVnfOptional = getGenericVnf(vnfId);
         final Cache cache = getCache(GENERIC_VNF_CACHE.getName());
         if (genericVnfOptional.isPresent()) {
             final GenericVnf genericVnf = genericVnfOptional.get();
             VfModules vfModules = null;
-            if(genericVnf.getVfModules()==null){
+            if (genericVnf.getVfModules() == null) {
                 vfModules = new VfModules();
                 genericVnf.setVfModules(vfModules);
             } else {
@@ -299,16 +293,15 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
     @Override
     public boolean patchVfModule(final String vnfId, final String vfModuleId, final VfModule vfModule) {
         final Optional<GenericVnf> genericVnfOptional = getGenericVnf(vnfId);
-        LOGGER.info("Create vfModule for vnfId: {} and vfModuleId: {}",
-                vnfId, vfModuleId);
+        LOGGER.info("Create vfModule for vnfId: {} and vfModuleId: {}", vnfId, vfModuleId);
         if (genericVnfOptional.isPresent()) {
             final GenericVnf cachedGenericVnf = genericVnfOptional.get();
             final VfModules vfmodules = cachedGenericVnf.getVfModules();
             LOGGER.info("vfModuleId is Matched");
             try {
-                vfmodules.getVfModule().stream().filter(tempVfModule ->
-                        tempVfModule.getVfModuleId().equalsIgnoreCase(vfModuleId)).forEach(tempVfModule ->
-                        tempVfModule.setOrchestrationStatus(vfModule.getOrchestrationStatus()));
+                vfmodules.getVfModule().stream()
+                        .filter(tempVfModule -> tempVfModule.getVfModuleId().equalsIgnoreCase(vfModuleId)).forEach(
+                                tempVfModule -> tempVfModule.setOrchestrationStatus(vfModule.getOrchestrationStatus()));
                 return true;
             } catch (final Exception exception) {
                 LOGGER.error("Unable to update VfModule for vfModuleId: {}", vfModule, exception);
@@ -317,4 +310,59 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
         LOGGER.error("Unable to find VfModule ...");
         return false;
     }
-}
\ No newline at end of file
+
+    @Override
+    public Optional<Relationship> addRelationShip(final String vnfId, final String vfModuleId,
+            final Relationship relationship, final String requestURI) {
+        final Optional<VfModule> optional = getVfModule(vnfId, vfModuleId);
+        if (optional.isPresent()) {
+            final VfModule vfModule = optional.get();
+
+            RelationshipList relationshipList = vfModule.getRelationshipList();
+            if (relationshipList == null) {
+                relationshipList = new RelationshipList();
+                vfModule.setRelationshipList(relationshipList);
+            }
+            relationshipList.getRelationship().add(relationship);
+            LOGGER.info("Successfully added relation to VfModule for vnfId: {} and vfModuleId: {}", vnfId, vfModuleId);
+
+            final String relatedLink = getBiDirectionalRelationShipListRelatedLink(requestURI);
+
+            final Relationship resultantRelationship = new Relationship();
+            resultantRelationship.setRelatedTo(VF_MODULE);
+            resultantRelationship.setRelationshipLabel(USES);
+            resultantRelationship.setRelatedLink(relatedLink);
+
+            final RelationshipData genericVnfRelationshipData = new RelationshipData();
+            genericVnfRelationshipData.setRelationshipKey(GENERIC_VNF_VNF_ID);
+            genericVnfRelationshipData.setRelationshipValue(vnfId);
+            resultantRelationship.getRelationshipData().add(genericVnfRelationshipData);
+
+            final RelationshipData vfModuleRelationshipData = new RelationshipData();
+            vfModuleRelationshipData.setRelationshipKey(VF_MODULE_VF_MODULE_ID);
+            vfModuleRelationshipData.setRelationshipValue(vfModuleId);
+            resultantRelationship.getRelationshipData().add(vfModuleRelationshipData);
+            return Optional.of(resultantRelationship);
+        }
+
+        LOGGER.error("Unable to find VfModule ...");
+        return Optional.empty();
+    }
+
+    @Override
+    public boolean deleteVfModule(final String vnfId, final String vfModuleId, final String resourceVersion) {
+        final Optional<GenericVnf> genericVnfOptional = getGenericVnf(vnfId);
+        final Optional<VfModule> vfModuleOptional = getVfModule(vnfId, vfModuleId);
+        if (genericVnfOptional.isPresent() && vfModuleOptional.isPresent()) {
+            final GenericVnf genericVnf = genericVnfOptional.get();
+            final VfModule vfModule = vfModuleOptional.get();
+            if (genericVnf.getVfModules() != null && vfModule.getResourceVersion().equals(resourceVersion)) {
+                LOGGER.info("VfModule: {} deleted from the Generic VNF: {}",vfModuleId, vnfId);
+                return genericVnf.getVfModules().getVfModule().remove(vfModule);
+            }
+        }
+        LOGGER.error("There are no VfModules associated to vnf ID: {}", vnfId);
+        return false;
+    }
+
+}
index 4cd5b25..71c0bd5 100644 (file)
@@ -89,9 +89,11 @@ public class Constants {
     public static final String COMPOSED_OF = "org.onap.relationships.inventory.ComposedOf";
 
     public static final String GENERIC_VNF = "generic-vnf";
-    
+
     public static final String VF_MODULE = "vf-module";
 
+    public static final String VF_MODULE_VF_MODULE_ID = "vf-module.vf-module-id";
+
     public static final String PLATFORM = "platform";
 
     public static final String USES = "org.onap.relationships.inventory.Uses";
@@ -144,6 +146,12 @@ public class Constants {
 
     public static final String VSERVER = "vserver";
 
+    public static final String K8S_RESOURCE = "k8s-resource";
+
+    public static final String K8S_RESOURCE_ID = "k8s-resource.id";
+
+    public static final String K8S_RESOURCE_NAME = "k8s-resource.name";
+
     private Constants() {}
 
 }
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/14dbe730-b3b9-4b51-9983-76a96233228c.csar b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/14dbe730-b3b9-4b51-9983-76a96233228c.csar
new file mode 100644 (file)
index 0000000..b439abf
Binary files /dev/null and b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/14dbe730-b3b9-4b51-9983-76a96233228c.csar differ
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/14dbe730-b3b9-4b51-9983-76a96233228c.json b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/14dbe730-b3b9-4b51-9983-76a96233228c.json
new file mode 100644 (file)
index 0000000..e1c9614
--- /dev/null
@@ -0,0 +1,82 @@
+{
+    "uuid": "14dbe730-b3b9-4b51-9983-76a96233228c",
+    "invariantUUID": "198ab85b-ad8d-42e5-889d-4bdf486dfc91",
+    "name": "ericsson-vsp-cnf-1",
+    "version": "1.0",
+    "toscaModelURL": "/sdc/v1/catalog/resources/14dbe730-b3b9-4b51-9983-76a96233228c/toscaModel",
+    "category": "Generic",
+    "subCategory": "Network Elements",
+    "resourceType": "VF",
+    "lifecycleState": "CERTIFIED",
+    "lastUpdaterUserId": "cs0008",
+    "lastUpdaterFullName": "Carlos Santana",
+    "toscaResourceName": "org.openecomp.resource.vf.EricssonVspCnf1",
+    "resources": [
+        {
+            "resourceInstanceName": "applicationServiceDescriptor",
+            "resourceName": "asd",
+            "resourceInvariantUUID": "12deb51f-0829-4b77-aacb-69bb114d4d1b",
+            "resourceVersion": "1.0",
+            "resoucreType": "VFC",
+            "resourceUUID": "09a8c85c-0d45-4604-987f-d3cd7ee16656"
+        }
+    ],
+    "artifacts": [
+        {
+            "artifactName": "vf-license-model.xml",
+            "artifactType": "VF_LICENSE",
+            "artifactURL": "/sdc/v1/catalog/resources/14dbe730-b3b9-4b51-9983-76a96233228c/artifacts/6a456db8-f06b-455c-aa86-d95eea809479",
+            "artifactDescription": "VF license file",
+            "artifactChecksum": "N2JiNzQ1ZTE0ZDM0ZmYyNjQzYzQyZTIyYzcxZTdmZjE=",
+            "artifactUUID": "6a456db8-f06b-455c-aa86-d95eea809479",
+            "artifactVersion": "1",
+            "artifactLabel": "vflicense",
+            "artifactGroupType": "DEPLOYMENT"
+        },
+        {
+            "artifactName": "nginx-12.0.4.tgz",
+            "artifactType": "HELM",
+            "artifactURL": "/sdc/v1/catalog/resources/14dbe730-b3b9-4b51-9983-76a96233228c/artifacts/2d8319c2-e0a5-42da-ac20-c9cabe7d3af7",
+            "artifactDescription": "Artifact created from csar",
+            "artifactChecksum": "Yjk0MWUxNTRlMmVmM2E1ZmI3OGRjNDc4YTVmYzEwMGM=",
+            "artifactUUID": "2d8319c2-e0a5-42da-ac20-c9cabe7d3af7",
+            "artifactVersion": "1",
+            "artifactLabel": "nginx1204tgz",
+            "artifactGroupType": "DEPLOYMENT"
+        },
+        {
+            "artifactName": "vendor-license-model.xml",
+            "artifactType": "VENDOR_LICENSE",
+            "artifactURL": "/sdc/v1/catalog/resources/14dbe730-b3b9-4b51-9983-76a96233228c/artifacts/d1eae10b-c5cd-4fee-8eb2-b7ea7ce514bb",
+            "artifactDescription": " Vendor license file",
+            "artifactChecksum": "ODg3YTc0YjhiYzVjZTJjNGM2NzRmZDE2ZDc0MWNjOGQ=",
+            "artifactUUID": "d1eae10b-c5cd-4fee-8eb2-b7ea7ce514bb",
+            "artifactVersion": "1",
+            "artifactLabel": "vendorlicense",
+            "artifactGroupType": "DEPLOYMENT"
+        },
+        {
+            "artifactName": "asd_modified.csar",
+            "artifactType": "ETSI_PACKAGE",
+            "artifactURL": "/sdc/v1/catalog/resources/14dbe730-b3b9-4b51-9983-76a96233228c/artifacts/25c0a778-2dd7-4495-b7b5-cd37605d1087",
+            "artifactDescription": "Artifact created from csar",
+            "artifactChecksum": "MDM4NmQzNmNhODdkNTY0NDczMGMyZDNlMmE4MWU1MTQ=",
+            "artifactUUID": "25c0a778-2dd7-4495-b7b5-cd37605d1087",
+            "artifactVersion": "1",
+            "artifactLabel": "asdmodifiedcsar",
+            "artifactGroupType": "DEPLOYMENT"
+        },
+        {
+            "artifactName": "mariadb-11.0.13.tgz",
+            "artifactType": "HELM",
+            "artifactURL": "/sdc/v1/catalog/resources/14dbe730-b3b9-4b51-9983-76a96233228c/artifacts/769dba94-6b7b-4bf3-a9cf-2b7727abb50a",
+            "artifactDescription": "Artifact created from csar",
+            "artifactChecksum": "OWYxMGI4MDZlN2JmM2VhY2VkMmI2Y2M3MDRjZDYzZDA=",
+            "artifactUUID": "769dba94-6b7b-4bf3-a9cf-2b7727abb50a",
+            "artifactVersion": "1",
+            "artifactLabel": "mariadb11013tgz",
+            "artifactGroupType": "DEPLOYMENT"
+        }
+    ],
+    "description": "ericsson-vsp-cnf-1"
+}
\ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/8839a41e-8644-46c0-a08f-206d8b0edff2.csar b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/8839a41e-8644-46c0-a08f-206d8b0edff2.csar
new file mode 100644 (file)
index 0000000..011fe93
Binary files /dev/null and b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/8839a41e-8644-46c0-a08f-206d8b0edff2.csar differ
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/8839a41e-8644-46c0-a08f-206d8b0edff2.json b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/8839a41e-8644-46c0-a08f-206d8b0edff2.json
new file mode 100644 (file)
index 0000000..ccbd88b
--- /dev/null
@@ -0,0 +1,105 @@
+{
+    "uuid": "8839a41e-8644-46c0-a08f-206d8b0edff2",
+    "invariantUUID": "ef54671d-31e4-43e0-86e2-c3ab73c2a5a7",
+    "name": "ericsson-demo-service-1",
+    "version": "1.0",
+    "toscaModelURL": "/sdc/v1/catalog/services/8839a41e-8644-46c0-a08f-206d8b0edff2/toscaModel",
+    "category": "Network L1-3",
+    "lifecycleState": "CERTIFIED",
+    "lastUpdaterUserId": "cs0008",
+    "distributionStatus": "DISTRIBUTED",
+    "lastUpdaterFullName": "Carlos Santana",
+    "resources": [
+        {
+            "resourceInstanceName": "ericsson-vsp-cnf-1 0",
+            "resourceName": "ericsson-vsp-cnf-1",
+            "resourceInvariantUUID": "198ab85b-ad8d-42e5-889d-4bdf486dfc91",
+            "resourceVersion": "1.0",
+            "resoucreType": "VF",
+            "resourceUUID": "14dbe730-b3b9-4b51-9983-76a96233228c",
+            "artifacts": [
+                {
+                    "artifactName": "vf-license-model.xml",
+                    "artifactType": "VF_LICENSE",
+                    "artifactURL": "/sdc/v1/catalog/services/8839a41e-8644-46c0-a08f-206d8b0edff2/resourceInstances/ericssonvspcnf10/artifacts/6a456db8-f06b-455c-aa86-d95eea809479",
+                    "artifactDescription": "VF license file",
+                    "artifactChecksum": "N2JiNzQ1ZTE0ZDM0ZmYyNjQzYzQyZTIyYzcxZTdmZjE=",
+                    "artifactUUID": "6a456db8-f06b-455c-aa86-d95eea809479",
+                    "artifactVersion": "1",
+                    "artifactLabel": "vflicense",
+                    "artifactGroupType": "DEPLOYMENT"
+                },
+                {
+                    "artifactName": "nginx-12.0.4.tgz",
+                    "artifactType": "HELM",
+                    "artifactURL": "/sdc/v1/catalog/services/8839a41e-8644-46c0-a08f-206d8b0edff2/resourceInstances/ericssonvspcnf10/artifacts/2d8319c2-e0a5-42da-ac20-c9cabe7d3af7",
+                    "artifactDescription": "Artifact created from csar",
+                    "artifactTimeout": 30,
+                    "artifactChecksum": "Yjk0MWUxNTRlMmVmM2E1ZmI3OGRjNDc4YTVmYzEwMGM=",
+                    "artifactUUID": "2d8319c2-e0a5-42da-ac20-c9cabe7d3af7",
+                    "artifactVersion": "1",
+                    "artifactLabel": "nginx1204tgz",
+                    "artifactGroupType": "DEPLOYMENT"
+                },
+                {
+                    "artifactName": "mariadb-11.0.13.env",
+                    "artifactType": "HEAT_ENV",
+                    "artifactURL": "/sdc/v1/catalog/services/8839a41e-8644-46c0-a08f-206d8b0edff2/resourceInstances/ericssonvspcnf10/artifacts/61de4c88-8085-40bd-bdcb-b4d05652b587",
+                    "artifactDescription": "Auto-generated HEAT Environment deployment artifact",
+                    "artifactChecksum": "MTA2MjAxNDAyMmY0NmMwYTlmMDMyN2FjZDUxODkzNWI=",
+                    "artifactUUID": "61de4c88-8085-40bd-bdcb-b4d05652b587",
+                    "artifactVersion": "2",
+                    "generatedFromUUID": "49acb97e-8577-4840-982b-8986ad40f446.mariadb11013tgz",
+                    "artifactLabel": "mariadb11013tgzenv",
+                    "artifactGroupType": "DEPLOYMENT"
+                },
+                {
+                    "artifactName": "vendor-license-model.xml",
+                    "artifactType": "VENDOR_LICENSE",
+                    "artifactURL": "/sdc/v1/catalog/services/8839a41e-8644-46c0-a08f-206d8b0edff2/resourceInstances/ericssonvspcnf10/artifacts/d1eae10b-c5cd-4fee-8eb2-b7ea7ce514bb",
+                    "artifactDescription": " Vendor license file",
+                    "artifactChecksum": "ODg3YTc0YjhiYzVjZTJjNGM2NzRmZDE2ZDc0MWNjOGQ=",
+                    "artifactUUID": "d1eae10b-c5cd-4fee-8eb2-b7ea7ce514bb",
+                    "artifactVersion": "1",
+                    "artifactLabel": "vendorlicense",
+                    "artifactGroupType": "DEPLOYMENT"
+                },
+                {
+                    "artifactName": "nginx-12.0.4.env",
+                    "artifactType": "HEAT_ENV",
+                    "artifactURL": "/sdc/v1/catalog/services/8839a41e-8644-46c0-a08f-206d8b0edff2/resourceInstances/ericssonvspcnf10/artifacts/7dbe6f73-41e9-4d59-9ae2-9d9889339f80",
+                    "artifactDescription": "Auto-generated HEAT Environment deployment artifact",
+                    "artifactChecksum": "MTA2MjAxNDAyMmY0NmMwYTlmMDMyN2FjZDUxODkzNWI=",
+                    "artifactUUID": "7dbe6f73-41e9-4d59-9ae2-9d9889339f80",
+                    "artifactVersion": "2",
+                    "generatedFromUUID": "49acb97e-8577-4840-982b-8986ad40f446.nginx1204tgz",
+                    "artifactLabel": "nginx1204tgzenv",
+                    "artifactGroupType": "DEPLOYMENT"
+                },
+                {
+                    "artifactName": "asd_modified.csar",
+                    "artifactType": "ETSI_PACKAGE",
+                    "artifactURL": "/sdc/v1/catalog/services/8839a41e-8644-46c0-a08f-206d8b0edff2/resourceInstances/ericssonvspcnf10/artifacts/25c0a778-2dd7-4495-b7b5-cd37605d1087",
+                    "artifactDescription": "Artifact created from csar",
+                    "artifactChecksum": "MDM4NmQzNmNhODdkNTY0NDczMGMyZDNlMmE4MWU1MTQ=",
+                    "artifactUUID": "25c0a778-2dd7-4495-b7b5-cd37605d1087",
+                    "artifactVersion": "1",
+                    "artifactLabel": "asdmodifiedcsar",
+                    "artifactGroupType": "DEPLOYMENT"
+                },
+                {
+                    "artifactName": "mariadb-11.0.13.tgz",
+                    "artifactType": "HELM",
+                    "artifactURL": "/sdc/v1/catalog/services/8839a41e-8644-46c0-a08f-206d8b0edff2/resourceInstances/ericssonvspcnf10/artifacts/769dba94-6b7b-4bf3-a9cf-2b7727abb50a",
+                    "artifactDescription": "Artifact created from csar",
+                    "artifactTimeout": 30,
+                    "artifactChecksum": "OWYxMGI4MDZlN2JmM2VhY2VkMmI2Y2M3MDRjZDYzZDA=",
+                    "artifactUUID": "769dba94-6b7b-4bf3-a9cf-2b7727abb50a",
+                    "artifactVersion": "1",
+                    "artifactLabel": "mariadb11013tgz",
+                    "artifactGroupType": "DEPLOYMENT"
+                }
+            ]
+        }
+    ]
+}
\ No newline at end of file
index e5a6e7f..51b90fa 100644 (file)
@@ -115,8 +115,8 @@ public class CatalogControllerTest {
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertTrue(response.hasBody());
-        assertEquals(1, response.getBody().size());
-        assertEquals(SUB_CATEGORY, response.getBody().iterator().next().getSubCategory());
+        assertEquals(2, response.getBody().size());
+        assertTrue(response.getBody().stream().anyMatch(predicate -> SUB_CATEGORY.equals(predicate.getSubCategory())));
 
     }
 
@@ -129,8 +129,9 @@ public class CatalogControllerTest {
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertTrue(response.hasBody());
-        assertEquals(1, response.getBody().size());
-        assertEquals(DISTRIBUTION_STATUS, response.getBody().iterator().next().getDistributionStatus());
+        assertEquals(2, response.getBody().size());
+        assertTrue(response.getBody().stream()
+            .anyMatch(predicate -> DISTRIBUTION_STATUS.equals(predicate.getDistributionStatus())));
 
     }
 
index 4e3edeb..d580f91 100755 (executable)
@@ -30,8 +30,8 @@ TESTPLANDIR=${WORKSPACE}/${TESTPLAN}
 if [ -f ${WORKSPACE}/env.properties ]; then
     source ${WORKSPACE}/env.properties
 fi
-if [ -f ${ROBOT_VENV}/bin/activate ]; then
-    source ${ROBOT_VENV}/bin/activate
+if [ -f ${ROBOT3_VENV}/bin/activate ]; then
+    source ${ROBOT3_VENV}/bin/activate
 else
     rm -rf /tmp/ci-management
     rm -f ${WORKSPACE}/env.properties
@@ -41,18 +41,18 @@ else
 fi
 
 # install required Robot libraries
-pip install robotframework-selenium2library==1.8.0 robotframework-extendedselenium2library==0.9.1
+pip install robotframework-extendedselenium2library==0.9.1
 
 # install eteutils
-mkdir -p ${ROBOT_VENV}/src/onap
-rm -rf ${ROBOT_VENV}/src/onap/testsuite
+mkdir -p ${ROBOT3_VENV}/src/onap
+rm -rf ${ROBOT3_VENV}/src/onap/testsuite
 pip install --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==11.0.0.*' --pre
 
 pip freeze
 
 # install chrome driver
-if [ ! -x ${ROBOT_VENV}/bin/chromedriver ]; then
-    pushd ${ROBOT_VENV}/bin
+if [ ! -x ${ROBOT3_VENV}/bin/chromedriver ]; then
+    pushd ${ROBOT3_VENV}/bin
     wget -N http://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
     unzip chromedriver_linux64.zip
     chmod +x chromedriver
index ce9cf80..55b755d 100755 (executable)
@@ -153,13 +153,13 @@ TESTPLANDIR="${WORKSPACE}/${TESTPLAN}"
 source_safely "${WORKSPACE}/prepare-csit.sh"
 
 # Activate the virtualenv containing all the required libraries installed by prepare-csit.sh
-source_safely "${ROBOT_VENV}/bin/activate"
+source_safely "${ROBOT3_VENV}/bin/activate"
 
 WORKDIR=$(mktemp -d --suffix=-robot-workdir)
 cd "${WORKDIR}"
 
 # Add csit scripts to PATH
-export PATH="${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT_VENV}/bin"
+export PATH="${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT3_VENV}/bin"
 export SCRIPTS="${WORKSPACE}/scripts"
 export ROBOT_VARIABLES=
 
@@ -187,7 +187,7 @@ SUITES=$( xargs -a testplan.txt )
 echo ROBOT_VARIABLES="${ROBOT_VARIABLES}"
 echo "Starting Robot test suites ${SUITES} ..."
 relax_set
-python -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
+python3 -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
 RESULT=$?
 load_set
 echo "RESULT: $RESULT"