diff options
author | Ram Krishna Verma <ram.krishna.verma@est.tech> | 2019-06-27 19:12:16 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-06-27 19:12:16 +0000 |
commit | 9520a45c23ef2d0dc3130b0b885800a9df911fd7 (patch) | |
tree | 2a6bda338c0ed599e41b158af34c2d283e688972 /examples/examples-onap-bbs/src/main/resources/logic | |
parent | ce9d82d2c0e863597d84cc8909955e398405f45a (diff) | |
parent | fad6fa4890538fe8f4cbb96ae3fb0be6767d28d1 (diff) |
Merge "Fix Sonar/Checkstyle issues in apex-pdp"
Diffstat (limited to 'examples/examples-onap-bbs/src/main/resources/logic')
4 files changed, 177 insertions, 258 deletions
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js index 419ce4350..6e72e618c 100644 --- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js +++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,8 +33,7 @@ var attachmentPoint = executor.inFields.get("attachmentPoint"); var requestID = executor.inFields.get("requestID"); var serviceInstanceId = executor.inFields.get("serviceInstanceId"); -var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( - attachmentPoint); +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(attachmentPoint); executor.logger.info(NomadicONTContext); var jsonObj; @@ -42,7 +42,6 @@ var aaiUpdateResult = true; var wbClient = Java.type("org.onap.policy.apex.examples.bbs.WebClient"); var client = new wbClient(); - /* Get AAI URL from Configuration file. */ var AAI_URL = "localhost:8080"; var CUSTOMER_ID = requestID; @@ -55,8 +54,7 @@ var results; var putUrl; var service_instance; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/config.txt")); + var br = Files.newBufferedReader(Paths.get("/home/apexuser/examples/config/ONAPBBS/config.txt")); var line; while ((line = br.readLine()) != null) { if (line.startsWith("AAI_URL")) { @@ -81,14 +79,12 @@ executor.logger.info("AAI_URL " + AAI_URL); /* Get service instance Id from AAI */ try { - var urlGet = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + - SERVICE_INSTANCE_ID + "?format=resource_and_url"; + var urlGet = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + + SERVICE_INSTANCE_ID + "?format=resource_and_url"; executor.logger.info("Query url" + urlGet); - result = client.httpsRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true); executor.logger.info("Data received From " + urlGet + " " + result); jsonObj = JSON.parse(result.toString()); @@ -100,9 +96,8 @@ try { service_instance_id = service_instance['service-instance-id']; resource_version = service_instance['resource-version']; relationship_list = service_instance['relationship-list']; - executor.logger.info("After Parse service_instance " + JSON.stringify( - service_instance, null, 4) + "\n url " + putUrl + - "\n Service instace Id " + service_instance_id); + executor.logger.info("After Parse service_instance " + JSON.stringify(service_instance, null, 4) + "\n url " + + putUrl + "\n Service instace Id " + service_instance_id); if (result == "") { aaiUpdateResult = false; @@ -112,21 +107,16 @@ try { aaiUpdateResult = false; } - - /* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */ var putUpddateServInstance; putUpddateServInstance = service_instance; try { if (aaiUpdateResult == true) { putUpddateServInstance["orchestration-status"] = "active"; - executor.logger.info("ready to putAfter Parse " + JSON.stringify( - putUpddateServInstance, null, 4)); - var urlPut = HTTP_PROTOCOL + AAI_URL + - putUrl + "?resource_version=" + resource_version; - result = client.httpsRequest(urlPut, "PUT", JSON.stringify( - putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + executor.logger.info("ready to putAfter Parse " + JSON.stringify(putUpddateServInstance, null, 4)); + var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version; + result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlPut + " " + result); /* If failure to retrieve data proceed to Failure */ if (result != "") { @@ -138,11 +128,9 @@ try { aaiUpdateResult = false; } -if (!service_instance.hasOwnProperty('input-parameters') || !service_instance - .hasOwnProperty('metadata')) { +if (!service_instance.hasOwnProperty('input-parameters') || !service_instance.hasOwnProperty('metadata')) { aaiUpdateResult = false; - executor.logger.info( - "Validate data failed. input-parameters or metadata is missing"); + executor.logger.info("Validate data failed. input-parameters or metadata is missing"); } /* update logical link in pnf */ @@ -154,25 +142,22 @@ try { var pnfUpdate; var relationShips = relationship_list["relationship"]; - for (var i = 0; i < relationShips.length; i++) { if (relationShips[i]["related-to"] == "pnf") { - var relationship_data = relationShips[i]["relationship-data"]; - for (var j = 0; j < relationship_data.length; j++) { - if (relationship_data[j]["relationship-key"] == "pnf.pnf-name") { + var relationship_data = relationShips[i]["relationship-data"]; + for (var j = 0; j < relationship_data.length; j++) { + if (relationship_data[j]["relationship-key"] == "pnf.pnf-name") { pnfName = relationship_data[j]['relationship-value']; break; - } - } + } + } } } executor.logger.info("pnf-name found " + pnfName); /* 1. Get PNF */ - var urlGetPnf = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; - pnfResponse = client.httpsRequest(urlGetPnf, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + var urlGetPnf = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; + pnfResponse = client.httpRequest(urlGetPnf, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true); executor.logger.info("Data received From " + urlGetPnf + " " + pnfResponse); /* If failure to retrieve data proceed to Failure */ if (result != "") { @@ -181,18 +166,17 @@ try { pnfUpdate = JSON.parse(pnfResponse.toString()); executor.logger.info(JSON.stringify(pnfUpdate, null, 4)); - /*2. Create logical link */ var link_name = attachmentPoint; var logicalLink = { - "link-name": link_name, - "in-maint": false, - "link-type": "attachment-point" - }; - var urlNewLogicalLink = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/network/logical-links/logical-link/" + link_name; - result = client.httpsRequest(urlNewLogicalLink, "PUT", JSON.stringify(logicalLink), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + "link-name" : link_name, + "in-maint" : false, + "link-type" : "attachment-point" + }; + var urlNewLogicalLink = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + + "/network/logical-links/logical-link/" + link_name; + result = client.httpRequest(urlNewLogicalLink, "PUT", JSON.stringify(logicalLink), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlNewLogicalLink + " " + result); /* If failure to retrieve data proceed to Failure */ if (result != "") { @@ -202,9 +186,10 @@ try { /*3. Update pnf with new relation*/ for (var i = 0; i < pnfUpdate["relationship-list"]["relationship"].length; i++) { if (pnfUpdate["relationship-list"]["relationship"][i]['related-to'] == 'logical-link') { - pnfUpdate["relationship-list"]["relationship"][i]['related-link'] = "/aai/" + AAI_VERSION + "/network/logical-links/logical-link/" + link_name; + pnfUpdate["relationship-list"]["relationship"][i]['related-link'] = "/aai/" + AAI_VERSION + + "/network/logical-links/logical-link/" + link_name; for (var j = 0; j < pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'].length; j++) { - if (pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-key'] == "logical-link.link-name") { + if (pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-key'] == "logical-link.link-name") { oldLinkName = pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-value']; pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-value'] = link_name; break; @@ -215,10 +200,9 @@ try { } executor.logger.info("Put pnf to aai " + JSON.stringify(pnfUpdate, null, 4)); - var urlPutPnf = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; - result = client.httpsRequest(urlPutPnf, "PUT", JSON.stringify(pnfUpdate), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + var urlPutPnf = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/network/pnfs/pnf/" + pnfName; + result = client.httpRequest(urlPutPnf, "PUT", JSON.stringify(pnfUpdate), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlPutPnf + " " + result); /* If failure to retrieve data proceed to Failure */ @@ -229,18 +213,19 @@ try { /* Get and Delete the Stale logical link */ var oldLinkResult; var linkResult; - var urlOldLogicalLink = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/network/logical-links/logical-link/" + oldLinkName; - linkResult = client.httpsRequest(urlOldLogicalLink, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); - executor.logger.info("Data received From " + urlOldLogicalLink + " " + linkResult + " " + linkResult.hasOwnProperty("link-name")); + var urlOldLogicalLink = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + + "/network/logical-links/logical-link/" + oldLinkName; + linkResult = client + .httpRequest(urlOldLogicalLink, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true); + executor.logger.info("Data received From " + urlOldLogicalLink + " " + linkResult + " " + + linkResult.hasOwnProperty("link-name")); oldLinkResult = JSON.parse(linkResult.toString()); if (oldLinkResult.hasOwnProperty("link-name") == true) { var res_version = oldLinkResult["resource-version"]; var urlDelOldLogicalLink = urlOldLogicalLink + "?resource-version=" + res_version; executor.logger.info("Delete called for " + urlDelOldLogicalLink); - result = client.httpsRequest(urlDelOldLogicalLink, "DELETE", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlDelOldLogicalLink, "DELETE", null, AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Delete called for " + urlDelOldLogicalLink + " result " + result); } } @@ -262,8 +247,7 @@ if (aaiUpdateResult === true) { executor.outFields.put("requestID", requestID); executor.outFields.put("attachmentPoint", attachmentPoint); -executor.outFields.put("serviceInstanceId", executor.inFields.get( - "serviceInstanceId")); +executor.outFields.put("serviceInstanceId", executor.inFields.get("serviceInstanceId")); var returnValue = executor.isTrue; executor.logger.info(executor.outFields); @@ -278,4 +262,4 @@ function IsValidJSONString(str) { } return true; } -/* Utility functions End */
\ No newline at end of file +/* Utility functions End */ diff --git a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js index 5d18f23b0..7e116f0ea 100644 --- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js +++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,11 +33,10 @@ var attachmentPoint = executor.inFields.get("attachmentPoint"); var requestID = executor.inFields.get("requestID"); var serviceInstanceId = executor.inFields.get("serviceInstanceId"); -var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( - attachmentPoint); +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(attachmentPoint); executor.logger.info(NomadicONTContext); -//Get the AAI URL from configuraiotn file +// Get the AAI URL from configuraiotn file var AAI_URL = "localhost:8080"; var CUSTOMER_ID = requestID; var BBS_CFS_SERVICE_TYPE = "BBS-CFS-Access_Test"; @@ -48,8 +48,7 @@ var client = new wbClient(); var AAI_USERNAME = null; var AAI_PASSWORD = null; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/config.txt")); + var br = Files.newBufferedReader(Paths.get("/home/apexuser/examples/config/ONAPBBS/config.txt")); // read line by line var line; while ((line = br.readLine()) != null) { @@ -74,14 +73,12 @@ executor.logger.info("AAI_URL " + AAI_URL); var aaiUpdateResult = true; /* Get service instance Id from AAI */ try { - var urlGet = HTTP_PROTOCOL + AAI_URL + - "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + - SERVICE_INSTANCE_ID + "?format=resource_and_url"; + var urlGet = HTTP_PROTOCOL + AAI_URL + "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" + + SERVICE_INSTANCE_ID + "?format=resource_and_url"; executor.logger.info("Query url" + urlGet); - result = client.httpsRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, "application/json", true); executor.logger.info("Data received From " + urlGet + " " + result); jsonObj = JSON.parse(result); @@ -90,9 +87,8 @@ try { results = jsonObj['results'][0]; putUrl = results['url']; service_instance = results['service-instance']; - executor.logger.info("After Parse service_instance " + JSON.stringify( - service_instance, null, 4) + "\n url " + putUrl + - "\n Service instace Id " + SERVICE_INSTANCE_ID); + executor.logger.info("After Parse service_instance " + JSON.stringify(service_instance, null, 4) + "\n url " + + putUrl + "\n Service instace Id " + SERVICE_INSTANCE_ID); if (result == "") { aaiUpdateResult = false; @@ -104,21 +100,17 @@ try { var putUpddateServInstance = service_instance; putUpddateServInstance['orchestration-status'] = "created"; -executor.logger.info(" string" + JSON.stringify(putUpddateServInstance, null, - 4)); +executor.logger.info(" string" + JSON.stringify(putUpddateServInstance, null, 4)); var resource_version = putUpddateServInstance['resource-version']; var putUrl = NomadicONTContext.get("url"); -/*BBS Policy updates {{bbs-cfs-service-instance-UUID}} orchestration-status [ assigned --> created ]*/ +/* BBS Policy updates {{bbs-cfs-service-instance-UUID}} orchestration-status [ assigned --> created ] */ try { if (aaiUpdateResult == true) { - executor.logger.info("ready to putAfter Parse " + JSON.stringify( - putUpddateServInstance, null, 4)); - var urlPut = HTTP_PROTOCOL + AAI_URL + - putUrl + "?resource_version=" + resource_version; - result = client.httpsRequest(urlPut, "PUT", JSON.stringify( - putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + executor.logger.info("ready to putAfter Parse " + JSON.stringify(putUpddateServInstance, null, 4)); + var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version; + result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlPut + " " + result); /* If failure to retrieve data proceed to Failure */ if (result != "") { @@ -139,9 +131,8 @@ if (aaiUpdateResult === true) { executor.outFields.put("requestID", requestID); executor.outFields.put("attachmentPoint", attachmentPoint); -executor.outFields.put("serviceInstanceId", executor.inFields.get( - "serviceInstanceId")); +executor.outFields.put("serviceInstanceId", executor.inFields.get("serviceInstanceId")); var returnValue = executor.isTrue; executor.logger.info(executor.outFields); -executor.logger.info("End Execution AAIServiceCreateTask.js");
\ No newline at end of file +executor.logger.info("End Execution AAIServiceCreateTask.js"); diff --git a/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js b/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js index 55f5a1ba1..d588eaf48 100644 --- a/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js +++ b/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,8 +39,7 @@ var uuidType = Java.type("java.util.UUID"); var wbClient = Java.type("org.onap.policy.apex.examples.bbs.WebClient"); var client = new wbClient(); -var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get( - attachmentPoint); +var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(attachmentPoint); var sdncUUID = uuidType.randomUUID(); executor.logger.info(NomadicONTContext); var jsonObj; @@ -50,8 +50,7 @@ var SVC_NOTIFICATION_URL; var putUpddateServInstance = JSON.parse(NomadicONTContext.get("aai_message")); var input_param = JSON.parse(putUpddateServInstance['input-parameters']); try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/config.txt")); + var br = Files.newBufferedReader(Paths.get("/home/apexuser/examples/config/ONAPBBS/config.txt")); var line; while ((line = br.readLine()) != null) { if (line.startsWith("SDNC_URL")) { @@ -60,8 +59,7 @@ try { } else if (line.startsWith("SVC_NOTIFICATION_URL")) { var str = line.split("="); SVC_NOTIFICATION_URL = str[str.length - 1]; - } - else if (line.startsWith("SDNC_USERNAME")) { + } else if (line.startsWith("SDNC_USERNAME")) { var str = line.split("="); SDNC_USERNAME = str[str.length - 1]; } else if (line.startsWith("SDNC_PASSWORD")) { @@ -79,12 +77,11 @@ var jsonObj; var sdncUpdateResult = true; /* BBS Policy calls SDN-C GR-API to delete AccessConnectivity VF ID */ -/* Prepare Data*/ +/* Prepare Data */ var xmlDeleteAccess = ""; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/sdnc_DeleteAccessConnectivityInstance.txt" - )); + var br = Files.newBufferedReader(Paths + .get("/home/apexuser/examples/config/ONAPBBS/sdnc_DeleteAccessConnectivityInstance.txt")); var line; while ((line = br.readLine()) != null) { xmlDeleteAccess += line; @@ -96,56 +93,39 @@ try { /* BBS Policy calls SDN-C GR-API to delete AccessConnectivity */ xmlDeleteAccess = xmlDeleteAccess.replace("svc_request_id_value", sdncUUID); -xmlDeleteAccess = xmlDeleteAccess.replace("svc_notification_url_value", - SVC_NOTIFICATION_URL); +xmlDeleteAccess = xmlDeleteAccess.replace("svc_notification_url_value", SVC_NOTIFICATION_URL); xmlDeleteAccess = xmlDeleteAccess.replace("request_id_value", sdncUUID); xmlDeleteAccess = xmlDeleteAccess.replace("service_id_value", sdncUUID); -xmlDeleteAccess = xmlDeleteAccess.replace("service_instance_id_value", - putUpddateServInstance['service-instance-id']); -xmlDeleteAccess = xmlDeleteAccess.replace("service_type_value", input_param[ - 'service']['serviceType']); -xmlDeleteAccess = xmlDeleteAccess.replace("customer_id_value", input_param[ - 'service']['globalSubscriberId']); -xmlDeleteAccess = xmlDeleteAccess.replace("customer_name_value", input_param[ - 'service']['globalSubscriberId']); - -xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_custom_uuid_value", - getResourceCustomizationUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("service_instance_id_value", putUpddateServInstance['service-instance-id']); +xmlDeleteAccess = xmlDeleteAccess.replace("service_type_value", input_param['service']['serviceType']); +xmlDeleteAccess = xmlDeleteAccess.replace("customer_id_value", input_param['service']['globalSubscriberId']); +xmlDeleteAccess = xmlDeleteAccess.replace("customer_name_value", input_param['service']['globalSubscriberId']); + +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_name_value", "AccessConnectivity"); -xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace( - "network_info_model_custom_uuid_value", getResourceCustomizationUuid( +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_uuid_value", getResourceUuid( input_param['service']['parameters']['resources'], 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'AccessConnectivity')); -xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_name_value", - "AccessConnectivity"); - -xmlDeleteAccess = xmlDeleteAccess.replace("vendor_value", input_param['service'] - ['parameters']['requestInputs']['ont_ont_manufacturer']); +xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_name_value", "AccessConnectivity"); + +xmlDeleteAccess = xmlDeleteAccess.replace("vendor_value", + input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']); xmlDeleteAccess = xmlDeleteAccess.replace("service_id_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], - 'controller-service-id')); + putUpddateServInstance['metadata']['metadatum'], 'controller-service-id')); executor.logger.info(client.toPrettyString(xmlDeleteAccess, 4)); try { - var urlPost1 = HTTP_PROTOCOL + SDNC_URL + - "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; - result = client.httpRequest(urlPost1, "POST", xmlDeleteAccess, SDNC_USERNAME, SDNC_PASSWORD, - "application/xml", true, true); + var urlPost1 = HTTP_PROTOCOL + SDNC_URL + "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; + result = client.httpRequest(urlPost1, "POST", xmlDeleteAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml", + false); executor.logger.info("Data received From " + urlPost1 + " " + result); if (result == "") { sdncUpdateResult = false; @@ -155,14 +135,13 @@ try { sdncUpdateResult = false; } -/* BBS Policy calls SDN-C GR-API to create new AccessConnectivity VF */ +/* BBS Policy calls SDN-C GR-API to create new AccessConnectivity VF */ -/* Prepare Data*/ +/* Prepare Data */ var xmlCreateAccess = ""; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/sdnc_CreateAccessConnectivityInstance.txt" - )); + var br = Files.newBufferedReader(Paths + .get("/home/apexuser/examples/config/ONAPBBS/sdnc_CreateAccessConnectivityInstance.txt")); var line; while ((line = br.readLine()) != null) { xmlCreateAccess += line; @@ -172,62 +151,47 @@ try { executor.logger.info("Failed to retrieve data " + err); } xmlCreateAccess = xmlCreateAccess.replace("svc_request_id_value", sdncUUID); -xmlCreateAccess = xmlCreateAccess.replace("svc_notification_url_value", - SVC_NOTIFICATION_URL); +xmlCreateAccess = xmlCreateAccess.replace("svc_notification_url_value", SVC_NOTIFICATION_URL); xmlCreateAccess = xmlCreateAccess.replace("request_id_value", requestID); xmlCreateAccess = xmlCreateAccess.replace("service_id_value", sdncUUID); -xmlCreateAccess = xmlCreateAccess.replace("service_instance_id_value", - putUpddateServInstance['service-instance-id']); -xmlCreateAccess = xmlCreateAccess.replace("service_type_value", input_param[ - 'service']['serviceType']); -xmlCreateAccess = xmlCreateAccess.replace("customer_id_value", input_param[ - 'service']['globalSubscriberId']); -xmlCreateAccess = xmlCreateAccess.replace("customer_name_value", input_param[ - 'service']['globalSubscriberId']); - -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value", - getResourceCustomizationUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("service_instance_id_value", putUpddateServInstance['service-instance-id']); +xmlCreateAccess = xmlCreateAccess.replace("service_type_value", input_param['service']['serviceType']); +xmlCreateAccess = xmlCreateAccess.replace("customer_id_value", input_param['service']['globalSubscriberId']); +xmlCreateAccess = xmlCreateAccess.replace("customer_name_value", input_param['service']['globalSubscriberId']); + +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_name_value", "AccessConnectivity"); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace( - "network_info_model_custom_uuid_value", getResourceCustomizationUuid( +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'AccessConnectivity')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value", getResourceUuid( input_param['service']['parameters']['resources'], 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'AccessConnectivity')); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value", - "AccessConnectivity"); - -xmlCreateAccess = xmlCreateAccess.replace("vendor_value", input_param['service'] - ['parameters']['requestInputs']['ont_ont_manufacturer']); -xmlCreateAccess = xmlCreateAccess.replace("ont_sn_value", input_param['service'] - ['parameters']['requestInputs']['ont_ont_serial_num']); -xmlCreateAccess = xmlCreateAccess.replace("s_vlan_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'svlan')); -xmlCreateAccess = xmlCreateAccess.replace("c_vlan_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'cvlan')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value", "AccessConnectivity"); + +xmlCreateAccess = xmlCreateAccess.replace("vendor_value", + input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']); +xmlCreateAccess = xmlCreateAccess.replace("ont_sn_value", + input_param['service']['parameters']['requestInputs']['ont_ont_serial_num']); +xmlCreateAccess = xmlCreateAccess.replace("s_vlan_value", getMetaValue(putUpddateServInstance['metadata']['metadatum'], + 'svlan')); +xmlCreateAccess = xmlCreateAccess.replace("c_vlan_value", getMetaValue(putUpddateServInstance['metadata']['metadatum'], + 'cvlan')); xmlCreateAccess = xmlCreateAccess.replace("remote_id_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'remote-id')); + putUpddateServInstance['metadata']['metadatum'], 'remote-id')); executor.logger.info(client.toPrettyString(xmlCreateAccess, 4)); try { if (sdncUpdateResult == true) { - var urlPost2 = HTTP_PROTOCOL + SDNC_URL + - "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; - result = client.httpRequest(urlPost2, "POST", xmlCreateAccess, SDNC_USERNAME, SDNC_PASSWORD, - "application/xml", true, true); + var urlPost2 = HTTP_PROTOCOL + SDNC_URL + + "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; + result = client.httpRequest(urlPost2, "POST", xmlCreateAccess, SDNC_USERNAME, SDNC_PASSWORD, "application/xml", + false); executor.logger.info("Data received From " + urlPost2 + " " + result); if (result == "") { sdncUpdateResult = false; @@ -238,12 +202,11 @@ try { sdncUpdateResult = false; } -/* BBS Policy calls SDN-C GR-API to create change Internet Profile */ +/* BBS Policy calls SDN-C GR-API to create change Internet Profile */ var xmlChangeProfile = ""; try { - var br = Files.newBufferedReader(Paths.get( - "/home/apexuser/examples/config/ONAPBBS/sdnc_ChangeInternetProfileInstance.txt" - )); + var br = Files.newBufferedReader(Paths + .get("/home/apexuser/examples/config/ONAPBBS/sdnc_ChangeInternetProfileInstance.txt")); var line; while ((line = br.readLine()) != null) { xmlChangeProfile += line; @@ -254,75 +217,56 @@ try { } xmlChangeProfile = xmlChangeProfile.replace("svc_request_id_value", sdncUUID); -xmlChangeProfile = xmlChangeProfile.replace("svc_notification_url_value", - SVC_NOTIFICATION_URL); +xmlChangeProfile = xmlChangeProfile.replace("svc_notification_url_value", SVC_NOTIFICATION_URL); xmlChangeProfile = xmlChangeProfile.replace("request_id_value", requestID); xmlChangeProfile = xmlChangeProfile.replace("service_id_value", sdncUUID); -xmlChangeProfile = xmlChangeProfile.replace("service_instance_id_value", - putUpddateServInstance['service-instance-id']); -xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param[ - 'service']['serviceType']); -xmlChangeProfile = xmlChangeProfile.replace("customer_id_value", input_param[ - 'service']['globalSubscriberId']); -xmlChangeProfile = xmlChangeProfile.replace("customer_name_value", input_param[ - 'service']['globalSubscriberId']); - -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value", - getResourceCustomizationUuid(input_param['service']['parameters'][ - 'resources' - ], 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_name_value", - "InternetProfile"); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value", - getResourceInvariantUuid(input_param['service']['parameters'][ - 'resources' - ], 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace( - "network_info_model_custom_uuid_value", getResourceCustomizationUuid( - input_param['service']['parameters']['resources'], - 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value", - getResourceUuid(input_param['service']['parameters']['resources'], - 'InternetProfile')); -xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value", - "InternetProfile"); - -xmlChangeProfile = xmlChangeProfile.replace("vendor_value", input_param[ - 'service']['parameters']['requestInputs']['ont_ont_manufacturer']); +xmlChangeProfile = xmlChangeProfile.replace("service_instance_id_value", putUpddateServInstance['service-instance-id']); +xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param['service']['serviceType']); +xmlChangeProfile = xmlChangeProfile.replace("customer_id_value", input_param['service']['globalSubscriberId']); +xmlChangeProfile = xmlChangeProfile.replace("customer_name_value", input_param['service']['globalSubscriberId']); + +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_name_value", "InternetProfile"); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value", getResourceInvariantUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_custom_uuid_value", getResourceCustomizationUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value", getResourceUuid( + input_param['service']['parameters']['resources'], 'InternetProfile')); +xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value", "InternetProfile"); + +xmlChangeProfile = xmlChangeProfile.replace("vendor_value", + input_param['service']['parameters']['requestInputs']['ont_ont_manufacturer']); xmlChangeProfile = xmlChangeProfile.replace("service_id_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], - 'controller-service-id')); + putUpddateServInstance['metadata']['metadatum'], 'controller-service-id')); xmlChangeProfile = xmlChangeProfile.replace("remote_id_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'remote-id')); -xmlChangeProfile = xmlChangeProfile.replace("ont_sn_value", input_param[ - 'service']['parameters']['requestInputs']['ont_ont_serial_num']); -xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param[ - 'service']['serviceType']); -xmlChangeProfile = xmlChangeProfile.replace("mac_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'rgw-mac-address')); + putUpddateServInstance['metadata']['metadatum'], 'remote-id')); +xmlChangeProfile = xmlChangeProfile.replace("ont_sn_value", + input_param['service']['parameters']['requestInputs']['ont_ont_serial_num']); +xmlChangeProfile = xmlChangeProfile.replace("service_type_value", input_param['service']['serviceType']); +xmlChangeProfile = xmlChangeProfile.replace("mac_value", getMetaValue(putUpddateServInstance['metadata']['metadatum'], + 'rgw-mac-address')); xmlChangeProfile = xmlChangeProfile.replace("up_speed_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'up-speed')); + putUpddateServInstance['metadata']['metadatum'], 'up-speed')); xmlChangeProfile = xmlChangeProfile.replace("down_speed_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'down-speed')); + putUpddateServInstance['metadata']['metadatum'], 'down-speed')); xmlChangeProfile = xmlChangeProfile.replace("s_vlan_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'svlan')); + putUpddateServInstance['metadata']['metadatum'], 'svlan')); xmlChangeProfile = xmlChangeProfile.replace("c_vlan_value", getMetaValue( - putUpddateServInstance['metadata']['metadatum'], 'cvlan')); + putUpddateServInstance['metadata']['metadatum'], 'cvlan')); executor.logger.info(client.toPrettyString(xmlChangeProfile, 4)); try { if (sdncUpdateResult == true) { - var urlPost3 = HTTP_PROTOCOL + SDNC_URL + - "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; + var urlPost3 = HTTP_PROTOCOL + SDNC_URL + + "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; result = client.httpRequest(urlPost3, "POST", xmlChangeProfile, SDNC_USERNAME, SDNC_PASSWORD, - "application/xml", true, true); + "application/xml", false); executor.logger.info("Data received From " + urlPost3 + " " + result); if (result == "") { sdncUpdateResult = false; @@ -345,8 +289,7 @@ if (sdncUpdateResult === true) { executor.outFields.put("requestID", requestID); executor.outFields.put("attachmentPoint", attachmentPoint); -executor.outFields.put("serviceInstanceId", executor.inFields.get( - "serviceInstanceId")); +executor.outFields.put("serviceInstanceId", executor.inFields.get("serviceInstanceId")); var returnValue = executor.isTrue; executor.logger.info(executor.outFields); @@ -401,4 +344,4 @@ function IsValidJSONString(str) { } return true; } -/* Utility functions End */
\ No newline at end of file +/* Utility functions End */ diff --git a/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js b/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js index 56be83628..90b1b0075 100644 --- a/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js +++ b/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2019 Huawei. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,8 +84,8 @@ try { SERVICE_INSTANCE_ID + "?format=resource_and_url" executor.logger.info("Query url" + urlGet); - result = client.httpsRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlGet + " " + result); jsonObj = JSON.parse(result); @@ -122,8 +123,8 @@ try { putUpddateServInstance, null, 4)); var urlPut = HTTP_PROTOCOL + AAI_URL + putUrl + "?resource_version=" + resource_version; - result = client.httpsRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, - "application/json", true, true); + result = client.httpRequest(urlPut, "PUT", JSON.stringify(putUpddateServInstance), AAI_USERNAME, AAI_PASSWORD, + "application/json", true); executor.logger.info("Data received From " + urlPut + " " + result); /* If failure to retrieve data proceed to Failure */ if (result != "") { |