summaryrefslogtreecommitdiffstats
path: root/examples/examples-onap-bbs/src
diff options
context:
space:
mode:
authors00370346 <swarup.nayak1@huawei.com>2019-04-17 23:32:08 +0530
committers00370346 <swarup.nayak1@huawei.com>2019-04-22 10:20:54 +0530
commit39f7edcc4a181394b8895aef8b4b43a8a19b045b (patch)
treebb6445f96fcea9abf7391c45a29735b93bdc683c /examples/examples-onap-bbs/src
parente5f139e3c865eb429dc11a987ad7a01b759c6692 (diff)
ONAP BBS: Apex Nomadic ONT bug fixes
Issue-ID: DCAEGEN2-1237 Change-Id: I739f8e55113793f5cd4d3b70e0a1296d775bb414 Signed-off-by: s00370346 <swarup.nayak1@huawei.com>
Diffstat (limited to 'examples/examples-onap-bbs/src')
-rw-r--r--examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/NomadicONTPolicyModel_config.json7
-rw-r--r--examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/config.txt5
-rw-r--r--examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_ChangeInternetProfileInstance.txt81
-rw-r--r--examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_CreateAccessConnectivityInstance.txt61
-rw-r--r--examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_DeleteAccessConnectivityInstance.txt49
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js120
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js84
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/ErrorAAIServiceAssignedLogTask.js1
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/ErrorSdncResourceUpdateTaskLogTask.js1
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/GetBBSCloseLoopEventTask.js135
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/NomadicEventSuccessTask.js15
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/RUorInitStateSelect.js16
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/SU2orInitStateSelect.js15
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js397
-rw-r--r--examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js154
-rw-r--r--examples/examples-onap-bbs/src/main/resources/policy/NomadicONTPolicyModel.apex22
-rw-r--r--examples/examples-onap-bbs/src/main/resources/schemas/NomadicONTContextType.avsc (renamed from examples/examples-onap-bbs/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc)6
17 files changed, 860 insertions, 309 deletions
diff --git a/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/NomadicONTPolicyModel_config.json b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/NomadicONTPolicyModel_config.json
index eef2d99a6..f38bb8cd2 100644
--- a/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/NomadicONTPolicyModel_config.json
+++ b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/NomadicONTPolicyModel_config.json
@@ -56,11 +56,12 @@
}
},
"eventInputParameters": {
- "SecondConsumer": {
+ "DCAEConsumer": {
"carrierTechnologyParameters": {
- "carrierTechnology": "FILE",
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
"parameters": {
- "fileName": "examples/events/ONAPBBS/EventsIn.json.txt"
+ "url": "http://172.30.0.130:30227/events/unauthenticated.DCAE_CL_OUTPUT/g1/c1?timeout=60000"
}
},
"eventProtocolParameters": {
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 56b6821f7..794398be4 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,2 +1,3 @@
-AAI_URL=192.167.1.3:8080
-SDNC_URL=192.167.1.3:8080 \ No newline at end of file
+AAI_URL=aai.api.simpledemo.openecomp.org:30233
+SDNC_URL=aai.api.simpledemo.openecomp.org:8443
+SVC_NOTIFICATION_URL=http://c1.vm1.mso.simpledemo.openecomp.org:8080 \ No newline at end of file
diff --git a/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_ChangeInternetProfileInstance.txt b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_ChangeInternetProfileInstance.txt
new file mode 100644
index 000000000..2304e5739
--- /dev/null
+++ b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_ChangeInternetProfileInstance.txt
@@ -0,0 +1,81 @@
+<input>
+ <sdnc-request-header>
+ <svc-request-id>svc_request_id_value</svc-request-id>
+ <svc-action>update</svc-action>
+ <svc-notification-url>svc_notification_url_value</svc-notification-url>
+ </sdnc-request-header>
+ <request-information>
+ <request-id>request_id_value</request-id>
+ <request-action>ChangeInternetProfileInstance</request-action>
+ <source>null</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>service_id_value</service-id>
+ <service-instance-id>service_instance_id_value</service-instance-id>
+ <subscription-service-type>service_type_value</subscription-service-type>
+ <global-customer-id>customer_id_value</global-customer-id>
+ <subscriber-name>customer_name_value</subscriber-name>
+ <onap-model-information>
+ <model-invariant-uuid>srv_info_model_inv_uuid_value</model-invariant-uuid>
+ <model-customization-uuid>srv_info_model_custom_uuid_value</model-customization-uuid>
+ <model-uuid>srv_info_model_uuid_value</model-uuid>
+ <model-name>srv_info_model_name_value</model-name>
+ </onap-model-information>
+ </service-information>
+ <network-information>
+ <onap-model-information>
+ <model-invariant-uuid>network_info_model_inv_uuid_value</model-invariant-uuid>
+ <model-customization-uuid>network_info_model_custom_uuid_value</model-customization-uuid>
+ <model-uuid>network_info_model_uuid_value</model-uuid>
+ <model-name>network_info_model_name_value</model-name>
+ </onap-model-information>
+ </network-information>
+ <network-request-input>
+ <network-input-parameters>
+ <param>
+ <name>vendor</name>
+ <value>vendor_value</value>
+ </param>
+ <param>
+ <name>service_id</name>
+ <value>service_id_value</value>
+ </param>
+ <param>
+ <name>access_id</name>
+ <value>access_id_value</value>
+ </param>
+ <param>
+ <name>ont_sn</name>
+ <value>ont_sn_value</value>
+ </param>
+ <param>
+ <name>service_type</name>
+ <value>service_type_value</value>
+ </param>
+ <param>
+ <name>mac</name>
+ <value>mac_value</value>
+ </param>
+ <param>
+ <name>up_speed</name>
+ <value>up_speed_value</value>
+ </param>
+ <param>
+ <name>down_speed</name>
+ <value>down_speed_value</value>
+ </param>
+ <param>
+ <name>s_vlan</name>
+ <value>s_vlan_value</value>
+ </param>
+ <param>
+ <name>c_vlan</name>
+ <value>c_vlan_value</value>
+ </param>
+ </network-input-parameters>
+ </network-request-input>
+ <_xmlns>org:onap:sdnc:northbound:generic-resource</_xmlns>
+</input>
diff --git a/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_CreateAccessConnectivityInstance.txt b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_CreateAccessConnectivityInstance.txt
new file mode 100644
index 000000000..7410c0bc6
--- /dev/null
+++ b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_CreateAccessConnectivityInstance.txt
@@ -0,0 +1,61 @@
+<input>
+ <sdnc-request-header>
+ <svc-request-id>svc_request_id_value</svc-request-id>
+ <svc-action>create</svc-action>
+ <svc-notification-url>svc_notification_url_value</svc-notification-url>
+ </sdnc-request-header>
+ <request-information>
+ <request-id>request_id_value</request-id>
+ <request-action>CreateAccessConnectivityInstance</request-action>
+ <source>null</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>service_id_value</service-id>
+ <service-instance-id>service_instance_id_value</service-instance-id>
+ <subscription-service-type>service_type_value</subscription-service-type>
+ <global-customer-id>customer_id_value</global-customer-id>
+ <subscriber-name>customer_name_value</subscriber-name>
+ <onap-model-information>
+ <model-invariant-uuid>srv_info_model_inv_uuid_value</model-invariant-uuid>
+ <model-customization-uuid>srv_info_model_custom_uuid_value</model-customization-uuid>
+ <model-uuid>srv_info_model_uuid_value</model-uuid>
+ <model-name>srv_info_model_name_value</model-name>
+ </onap-model-information>
+ </service-information>
+ <network-information>
+ <onap-model-information>
+ <model-invariant-uuid>network_info_model_inv_uuid_value</model-invariant-uuid>
+ <model-customization-uuid>network_info_model_custom_uuid_value</model-customization-uuid>
+ <model-uuid>network_info_model_uuid_value</model-uuid>
+ <model-name>network_info_model_name_value</model-name>
+ </onap-model-information>
+ </network-information>
+ <network-request-input>
+ <network-input-parameters>
+ <param>
+ <name>vendor</name>
+ <value>vendor_value</value>
+ </param>
+ <param>
+ <name>ONTSN</name>
+ <value>ont_sn_value</value>
+ </param>
+ <param>
+ <name>CVLAN</name>
+ <value>c_vlan_value</value>
+ </param>
+ <param>
+ <name>SVLAN</name>
+ <value>s_vlan_value</value>
+ </param>
+ <param>
+ <name>accessID</name>
+ <value>access_id_value</value>
+ </param>
+ </network-input-parameters>
+ </network-request-input>
+ <_xmlns>org:onap:sdnc:northbound:generic-resource</_xmlns>
+</input>
diff --git a/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_DeleteAccessConnectivityInstance.txt b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_DeleteAccessConnectivityInstance.txt
new file mode 100644
index 000000000..e464e2ee1
--- /dev/null
+++ b/examples/examples-onap-bbs/src/main/resources/examples/config/ONAPBBS/sdnc_DeleteAccessConnectivityInstance.txt
@@ -0,0 +1,49 @@
+<input>
+ <sdnc-request-header>
+ <svc-request-id>svc_request_id_value</svc-request-id>
+ <svc-action>delete</svc-action>
+ <svc-notification-url>svc_notification_url_value</svc-notification-url>
+ </sdnc-request-header>
+ <request-information>
+ <request-id>request_id_value</request-id>
+ <request-action>DeleteAccessConnectivityInstance</request-action>
+ <source>null</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>service_id_value</service-id>
+ <service-instance-id>service_instance_id_value</service-instance-id>
+ <subscription-service-type>service_type_value</subscription-service-type>
+ <global-customer-id>customer_id_value</global-customer-id>
+ <subscriber-name>customer_name_value</subscriber-name>
+ <onap-model-information>
+ <model-invariant-uuid>srv_info_model_inv_uuid_value</model-invariant-uuid>
+ <model-customization-uuid>srv_info_model_custom_uuid_value</model-customization-uuid>
+ <model-uuid>srv_info_model_uuid_value</model-uuid>
+ <model-name>srv_info_model_name_value</model-name>
+ </onap-model-information>
+ </service-information>
+ <network-information>
+ <onap-model-information>
+ <model-invariant-uuid>network_info_model_inv_uuid_value</model-invariant-uuid>
+ <model-customization-uuid>network_info_model_custom_uuid_value</model-customization-uuid>
+ <model-uuid>network_info_model_uuid_value</model-uuid>
+ <model-name>network_info_model_name_value</model-name>
+ </onap-model-information>
+ </network-information>
+ <network-request-input>
+ <network-input-parameters>
+ <param>
+ <name>vendor</name>
+ <value>vendor_value</value>
+ </param>
+ <param>
+ <name>serviceID</name>
+ <value>serviceID_value</value>
+ </param>
+ </network-input-parameters>
+ </network-request-input>
+ <_xmlns>org:onap:sdnc:northbound:generic-resource</_xmlns>
+</input>
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 f488c27bf..744b6d48b 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceAssignedTask.js
@@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
load("nashorn:mozilla_compat.js");
importClass(org.apache.avro.Schema);
importClass(java.io.BufferedReader);
@@ -33,8 +32,9 @@ var attachmentPoint = executor.inFields.get("attachmentPoint");
var requestID = executor.inFields.get("requestID");
var serviceInstanceId = executor.inFields.get("serviceInstanceId");
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(attachmentPoint);
-executor.logger.info(vcpeClosedLoopStatus);
+var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(
+ attachmentPoint);
+executor.logger.info(NomadicONTContext);
var jsonObj;
var aaiUpdateResult = true;
@@ -42,14 +42,16 @@ var aaiUpdateResult = true;
/* Get AAI URL from Configuration file. */
var AAI_URL = "localhost:8080";
var CUSTOMER_ID = requestID;
-var BBS_CFS_SERVICE_TYPE = "BBS-CFS-Access_Test";
-var SERVICE_INSTANCE_UUID = serviceInstanceId;
-var service_instance_id;
+var SERVICE_INSTANCE_ID = serviceInstanceId;
var resource_version;
var relationship_list;
-var orchStatus;
+var HTTP_PROTOCOL = "https://";
+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"));
// read line by line
var line;
while ((line = br.readLine()) != null) {
@@ -63,12 +65,13 @@ try {
executor.logger.info("Failed to retrieve data " + err);
}
-executor.logger.info("AAI_URL=>" + AAI_URL);
+executor.logger.info("AAI_URL " + AAI_URL);
/* Get service instance Id from AAI */
try {
- //var urlGet = "https://" + AAI_URL + "/aai/v14/business/customers/customer/" + CUSTOMER_ID + "/service-subscriptions/service-subscription/" + BBS_CFS_SERVICE_TYPE + "/service-instances/service-instance/" + SERVICE_INSTANCE_UUID
- var urlGet = "http://" + AAI_URL + "/RestConfServer/rest/operations/policy/su1/getService";
+ var urlGet = HTTP_PROTOCOL + AAI_URL +
+ "/aai/v14/nodes/service-instances/service-instance/" +
+ SERVICE_INSTANCE_ID + "?format=resource_and_url";
executor.logger.info("Query url" + urlGet);
result = httpGet(urlGet).data;
@@ -77,34 +80,34 @@ try {
/* Retrieve the service instance id */
- service_instance_id = jsonObj['service-instance-id'];
- resource_version = jsonObj['resource-version'];
- relationship_list = jsonObj['relationship-list'];
+ results = jsonObj['results'];
+ putUrl = results["url"];
+ service_instance = results["service-instance"];
+ 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 " + JSON.stringify(jsonObj, null, 4));
if (result == "") {
aaiUpdateResult = false;
}
-}catch (err) {
+} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
aaiUpdateResult = false;
}
/* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */
-orchStatus = {
- "service-instance-id": service_instance_id,
- "resource-version": resource_version,
- "orchestration-status": "assigned",
- "relationship-list": relationship_list
- };
+var putUpddateServInstance;
+putUpddateServInstance = service_instance;
try {
if (aaiUpdateResult == true) {
- executor.logger.info("ready to putAfter Parse " + JSON.stringify(orchStatus, null, 4));
-
- //var urlPut = "https://" + AAI_URL + "/aai/v14/business/customers/customer/" + CUSTOMER_ID + "/service-subscriptions/service-subscription/" + BBS_CFS_SERVICE_TYPE + "/service-instances/service-instance/" + SERVICE_INSTANCE_UUID;
- var urlPut = "http://" + AAI_URL + "/RestConfServer/rest/operations/policy/su1/putOrchStatus";
- result = httpPut(urlPut, JSON.stringify(orchStatus)).data;
- executor.logger.info("Data received From " + urlPut + " " +result.toString());
+ 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 = httpPut(urlPut, JSON.stringify(putUpddateServInstance)).data;
+ executor.logger.info("Data received From " + urlPut + " " + result.toString());
jsonObj = JSON.parse(result);
executor.logger.info("After Parse " + JSON.stringify(jsonObj, null, 4));
@@ -113,98 +116,83 @@ try {
aaiUpdateResult = false;
}
}
-}catch (err) {
+} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
aaiUpdateResult = false;
}
-/* BBS Policy fetches from AAI {{bbs-cfs-service-instance-UUID}} relationship-list, including: CPE PNF ID, AccessConnectivity VF ID, InternetProfile VF ID */
-try {
- if (aaiUpdateResult == true) {
- var urlGet2 = "http://" + AAI_URL + "/RestConfServer/rest/operations/policy/su1/getHsia";
- //var urlGet2 = "https://"+ AAI_URL + "/aai/v11/business/customers/customer/" + CUSTOMER_ID + "/service-subscriptions/service-subscription/" + BBS_CFS_SERVICE_TYPE +"/service-instances/service-instance/"+ SERVICE_INSTANCE_UUID + "?depth=all"
- result = httpGet(urlGet2).data;
- executor.logger.info("Data received From " + urlGet2 + " " +result.toString());
- jsonObj = JSON.parse(result);
- executor.logger.info("After Parse " + JSON.stringify(jsonObj, null, 4));
-
- /* If failure to retrieve data proceed to Failure */
- if ((result == "") || (jsonObj['orchestration-status'] != 'assigned')) {
- executor.logger.info("Failed to get assigned status ");
- aaiUpdateResult = false;
- }
- }
-}catch (err) {
- executor.logger.info("Failed to retrieve data " + err);
- aaiUpdateResult = false;
-}
/* If Success then Fill output schema */
if (aaiUpdateResult === true) {
- vcpeClosedLoopStatus.put("result", "SUCCESS");
- vcpeClosedLoopStatus.put("aai_message", JSON.stringify(orchStatus));
+ NomadicONTContext.put("result", "SUCCESS");
+ NomadicONTContext.put("aai_message", JSON.stringify(service_instance));
+ NomadicONTContext.put("url", putUrl);
} else {
- vcpeClosedLoopStatus.put("result", "FAILURE");
+ NomadicONTContext.put("result", "FAILURE");
}
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(executor.outFields);
executor.logger.info("End Execution AAIServiceAssignedTask.js");
/* Utility functions Begin */
-function httpGet(theUrl){
+function httpGet(theUrl) {
var con = new java.net.URL(theUrl).openConnection();
con.requestMethod = "GET";
return asResponse(con);
}
-function httpPost(theUrl, data, contentType){
+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;
+ con.doOutput = true;
write(con.outputStream, data);
return asResponse(con);
}
-function httpPut(theUrl, data, contentType){
+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;
+ con.doOutput = true;
write(con.outputStream, data);
return asResponse(con);
}
-function asResponse(con){
+function asResponse(con) {
var d = read(con.inputStream);
- return {data : d, statusCode : con.resultCode};
+ return {
+ data: d,
+ statusCode: con.resultCode
+ };
}
-function write(outputStream, data){
+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));
+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);
+ result.append(inputLine);
}
inReader.close();
return result.toString();
}
-/* Utility functions End */
-
+/* Utility functions End */ \ No newline at end of file
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 e4f22369c..9ddc91e8c 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/AAIServiceCreateTask.js
@@ -37,9 +37,11 @@ var AAI_URL = "localhost:8080";
var CUSTOMER_ID = requestID;
var BBS_CFS_SERVICE_TYPE = "BBS-CFS-Access_Test";
var SERVICE_INSTANCE_UUID = serviceInstanceId;
+var HTTP_PROTOCOL = "https://";
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) {
@@ -53,106 +55,118 @@ try {
} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
}
-executor.logger.info("AAI_URL=>" + AAI_URL);
+executor.logger.info("AAI_URL " + AAI_URL);
var attachmentPoint = executor.inFields.get("attachmentPoint");
var requestID = executor.inFields.get("requestID");
var serviceInstanceId = executor.inFields.get("serviceInstanceId");
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(attachmentPoint);
-executor.logger.info(vcpeClosedLoopStatus);
+var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(
+ attachmentPoint);
+executor.logger.info(NomadicONTContext);
-var jsonObj = JSON.parse(vcpeClosedLoopStatus.get("aai_message"));
-
-jsonObj['orchestration-status'] = "created";
-executor.logger.info(" string" + JSON.stringify(jsonObj, null, 4));
+var putUpddateServInstance = JSON.parse(NomadicONTContext.get("aai_message"));
+putUpddateServInstance['orchestration-status'] = "created";
+executor.logger.info(" string" + JSON.stringify(putUpddateServInstance, null, 4));
+var resource_version = putUpddateServInstance['resource-version'];
+var putUrl = NomadicONTContext.get("url");
var aaiUpdateResult = true;
/*BBS Policy updates {{bbs-cfs-service-instance-UUID}} orchestration-status [ assigned --> created ]*/
try {
- //var urlPut = "https://" + AAI_URL + "/aai/v14/business/customers/customer/" + CUSTOMER_ID + "/service-subscriptions/service-subscription/" + BBS_CFS_SERVICE_TYPE + "/service-instances/service-instance/" + SERVICE_INSTANCE_UUID;
- var urlPut = "http://" + AAI_URL + "/RestConfServer/rest/operations/policy/su2/aaiUpdate";
- result = httpPut(urlPut, JSON.stringify(jsonObj)).data;
- executor.logger.info("Data received From " + urlPut + " " +result.toString());
- repos = JSON.parse(result);
- executor.logger.info("After Parse " + result.toString());
-
- if (result == "") {
- aaiUpdateResult = false;
+ 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 = httpPut(urlPut, JSON.stringify(putUpddateServInstance)).data;
+ executor.logger.info("Data received From " + urlPut + " " + result.toString());
+ jsonObj = JSON.parse(result);
+ executor.logger.info("After Parse " + JSON.stringify(jsonObj, null, 4));
+
+ /* If failure to retrieve data proceed to Failure */
+ if (result == "") {
+ aaiUpdateResult = false;
+ }
}
-}catch (err) {
+} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
aaiUpdateResult = false;
}
-
/* If Success then Fill output schema */
if (aaiUpdateResult === true) {
- vcpeClosedLoopStatus.put("result", "SUCCESS");
+ NomadicONTContext.put("result", "SUCCESS");
} else {
- vcpeClosedLoopStatus.put("result", "FAILURE");
+ NomadicONTContext.put("result", "FAILURE");
}
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(executor.outFields);
executor.logger.info("End Execution AAIServiceCreateTask.js");
+/* Utility functions Begin */
-function httpGet(theUrl){
+function httpGet(theUrl) {
var con = new java.net.URL(theUrl).openConnection();
con.requestMethod = "GET";
return asResponse(con);
}
-function httpPost(theUrl, data, contentType){
+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;
+ con.doOutput = true;
write(con.outputStream, data);
return asResponse(con);
}
-function httpPut(theUrl, data, contentType){
+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;
+ con.doOutput = true;
write(con.outputStream, data);
return asResponse(con);
}
-function asResponse(con){
+function asResponse(con) {
var d = read(con.inputStream);
- return {data : d, statusCode : con.resultCode};
+ return {
+ data: d,
+ statusCode: con.resultCode
+ };
}
-function write(outputStream, data){
+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));
+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);
+ result.append(inputLine);
}
inReader.close();
return result.toString();
}
-
+/* Utility functions End */ \ No newline at end of file
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/ErrorAAIServiceAssignedLogTask.js b/examples/examples-onap-bbs/src/main/resources/logic/ErrorAAIServiceAssignedLogTask.js
index ee646fa36..91316bc40 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/ErrorAAIServiceAssignedLogTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/ErrorAAIServiceAssignedLogTask.js
@@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
executor.logger.info("Begin Execution ErrorServiceUpdateOneLogTask.js");
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/ErrorSdncResourceUpdateTaskLogTask.js b/examples/examples-onap-bbs/src/main/resources/logic/ErrorSdncResourceUpdateTaskLogTask.js
index 19a61cabd..7ba674553 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/ErrorSdncResourceUpdateTaskLogTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/ErrorSdncResourceUpdateTaskLogTask.js
@@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
executor.logger.info("Begin Execution ErrorResourceUpdateLogTask.js");
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/GetBBSCloseLoopEventTask.js b/examples/examples-onap-bbs/src/main/resources/logic/GetBBSCloseLoopEventTask.js
index 06b11acd5..57fe182e1 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/GetBBSCloseLoopEventTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/GetBBSCloseLoopEventTask.js
@@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
load("nashorn:mozilla_compat.js");
executor.logger.info("Begin Execution GetBBSCloseLoopEventTask.js");
@@ -25,9 +24,8 @@ executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
var returnValue = executor.isTrue;
-//**************************************************************************//
-
-var clEventType = Java.type("org.onap.policy.controlloop.VirtualControlLoopEvent");
+var clEventType = Java.type(
+ "org.onap.policy.controlloop.VirtualControlLoopEvent");
var clEvent = executor.inFields.get("VirtualControlLoopEvent");
executor.logger.info(clEvent.toString());
executor.logger.info(clEvent.getClosedLoopControlName());
@@ -35,65 +33,80 @@ executor.logger.info(clEvent.getClosedLoopControlName());
var requestID = clEvent.getRequestId();
executor.logger.info("requestID = " + requestID);
var attachmentPoint = null;
-var vcpeClosedLoopStatus = null;
+var NomadicONTContext = null;
var serviceInstanceId = null;
if (clEvent.getAai().get("attachmentPoint") != null) {
- attachmentPoint = clEvent.getAai().get("attachmentPoint");
- executor.logger.info("attachmentPoint = " + attachmentPoint);
- vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(attachmentPoint);
- serviceInstanceId = clEvent.getAai().get("service-information.hsia-cfs-service-instance-id");
- executor.logger.info("serviceInstanceId = " + serviceInstanceId);
-
- if (vcpeClosedLoopStatus == null) {
- executor.logger.info("Creating context information for new ONT Device \"" + attachmentPoint.toString() + "\"");
-
- vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewInstance();
-
- vcpeClosedLoopStatus.put("closedLoopControlName", clEvent.getClosedLoopControlName());
- vcpeClosedLoopStatus.put("closedLoopAlarmStart", clEvent.getClosedLoopAlarmStart().toEpochMilli());
- vcpeClosedLoopStatus.put("closedLoopEventClient", clEvent.getClosedLoopEventClient());
- vcpeClosedLoopStatus.put("closedLoopEventStatus", clEvent.getClosedLoopEventStatus().toString());
- vcpeClosedLoopStatus.put("version", clEvent.getVersion());
- vcpeClosedLoopStatus.put("requestID", clEvent.getRequestId().toString());
- vcpeClosedLoopStatus.put("target_type", clEvent.getTargetType().toString());
- vcpeClosedLoopStatus.put("target", clEvent.getTarget());
- vcpeClosedLoopStatus.put("from", clEvent.getFrom());
- vcpeClosedLoopStatus.put("policyScope", "Nomadic ONT");
- vcpeClosedLoopStatus.put("policyName", clEvent.getPolicyName());
- vcpeClosedLoopStatus.put("policyVersion", "1.0.0");
- vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
- vcpeClosedLoopStatus.put("message", "");
- vcpeClosedLoopStatus.put("result", "SUCCESS");
- var aaiInfo = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type");
-
- aaiInfo.put("attachmentPoint", clEvent.getAai().get("attachmentPoint"));
- aaiInfo.put("cvlan", clEvent.getAai().get("cvlan"));
- aaiInfo.put("service_information_hsia_cfs_service_instance_id", clEvent.getAai().get("service-information.hsia-cfs-service-instance-id"));
- aaiInfo.put("svlan", clEvent.getAai().get("svlan"));
- aaiInfo.put("remoteId", clEvent.getAai().get("remoteId"));
-
-
- vcpeClosedLoopStatus.put("AAI", aaiInfo);
-
- if (clEvent.getClosedLoopAlarmEnd() != null) {
- vcpeClosedLoopStatus.put("closedLoopAlarmEnd", clEvent.getClosedLoopAlarmEnd().toEpochMilli());
- } else {
- vcpeClosedLoopStatus.put("closedLoopAlarmEnd", java.lang.Long.valueOf(0));
- }
-
- executor.getContextAlbum("VCPEClosedLoopStatusAlbum").put(attachmentPoint.toString(), vcpeClosedLoopStatus);
- executor.logger.info("Created context information for new vCPE VNF \"" + attachmentPoint.toString() + "\"");
- }
-
- executor.outFields.put("requestID", requestID);
- executor.outFields.put("attachmentPoint", attachmentPoint);
- executor.outFields.put("serviceInstanceId", attachmentPoint);
- executor.logger.info(executor.outFields);
+ attachmentPoint = clEvent.getAai().get("attachmentPoint");
+ executor.logger.info("attachmentPoint = " + attachmentPoint);
+ NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(
+ attachmentPoint);
+ serviceInstanceId = clEvent.getAai().get(
+ "service-information.hsia-cfs-service-instance-id");
+ executor.logger.info("serviceInstanceId = " + serviceInstanceId);
+
+ if (NomadicONTContext == null) {
+ executor.logger.info(
+ "Creating context information for new ONT Device \"" +
+ attachmentPoint.toString() + "\"");
+
+ NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").getSchemaHelper()
+ .createNewInstance();
+
+ NomadicONTContext.put("closedLoopControlName", clEvent.getClosedLoopControlName());
+ NomadicONTContext.put("closedLoopAlarmStart", clEvent.getClosedLoopAlarmStart()
+ .toEpochMilli());
+ NomadicONTContext.put("closedLoopEventClient", clEvent.getClosedLoopEventClient());
+ NomadicONTContext.put("closedLoopEventStatus", clEvent.getClosedLoopEventStatus()
+ .toString());
+ NomadicONTContext.put("version", clEvent.getVersion());
+ NomadicONTContext.put("requestID", clEvent.getRequestId().toString());
+ NomadicONTContext.put("target_type", clEvent.getTargetType().toString());
+ NomadicONTContext.put("target", clEvent.getTarget());
+ NomadicONTContext.put("from", clEvent.getFrom());
+ NomadicONTContext.put("policyScope", "Nomadic ONT");
+ NomadicONTContext.put("policyName", clEvent.getPolicyName());
+ NomadicONTContext.put("policyVersion", "1.0.0");
+ NomadicONTContext.put("notificationTime", java.lang.System.currentTimeMillis());
+ NomadicONTContext.put("message", "");
+ NomadicONTContext.put("result", "SUCCESS");
+ var aaiInfo = executor.getContextAlbum("NomadicONTContextAlbum").getSchemaHelper()
+ .createNewSubInstance("VCPE_AAI_Type");
+
+ aaiInfo.put("attachmentPoint", clEvent.getAai().get("attachmentPoint"));
+ aaiInfo.put("cvlan", clEvent.getAai().get("cvlan"));
+ aaiInfo.put("service_information_hsia_cfs_service_instance_id", clEvent
+ .getAai().get(
+ "service-information.hsia-cfs-service-instance-id"));
+ aaiInfo.put("svlan", clEvent.getAai().get("svlan"));
+ aaiInfo.put("remoteId", clEvent.getAai().get("remoteId"));
+
+
+ NomadicONTContext.put("AAI", aaiInfo);
+
+ if (clEvent.getClosedLoopAlarmEnd() != null) {
+ NomadicONTContext.put("closedLoopAlarmEnd", clEvent.getClosedLoopAlarmEnd()
+ .toEpochMilli());
+ } else {
+ NomadicONTContext.put("closedLoopAlarmEnd", java.lang.Long.valueOf(
+ 0));
+ }
+
+ executor.getContextAlbum("NomadicONTContextAlbum").put(attachmentPoint.toString(),
+ NomadicONTContext);
+ executor.logger.info("Created context information for new vCPE VNF \"" +
+ attachmentPoint.toString() + "\"");
+ }
+
+ executor.outFields.put("requestID", requestID);
+ executor.outFields.put("attachmentPoint", attachmentPoint);
+ executor.outFields.put("serviceInstanceId", serviceInstanceId);
+ executor.logger.info(executor.outFields);
+ executor.logger.info("Event Successfully Received and stored in album");
+}
+else
+{
+ executor.message = "Received NULL attachment-point";
+ returnValue = executor.isFalse;
}
-
-executor.logger.info("********************* Event Successfully Received and stored in album *********************");
-
-//**************************************************************************//
-
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/NomadicEventSuccessTask.js b/examples/examples-onap-bbs/src/main/resources/logic/NomadicEventSuccessTask.js
index f6a7c4ce7..36b21b8f4 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/NomadicEventSuccessTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/NomadicEventSuccessTask.js
@@ -25,22 +25,23 @@ executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
var attachmentPoint = executor.inFields.get("attachmentPoint");
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(attachmentPoint);
+var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(
+ attachmentPoint);
-executor.logger.info("==========>" + executor.outFields);
-executor.logger.info("==========>" + executor.inFields);
+executor.logger.info(executor.outFields);
+executor.logger.info(executor.inFields);
-result = vcpeClosedLoopStatus.get("result");
+result = NomadicONTContext.get("result");
if (result === "SUCCESS") {
returnValue = executor.isTrue;
executor.outFields.put("result", "SUCCCESS");
- executor.logger.info("BBS policy Execution Done$$$$$$$$$$$");
+ executor.logger.info("BBS policy Execution Done");
} else {
- executor.logger.info("BBS policy Execution Failed$$$$$$$$$$$");
+ executor.logger.info("BBS policy Execution Failed");
executor.outFields.put("result", "FAILURE");
returnValue = executor.isFalse;
}
var returnValue = executor.isTrue;
-executor.logger.info("End Execution NomadicEventSuccess.js");
+executor.logger.info("End Execution NomadicEventSuccess.js"); \ No newline at end of file
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/RUorInitStateSelect.js b/examples/examples-onap-bbs/src/main/resources/logic/RUorInitStateSelect.js
index 959eab772..6e609b1cc 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/RUorInitStateSelect.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/RUorInitStateSelect.js
@@ -25,19 +25,21 @@ var returnValue = executor.isTrue;
var result = null;
var attachmentPoint = executor.inFields.get("attachmentPoint");
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(attachmentPoint);
+var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(
+ attachmentPoint);
-executor.logger.info("==========>" + executor.outFields);
-executor.logger.info("==========>" + executor.inFields);
+executor.logger.info(executor.outFields);
+executor.logger.info(executor.inFields);
-result = vcpeClosedLoopStatus.get("result");
+result = NomadicONTContext.get("result");
if (result === "SUCCESS") {
executor.subject.getTaskKey("SdncResourceUpdateTask").copyTo(executor.selectedTask);
} else {
- executor.subject.getTaskKey("ErrorAAIServiceAssignedLogTask").copyTo(executor.selectedTask);
+ executor.subject.getTaskKey("ErrorAAIServiceAssignedLogTask").copyTo(
+ executor.selectedTask);
onsetFlag = executor.isFalse;
-}
+}
executor.logger.info("State Selected Task:" + executor.selectedTask);
-executor.logger.info("End Execution RUorInitStateSelect.js");
+executor.logger.info("End Execution RUorInitStateSelect.js"); \ No newline at end of file
diff --git a/examples/examples-onap-bbs/src/main/resources/logic/SU2orInitStateSelect.js b/examples/examples-onap-bbs/src/main/resources/logic/SU2orInitStateSelect.js
index 6b4c4ff34..214a76fe8 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/SU2orInitStateSelect.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/SU2orInitStateSelect.js
@@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
executor.logger.info("Begin Execution SU2orInitStateSelect.js");
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
@@ -26,19 +25,21 @@ var returnValue = executor.isTrue;
var result = null;
var attachmentPoint = executor.inFields.get("attachmentPoint");
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(attachmentPoint);
+var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(
+ attachmentPoint);
-executor.logger.info("==========>" + executor.outFields);
-executor.logger.info("==========>" + executor.inFields);
+executor.logger.info(executor.outFields);
+executor.logger.info(executor.inFields);
-result = vcpeClosedLoopStatus.get("result");
+result = NomadicONTContext.get("result");
if (result === "SUCCESS") {
executor.subject.getTaskKey("AAIServiceCreateTask").copyTo(executor.selectedTask);
} else {
- executor.subject.getTaskKey("SdncResourceUpdateErrorLogOutput").copyTo(executor.selectedTask);
+ executor.subject.getTaskKey("SdncResourceUpdateErrorLogOutput").copyTo(
+ executor.selectedTask);
onsetFlag = executor.isFalse;
}
executor.logger.info("State Selected Task:" + executor.selectedTask);
-executor.logger.info("End Execution RUorInitStateSelect.js"); \ No newline at end of file
+executor.logger.info("End Execution SU2orInitStateSelect.js"); \ No newline at end of file
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 6a302ea6a..033d778be 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/SdncResourceUpdateTask.js
@@ -17,13 +17,16 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
load("nashorn:mozilla_compat.js");
importClass(org.apache.avro.Schema);
importClass(java.io.BufferedReader);
importClass(java.io.IOException);
importClass(java.nio.file.Files);
importClass(java.nio.file.Paths);
+
+importPackage(org.json.XML);
+
+
executor.logger.info("Begin Execution SdncResourceUpdateTask.js");
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
@@ -31,14 +34,24 @@ executor.logger.info(executor.inFields);
var attachmentPoint = executor.inFields.get("attachmentPoint");
var requestID = executor.inFields.get("requestID");
var serviceInstanceId = executor.inFields.get("serviceInstanceId");
+var uuidType = Java.type("java.util.UUID");
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(attachmentPoint);
-executor.logger.info(vcpeClosedLoopStatus);
+
+
+var NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(
+ attachmentPoint);
+var sdncUUID = uuidType.randomUUID();
+executor.logger.info(NomadicONTContext);
var jsonObj;
var aaiUpdateResult = true;
var SDNC_URL = "localhost:8080";
+var HTTP_PROTOCOL ="https://"
+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"));
// read line by line
var line;
while ((line = br.readLine()) != null) {
@@ -46,118 +59,414 @@ try {
var str = line.split("=");
SDNC_URL = str[str.length - 1];
break;
+ } else if (line.startsWith("SVC_NOTIFICATION_URL")) {
+ var str = line.split("=");
+ SVC_NOTIFICATION_URL = str[str.length - 1];
+ break;
}
}
} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
}
-executor.logger.info("SDNC_URL=>" + SDNC_URL);
-
+executor.logger.info("SDNC_URL " + SDNC_URL);
+executor.logger.info("input param " + JSON.stringify(input_param,
+ null, 4));
var result;
var jsonObj;
-var aaiUpdateResult = true;
+var sdncUpdateResult = true;
+
+
/* BBS Policy calls SDN-C GR-API to delete AccessConnectivity VF ID */
-var json = {id: 1, someValue: "1234"};
+/* Prepare Data*/
+var xmlDeleteAccess = "";
+try {
+ var br = Files.newBufferedReader(Paths.get(
+ "/home/apexuser/examples/config/ONAPBBS/sdnc_DeleteAccessConnectivityInstance.txt"
+ ));
+ // read line by line
+ var line;
+ while ((line = br.readLine()) != null) {
+ xmlDeleteAccess += line;
+ }
+
+} catch (err) {
+ executor.logger.info("Failed to retrieve data " + err);
+}
+
+/* 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("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'
+ ], 'OLT'));
+xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_custom_uuid_value",
+ getResourceCustomizationUuid(input_param['service']['parameters'][
+ 'resources'
+ ], 'OLT'));
+xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_uuid_value",
+ getResourceUuid(input_param['service']['parameters']['resources'],
+ 'OLT'));
+xmlDeleteAccess = xmlDeleteAccess.replace("srv_info_model_name_value", "OLT");
+xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_inv_uuid_value",
+ getResourceInvariantUuid(input_param['service']['parameters'][
+ 'resources'
+ ], 'OLT'));
+xmlDeleteAccess = xmlDeleteAccess.replace(
+ "network_info_model_custom_uuid_value", getResourceCustomizationUuid(
+ input_param['service']['parameters']['resources'], 'OLT'));
+xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_uuid_value",
+ getResourceUuid(input_param['service']['parameters']['resources'],
+ 'OLT'));
+xmlDeleteAccess = xmlDeleteAccess.replace("network_info_model_name_value",
+ "OLT");
+
+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'));
+executor.logger.info("Delete Access Prfile " + xmlDeleteAccess);
+
try {
- var urlPost1 = "http://" + SDNC_URL + "/RestConfServer/rest/operations/policy/ru/createInstance";
- result = httpPost(urlPost1, JSON.stringify(json) ,"application/json").data;
- executor.logger.info("Data received From " + urlPost1 + " " +result.toString());
+ var urlPost1 = HTTP_PROTOCOL + SDNC_URL +
+ "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation";
+ result = httpDelete(urlPost1, xmlDeleteAccess, "application/xml").data;
+ executor.logger.info("Data received From " + urlPost1 + " " + result.toString());
jsonObj = JSON.parse(result);
executor.logger.info("After Parse " + jsonObj.toString());
if (result == "") {
- aaiUpdateResult = false;
+ sdncUpdateResult = false;
}
-}catch (err) {
+} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
- aaiUpdateResult = false;
+ sdncUpdateResult = false;
}
+
+
/* BBS Policy calls SDN-C GR-API to create new AccessConnectivity VF */
+
+/* Prepare Data*/
+var xmlCreateAccess = "";
try {
- if (aaiUpdateResult == true) {
- var json = {id: 2, someValue: "1234"};
- var urlPost2 = "http://" + SDNC_URL + "/RestConfServer/rest/operations/policy/ru/createInstance";
- result = httpPost(urlPost2, JSON.stringify(json), "application/json").data;
- executor.logger.info("Data received From " + urlPost2 + " " +result.toString());
+ var br = Files.newBufferedReader(Paths.get(
+ "/home/apexuser/examples/config/ONAPBBS/sdnc_CreateAccessConnectivityInstance.txt"
+ ));
+ // read line by line
+ var line;
+ while ((line = br.readLine()) != null) {
+ xmlCreateAccess += line;
+ }
+
+} catch (err) {
+ 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("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'
+ ], 'OLT'));
+xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value",
+ getResourceCustomizationUuid(input_param['service']['parameters'][
+ 'resources'
+ ], 'OLT'));
+xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value",
+ getResourceUuid(input_param['service']['parameters']['resources'],
+ 'OLT'));
+xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_name_value", "OLT");
+xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value",
+ getResourceInvariantUuid(input_param['service']['parameters'][
+ 'resources'
+ ], 'OLT'));
+xmlCreateAccess = xmlCreateAccess.replace(
+ "network_info_model_custom_uuid_value", getResourceCustomizationUuid(
+ input_param['service']['parameters']['resources'], 'OLT'));
+xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value",
+ getResourceUuid(input_param['service']['parameters']['resources'],
+ 'OLT'));
+xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value",
+ "OLT");
+
+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("access_id_value", getMetaValue(
+ putUpddateServInstance['metadata']['metadatum'], 'remote-id'));
+executor.logger.info("Create Access Prfile " + xmlCreateAccess);
+try {
+ if (sdncUpdateResult == true) {
+ var urlPost2 = HTTP_PROTOCOL + SDNC_URL +
+ "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation";
+ result = httpPost(urlPost2, xmlCreateAccess, "application/xml").data;
+ executor.logger.info("Data received From " + urlPost2 + " " + result.toString());
jsonObj = JSON.parse(result);
executor.logger.info("After Parse " + jsonObj.toString());
if (result == "") {
+ sdncUpdateResult = false;
}
}
-}catch (err) {
+} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
- aaiUpdateResult = false;
+ sdncUpdateResult = false;
+}
+
+
+
+/* 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"
+ ));
+ // read line by line
+ var line;
+ while ((line = br.readLine()) != null) {
+ xmlChangeProfile += line;
+ }
+
+} catch (err) {
+ executor.logger.info("Failed to retrieve data " + err);
+}
+
+xmlChangeProfile = xmlChangeProfile.replace("svc_request_id_value", sdncUUID);
+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'
+ ], 'EdgeInternetProfile'));
+xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_custom_uuid_value",
+ getResourceCustomizationUuid(input_param['service']['parameters'][
+ 'resources'
+ ], 'EdgeInternetProfile'));
+xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_uuid_value",
+ getResourceUuid(input_param['service']['parameters']['resources'],
+ 'EdgeInternetProfile'));
+xmlCreateAccess = xmlCreateAccess.replace("srv_info_model_name_value",
+ "EdgeInternetProfile");
+xmlCreateAccess = xmlCreateAccess.replace("network_info_model_inv_uuid_value",
+ getResourceInvariantUuid(input_param['service']['parameters'][
+ 'resources'
+ ], 'EdgeInternetProfile'));
+xmlCreateAccess = xmlCreateAccess.replace(
+ "network_info_model_custom_uuid_value", getResourceCustomizationUuid(
+ input_param['service']['parameters']['resources'],
+ 'EdgeInternetProfile'));
+xmlCreateAccess = xmlCreateAccess.replace("network_info_model_uuid_value",
+ getResourceUuid(input_param['service']['parameters']['resources'],
+ 'EdgeInternetProfile'));
+xmlCreateAccess = xmlCreateAccess.replace("network_info_model_name_value",
+ "EdgeInternetProfile");
+
+
+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'));
+xmlChangeProfile = xmlChangeProfile.replace("access_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'));
+xmlChangeProfile = xmlChangeProfile.replace("up_speed_value", getMetaValue(
+ putUpddateServInstance['metadata']['metadatum'], 'up-speed'));
+xmlChangeProfile = xmlChangeProfile.replace("down_speed_value", getMetaValue(
+ putUpddateServInstance['metadata']['metadatum'], 'down-speed'));
+xmlChangeProfile = xmlChangeProfile.replace("s_vlan_value", getMetaValue(
+ putUpddateServInstance['metadata']['metadatum'], 'svlan'));
+xmlChangeProfile = xmlChangeProfile.replace("c_vlan_value", getMetaValue(
+ putUpddateServInstance['metadata']['metadatum'], 'cvlan'));
+executor.logger.info("Change Internet Profile " + xmlChangeProfile);
+
+try {
+ if (sdncUpdateResult == true) {
+ var urlPost3 = HTTP_PROTOCOL + SDNC_URL + "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation";
+ result = httpPost(urlPost3, xmlChangeProfile, "application/xml").data;
+ executor.logger.info("Data received From " + urlPost3 + " " + result.toString());
+ jsonObj = JSON.parse(result);
+ executor.logger.info("After Parse " + jsonObj.toString());
+
+ if (result == "") {
+ sdncUpdateResult = false;
+ }
+ }
+} catch (err) {
+ executor.logger.info("Failed to retrieve data " + err);
+ sdncUpdateResult = false;
}
/* If Success then Fill output schema */
-if (aaiUpdateResult === true) {
- vcpeClosedLoopStatus.put("result", "SUCCESS");
+
+if (sdncUpdateResult === true) {
+ NomadicONTContext.put("result", "SUCCESS");
} else {
- vcpeClosedLoopStatus.put("result", "FAILURE");
+ NomadicONTContext.put("result", "FAILURE");
}
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(executor.outFields);
executor.logger.info("End Execution SdncResourceUpdateTask.js");
+function getMetaValue(metaJson, metaname) {
+ for (var i = 0; i < metaJson.length; i++) {
+ if (metaJson[i]['metaname'] == metaname) {
+ var metaValue = metaJson[i]['metaval'];
+ return metaValue;
+ }
+ }
+
+}
+
+function getResourceInvariantUuid(resJson, resourceName) {
+ for (var i = 0; i < resJson.length; i++) {
+ if (resJson[i]['resourceName'] == resourceName) {
+ var resValue = resJson[i]['resourceInvariantUuid'];
+ return resValue;
+ }
+ }
+
+}
+
+function getResourceUuid(resJson, resourceName) {
+ for (var i = 0; i < resJson.length; i++) {
+ if (resJson[i]['resourceName'] == resourceName) {
+ var resValue = resJson[i]['resourceUuid'];
+ return resValue;
+ }
+ }
+
+}
+
+function getResourceCustomizationUuid(resJson, resourceName) {
+ for (var i = 0; i < resJson.length; i++) {
+ if (resJson[i]['resourceName'] == resourceName) {
+ var resValue = resJson[i]['resourceCustomizationUuid'];
+ return resValue;
+ }
+ }
+
+}
+
/* Utility functions Begin */
-function httpGet(theUrl){
+function httpGet(theUrl) {
var con = new java.net.URL(theUrl).openConnection();
con.requestMethod = "GET";
return asresult(con);
}
-function httpPost(theUrl, data, contentType){
+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;
+ con.doOutput = true;
+ write(con.outputStream, data);
+ return asresult(con);
+}
+
+function httpDelete(theUrl, data, contentType) {
+ contentType = contentType || "application/json";
+ var con = new java.net.URL(theUrl).openConnection();
+ con.requestMethod = "DELETE";
+ con.setRequestProperty("Content-Type", contentType);
+ con.doOutput = true;
write(con.outputStream, data);
return asresult(con);
}
-function httpPut(theUrl, data, contentType){
+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;
+ con.doOutput = true;
write(con.outputStream, data);
return asresult(con);
}
-function asresult(con){
+function asresult(con) {
var d = read(con.inputStream);
- return {data : d, statusCode : con.resultCode};
+ return {
+ data: d,
+ statusCode: con.resultCode
+ };
}
-function write(outputStream, data){
+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();
+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);
+ while ((inputLine = inReader.readLine()) != null) {
+ result.append(inputLine);
+ }
+ inReader.close();
+ return result.toString();
}
- inReader.close();
- return result.toString();
-}
-/* Utility functions End */
+ /* Utility functions End */ \ No newline at end of file
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 9c48f0d52..62c280531 100644
--- a/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js
+++ b/examples/examples-onap-bbs/src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js
@@ -17,31 +17,39 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
load("nashorn:mozilla_compat.js");
importClass(java.io.BufferedReader);
importClass(java.io.IOException);
importClass(java.nio.file.Files);
importClass(java.nio.file.Paths);
+
executor.logger.info("Begin Execution ServiceUpdateStateCpeAuthTask.js");
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
-var returnValue = executor.isTrue;
-//**************************************************************************//
-
-var clEventType = Java.type("org.onap.policy.controlloop.VirtualControlLoopEvent");
+var clEventType = Java.type(
+ "org.onap.policy.controlloop.VirtualControlLoopEvent");
var clEvent = executor.inFields.get("VirtualControlLoopEvent");
-executor.logger.info(clEvent.toString());
-executor.logger.info(clEvent.getClosedLoopControlName());
+var serviceInstanceId = clEvent.getAai().get(
+ "service-information.hsia-cfs-service-instance-id");
var requestID = clEvent.getRequestId();
-executor.logger.info("requestID = " + requestID);
-var attachmentPoint = null;
-var serviceInstanceId = null;
+
+var jsonObj;
+var aaiUpdateResult = true;
+
+/* Get AAI URL from Configuration file. */
var AAI_URL = "localhost:8080";
+var CUSTOMER_ID = requestID;
+var SERVICE_INSTANCE_ID = serviceInstanceId;
+var resource_version;
+var HTTP_PROTOCOL = "https://";
+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"));
// read line by line
var line;
while ((line = br.readLine()) != null) {
@@ -50,106 +58,126 @@ try {
AAI_URL = str[str.length - 1];
break;
}
-
}
} catch (err) {
executor.logger.info("Failed to retrieve data " + err);
}
+
executor.logger.info("AAI_URL=>" + AAI_URL);
-if (clEvent.getAai().get("attachmentPoint") != null) {
- attachmentPoint = clEvent.getAai().get("attachmentPoint");
- executor.logger.info("attachmentPoint = " + attachmentPoint);
- serviceInstanceId = clEvent.getAai().get("service-information.hsia-cfs-service-instance-id");
- executor.logger.info("serviceInstanceId = " + serviceInstanceId);
-
- var result;
- var jsonObj;
- var prevResult = true;
-
-
- /*BBS Policy updates {{bbs-cfs-service-instance-UUID}} orchestration-status [ assigned --> created ]*/
- var json = {id: 1, someValue: "1234"};
- try {
- var urlPut = "http://" + AAI_URL + "/RestConfServer/rest/operations/policy/cpe/cpeAuthUpdate";
- result = httpPut(urlPut, JSON.stringify(json)).data;
- executor.logger.info("Data received From " + urlPut + " " +result.toString());
- repos = JSON.parse(result);
- executor.logger.info("After Parse " + result.toString());
-
- if (result == "") {
- prevResult = false;
- }
- }catch (err) {
- executor.logger.info("Failed to retrieve data " + err);
- prevResult = false;
- }
-
- /* If Success then Fill output schema */
- if (prevResult == true) {
- executor.outFields.put("result", "SUCCCESS");
- } else {
- executor.outFields.put("result", "FAILURE");
- }
-
- executor.outFields.put("requestID", requestID);
- executor.outFields.put("attachmentPoint", attachmentPoint);
- executor.outFields.put("serviceInstanceId", attachmentPoint);
- executor.logger.info(executor.outFields);
+/* Get service instance Id from AAI */
+try {
+ var urlGet = HTTP_PROTOCOL + AAI_URL +
+ "/aai/v14/nodes/service-instances/service-instance/" +
+ SERVICE_INSTANCE_ID + "?format=resource_and_url"
+ executor.logger.info("Query url" + urlGet);
+
+ result = httpGet(urlGet).data;
+ executor.logger.info("Data received From " + urlGet + " " + result.toString());
+ jsonObj = JSON.parse(result);
+
+
+ /* Retrieve the service instance id */
+ results = jsonObj['results'];
+ putUrl = results["url"];
+ service_instance = results["service-instance"];
+ resource_version = service_instance['resource-version'];
+ executor.logger.info("After Parse " + JSON.stringify(jsonObj, null, 4));
+
+ if (result == "") {
+ aaiUpdateResult = false;
+ }
+} catch (err) {
+ executor.logger.info("Failed to retrieve data " + err);
+ aaiUpdateResult = false;
}
+/* BBS Policy updates orchestration status of {{bbs-cfs-service-instance-UUID}} [ active --> assigned ] */
+var putUpddateServInstance;
+putUpddateServInstance = service_instance;
+putUpddateServInstance["orchestration-status"] = "active";
+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 = httpPut(urlPut, JSON.stringify(putUpddateServInstance)).data;
+ executor.logger.info("Data received From " + urlPut + " " + result.toString());
+ jsonObj = JSON.parse(result);
+ executor.logger.info("After Parse " + JSON.stringify(jsonObj, null, 4));
+
+ /* If failure to retrieve data proceed to Failure */
+ if (result == "") {
+ aaiUpdateResult = false;
+ }
+ }
+} catch (err) {
+ executor.logger.info("Failed to retrieve data " + err);
+ aaiUpdateResult = false;
+}
+if (aaiUpdateResult == true) {
+ executor.outFields.put("result", "SUCCCESS");
+} else {
+ executor.outFields.put("result", "FAILURE");
+}
+executor.logger.info(executor.outFields);
var returnValue = executor.isTrue;
executor.logger.info("End Execution ServiceUpdateStateCpeAuthTask.js");
-function httpGet(theUrl){
+function httpGet(theUrl) {
var con = new java.net.URL(theUrl).openConnection();
con.requestMethod = "GET";
return asResponse(con);
}
-function httpPost(theUrl, data, contentType){
+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;
+ con.doOutput = true;
write(con.outputStream, data);
return asResponse(con);
}
-function httpPut(theUrl, data, contentType){
+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;
+ con.doOutput = true;
write(con.outputStream, data);
return asResponse(con);
}
-function asResponse(con){
+function asResponse(con) {
var d = read(con.inputStream);
- return {data : d, statusCode : con.resultCode};
+ return {
+ data: d,
+ statusCode: con.resultCode
+ };
}
-function write(outputStream, data){
+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));
+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);
+ result.append(inputLine);
}
inReader.close();
return result.toString();
-}
+} \ No newline at end of file
diff --git a/examples/examples-onap-bbs/src/main/resources/policy/NomadicONTPolicyModel.apex b/examples/examples-onap-bbs/src/main/resources/policy/NomadicONTPolicyModel.apex
index e3f319661..108459eca 100644
--- a/examples/examples-onap-bbs/src/main/resources/policy/NomadicONTPolicyModel.apex
+++ b/examples/examples-onap-bbs/src/main/resources/policy/NomadicONTPolicyModel.apex
@@ -30,12 +30,12 @@ schema create name=UUIDType flavour=Java schema=java.util.UUID
schema create name=VirtualControlLoopEventType flavour=Java schema=org.onap.policy.controlloop.VirtualControlLoopEvent
-schema create name=VCPEClosedLoopStatusType flavour=Avro schema=LS
-#MACROFILE:"src/main/resources/schemas/VCPEClosedLoopStatusType.avsc"
+schema create name=NomadicONTContextType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/NomadicONTContextType.avsc"
LE
#=======================> Create Albums
-album create name=VCPEClosedLoopStatusAlbum scope=policy writable=true schemaName=VCPEClosedLoopStatusType
+album create name=NomadicONTContextAlbum scope=policy writable=true schemaName=NomadicONTContextType
#===================================> Define Events
@@ -92,7 +92,7 @@ task inputfield create name=GetBBSCloseLoopEventTask fieldName=VirtualControlLoo
task outputfield create name=GetBBSCloseLoopEventTask fieldName=requestID schemaName=UUIDType
task outputfield create name=GetBBSCloseLoopEventTask fieldName=attachmentPoint schemaName=SimpleStringType
task outputfield create name=GetBBSCloseLoopEventTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true
-task contextref create name=GetBBSCloseLoopEventTask albumName=VCPEClosedLoopStatusAlbum
+task contextref create name=GetBBSCloseLoopEventTask albumName=NomadicONTContextAlbum
task logic create name=GetBBSCloseLoopEventTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/GetBBSCloseLoopEventTask.js"
@@ -107,7 +107,7 @@ task outputfield create name=AAIServiceAssignedTask fieldName=requestID schemaNa
task outputfield create name=AAIServiceAssignedTask fieldName=attachmentPoint schemaName=SimpleStringType
task outputfield create name=AAIServiceAssignedTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true
-task contextref create name=AAIServiceAssignedTask albumName=VCPEClosedLoopStatusAlbum
+task contextref create name=AAIServiceAssignedTask albumName=NomadicONTContextAlbum
task logic create name=AAIServiceAssignedTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/AAIServiceAssignedTask.js"
@@ -133,7 +133,7 @@ task inputfield create name=SdncResourceUpdateTask fieldName=serviceInstanceId
task outputfield create name=SdncResourceUpdateTask fieldName=requestID schemaName=UUIDType
task outputfield create name=SdncResourceUpdateTask fieldName=attachmentPoint schemaName=SimpleStringType
task outputfield create name=SdncResourceUpdateTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true
-task contextref create name=SdncResourceUpdateTask albumName=VCPEClosedLoopStatusAlbum
+task contextref create name=SdncResourceUpdateTask albumName=NomadicONTContextAlbum
task logic create name=SdncResourceUpdateTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/SdncResourceUpdateTask.js"
@@ -160,7 +160,7 @@ task outputfield create name=AAIServiceCreateTask fieldName=requestID schemaName
task outputfield create name=AAIServiceCreateTask fieldName=attachmentPoint schemaName=SimpleStringType
task outputfield create name=AAIServiceCreateTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true
task outputfield create name=AAIServiceCreateTask fieldName=result schemaName=SimpleStringType
-task contextref create name=AAIServiceCreateTask albumName=VCPEClosedLoopStatusAlbum
+task contextref create name=AAIServiceCreateTask albumName=NomadicONTContextAlbum
task logic create name=AAIServiceCreateTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/AAIServiceCreateTask.js"
@@ -172,7 +172,7 @@ task inputfield create name=NomadicEventSuccessTask fieldName=requestID schemaNa
task inputfield create name=NomadicEventSuccessTask fieldName=attachmentPoint schemaName=SimpleStringType
task inputfield create name=NomadicEventSuccessTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true
task outputfield create name=NomadicEventSuccessTask fieldName=result schemaName=SimpleStringType optional=true
-task contextref create name=NomadicEventSuccessTask albumName=VCPEClosedLoopStatusAlbum
+task contextref create name=NomadicEventSuccessTask albumName=NomadicONTContextAlbum
task logic create name=NomadicEventSuccessTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/NomadicEventSuccessTask.js"
@@ -187,7 +187,7 @@ task outputfield create name=ServiceUpdateStateCpeAuthTask fieldName=result sche
task outputfield create name=ServiceUpdateStateCpeAuthTask fieldName=requestID schemaName=UUIDType
task outputfield create name=ServiceUpdateStateCpeAuthTask fieldName=attachmentPoint schemaName=SimpleStringType
task outputfield create name=ServiceUpdateStateCpeAuthTask fieldName=serviceInstanceId schemaName=SimpleStringType optional=true
-task contextref create name=ServiceUpdateStateCpeAuthTask albumName=VCPEClosedLoopStatusAlbum
+task contextref create name=ServiceUpdateStateCpeAuthTask albumName=NomadicONTContextAlbum
task logic create name=ServiceUpdateStateCpeAuthTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/ServiceUpdateStateCpeAuthTask.js"
@@ -209,7 +209,7 @@ policy state taskref create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CRE
policy state output create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE outputName=SdncResourceUpdateErrorLogOutput eventName=ERROR_LOG
policy state taskref create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE taskName=ErrorSdncResourceUpdateTaskLogTask outputType=DIRECT outputName=SdncResourceUpdateErrorLogOutput
-policy state contextref create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE albumName=VCPEClosedLoopStatusAlbum
+policy state contextref create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE albumName=NomadicONTContextAlbum
policy state selecttasklogic create name=ONTRegistrationPolicy stateName=AAI_SERVICE_CREATE logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/SU2orInitStateSelect.js"
@@ -225,7 +225,7 @@ policy state taskref create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE
policy state output create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE outputName=AAIServiceAssignedErrorLogOutput eventName=ERROR_LOG
policy state taskref create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE taskName=ErrorAAIServiceAssignedLogTask outputType=DIRECT outputName=AAIServiceAssignedErrorLogOutput
-policy state contextref create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE albumName=VCPEClosedLoopStatusAlbum
+policy state contextref create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE albumName=NomadicONTContextAlbum
policy state selecttasklogic create name=ONTRegistrationPolicy stateName=SDNC_RES_UPDATE logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/RUorInitStateSelect.js"
diff --git a/examples/examples-onap-bbs/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc b/examples/examples-onap-bbs/src/main/resources/schemas/NomadicONTContextType.avsc
index 5d1b317a8..2eaeb7159 100644
--- a/examples/examples-onap-bbs/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc
+++ b/examples/examples-onap-bbs/src/main/resources/schemas/NomadicONTContextType.avsc
@@ -1,6 +1,6 @@
{
"type": "record",
- "name": "VCPEClosedLoopStatus",
+ "name": "NomadicONTContext",
"fields": [
{
"name": "AAI",
@@ -101,6 +101,10 @@
"type": "string"
},
{
+ "name": "url",
+ "type": "string"
+ },
+ {
"name": "aai_message",
"type": "string"
}