diff options
author | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2019-08-27 17:36:21 +0530 |
---|---|---|
committer | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2019-08-29 16:39:04 +0530 |
commit | eb3835986cec920c7add691fc9233e4be7c238cc (patch) | |
tree | 0fbeec611cb356568deefffc334156bcbdbcd567 /asdc-controller/src | |
parent | e709eab9ab55753eb17e435ee87f7f32d811bce2 (diff) |
Fixing ccvpn parsing issue
Fixing ccvpn parsing issue.
Issue-ID: SO-1393
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
Change-Id: Iaee7d003f8d657a93901b51bef9bedab0433b75c
Diffstat (limited to 'asdc-controller/src')
5 files changed, 70 insertions, 77 deletions
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 08aee1ab4e..9d07670d0b 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 @@ -977,29 +977,28 @@ public class ToscaResourceInstaller { logger.debug("VF Category is : " + vfCustomizationCategory); - if (vfResourceStructure.getVfModuleStructure() != null - && !vfResourceStructure.getVfModuleStructure().isEmpty()) { + String vfCustomizationUUID = + vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); - String vfCustomizationUUID = - vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); + logger.debug("VFCustomizationUUID=" + vfCustomizationUUID); - logger.debug("VFCustomizationUUID=" + vfCustomizationUUID); + IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance(); - IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance(); + // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before + // comparing their VF Modules UUID's + logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: " + + vfCustomizationUUID); - // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before - // comparing their VF Modules UUID's - logger.debug("Checking if Notification VF ResourceCustomizationUUID: " - + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: " - + vfCustomizationUUID); + if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) { - if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) { + logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + + " matches vfNotificationResource CustomizationUUID"); - logger.debug("vfCustomizationUUID: " + vfCustomizationUUID - + " matches vfNotificationResource CustomizationUUID"); - - VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service); + VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service); + if (vfResourceStructure.getVfModuleStructure() != null + && !vfResourceStructure.getVfModuleStructure().isEmpty()) { Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>(); Set<VnfcCustomization> existingVnfcSet = new HashSet<>(); List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom = new ArrayList<>(); @@ -1036,34 +1035,33 @@ public class ToscaResourceInstaller { + vfMetadata.getVfModuleModelCustomizationUUID()); } + } - // Check for VNFC Instance Group info and add it if there is - List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct, - EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"), - TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false); + // Check for VNFC Instance Group info and add it if there is + List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct, + EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"), + TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false); - for (IEntityDetails groupEntity : vfcEntityList) { - VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = - createVNFCInstanceGroup(groupEntity, nodeTemplate, vnfResource, toscaResourceStruct); - vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization); - } + for (IEntityDetails groupEntity : vfcEntityList) { + VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = + createVNFCInstanceGroup(groupEntity, nodeTemplate, vnfResource, toscaResourceStruct); + vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization); + } - List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, vfcEntityList); - if (!CollectionUtils.isEmpty(seqResult)) { - String resultStr = seqResult.stream().collect(Collectors.joining(",")); - vnfResource.setVnfcInstanceGroupOrder(resultStr); - logger.debug( - "vnfcGroupOrder result for service uuid(" + service.getModelUUID() + ") : " + resultStr); - } - // add this vnfResource with existing vnfResource for this service - addVnfCustomization(service, vnfResource); - } else { - logger.debug("Notification VF ResourceCustomizationUUID: " - + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " - + "Tosca VF Customization UUID: " + vfCustomizationUUID); + List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, vfcEntityList); + if (!CollectionUtils.isEmpty(seqResult)) { + String resultStr = seqResult.stream().collect(Collectors.joining(",")); + vnfResource.setVnfcInstanceGroupOrder(resultStr); + logger.debug("vnfcGroupOrder result for service uuid(" + service.getModelUUID() + ") : " + resultStr); } + // add this vnfResource with existing vnfResource for this service + addVnfCustomization(service, vnfResource); + } else { + logger.debug("Notification VF ResourceCustomizationUUID: " + + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " + + "Tosca VF Customization UUID: " + vfCustomizationUUID); } } @@ -1494,17 +1492,17 @@ public class ToscaResourceInstaller { Optional<ToscaCsar> toscaCsarOpt = toscaCsarRepo.findById(toscaResourceStructure.getToscaArtifact().getArtifactUUID()); ToscaCsar toscaCsar; - if (toscaCsarOpt.isPresent()) { - toscaCsar = toscaCsarOpt.get(); - } else { + if (!toscaCsarOpt.isPresent()) { toscaCsar = new ToscaCsar(); + toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID()); + } else { + toscaCsar = toscaCsarOpt.get(); } if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) { toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum()); } else { toscaCsar.setArtifactChecksum(MANUAL_RECORD); } - toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID()); toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName()); toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion()); toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription()); @@ -1878,10 +1876,11 @@ public class ToscaResourceInstaller { InstanceGroup existingInstanceGroup = instanceGroupRepo.findByModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup(); + VFCInstanceGroup vfcInstanceGroup; if (existingInstanceGroup == null) { // Populate InstanceGroup + vfcInstanceGroup = new VFCInstanceGroup(); vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); vfcInstanceGroup .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java index cfcf5ac599..2a4b3aa6fb 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java @@ -43,6 +43,8 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.mockito.ArgumentMatchers; +import org.mockito.Mockito; import org.mockito.Spy; import org.onap.so.asdc.BaseTest; import org.onap.so.asdc.client.test.emulators.DistributionClientEmulator; @@ -67,6 +69,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.test.util.ReflectionTestUtils; public class ASDCRestInterfaceTest extends BaseTest { @@ -107,6 +110,7 @@ public class ASDCRestInterfaceTest extends BaseTest { public void setUp() { // ASDC Controller writes to this path System.setProperty("mso.config.path", folder.getRoot().toString()); + ReflectionTestUtils.setField(toscaInstaller, "toscaCsarRepo", toscaCsarRepo); } @Test @@ -310,9 +314,9 @@ public class ASDCRestInterfaceTest extends BaseTest { HttpMethod.POST, entity, String.class); assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - Optional<Service> service = serviceRepo.findById("5c4d4793-67fb-4155-b7d8-60ec011138c9"); + Optional<Service> service = serviceRepo.findById("317887d3-a4e4-45cb-8971-2a78426fefac"); assertTrue(service.isPresent()); - assertEquals("SDWAN", service.get().getModelName()); + assertEquals("CCVPNService", service.get().getModelName()); } protected String createURLWithPort(String uri) { diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json b/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json index bc7d7d7979..1ca96f7dc9 100644 --- a/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json +++ b/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json @@ -1,31 +1,31 @@ { - "distributionID": "cbc7ab24-7d96-4cb5-949c-f23ada265513", - "serviceName": "SDWAN", - "serviceVersion": "2.0", - "serviceUUID": "5c4d4793-67fb-4155-b7d8-60ec011138c9", - "serviceDescription": "SDWAN Service", - "serviceInvariantUUID": "e830c260-ee21-4830-980c-c802cd9bbb1c", + "distributionID": "8a01603d-606d-4e40-8bc4-37107ad97897", + "serviceName": "CCVPNService", + "serviceVersion": "1.0", + "serviceUUID": "317887d3-a4e4-45cb-8971-2a78426fefac", + "serviceDescription": "CCVPN", + "serviceInvariantUUID": "e43f9b81-3035-44df-b618-a787e1c49427", "resources": [ { - "resourceInstanceName": "siteVF 0", - "resourceName": "siteVF", + "resourceInstanceName": "siteResource", + "resourceCustomizationUUID": "e9e01777-bb2f-42f0-b825-aef0f4c37ccf", + "resourceName": "siteResource", "resourceVersion": "1.0", "resoucreType": "VF", - "resourceUUID": "2c10d85c-e492-4813-a2d6-d1fab757fe49", - "resourceInvariantUUID": "ed9b1fe5-1e94-4974-a48f-389571837fd6", - "resourceCustomizationUUID": "33de5105-edf3-48cb-bda0-37b2aa2f681f", + "resourceUUID": "5a641276-443b-45ca-ac9c-a0ee84f5007b", + "resourceInvariantUUID": "5338673f-df81-483a-afa4-b9766442ebf1", "category": "Configuration", "subcategory": "Configuration", "artifacts": [] }, { - "resourceInstanceName": "vpn 0", - "resourceName": "vpn", - "resourceVersion": "2.0", + "resourceInstanceName": "SDWANVPNResource", + "resourceCustomizationUUID": "7815f32c-bdbf-41f7-9a18-6f0e6d5a0d0e", + "resourceName": "SDWANVPNResource", + "resourceVersion": "1.0", "resoucreType": "VF", - "resourceUUID": "235861f1-ea93-4443-94fa-82f29903f54f", - "resourceInvariantUUID": "c4eff5e7-c4fe-4caf-989b-11efc8e42a73", - "resourceCustomizationUUID": "faa89d44-329b-4fcb-a5dc-6e6f84946537", + "resourceUUID": "5f9f2164-f7e4-461d-b8de-3470297ce2b3", + "resourceInvariantUUID": "5ca15886-9990-419c-a4bb-f0229eac0926", "category": "Configuration", "subcategory": "Configuration", "artifacts": [] @@ -33,24 +33,14 @@ ], "serviceArtifacts": [ { - "artifactName": "service-Sdwan-template.yml", - "artifactType": "TOSCA_TEMPLATE", - "artifactURL": "/sdc/v1/catalog/services/Sdwan/2.0/artifacts/service-Sdwan-template.yml", - "artifactChecksum": "Zjg4MmJmNzI1MTliYzBiZjA2ZmJjN2EwNzZhZTcxYTQ=", - "artifactDescription": "TOSCA representation of the asset", - "artifactTimeout": 0, - "artifactUUID": "5e7beb91-61f9-4613-8cc5-1d288a624abb", - "artifactVersion": "2" - }, - { - "artifactName": "service-Sdwan-csar.csar", + "artifactName": "service-Ccvpnservice-csar.csar", "artifactType": "TOSCA_CSAR", - "artifactURL": "/service-Sdwan-csar.csar", - "artifactChecksum": "ODA1ZGViMzI0NzIxMmRmNTIzYzE0ZTg5NmExYWFjZTE=", + "artifactURL": "/service-Ccvpnservice-csar.csar", + "artifactChecksum": "NTZlNGU4YTQwNzVkZWMwYWZkODE5M2MwYzcyNzM3M2U\u003d", "artifactDescription": "TOSCA definition package of the asset", "artifactTimeout": 0, - "artifactUUID": "771ec21a-1d14-4891-a56f-d4e47e2c8c91", - "artifactVersion": "2" + "artifactVersion": "2", + "artifactUUID": "59f34dcf-ec33-4a88-8dbe-aa7f4571ef59" } ], "workloadContext": "Production" diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Ccvpnservice-csar.csar b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Ccvpnservice-csar.csar Binary files differnew file mode 100644 index 0000000000..ce2ac5e0c9 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Ccvpnservice-csar.csar diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar Binary files differdeleted file mode 100644 index 7a508429f8..0000000000 --- a/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar +++ /dev/null |