summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlalena.aria <lalena.aria@att.com>2019-09-16 18:43:54 +0000
committerDan Timoney <dtimoney@att.com>2019-09-17 00:53:34 +0000
commitab4d7bb7087197977c464031239c202b220e6ad4 (patch)
tree2d6651ae08cc5c0637f6c0f0e1b3da5b5aaaf2ee
parent85962cd92a89187b61ca63a597c7f1f172cd98f2 (diff)
Migrate SdncVFModel to getEntity
Changes made: Replace deprecated APIs with getEntity for processing VF nodes in a model. Replace nodeTemplate with entityDetails in SdncVFModel. Corresponding changes in SdncVFModelTest. Issue-ID: CCSDK-1425 Change-Id: I2175af818c80f4526e0a57a196d03c9fba73bdbf Signed-off-by: lalena.aria <lalena.aria@att.com>
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java46
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java65
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java23
3 files changed, 70 insertions, 64 deletions
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
index d7418824b..a3662604e 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
@@ -77,7 +77,6 @@ import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.utils.ArtifactTypeEnum;
import org.onap.sdc.utils.DistributionActionResultEnum;
@@ -745,29 +744,30 @@ public class SdncUebCallback implements INotificationCallback {
}
}
- // Ingest Network (VF) Data - 1707
- List<NodeTemplate> vfNodeTemplatesList = sdcCsarHelper.getServiceVfList();
-
- for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
-
- SdncVFModel vfNodeModel = null;
- try {
- vfNodeModel = new SdncVFModel (sdcCsarHelper, nodeTemplate, jdbcDataSource, config);
- vfNodeModel.setServiceUUID(serviceModel.getServiceUUID());
- vfNodeModel.setServiceInvariantUUID(serviceModel.getServiceInvariantUUID());
- vfNodeModel.insertData();
-
- } catch (IOException e) {
- deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
- }
+ // Ingest Network (VF) Data - 1707 / migrate to getEntity - 1911
+ // Use getEntity to get all VFs in the service
+ if (vfEntities != null) {
+ for (IEntityDetails vfEntity : vfEntities){
- // For each VF, insert VNF Configuration data
- DistributionStatusEnum vnfConfigDeployStatus = customProcessVnfConfig(sdcCsarHelper, vfNodeModel, jdbcDataSource);
- if (vnfConfigDeployStatus == DistributionStatusEnum.DEPLOY_ERROR) {
- deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
- }
-
- } // VF loop
+ SdncVFModel vfNodeModel = null;
+ try {
+ vfNodeModel = new SdncVFModel (sdcCsarHelper, vfEntity, jdbcDataSource, config);
+ vfNodeModel.setServiceUUID(serviceModel.getServiceUUID());
+ vfNodeModel.setServiceInvariantUUID(serviceModel.getServiceInvariantUUID());
+ vfNodeModel.insertData();
+
+ } catch (IOException e) {
+ deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
+ }
+
+ // For each VF, insert VNF Configuration data
+ DistributionStatusEnum vnfConfigDeployStatus = customProcessVnfConfig(sdcCsarHelper, vfNodeModel, jdbcDataSource);
+ if (vnfConfigDeployStatus == DistributionStatusEnum.DEPLOY_ERROR) {
+ deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
+ }
+
+ } // VF loop
+ }
// Ingest Network (PNF) Data - Dublin/1906
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java
index 76e208635..fa54c7c41 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java
@@ -32,8 +32,6 @@ import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
-import org.onap.sdc.toscaparser.api.Group;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Property;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
@@ -51,19 +49,12 @@ public class SdncVFModel extends SdncBaseModel {
private String serviceUUID = null;
private String serviceInvariantUUID = null;
- public SdncVFModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
+ public SdncVFModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails entityDetails, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
- super(sdcCsarHelper, nodeTemplate, jdbcDataSource, config);
+ super(sdcCsarHelper, entityDetails, jdbcDataSource, config);
- // Since SdncVFModel is not yet converted for getEntity, find the entity for this nodeTemplate
- EntityQuery vfEntityQuery = EntityQuery.newBuilder(SdcTypes.VF).customizationUUID(getCustomizationUUIDNoQuotes()).build();
- TopologyTemplateQuery vfTopologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
- List<IEntityDetails> vfEntities = sdcCsarHelper.getEntity(vfEntityQuery, vfTopologyTemplateQuery, true);
- if (vfEntities != null && !vfEntities.isEmpty()) {
- entityDetails = vfEntities.get(0);
- }
// extract metadata
- Metadata metadata = nodeTemplate.getMetaData();
+ Metadata metadata = entityDetails.getMetadata();
addParameter("name", extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_NAME));
vendor = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDOR);
addParameter("vendor", vendor);
@@ -71,30 +62,36 @@ public class SdncVFModel extends SdncBaseModel {
addParameter("vendor_version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDORRELEASE));
// extract properties
- addParameter("ecomp_generated_naming", extractBooleanValue(nodeTemplate, "nf_naming#ecomp_generated_naming"));
- addParameter("naming_policy", extractValue(nodeTemplate, "nf_naming#naming_policy"));
- addParameter("nf_type", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- addParameter("nf_role", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- nfNamingCode = extractValue(nodeTemplate, "nf_naming_code");
+ addParameter("ecomp_generated_naming", extractBooleanValue(entityDetails, "nf_naming", "ecomp_generated_naming"));
+ addParameter("naming_policy", extractValue(entityDetails, "nf_naming", "naming_policy"));
+ addParameter("nf_type", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+ addParameter("nf_role", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ nfNamingCode = extractValue(entityDetails, "nf_naming_code");
addParameter("nf_code", nfNamingCode);
- addParameter("nf_function", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- addIntParameter("avail_zone_max_count", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONEMAXCOUNT));
- addParameter("sdnc_model_name", extractValue(nodeTemplate, "sdnc_model_name"));
- addParameter("sdnc_model_version", extractValue(nodeTemplate, "sdnc_model_version"));
- addParameter("sdnc_artifact_name", extractValue(nodeTemplate, "sdnc_artifact_name"));
+ addParameter("nf_function", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ addIntParameter("avail_zone_max_count", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONEMAXCOUNT));
+ addParameter("sdnc_model_name", extractValue(entityDetails, "sdnc_model_name"));
+ addParameter("sdnc_model_version", extractValue(entityDetails, "sdnc_model_version"));
+ addParameter("sdnc_artifact_name", extractValue(entityDetails, "sdnc_artifact_name"));
// store additional properties in ATTRIBUTE_VALUE_PAIR
// additional complex properties are extracted via VfcInstanceGroup
-
- List<Group> vfcInstanceGroupListForVf = sdcCsarHelper.getGroupsOfOriginOfNodeTemplateByToscaGroupType(nodeTemplate, "org.openecomp.groups.VfcInstanceGroup");
- for (Group group : vfcInstanceGroupListForVf){
-
- String vfcInstanceGroupFunction = extractGetInputValue(group, nodeTemplate, "vfc_instance_group_function");
- addParameter("vfc_instance_group_function", vfcInstanceGroupFunction, attributeValueParams);
- String networkCollectionFunction = extractGetInputValue(group, nodeTemplate, "network_collection_function");
- addParameter("network_collection_function", networkCollectionFunction, attributeValueParams);
- String initSubinterfaceQuantity = extractGetInputValue(group, nodeTemplate, "init_subinterface_quantity");
- addParameter("init_subinterface_quantity", initSubinterfaceQuantity, attributeValueParams);
+ EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup").build();
+ String vfCustomizationUuid = getCustomizationUUIDNoQuotes();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .customizationUUID(vfCustomizationUuid).build();
+ List<IEntityDetails> vfcInstanceGroupListForVf = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
+ if (vfcInstanceGroupListForVf != null) {
+
+ for (IEntityDetails group : vfcInstanceGroupListForVf){
+
+ String vfcInstanceGroupFunction = extractGetInputValue(group, entityDetails, "vfc_instance_group_function");
+ addParameter("vfc_instance_group_function", vfcInstanceGroupFunction, attributeValueParams);
+ String networkCollectionFunction = extractGetInputValue(group, entityDetails, "network_collection_function");
+ addParameter("network_collection_function", networkCollectionFunction, attributeValueParams);
+ String initSubinterfaceQuantity = extractGetInputValue(group, entityDetails, "init_subinterface_quantity");
+ addParameter("init_subinterface_quantity", initSubinterfaceQuantity, attributeValueParams);
+ }
}
}
@@ -155,7 +152,7 @@ public class SdncVFModel extends SdncBaseModel {
for (IEntityDetails vfModule : vfModules){
// If this vfModule name is prefixed with the VF name of the VF being processed, insert this VF Module in VF_MODULE_MODEL
- String normailizedVfName = nodeTemplate.getName().toLowerCase().replace(" ", "").replace("-", "").replace(".", ""); // need full set of normalization rules from ASDC
+ String normailizedVfName = entityDetails.getName().toLowerCase().replace(" ", "").replace("-", "").replace(".", ""); // need full set of normalization rules from ASDC
if (!vfModule.getName().startsWith(normailizedVfName)) {
continue;
}
@@ -434,7 +431,7 @@ public class SdncVFModel extends SdncBaseModel {
}
// For each target node, get External policies
- SdcTypes queryType = SdcTypes.valueOf(extractValue(nodeTemplate.getMetaData(), SdcPropertyNames.PROPERTY_NAME_TYPE));
+ SdcTypes queryType = SdcTypes.valueOf(extractValue(entityDetails.getMetadata(), SdcPropertyNames.PROPERTY_NAME_TYPE));
insertEntityPolicyData(getCustomizationUUIDNoQuotes(), getUUID().replace("\"", ""), queryType, targetNodeCustomizationUuid, targetNodeUuid, targetNodeType, "org.openecomp.policies.External"); // AFTER getEntity
}
}
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java
index 3f795a354..f20c1edbf 100644
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java
+++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java
@@ -4,11 +4,15 @@ import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.Property;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
@@ -19,17 +23,22 @@ import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
@Before
public void setUp() throws Exception {
ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
- NodeTemplate nodeTemplate = mock(NodeTemplate.class);
+ IEntityDetails mockEntityDetails = mock(IEntityDetails.class);
Metadata mockMetadata = mock(Metadata.class);
- DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
+ DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
- when(nodeTemplate.getMetaData()).thenReturn(mockMetadata);
- when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, "customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
- when(mockCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")).thenReturn("test-nf-naming-code");
+ Property mockProperty = mock(Property.class);
+ Map<String, Property> mockProperties = new HashMap<String, Property>();
+ when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
+ when(mockEntityDetails.getProperties()).thenReturn(mockProperties);
+ when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, "customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
+ when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn("VF");
+ mockProperty.setValue("test-nf-naming-code");
+ when(mockProperties.get("nf_naming_code")).thenReturn(mockProperty);
try {
- testSdncVFModel = new SdncVFModel(mockCsarHelper,nodeTemplate,mockDBResourceManager,mockSdncUebConfiguration);
+ testSdncVFModel = new SdncVFModel(mockCsarHelper,mockEntityDetails,mockDBResourceManager,mockSdncUebConfiguration);
testSdncVFModel.setServiceUUID("bbbb-cccc-dddd-eeee");
testSdncVFModel.setServiceInvariantUUID("cccc-dddd-eeee-ffff");
testSdncVFModel.setVendor("Cisco");