aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/config.txt1
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js113
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js6
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js10
4 files changed, 125 insertions, 5 deletions
diff --git a/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/config.txt b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/config.txt
index 3db686867..162335d47 100644
--- a/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/config.txt
+++ b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/config.txt
@@ -1,6 +1,7 @@
AAI_URL=aai:8443
AAI_USERNAME=AAI
AAI_PASSWORD=AAI
+AAI_VERSION=v14
SDNC_URL=sdnc:8282
SDNC_USERNAME=admin
SDNC_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
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 9d38db1b4..419ce4350 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js
@@ -47,6 +47,7 @@ var client = new wbClient();
var AAI_URL = "localhost:8080";
var CUSTOMER_ID = requestID;
var SERVICE_INSTANCE_ID = serviceInstanceId;
+var AAI_VERSION = "v14";
var resource_version;
var relationship_list;
var HTTP_PROTOCOL = "https://";
@@ -67,6 +68,9 @@ try {
} else if (line.startsWith("AAI_PASSWORD")) {
var str = line.split("=");
AAI_PASSWORD = str[str.length - 1];
+ } else if (line.startsWith("AAI_VERSION")) {
+ var str = line.split("=");
+ AAI_VERSION = str[str.length - 1];
}
}
} catch (err) {
@@ -78,7 +82,7 @@ executor.logger.info("AAI_URL " + AAI_URL);
/* Get service instance Id from AAI */
try {
var urlGet = HTTP_PROTOCOL + AAI_URL +
- "/aai/v14/nodes/service-instances/service-instance/" +
+ "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" +
SERVICE_INSTANCE_ID + "?format=resource_and_url";
executor.logger.info("Query url" + urlGet);
@@ -108,6 +112,8 @@ try {
aaiUpdateResult = false;
}
+
+
/* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */
var putUpddateServInstance;
putUpddateServInstance = service_instance;
@@ -138,6 +144,111 @@ if (!service_instance.hasOwnProperty('input-parameters') || !service_instance
executor.logger.info(
"Validate data failed. input-parameters or metadata is missing");
}
+
+/* update logical link in pnf */
+var oldLinkName = "";
+try {
+ if (aaiUpdateResult == true) {
+ var pnfName = "";
+ var pnfResponse;
+ 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") {
+ 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);
+ executor.logger.info("Data received From " + urlGetPnf + " " + pnfResponse);
+ /* If failure to retrieve data proceed to Failure */
+ if (result != "") {
+ aaiUpdateResult = false;
+ }
+ 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);
+ executor.logger.info("Data received From " + urlNewLogicalLink + " " + result);
+ /* If failure to retrieve data proceed to Failure */
+ if (result != "") {
+ aaiUpdateResult = false;
+ }
+
+ /*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;
+ 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") {
+ oldLinkName = pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-value'];
+ pnfUpdate["relationship-list"]["relationship"][i]['relationship-data'][j]['relationship-value'] = link_name;
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ 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);
+ executor.logger.info("Data received From " + urlPutPnf + " " + result);
+
+ /* If failure to retrieve data proceed to Failure */
+ if (result != "") {
+ aaiUpdateResult = false;
+ }
+
+ /* 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"));
+ 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);
+ executor.logger.info("Delete called for " + urlDelOldLogicalLink + " result " + result);
+ }
+ }
+} catch (err) {
+ executor.logger.info("Failed to retrieve data " + err);
+ aaiUpdateResult = false;
+}
+
/* If Success then Fill output schema */
if (aaiUpdateResult === true) {
executor.outFields.put("result", "SUCCESS");
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 a1c11adae..5d18f23b0 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js
@@ -41,6 +41,7 @@ var AAI_URL = "localhost:8080";
var CUSTOMER_ID = requestID;
var BBS_CFS_SERVICE_TYPE = "BBS-CFS-Access_Test";
var SERVICE_INSTANCE_ID = serviceInstanceId;
+var AAI_VERSION = "v14";
var HTTP_PROTOCOL = "https://";
var wbClient = Java.type("org.onap.policy.apex.examples.bbs.WebClient");
var client = new wbClient();
@@ -61,6 +62,9 @@ try {
} else if (line.startsWith("AAI_PASSWORD")) {
var str = line.split("=");
AAI_PASSWORD = str[str.length - 1];
+ } else if (line.startsWith("AAI_VERSION")) {
+ var str = line.split("=");
+ AAI_VERSION = str[str.length - 1];
}
}
} catch (err) {
@@ -71,7 +75,7 @@ var aaiUpdateResult = true;
/* Get service instance Id from AAI */
try {
var urlGet = HTTP_PROTOCOL + AAI_URL +
- "/aai/v14/nodes/service-instances/service-instance/" +
+ "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" +
SERVICE_INSTANCE_ID + "?format=resource_and_url";
executor.logger.info("Query url" + urlGet);
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 839956cc9..56be83628 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js
@@ -50,6 +50,7 @@ var HTTP_PROTOCOL = "https://";
var results;
var putUrl;
var service_instance;
+var AAI_VERSION = "v14";
try {
var br = Files.newBufferedReader(Paths.get(
"/home/apexuser/examples/config/ONAPBBS/config.txt"));
@@ -64,8 +65,11 @@ try {
} else if (line.startsWith("AAI_PASSWORD")) {
var str = line.split("=");
AAI_PASSWORD = str[str.length - 1];
- }
- }
+ }else if (line.startsWith("AAI_VERSION")) {
+ var str = line.split("=");
+ AAI_VERSION = str[str.length - 1];
+ }
+ }
} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
}
@@ -75,7 +79,7 @@ executor.logger.info("AAI_URL=>" + AAI_URL);
/* Get service instance Id from AAI */
try {
var urlGet = HTTP_PROTOCOL + AAI_URL +
- "/aai/v14/nodes/service-instances/service-instance/" +
+ "/aai/" + AAI_VERSION + "/nodes/service-instances/service-instance/" +
SERVICE_INSTANCE_ID + "?format=resource_and_url"
executor.logger.info("Query url" + urlGet);