aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-09 09:32:29 -0400
committerMarcus Williams <marcus.williams@intel.com>2018-08-09 22:34:52 +0000
commit709352852e50aa92edc9cf80a7d1c0387c532521 (patch)
treeecdb8b85504808f7c35f76ab6332cbab9f320b3b /asdc-controller/src
parentf690106dbb6f2da96fdaa35541bc5ba152f9d299 (diff)
GR-API flow, VF Module, SDNC GR API Fixes
Fixes the new GR-API flow Various fixes in the create VF Module area Fixes issues parsing the SDNC GR API response Fixes new resource type in ASDC controller Fixes AppC mismatch in JSON marshaling Issue-ID: SO-821 Change-Id: I4ace0d348483ab1303fcfee26c5801674be51466 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'asdc-controller/src')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java9
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java34
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java3
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java2
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java128
5 files changed, 140 insertions, 36 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
index 565ddf42b5..8353f708a9 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
@@ -65,7 +65,6 @@ public class ToscaResourceStructure {
String envHeatTemplateUUID;
String heatFilesUUID;
String workloadPerformance;
- boolean isVnfAlreadyInstalled = false;
String serviceVersion;
private boolean isDeployedSuccessfully=false;
@@ -314,14 +313,6 @@ public class ToscaResourceStructure {
this.toscaCsar = toscaCsar;
}
- public boolean isVnfAlreadyInstalled() {
- return isVnfAlreadyInstalled;
- }
-
- public void setVnfAlreadyInstalled(boolean isVnfAlreadyInstalled) {
- this.isVnfAlreadyInstalled = isVnfAlreadyInstalled;
- }
-
public String getVolHeatTemplateUUID() {
return volHeatTemplateUUID;
}
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 ea952f6daf..87df2648d1 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
@@ -440,33 +440,13 @@ public class ToscaResourceInstaller {
VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, vfResourceStructure,vfMetadata, vnfResource);
vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
}else
- throw (new Exception("Cannot find matching VFModule Customization"));
+ throw new Exception("Cannot find matching VFModule Customization for VF Module Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
}
service.getVnfCustomizations().add(vnfResource);
}
}
- protected void processFlexware(ToscaResourceStructure toscaResourceStruct, Service service, NodeTemplate nodeTemplate,
- String serviceType) {
- if (serviceType != null && serviceType.equalsIgnoreCase("Flexware")) {
-
- createVnfResource(nodeTemplate, toscaResourceStruct, service);
- String modelName = toscaResourceStruct.getVnfResourceCustomization().getVnfResources().getModelName();
-
- String modelVersion = BigDecimalVersion.castAndCheckNotificationVersionToString(
- toscaResourceStruct.getCatalogVnfResourceCustomization().getVnfResources().getModelVersion());
- // check for duplicate record already in the database
- VnfResource vnfResource = vnfRepo.findByModelNameAndModelVersion(modelName, modelVersion);
-
- if (vnfResource != null) {
- toscaResourceStruct.setVnfAlreadyInstalled(true);
- }
-
- vnfCustomizationRepo.saveAndFlush(toscaResourceStruct.getCatalogVnfResourceCustomization());
- }
- }
-
public void processWatchdog(String distributionId, String servideUUID) {
WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId,servideUUID);
watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
@@ -1263,12 +1243,20 @@ public class ToscaResourceInstaller {
// Set all Child Templates related to HEAT_VOLUME
if(!volumeHeatChildTemplates.isEmpty()){
- vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
+ if(vfModule.getVolumeHeatTemplate() != null){
+ vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
+ }else{
+ logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
+ }
}
// Set all Child Templates related to HEAT
if(!heatChildTemplates.isEmpty()){
- vfModule.getVolumeHeatTemplate().setChildTemplates(heatChildTemplates);
+ if(vfModule.getModuleHeatTemplate() != null){
+ vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
+ }else{
+ logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
+ }
}
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
index ef5b889d09..13af95a8fc 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
@@ -212,6 +212,9 @@ public class ASDCNotificationLogging {
buffer.append("Model Name:");
buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ buffer.append(System.lineSeparator());
buffer.append("Description:");
buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
buffer.append(System.lineSeparator());
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java
index de0d2e08a1..1e8b72d145 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java
@@ -83,7 +83,6 @@ public class ToscaResourceStructureTest {
toscaResourceStructure.setHeatFilesUUID("heatFilesUUID");
toscaResourceStructure.setToscaArtifact(artifactInfo);
toscaResourceStructure.setToscaCsar(new ToscaCsar());
- toscaResourceStructure.setVnfAlreadyInstalled(true);
toscaResourceStructure.setVolHeatTemplateUUID("volHeatTemplateUUID");
toscaResourceStructure.setEnvHeatTemplateUUID("envHeatTemplateUUID");
toscaResourceStructure.setServiceVersion("serviceVersion");
@@ -111,7 +110,6 @@ public class ToscaResourceStructureTest {
assertEquals("heatFilesUUID", toscaResourceStructure.getHeatFilesUUID());
assertEquals(artifactInfo, toscaResourceStructure.getToscaArtifact());
assertThat(toscaResourceStructure.getToscaCsar(), sameBeanAs(new ToscaCsar()));
- assertEquals(true, toscaResourceStructure.isVnfAlreadyInstalled());
assertEquals("volHeatTemplateUUID", toscaResourceStructure.getVolHeatTemplateUUID());
assertEquals("envHeatTemplateUUID", toscaResourceStructure.getEnvHeatTemplateUUID());
assertEquals("serviceVersion", toscaResourceStructure.getServiceVersion());
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index d96e480945..af0987f6d0 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -343,7 +343,6 @@ public class ToscaResourceInstallerTest extends BaseTest {
doReturn(nodeTemplateList).when(sdcCsarHelper).getAllottedResources();
doReturn(metadata).when(nodeTemplate).getMetaData();
doReturn("model_instance_name").when(nodeTemplate).getName();
- doReturn(false).when(toscaResourceStruct).isVnfAlreadyInstalled();
doReturn(vnfResourceCustomization).when(toscaResourceStruct).getCatalogVnfResourceCustomization();
doReturn(allottedResource).when(toscaResourceStruct).getAllottedResource();
doReturn(allottedResourceCustomization).when(toscaResourceStruct).getCatalogAllottedResourceCustomization();
@@ -474,6 +473,131 @@ public class ToscaResourceInstallerTest extends BaseTest {
return actualWatchdogComponentDistributionStatus;
}
+ private void populatevfResourceStructure() throws Exception {
+ vfResourceStructure = spy(new VfResourceStructure(notificationData, resourceInstance));
-
+ HashMap<String, VfModuleArtifact> vfModuleArtifacts = mock(HashMap.class);
+ CapabilityAssignments capabilityAssignments = mock(CapabilityAssignments.class);
+ CapabilityAssignment capabilityAssignment = mock(CapabilityAssignment.class);
+
+ Iterator artifactIterator = mock(Iterator.class);
+ Iterator nodeTemplateIterator = mock(Iterator.class);
+ IDistributionClientDownloadResult clientResult = mock(IDistributionClientDownloadResult.class);
+ doReturn(IOUtils.toByteArray(
+ new FileInputStream(
+ new File(
+ getClass().getClassLoader().getResource("resource-examples/simpleTest.yaml").getFile())
+ ))).when(clientResult).getArtifactPayload();
+ VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactInfo, clientResult);
+ Collection<VfModuleArtifact> vfModuleArtifactsValues = mock(Collection.class);
+
+ NodeTemplate nodeTemplate = mock(NodeTemplate.class);
+ List<NodeTemplate> nodeTemplateList = new ArrayList<>();
+ nodeTemplateList.add(nodeTemplate);
+
+ doReturn(sdcCsarHelper).when(toscaResourceStruct).getSdcCsarHelper();
+ doReturn("metadataPropertyValue").when(sdcCsarHelper).getMetadataPropertyValue(any(Metadata.class), any(String.class));
+ doReturn("ntPropertyLeafValue").when(sdcCsarHelper).getNodeTemplatePropertyLeafValue(any(NodeTemplate.class), any(String.class));
+ doReturn("true").when(sdcCsarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+ doReturn("1").when(sdcCsarHelper).getCapabilityPropertyLeafValue(any(CapabilityAssignment.class), any(String.class));
+ doReturn(vfGroups).when(sdcCsarHelper).getVfModulesByVf(any(String.class));
+ doReturn(capabilityAssignments).when(sdcCsarHelper).getCapabilitiesOf(any(NodeTemplate.class));
+ doReturn(capabilityAssignment).when(capabilityAssignments).getCapabilityByName(any(String.class));
+ doReturn(vfModuleArtifacts).when(vfResourceStructure).getArtifactsMapByUUID();
+ when(vfModuleArtifacts.values()).thenReturn(vfModuleArtifactsValues);
+ when(vfModuleArtifactsValues.iterator()).thenReturn(artifactIterator);
+ when(artifactIterator.hasNext()).thenReturn(true, false);
+ when(artifactIterator.next()).thenReturn(vfModuleArtifact);
+ when(artifactInfo.getArtifactType()).thenReturn(ASDCConfiguration.OTHER);
+ when(nodeTemplateIterator.hasNext()).thenReturn(true, false);
+ doReturn(nodeTemplateList).when(sdcCsarHelper).getServiceVfList();
+ doReturn(nodeTemplateList).when(sdcCsarHelper).getServiceVlList();
+ doReturn(nodeTemplateList).when(sdcCsarHelper).getAllottedResources();
+ doReturn(metadata).when(nodeTemplate).getMetaData();
+ doReturn("model_instance_name").when(nodeTemplate).getName();
+ }
+
+ private void populateToscaResourceStruct() {
+
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelName("modelName");
+ vnfResource.setModelVersion("1.1");
+ vnfResource.setModelUUID("modelUUID");
+ vnfResource.setOrchestrationMode("orchestrationMode");
+
+ VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
+ vnfResourceCustomization.setVnfResources(vnfResource);
+ vnfResourceCustomization.setModelCustomizationUUID("vnfResCustModelCustomizationUUID");
+ vnfResourceCustomization.setModelInstanceName("modelInstanceName");
+
+ allottedResource = new AllottedResource();
+ allottedResource.setModelUUID("serviceMetadataValue");
+ allottedResource.setModelInvariantUUID("modelInvariantUUID");
+ allottedResource.setModelName("modelName");
+ allottedResource.setModelVersion("1.1");
+
+ allottedResourceCustomization = new AllottedResourceCustomization();
+ allottedResourceCustomization.setAllottedResource(allottedResource);
+ allottedResourceCustomization.setModelCustomizationUUID("modelCustomizationUUID");
+ allottedResourceCustomization.setModelInstanceName("modelInstanceName");
+
+ catalogService = new Service();
+ catalogService.setServiceType("Bonding");
+ catalogService.setModelUUID("5df8b6de-2083-11e7-93ae-92361f002672");
+ catalogService.setModelInvariantUUID("modelInvariantUUID");
+ catalogService.setModelName("modelName");
+ catalogService.setModelVersion("modelVersion");
+ catalogService.getVnfCustomizations().add(vnfResourceCustomization);
+
+ catalogService.setServiceRole("COLLABORATE");
+
+ HeatTemplate heatTemplate = new HeatTemplate();
+ heatTemplate.setArtifactUuid("ff874603-4222-11e7-9252-005056850d2e");
+ heatTemplate.setArtifactChecksum("MANUAL RECORD");
+ heatTemplate.setTemplateBody("templateBody");
+ heatTemplate.setTemplateName("module_mns_zrdm3frwl01exn_01_rgvm_1.yml");
+ heatTemplate.setVersion("1");
+
+ NetworkResource networkResource = new NetworkResource();
+ networkResource.setAicVersionMin("aicVersionMin");
+ networkResource.setModelUUID("modelUUID");
+ networkResource.setOrchestrationMode("orchestrationMode");
+ networkResource.setModelVersion("modelVersion");
+ networkResource.setNeutronNetworkType("neutronNetworkType");
+ networkResource.setAicVersionMax("aicVersionMax");
+ networkResource.setModelName("CONTRAIL30_GNDIRECT");
+ networkResource.setModelInvariantUUID("modelInvariantUUID");
+ networkResource.setHeatTemplate(heatTemplate);
+
+ NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
+ networkResourceCustomization.setModelCustomizationUUID("modelCustomizationUUID");
+ networkResourceCustomization.setModelInstanceName("modelInstanceName");
+ networkResourceCustomization.setNetworkResource(networkResource);
+
+ doReturn(networkResource).when(toscaResourceStruct).getCatalogNetworkResource();
+ doReturn(networkResourceCustomization).when(toscaResourceStruct).getCatalogNetworkResourceCustomization();
+ doNothing().when(toscaResourceStruct).setSuccessfulDeployment();
+ doReturn("serviceVersion").when(toscaResourceStruct).getServiceVersion();
+ doReturn(catalogService).when(toscaResourceStruct).getCatalogService();
+ doReturn(artifactInfo).when(toscaResourceStruct).getToscaArtifact();
+ doReturn("artifactChecksum").when(artifactInfo).getArtifactChecksum();
+ doReturn("artifactUUID").when(artifactInfo).getArtifactUUID();
+ doReturn("artifactName").when(artifactInfo).getArtifactName();
+ doReturn("1.0").when(artifactInfo).getArtifactVersion();
+ doReturn("artifactDescription").when(artifactInfo).getArtifactDescription();
+ doReturn("artifactURL").when(artifactInfo).getArtifactURL();
+ doReturn(metadata).when(toscaResourceStruct).getServiceMetadata();
+ doReturn("serviceMetadataValue").when(metadata).getValue(any(String.class));
+ doReturn("CONTRAIL30_GNDIRECT").when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+ doReturn(vnfResourceCustomization).when(toscaResourceStruct).getCatalogVnfResourceCustomization();
+ doReturn(allottedResource).when(toscaResourceStruct).getAllottedResource();
+ doReturn(allottedResourceCustomization).when(toscaResourceStruct).getCatalogAllottedResourceCustomization();
+ }
+
+ private void populateNotificationData() {
+ notificationData.setDistributionID("testStatusSuccessTosca");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("5df8b6de-2083-11e7-93ae-92361f002671");
+ notificationData.setWorkloadContext("workloadContext");
+ }
}