aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeigh, Phillip (pl876u) <phillip.leigh@amdocs.com>2019-02-14 18:44:57 -0500
committerLeigh, Phillip (pl876u) <phillip.leigh@amdocs.com>2019-02-15 16:14:56 -0500
commit15c6cfa5faaa3445e7fdad2650d72c76dda1e0b9 (patch)
tree40750492073454bf4c84e2bb9635eacced9f6d2b
parentb2e9556678bbacd8c3777973b9fa89b63497e026 (diff)
Fix:align attributes after Pomba Audit model Chg
Issue-ID: SDNC-644 Change-Id: I784b312261ee6016ec61cabd8b007901e221cbab Signed-off-by: Leigh, Phillip (pl876u) <phillip.leigh@amdocs.com>
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java112
-rw-r--r--src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java60
-rw-r--r--src/test/resources/junit/genericVnfInput_set5.json100
-rw-r--r--src/test/resources/junit/vnfc-input1.json15
4 files changed, 272 insertions, 15 deletions
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
index e3a1b15..fcf4589 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
@@ -116,8 +116,9 @@ public class RestUtil {
private static final String ATTRIBUTE_LOCKEDBOOLEAN = "lockedBoolean";
private static final String ATTRIBUTE_HOSTNAME = "hostName";
private static final String ATTRIBUTE_IMAGEID = "imageId";
- private static final String ATTRIBUTE_NETWORK_FUNCTION = "networkFunction";
- private static final String ATTRIBUTE_NETWORK_ROLE = "networkRole";
+ private static final String ATTRIBUTE_NF_ROLE = "nfRole";
+ private static final String ATTRIBUTE_NF_TYPE = "nfType";
+ private static final String ATTRIBUTE_NF_FUNCTION = "nfFunction";
private static final String ATTRIBUTE_RESOURCE_VERSION = "resourceVersion";
private static final String ATTRIBUTE_NAME2 = "name2";
private static final String ATTRIBUTE_NAME2_SOURCE = "name2Source";
@@ -139,6 +140,7 @@ public class RestUtil {
private static final String ATTRIBUTE_INTERFACE_ROLE = "interfaceRole";
private static final String ATTRIBUTE_INTERFACE_TYPE = "interfaceType";
private static final String ATTRIBUTE_NETWORK_TYPE = "networkType";
+ private static final String ATTRIBUTE_NETWORK_ROLE = "networkRole";
private static final String ATTRIBUTE_NETWORK_TECHNOLOGY = "networkTechnology";
private static final String ATTRIBUTE_PHYSICAL_NETWORK_NAME = "physicalNetworkName";
private static final String ATTRIBUTE_SHARED_NETWORK_BOOLEAN = "sharedNetworkBoolean";
@@ -146,6 +148,8 @@ public class RestUtil {
private static final String ATTRIBUTE_NETWORK_NAME = "networkName";
private static final String ATTRIBUTE_MAC_ADDR = "macAddr";
private static final String ATTRIBUTE_ADMIN_STATUS = "adminStatus";
+ private static final String ATTRIBUTE_NFC_NAMING_CODE = "nfcNamingCode";
+ private static final String ATTRIBUTE_NF_NAMING_CODE = "nfNamingCode";
/**
@@ -617,7 +621,7 @@ public class RestUtil {
vf.setType(vnf.getVnfType());
vf.setModelVersionID(vnf.getModelVersionId());
vf.setDataQuality(DataQuality.ok());
-
+ vf.setAttributes(populateVnfAttributeList(vnf));
String key = vnf.getVnfId(); // generic vnf-id (top level of the key)
// ---------------- Handle VNFC data
@@ -631,7 +635,9 @@ public class RestUtil {
VNFC vnfcModel = new VNFC();
vnfcModel.setModelInvariantUUID(vnfc.getModelInvariantId());
vnfcModel.setName(vnfc.getVnfcName());
+ vnfcModel.setModelVersionID(vnfc.getModelVersionId());
vnfcModel.setUuid(vnfc.getModelVersionId());
+ vnfcModel.setAttributes(populateVnfcAttributeList(vnfc));
vnfcLst.add(vnfcModel);
}
}
@@ -776,6 +782,91 @@ public class RestUtil {
return context;
}
+ private static List<Attribute> populateVnfAttributeList (VnfInstance vnf) {
+ if (vnf == null) {
+ return null;
+ }
+
+ List<Attribute> attributeList = new ArrayList<>();
+
+ for (Attribute.Name name: Attribute.Name.values()) {
+ if ((name.name().equals(ATTRIBUTE_NF_NAMING_CODE ))
+ && isValid(vnf.getNfNamingCode())){
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.nfNamingCode);
+ att.setValue(String.valueOf(vnf.getNfNamingCode()));
+ attributeList.add(att);
+ }
+
+ if ((name.name().equals(ATTRIBUTE_NF_TYPE ))
+ && isValid(vnf.getNfType())){
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.nfType);
+ att.setValue(String.valueOf(vnf.getNfType()));
+ attributeList.add(att);
+ }
+
+ if ((name.name().equals(ATTRIBUTE_NF_ROLE ))
+ && isValid(vnf.getNfRole())){
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.nfRole);
+ att.setValue(String.valueOf(vnf.getNfRole()));
+ attributeList.add(att);
+ }
+
+ if ((name.name().equals(ATTRIBUTE_NF_FUNCTION ))
+ && isValid(vnf.getNfFunction())){
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.nfFunction);
+ att.setValue(String.valueOf(vnf.getNfFunction()));
+ attributeList.add(att);
+ }
+ }
+
+ if (attributeList.size() > 0 ) {
+ return attributeList;
+ }
+ return null;
+ }
+
+ private static List<Attribute> populateVnfcAttributeList (VnfcInstance vnfc) {
+ if (vnfc == null) {
+ return null;
+ }
+
+ List<Attribute> attributeList = new ArrayList<>();
+
+ for (Attribute.Name name: Attribute.Name.values()) {
+ if ((name.name().equals(ATTRIBUTE_NFC_NAMING_CODE ))
+ && isValid(vnfc.getNfcNamingCode())){
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.nfcNamingCode);
+ att.setValue(String.valueOf(vnfc.getNfcNamingCode()));
+ attributeList.add(att);
+ }
+
+ if ((name.name().equals(ATTRIBUTE_LOCKEDBOOLEAN ))
+ && (vnfc.getInMaintenance() != null) )
+ {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.nfcNamingCode);
+ att.setValue(String.valueOf(vnfc.getInMaintenance()));
+ attributeList.add(att);
+ }
+ }
+
+ if (attributeList.size() > 0 ) {
+ return attributeList;
+ }
+ return null;
+ }
+
private static Pserver getPserverInfo (List<PserverInstance> pserverInstanceList) {
if (pserverInstanceList == null) {
return null;
@@ -1029,20 +1120,11 @@ public class RestUtil {
// Iterate through the ENUM Attribute list
for (Attribute.Name name: Attribute.Name.values()) {
- if ((name.name().equals(ATTRIBUTE_NETWORK_FUNCTION ))
- && isValid(pnfFromAai.getNfFunction())){
- Attribute att = new Attribute();
- att.setDataQuality(DataQuality.ok());
- att.setName(Attribute.Name.networkFunction);
- att.setValue(String.valueOf( pnfFromAai.getNfFunction()));
- attributeList.add(att);
- }
-
- if ((name.name().equals(ATTRIBUTE_NETWORK_ROLE ))
+ if ((name.name().equals(ATTRIBUTE_NF_ROLE ))
&& isValid(pnfFromAai.getNfRole())){
Attribute att = new Attribute();
att.setDataQuality(DataQuality.ok());
- att.setName(Attribute.Name.networkRole);
+ att.setName(Attribute.Name.nfRole);
att.setValue(String.valueOf( pnfFromAai.getNfRole()));
attributeList.add(att);
}
@@ -1285,7 +1367,7 @@ public class RestUtil {
&& isValid(pInterfaceInstFromAai.getPortDescription())){
Attribute att = new Attribute();
att.setDataQuality(DataQuality.ok());
- att.setName(Attribute.Name.description);
+ att.setName(Attribute.Name.portDescription);
att.setValue(String.valueOf( pInterfaceInstFromAai.getPortDescription()));
pInterfaceAttributeList.add(att);
}
diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java
index bc649fb..9f82c69 100644
--- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java
+++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java
@@ -51,6 +51,7 @@ import org.onap.pomba.common.datatypes.ModelContext;
import org.onap.pomba.common.datatypes.VFModule;
import org.onap.pomba.common.datatypes.VM;
import org.onap.pomba.common.datatypes.VNF;
+import org.onap.pomba.common.datatypes.VNFC;
import org.json.JSONObject;
import com.google.gson.Gson;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
@@ -227,4 +228,63 @@ public class RestServiceTest {
assertEquals(vmList.get(0).getLInterfaceList().get(0).getName(), "junit-l-interface-name1"); //l-interface-name
assertEquals(vmList.get(0).getLInterfaceList().get(1).getName(), "junit-l-interface-name2"); //l-interface-name
}
+
+ ///Verify the relationship serviceInstanceId -> vnf + vnfc
+ @Test
+ public void testGetContext_VNFC() throws Exception {
+
+ String transactionId = UUID.randomUUID().toString();
+ String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json
+ String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId;
+
+ // Test with No Partner Name
+ final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders(
+ transactionId, testRestHeaders, httpBasicAuthorization);
+
+ // 1. simulate the response to obtainResourceLink based on ServiceInstanceId
+ addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule);
+ // 2. simulate the response of AAI (1 vnf)
+ // note: match serviceInstanceId in (1)
+ addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb",
+ "junit/aai-service-instance_set2.json", aaiEnricherRule);
+
+ // 3. simulate the rsp of VNF (with 1 vserver)
+ // note: match vnf_id in (2)
+ addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH,
+ "junit/genericVnfInput_set5.json", aaiEnricherRule);
+
+ // 4. simulate the rsp of vserer
+ // note: match to vserver-id to the path of "vserver" in (3)
+ addResponse(
+ "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant"
+ + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a",
+ "junit/aai-vserver-set2.json", aaiEnricherRule);
+
+ // 5. simulate the rsp of vnfc
+ // note: match to vnfc-name to the path of "vnfc" in (3)
+ addResponse(
+ "/aai/v13/network/vnfcs/vnfc/junit-vnfc-name1212",
+ "junit/vnfc-input1.json", aaiEnricherRule);
+
+ when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl);
+
+ Response response = this.dummyRestSvc.getContext(mockHttpHeaders, httpBasicAuthorization, testRestHeaders, transactionId,
+ serviceInstanceId);
+
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+ Gson gson = new Gson();
+ ModelContext modelCtx = gson.fromJson((String) response.getEntity(), ModelContext.class);
+ // verify results
+ List<VNF> vnfList = modelCtx.getVnfs();
+ assertEquals(vnfList.size(), 1);
+ List<VFModule> vfModuleList = vnfList.get(0).getVfModules();
+ assertEquals(vfModuleList.size(), 1);
+ List<VM> vmList = vfModuleList.get(0).getVms();
+ assertEquals(vmList.size(), 1);
+ assertEquals(vmList.get(0).getUuid(), "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a"); //vserver-id
+
+ List<VNFC> vnfcList = vnfList.get(0).getVnfcs();
+ assertEquals(vnfcList.size(), 1);
+ assertEquals(vnfcList.get(0).getName(), "junit-vnfc-name1212"); //vnfc-name
+ }
}
diff --git a/src/test/resources/junit/genericVnfInput_set5.json b/src/test/resources/junit/genericVnfInput_set5.json
new file mode 100644
index 0000000..05e39a0
--- /dev/null
+++ b/src/test/resources/junit/genericVnfInput_set5.json
@@ -0,0 +1,100 @@
+{
+ "vnf-id": "8a9ddb25-2e79-449c-a40d-5011bac0da39",
+ "vnf-name": "Firewall-1",
+ "vnf-type": "vFW-vSINK-service/vFWvSINK 0",
+ "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7",
+ "prov-status": "PREPROV",
+ "orchestration-status": "Created",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1527637940029",
+ "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820",
+ "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "nf-type": "nf-type1121",
+ "nf-function": "nf-function1123",
+ "nf-role": "nf-role1213",
+ "nf-naming-code": "nf-naming-code1212",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vserver",
+ "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "RegionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "b49b830686654191bb1e952a74b014ad"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a"
+ }
+ ]
+ },
+ {
+ "related-to": "vnfc",
+ "related-link": "/aai/v13/network/vnfcs/vnfc/junit-vnfc-name1212",
+ "relationship-data": [
+ {
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "junit-vnfc-name1212"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vnfc.nfc-naming-code",
+ "property-value": "nfc-naming-code-1212"
+ }
+ ]
+ },
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v13/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFWCL/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vFWCL"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "adc3cc2a-c73e-414f-8ddb-367de81300cb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "Firewall1"
+ }
+ ]
+ }
+ ]
+ },
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-id": "1563b649-9e05-4288-b7d9-e3639a54ace6",
+ "vf-module-name": "vFW_SINC_Module-2",
+ "heat-stack-id": "vFW_SINC_Module-2/41c4533a-748d-4cf4-a8d3-eccdd0aeb0d4",
+ "orchestration-status": "active",
+ "is-base-vf-module": true,
+ "resource-version": "1527638439198",
+ "model-invariant-id": "74bc1518-282d-4148-860f-8892b6369456",
+ "model-version-id": "4e3d28cf-d654-41af-a47b-04b4bd0ac58e",
+ "model-customization-id": "cc51ab7d-9b03-4bd6-9104-09df0c7c7907",
+ "module-index": 0
+ }
+ ]
+ }
+}
diff --git a/src/test/resources/junit/vnfc-input1.json b/src/test/resources/junit/vnfc-input1.json
new file mode 100644
index 0000000..d76de8b
--- /dev/null
+++ b/src/test/resources/junit/vnfc-input1.json
@@ -0,0 +1,15 @@
+{
+ "vnfc-name": "junit-vnfc-name1212",
+ "nfc-naming-code": "nfc-naming-code-1212",
+ "nfc-function": "nfcFunction1",
+ "prov-status": "11112222provStatus",
+ "orchestration-status": "orchestrationStatus1",
+ "ipaddress-v4-oam-vip": "8df84f0a-737a-4628-be9c-c3c78454f9d9",
+ "in-maint": "false",
+ "is-closed-loop-disabled": "true",
+ "model-invariant-id": "model-invariant-id1212",
+ "model-version-id": "model-version-id1212",
+ "model-customization-id": "modelCustomizationId99888",
+ "resource-version": "resourceVersion4989d67b2a6b7",
+ "cps": "cps12123"
+} \ No newline at end of file