From f7f9a94854dd70d29945cf25e7fe0ea1a10c16da Mon Sep 17 00:00:00 2001 From: "Tait,Trevor(rt0435)" Date: Tue, 12 Feb 2019 10:21:48 -0500 Subject: SdnccCtxBld unable to retrieve all VNF attributes Issue-ID: LOG-968 Change-Id: I93e95e18a9b498dbedcc9ca14c84dd8eab17f59f Signed-off-by: Tait,Trevor(rt0435) --- config/vnflist.spec | 19 - .../sdnc/handlers/VnfApiHandler.java | 2 +- .../pomba/contextbuilder/sdnc/util/RestUtil.java | 14 +- .../unittest/service/SdncContextBuilderTest.java | 2 +- src/test/resources/junit/vnfApiResponse.json | 385 ++++++++++----------- 5 files changed, 199 insertions(+), 223 deletions(-) delete mode 100644 config/vnflist.spec diff --git a/config/vnflist.spec b/config/vnflist.spec deleted file mode 100644 index ae55a5f..0000000 --- a/config/vnflist.spec +++ /dev/null @@ -1,19 +0,0 @@ -[ - // Use https://jolt-demo.appspot.com/#inception to develop/test - // any changes to this file - - { - // This section converts aai response for GET VNF-API from SDNC - // to org.onap.pomba.common.datatypes.VF - "operation": "shift", - "spec": { - "vnfs": { - "vnf-list": { - "*": { - "*": "vnf-list[&1].&" - } - } - } - } - } - ] diff --git a/src/main/java/org/onap/pomba/contextbuilder/sdnc/handlers/VnfApiHandler.java b/src/main/java/org/onap/pomba/contextbuilder/sdnc/handlers/VnfApiHandler.java index 2aeba1a..7cb9214 100644 --- a/src/main/java/org/onap/pomba/contextbuilder/sdnc/handlers/VnfApiHandler.java +++ b/src/main/java/org/onap/pomba/contextbuilder/sdnc/handlers/VnfApiHandler.java @@ -125,7 +125,7 @@ public class VnfApiHandler { private static List retrieveAaiVnfList(RestClient aaiClient, String aaiBaseUrl, String aaiBasicAuthorization, String transactionId, List genericVnfLinks) throws AuditException { List vnfList = new ArrayList<>(); for (String genericVnfLink : genericVnfLinks) { - String genericVnfUrl = RestUtil.generateAaiUrl(aaiBaseUrl, genericVnfLink, null); + String genericVnfUrl = RestUtil.generateAaiUrl(aaiBaseUrl, genericVnfLink, "?depth=all"); String genericVnfPayload = RestUtil.getAaiResource(aaiClient, genericVnfUrl, aaiBasicAuthorization, transactionId); if (genericVnfPayload.equals(EMPTY_JSON_STRING)) { log.info("retrieveAaiVnfList "+ genericVnfPayload +" is not found, " + "return empty Json "); diff --git a/src/main/java/org/onap/pomba/contextbuilder/sdnc/util/RestUtil.java b/src/main/java/org/onap/pomba/contextbuilder/sdnc/util/RestUtil.java index b35f9f4..0353661 100644 --- a/src/main/java/org/onap/pomba/contextbuilder/sdnc/util/RestUtil.java +++ b/src/main/java/org/onap/pomba/contextbuilder/sdnc/util/RestUtil.java @@ -95,7 +95,6 @@ public class RestUtil { private static final String FORWARD_SLASH = "/"; // SDNC vnf Json Path - private static final String VNF_SPEC_PATH = "config/vnflist.spec"; private static final String GENERIC_API_SPEC_PATH = "config/sdncgenericresource.spec"; private static final String PROVIDED_CONFIGURATIONS_SPEC_PATH = "config/providedConfigurations.spec"; private static final String PORT_MIRROR_CONFIGURATIONS_SPEC_PATH = "config/portMirrorConfigurations.spec"; @@ -562,13 +561,12 @@ public class RestUtil { * Extract the vnf-list from the Json payload. */ private static List extractVnfList(String payload) throws AuditException { - List jsonSpec = JsonUtils.filepathToList(VNF_SPEC_PATH); - Object jsonInput = JsonUtils.jsonToObject(payload); - Chainr chainr = Chainr.fromSpec(jsonSpec); - Object transObject = chainr.transform(jsonInput); - String vnfListString = JsonUtils.toPrettyJsonString(transObject); - VnfList vnfList = VnfList.fromJson(vnfListString); - return vnfList.getVnfList(); + VnfList vnfList = VnfList.fromJson(payload); + if (null != vnfList) { + return vnfList.getVnfList(); + } + return new ArrayList<>(); + } private static String abstractStrInfo (String origStr, String matchStr) { diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java index d5bdc51..f0c0210 100644 --- a/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java +++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java @@ -182,7 +182,7 @@ public class SdncContextBuilderTest { String vnfApiUrl = vnfPath + moduleId; addResponse(vnfApiUrl, "junit/vnfApiResponse.json", sdncRule); - String genericVnfUrl = genericVnfPath + genericVnfId; + String genericVnfUrl = genericVnfPath + genericVnfId + "?depth=all"; addResponse(genericVnfUrl, "junit/genericVnf.json", aaiEnricherRule); Response response = this.service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVfw); assertEquals(Status.OK.getStatusCode(), response.getStatus()); diff --git a/src/test/resources/junit/vnfApiResponse.json b/src/test/resources/junit/vnfApiResponse.json index e1e4e51..1dfd33c 100644 --- a/src/test/resources/junit/vnfApiResponse.json +++ b/src/test/resources/junit/vnfApiResponse.json @@ -1,195 +1,192 @@ -{ - "vnfs": { - "vnf-list": [ - { - "vnf-id": "2c3f8902-f278-4ee3-93cf-9d2364cbafca", - "service-data": { - "vnf-request-information": { - "vnf-type": "VshakenIst09042018..base_alb..module-3", - "generic-vnf-name": "zdyh3bsflb0001v_01", - "vnf-id": "2c3f8902-f278-4ee3-93cf-9d2364cbafca", - "use-preload": "Y", - "generic-vnf-type": "vShaken_DNS_ns592n/vSHAKEN_IST_09042018 0", - "tenant": "f2e24e16c51244539b1f00123809cf4f", - "vnf-name": "zdyh3bsflb0001v_base_module_01", - "aic-cloud-region": "dyh3b", - "generic-vnf-id": "6bd2296e-d3e8-4eb8-ad65-a54d7bdb86d6" - }, - "vnf-topology-information": { - "vnf-assignments": { - "vnf-networks": [ - { - "network-role": "signaling", - "network-name": "vshaken_signal", - "ipv6-subnet-id": "936e0970-7403-48ef-9cf3-6374b42c5497", - "neutron-id": "5755dd95-b8f4-469a-931f-200727ed1933", - "network-id": "77747167-c41f-43e4-a5be-9a39b21949c8", - "contrail-network-fqdn": "default-domain:APP-C-24595-T-IST-05A:vshaken_signal", - "ipv6-subnet-name": "vshaken_signal_v6_s1" - }, - { - "network-role": "management", - "subnet-name": "vshaken_mgmt_v4_s1", - "network-name": "vshaken_mgmt", - "subnet-id": "1bf746bc-aace-4575-b8e6-4c8f9ccddd42", - "neutron-id": "96f4178f-ef7a-4754-acd0-269e9c5f0fc4", - "network-id": "1dc87784-3359-4a47-a868-458c13545624", - "contrail-network-fqdn": "default-domain:APP-C-24595-T-IST-05A:vshaken_mgmt" - } - ], - "vnf-vms": [ - { - "vm-type": "alb", - "vm-networks": [ - { - "network-role": "management", - "network-ips": [ - { - "ip-address": "135.50.172.132" - }, - { - "ip-address": "135.50.172.133" - } - ], - "use-dhcp": "Y" - }, - { - "network-role": "signaling", - "network-ips-v6": [ - { - "ip-address-ipv6": "2001:1890:1001:2652::7:1" - }, - { - "ip-address-ipv6": "2001:1890:1001:2652::7:2" - }, - { - "ip-address-ipv6": "2001:1890:1001:2652::7:3" - }, - { - "ip-address-ipv6": "2001:1890:1001:2652::7:4" - }, - { - "ip-address-ipv6": "2001:1890:1001:2652::7:5" - }, - { - "ip-address-ipv6": "2001:1890:1001:2652::7:6" - }, - { - "ip-address-ipv6": "2001:1890:1001:2652::7:7" - }, - { - "ip-address-ipv6": "2001:1890:1001:2652::7:8" - } - ], - "use-dhcp": "Y" - } - ], - "vm-names": [ - { - "vm-name": "dyh3bsflb0001vm001" - }, - { - "vm-name": "dyh3bsflb0001vm002" - } - ], - "vm-count": 2 - } - ], - "availability-zones": [ - { - "availability-zone": "dyh3b-kvm-az01" - }, - { - "availability-zone": "dyh3b-kvm-az02" - } - ] - }, - "vnf-parameters": [ - { - "vnf-parameter-name": "license_server_ip", - "vnf-parameter-value": "135.69.241.53" - }, - { - "vnf-parameter-name": "alb_admin_password", - "vnf-parameter-value": "foobar" - }, - { - "vnf-parameter-name": "vf_module_id", - "vnf-parameter-value": "zdyh3bsflb0001v" - }, - { - "vnf-parameter-name": "alb_root_password", - "vnf-parameter-value": "boofar" - }, - { - "vnf-parameter-name": "vnf_id", - "vnf-parameter-value": "zdyh3bsflb0001v" - }, - { - "vnf-parameter-name": "license_server_password", - "vnf-parameter-value": "root" - }, - { - "vnf-parameter-name": "license_pool_name", - "vnf-parameter-value": "vshaken_pool" - }, - { - "vnf-parameter-name": "signaling_netmask", - "vnf-parameter-value": "64" - }, - { - "vnf-parameter-name": "alb_ssh_public_key", - "vnf-parameter-value": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDpbEGYuDm2azRRqDHmaNeeN1w7in2TeK8y+8hTc7BtwQFjuoZBdZb7Hexf4JbYMzNc7QMaVvGa/paFS5GHoYl+gDWhci9CB3LoHHaCDB9YbBm4VaTf/04tWmur9OAl+h7EnoL+7ksRp1+7aLy3ictdimJlvlbIVgio4pINobXRqzOFr+QP+LWH92sjFGlGe61WjU/19QGyQSq0EOMU7vIxo5QaxZHpwkdQy8R1rJjoXdMj/rh3COiXWlVy3hZi3eGtK50M7vQbXn56azF4hPeN6kxkIwn2syFE0Jmw4J1aj2mnJDsix7tTlf6DL6wi54G8M21ZHHnobzKPiojjYLfh" - } - ], - "vnf-topology-identifier": { - "service-type": "SDN-MOBILITY", - "vnf-type": "VshakenIst09042018..base_alb..module-3", - "generic-vnf-name": "zdyh3bsflb0001v_01", - "generic-vnf-type": "vShaken_DNS_ns592n/vSHAKEN_IST_09042018 0", - "vnf-name": "zdyh3bsflb0001v_base_module_01", - "inMaint":"no", - "pserver":{ - "hostname": "somerandomserver.ottawa.com" - }, - "image":{ - "image-name": "cfad8f38-3d4c-4aec-8bd4-f83ad605acbe" - }, - "prov-status": "Available" - } - }, - "service-information": { - "service-id": "null", - "service-type": "null", - "service-instance-id": "ccce0f34-6603-419a-b916-acc741f4ceb4", - "subscriber-name": "notsurewecare" - }, - "vnf-id": "2c3f8902-f278-4ee3-93cf-9d2364cbafca", - "sdnc-request-header": { - "svc-notification-url": "https://mso-sdnc-ist3.ecomp.idns.cip.att.com:30254/adapters/rest/SDNCNotify", - "svc-request-id": "906ece4b-d07f-4479-adbf-b7d476002808-1539182393957", - "svc-action": "assign" - }, - "oper-status": { - "order-status": "PendingCreate" - }, - "request-information": { - "source": "VID", - "request-action": "VNFActivateRequest", - "request-id": "906ece4b-d07f-4479-adbf-b7d476002808" - } - }, - "service-status": { - "final-indicator": "Y", - "request-status": "synccomplete", - "response-code": "200", - "rpc-name": "vnf-topology-operation", - "vnfsdn-action": "VNFActivateRequest", - "rpc-action": "assign", - "response-timestamp": "2018-10-10T14:39:55.433Z" - } - } - - ] - } +{ + "vnf-list": [ + { + "vnf-id": "2c3f8902-f278-4ee3-93cf-9d2364cbafca", + "service-data": { + "vnf-request-information": { + "vnf-type": "VshakenIst09042018..base_alb..module-3", + "generic-vnf-name": "zdyh3bsflb0001v_01", + "vnf-id": "2c3f8902-f278-4ee3-93cf-9d2364cbafca", + "use-preload": "Y", + "generic-vnf-type": "vShaken_DNS_ns592n/vSHAKEN_IST_09042018 0", + "tenant": "f2e24e16c51244539b1f00123809cf4f", + "vnf-name": "zdyh3bsflb0001v_base_module_01", + "aic-cloud-region": "dyh3b", + "generic-vnf-id": "6bd2296e-d3e8-4eb8-ad65-a54d7bdb86d6" + }, + "vnf-topology-information": { + "vnf-assignments": { + "vnf-networks": [ + { + "network-role": "signaling", + "network-name": "vshaken_signal", + "ipv6-subnet-id": "936e0970-7403-48ef-9cf3-6374b42c5497", + "neutron-id": "5755dd95-b8f4-469a-931f-200727ed1933", + "network-id": "77747167-c41f-43e4-a5be-9a39b21949c8", + "contrail-network-fqdn": "default-domain:APP-C-24595-T-IST-05A:vshaken_signal", + "ipv6-subnet-name": "vshaken_signal_v6_s1" + }, + { + "network-role": "management", + "subnet-name": "vshaken_mgmt_v4_s1", + "network-name": "vshaken_mgmt", + "subnet-id": "1bf746bc-aace-4575-b8e6-4c8f9ccddd42", + "neutron-id": "96f4178f-ef7a-4754-acd0-269e9c5f0fc4", + "network-id": "1dc87784-3359-4a47-a868-458c13545624", + "contrail-network-fqdn": "default-domain:APP-C-24595-T-IST-05A:vshaken_mgmt" + } + ], + "vnf-vms": [ + { + "vm-type": "alb", + "vm-networks": [ + { + "network-role": "management", + "network-ips": [ + { + "ip-address": "135.50.172.132" + }, + { + "ip-address": "135.50.172.133" + } + ], + "use-dhcp": "Y" + }, + { + "network-role": "signaling", + "network-ips-v6": [ + { + "ip-address-ipv6": "2001:1890:1001:2652::7:1" + }, + { + "ip-address-ipv6": "2001:1890:1001:2652::7:2" + }, + { + "ip-address-ipv6": "2001:1890:1001:2652::7:3" + }, + { + "ip-address-ipv6": "2001:1890:1001:2652::7:4" + }, + { + "ip-address-ipv6": "2001:1890:1001:2652::7:5" + }, + { + "ip-address-ipv6": "2001:1890:1001:2652::7:6" + }, + { + "ip-address-ipv6": "2001:1890:1001:2652::7:7" + }, + { + "ip-address-ipv6": "2001:1890:1001:2652::7:8" + } + ], + "use-dhcp": "Y" + } + ], + "vm-names": [ + { + "vm-name": "dyh3bsflb0001vm001" + }, + { + "vm-name": "dyh3bsflb0001vm002" + } + ], + "vm-count": 2 + } + ], + "availability-zones": [ + { + "availability-zone": "dyh3b-kvm-az01" + }, + { + "availability-zone": "dyh3b-kvm-az02" + } + ] + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "license_server_ip", + "vnf-parameter-value": "135.69.241.53" + }, + { + "vnf-parameter-name": "alb_admin_password", + "vnf-parameter-value": "foobar" + }, + { + "vnf-parameter-name": "vf_module_id", + "vnf-parameter-value": "zdyh3bsflb0001v" + }, + { + "vnf-parameter-name": "alb_root_password", + "vnf-parameter-value": "boofar" + }, + { + "vnf-parameter-name": "vnf_id", + "vnf-parameter-value": "zdyh3bsflb0001v" + }, + { + "vnf-parameter-name": "license_server_password", + "vnf-parameter-value": "root" + }, + { + "vnf-parameter-name": "license_pool_name", + "vnf-parameter-value": "vshaken_pool" + }, + { + "vnf-parameter-name": "signaling_netmask", + "vnf-parameter-value": "64" + }, + { + "vnf-parameter-name": "alb_ssh_public_key", + "vnf-parameter-value": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDpbEGYuDm2azRRqDHmaNeeN1w7in2TeK8y+8hTc7BtwQFjuoZBdZb7Hexf4JbYMzNc7QMaVvGa/paFS5GHoYl+gDWhci9CB3LoHHaCDB9YbBm4VaTf/04tWmur9OAl+h7EnoL+7ksRp1+7aLy3ictdimJlvlbIVgio4pINobXRqzOFr+QP+LWH92sjFGlGe61WjU/19QGyQSq0EOMU7vIxo5QaxZHpwkdQy8R1rJjoXdMj/rh3COiXWlVy3hZi3eGtK50M7vQbXn56azF4hPeN6kxkIwn2syFE0Jmw4J1aj2mnJDsix7tTlf6DL6wi54G8M21ZHHnobzKPiojjYLfh" + } + ], + "vnf-topology-identifier": { + "service-type": "SDN-MOBILITY", + "vnf-type": "VshakenIst09042018..base_alb..module-3", + "generic-vnf-name": "zdyh3bsflb0001v_01", + "generic-vnf-type": "vShaken_DNS_ns592n/vSHAKEN_IST_09042018 0", + "vnf-name": "zdyh3bsflb0001v_base_module_01", + "inMaint": "no", + "pserver": { + "hostname": "somerandomserver.ottawa.com" + }, + "image": { + "image-name": "cfad8f38-3d4c-4aec-8bd4-f83ad605acbe" + }, + "prov-status": "Available" + } + }, + "service-information": { + "service-id": "null", + "service-type": "null", + "service-instance-id": "ccce0f34-6603-419a-b916-acc741f4ceb4", + "subscriber-name": "notsurewecare" + }, + "vnf-id": "2c3f8902-f278-4ee3-93cf-9d2364cbafca", + "sdnc-request-header": { + "svc-notification-url": "https://mso-sdnc-ist3.ecomp.idns.cip.att.com:30254/adapters/rest/SDNCNotify", + "svc-request-id": "906ece4b-d07f-4479-adbf-b7d476002808-1539182393957", + "svc-action": "assign" + }, + "oper-status": { + "order-status": "PendingCreate" + }, + "request-information": { + "source": "VID", + "request-action": "VNFActivateRequest", + "request-id": "906ece4b-d07f-4479-adbf-b7d476002808" + } + }, + "service-status": { + "final-indicator": "Y", + "request-status": "synccomplete", + "response-code": "200", + "rpc-name": "vnf-topology-operation", + "vnfsdn-action": "VNFActivateRequest", + "rpc-action": "assign", + "response-timestamp": "2018-10-10T14:39:55.433Z" + } + } + ] } \ No newline at end of file -- cgit 1.2.3-korg