summaryrefslogtreecommitdiffstats
path: root/examples/examples-onap-bbs/src/main/resources/logic
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-onap-bbs/src/main/resources/logic')
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js4
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js78
2 files changed, 19 insertions, 63 deletions
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 60d4efed9..85977097f 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js
@@ -218,7 +218,7 @@ 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("access_id_value", getMetaValue(
+xmlCreateAccess = xmlCreateAccess.replace("remote_id_value", getMetaValue(
putUpddateServInstance['metadata']['metadatum'], 'remote-id'));
executor.logger.info(client.toPrettyString(xmlCreateAccess, 4));
@@ -299,7 +299,7 @@ xmlChangeProfile = xmlChangeProfile.replace("vendor_value", input_param[
xmlChangeProfile = xmlChangeProfile.replace("service_id_value", getMetaValue(
putUpddateServInstance['metadata']['metadatum'],
'controller-service-id'));
-xmlChangeProfile = xmlChangeProfile.replace("access_id_value", getMetaValue(
+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']);
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 86e4dfe1c..839956cc9 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js
@@ -39,7 +39,8 @@ var jsonObj;
var aaiUpdateResult = true;
var wbClient = Java.type("org.onap.policy.apex.examples.bbs.WebClient");
var client = new wbClient();
-
+var oldState = clEvent.getAai().get("cpe.old-authentication-state");
+var newState = clEvent.getAai().get("cpe.new-authentication-state");
/* Get AAI URL from Configuration file. */
var AAI_URL = "localhost:8080";
var CUSTOMER_ID = requestID;
@@ -78,17 +79,20 @@ try {
SERVICE_INSTANCE_ID + "?format=resource_and_url"
executor.logger.info("Query url" + urlGet);
- result = httpGet(urlGet).data;
+ result = client.httpsRequest(urlGet, "GET", null, AAI_USERNAME, AAI_PASSWORD,
+ "application/json", true, true);
executor.logger.info("Data received From " + urlGet + " " + result);
jsonObj = JSON.parse(result);
/* Retrieve the service instance id */
- results = jsonObj['results'];
+ results = jsonObj['results'][0];
putUrl = results["url"];
- service_instance = results["service-instance"];
+ service_instance = results['service-instance'];
resource_version = service_instance['resource-version'];
- executor.logger.info("After Parse " + JSON.stringify(jsonObj, null, 4));
+ 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;
@@ -101,10 +105,16 @@ try {
/* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */
var putUpddateServInstance;
putUpddateServInstance = service_instance;
-putUpddateServInstance["orchestration-status"] = "active";
+if (newState == 'inService') {
+ putUpddateServInstance['orchestration-status'] = "active";
+}
+else
+{
+ putUpddateServInstance['orchestration-status'] = "inActive";
+}
try {
if (aaiUpdateResult == true) {
- executor.logger.info("ready to putAfter Parse " + JSON.stringify(
+ executor.logger.info("ready to put After Parse " + JSON.stringify(
putUpddateServInstance, null, 4));
var urlPut = HTTP_PROTOCOL + AAI_URL +
putUrl + "?resource_version=" + resource_version;
@@ -131,57 +141,3 @@ executor.logger.info(executor.outFields);
var returnValue = executor.isTrue;
executor.logger.info("End Execution ServiceUpdateStateCpeAuthTask.js");
-
-function httpGet(theUrl) {
- var con = new java.net.URL(theUrl).openConnection();
- con.requestMethod = "GET";
- return asResponse(con);
-}
-
-function httpPost(theUrl, data, contentType) {
- contentType = contentType || "application/json";
- var con = new java.net.URL(theUrl).openConnection();
- con.requestMethod = "POST";
- con.setRequestProperty("Content-Type", contentType);
- con.doOutput = true;
- write(con.outputStream, data);
- return asResponse(con);
-}
-
-function httpPut(theUrl, data, contentType) {
- contentType = contentType || "application/json";
- var con = new java.net.URL(theUrl).openConnection();
- con.requestMethod = "PUT";
- con.setRequestProperty("Content-Type", contentType);
- con.doOutput = true;
- write(con.outputStream, data);
- return asResponse(con);
-}
-
-function asResponse(con) {
- var d = read(con.inputStream);
- return {
- data: d,
- statusCode: con.resultCode
- };
-}
-
-function write(outputStream, data) {
- var wr = new java.io.DataOutputStream(outputStream);
- wr.writeBytes(data);
- wr.flush();
- wr.close();
-}
-
-function read(inputStream) {
- var inReader = new java.io.BufferedReader(new java.io.InputStreamReader(
- inputStream));
- var inputLine;
- var result = new java.lang.StringBuffer();
-
- while ((inputLine = inReader.readLine()) != null) {
- result.append(inputLine);
- }
- inReader.close();
- return result.toString();
-} \ No newline at end of file