aboutsummaryrefslogtreecommitdiffstats
path: root/examples/examples-onap-vcpe/src/main/resources/logic
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-onap-vcpe/src/main/resources/logic')
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js51
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js69
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/AAILookupTask.js85
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js31
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js54
5 files changed, 102 insertions, 188 deletions
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js
deleted file mode 100644
index cab75f6cd..000000000
--- a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-executor.logger.info(executor.subject.id);
-executor.logger.info(executor.inFields);
-
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
- executor.inFields.get("vnfID").toString());
-
-var aaiRequest = new org.onap.policy.aai.AaiNqRequest;
-aaiRequest.setQueryParameters(new org.onap.policy.aai.AaiNqQueryParameters);
-aaiRequest.setInstanceFilters(new org.onap.policy.aai.AaiNqInstanceFilters);
-
-aaiRequest.getQueryParameters().setNamedQuery(new org.onap.policy.aai.AaiNqNamedQuery);
-aaiRequest.getQueryParameters().getNamedQuery().setNamedQueryUuid(executor.inFields.get("requestID"));
-
-var genericVnfInstanceFilterMap = new java.util.HashMap();
-genericVnfInstanceFilterMap.put("vnf-id", vcpeClosedLoopStatus.get("AAI").get("genericVnfVnfId"));
-
-var genericVnfFilterMap = new java.util.HashMap();
-genericVnfFilterMap.put("generic-vnf", genericVnfInstanceFilterMap);
-
-aaiRequest.getInstanceFilters().getInstanceFilter().add(genericVnfFilterMap);
-
-executor.logger.info(aaiRequest);
-
-executor.outFields.put("AAINamedQueryRequest", aaiRequest);
-
-executor.getContextAlbum("ControlLoopExecutionIDAlbum").put(executor.executionId.toString(),
- executor.inFields.get("vnfID"));
-
-executor.logger.info(executor.outFields);
-
-var returnValue = executor.isTrue; \ No newline at end of file
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js
deleted file mode 100644
index 50961c214..000000000
--- a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-executor.logger.info(executor.subject.id);
-executor.logger.info(executor.inFields);
-
-var vnfID = executor.getContextAlbum("ControlLoopExecutionIDAlbum").remove(executor.executionId.toString());
-
-executor.logger.info("Continuing execution with VNF ID: " + vnfID);
-
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID.toString());
-executor.logger.info(vcpeClosedLoopStatus);
-
-var aaiResponse = executor.inFields.get("AAINamedQueryResponse");
-
-for (var iterator = aaiResponse.getInventoryResponseItems().iterator(); iterator.hasNext(); ) {
- var responseItem = iterator.next();
-
- if (responseItem.getModelName() != "vCPE") {
- continue;
- }
-
- var aaiInfo = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type");
-
- aaiInfo.put("genericVnfResourceVersion", responseItem.getGenericVnf().getResourceVersion());
- aaiInfo.put("genericVnfVnfName", responseItem.getGenericVnf().getVnfName());
- aaiInfo.put("genericVnfProvStatus", responseItem.getGenericVnf().getProvStatus());
- aaiInfo.put("genericVnfIsClosedLoopDisabled", responseItem.getGenericVnf().getIsClosedLoopDisabled().toString());
- aaiInfo.put("genericVnfVnfType", responseItem.getGenericVnf().getVnfType());
- aaiInfo.put("genericVnfInMaint", responseItem.getGenericVnf().getInMaint().toString());
- aaiInfo.put("genericVnfServiceId", responseItem.getGenericVnf().getServiceId());
- aaiInfo.put("genericVnfVnfId", responseItem.getGenericVnf().getVnfId());
-
- aaiInfo.put("genericVnfOrchestrationStatus", responseItem.getVfModule().getOrchestrationStatus());
-
- vcpeClosedLoopStatus.put("AAI", aaiInfo);
-
- break;
-}
-
-// We should check here for the case where AAI returns an error or no data for the query
-
-
-var uuidType = Java.type("java.util.UUID");
-var requestID = uuidType.fromString(vcpeClosedLoopStatus.get("requestID"));
-
-executor.outFields.put("requestID", requestID);
-executor.outFields.put("vnfID", vnfID);
-
-executor.logger.info(executor.outFields);
-
-var returnValue = executor.isTrue;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupTask.js
new file mode 100644
index 000000000..fcb39052d
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupTask.js
@@ -0,0 +1,85 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfID").toString());
+
+executor.logger.info("Executing A&AI Lookup");
+executor.logger.info(vcpeClosedLoopStatus);
+
+var aaiInfo = vcpeClosedLoopStatus.get("AAI");
+
+if (aaiInfo.get("vserverName") == null) {
+ executor.message = "the field vserver.vserver-name must exist in the onset control loop event";
+ executor.logger.warn(executor.message);
+ var returnValue = executor.isFalse;
+}
+else if (aaiInfo.get("genericVnfVnfId") == null && aaiInfo.get("genericVnfVnfName") == null) {
+ executor.message = "either the field generic-vnf.vnf-id or generic-vnf.vnf-name must exist"
+ + " in the onset control loop event";
+ executor.logger.warn(executor.message);
+ var returnValue = executor.isFalse;
+}
+else {
+ var restManager = new org.onap.policy.rest.RestManager;
+ var aaiManager = new org.onap.policy.aai.AaiManager(restManager);
+
+ // We need to instantiate the type in order to trigger the static JAXB handling
+ // in the AaiCqResponse class
+ var aaiCqResponseType = Java.type("org.onap.policy.aai.AaiCqResponse");
+
+ var aaiResponse = aaiManager.getCustomQueryResponse(
+ "http://localhost:54321/OnapVCpeSim/sim",
+ "aai.username",
+ "aai.password",
+ executor.inFields.get("requestID"),
+ vcpeClosedLoopStatus.get("AAI").get("vserverName")
+ );
+
+ var genericVnf;
+
+ if (aaiInfo.get("genericVnfVnfId") != null) {
+ genericVnf = aaiResponse.getGenericVnfByModelInvariantId(aaiInfo.get("genericVnfVnfId"));
+ }
+ else {
+ genericVnf = aaiResponse.getGenericVnfByVnfName(aaiInfo.get("genericVnfVnfId"));
+ }
+
+ aaiInfo.put("genericVnfResourceVersion", genericVnf.getResourceVersion());
+ aaiInfo.put("genericVnfVnfName", genericVnf.getVnfName());
+ aaiInfo.put("genericVnfProvStatus", genericVnf.getProvStatus());
+ aaiInfo.put("genericVnfIsClosedLoopDisabled", genericVnf.isIsClosedLoopDisabled().toString());
+ aaiInfo.put("genericVnfVnfType", genericVnf.getVnfType());
+ aaiInfo.put("genericVnfInMaint", genericVnf.isInMaint().toString());
+ aaiInfo.put("genericVnfServiceId", genericVnf.getServiceId());
+ aaiInfo.put("genericVnfVnfId", genericVnf.getVnfId());
+ aaiInfo.put("genericVnfOrchestrationStatus",
+ genericVnf.getVfModules().getVfModule().get(0).getOrchestrationStatus());
+
+ executor.outFields.put("requestID", executor.inFields.get("requestID"));
+ executor.outFields.put("vnfID", executor.inFields.get("vnfID"));
+
+ executor.logger.info(executor.outFields);
+
+ var returnValue = executor.isTrue;
+}
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js
index 0ba3c0985..f4f6d908d 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js
@@ -5,15 +5,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* Note: The incoming closedloop message can be ONSET with both VNF-name and VNF-ID
* or ABATED with only VNF-name. So need to handle differently. For ABATED case,
* since we still keep the RequireIDVNFID context album, we can get it from there.
@@ -76,7 +76,10 @@ if (clEvent.getAai().get("generic-vnf.vnf-id") != null) {
aaiInfo.put("genericVnfInMaint", clEvent.getAai().get("generic-vnf.in-maint"));
aaiInfo.put("genericVnfServiceId", clEvent.getAai().get("generic-vnf.service-id"));
aaiInfo.put("genericVnfVnfId", clEvent.getAai().get("generic-vnf.vnf-id"));
-
+ aaiInfo.put("vserverIsClosedLoopDisabled", clEvent.getAai().get("vserver.is-closed-loop-disabled"));
+ aaiInfo.put("vserverProvStatus", clEvent.getAai().get("vserver.prov-status"));
+ aaiInfo.put("vserverName", clEvent.getAai().get("vserver.vserver-name"));
+
vcpeClosedLoopStatus.put("AAI", aaiInfo);
if (clEvent.getClosedLoopAlarmEnd() != null) {
@@ -99,14 +102,14 @@ else {
executor.logger.info("No vnf-id in VirtualControlLoopEvent, status:" + clEvent.getClosedLoopEventStatus().toString());
var vnfName = clEvent.getAai().get("generic-vnf.vnf-name");
executor.logger.info("No vnf-id in VirtualControlLoopEvent for " + vnfName);
-
+
vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfName.toString());
-
+
if (vcpeClosedLoopStatus == null) {
executor.logger.info("Creating context information for new vCPE VNF \"" + vnfName.toString() + "\"");
-
+
vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewInstance();
-
+
vcpeClosedLoopStatus.put("closedLoopControlName", clEvent.getClosedLoopControlName());
vcpeClosedLoopStatus.put("closedLoopAlarmStart", clEvent.getClosedLoopAlarmStart().toEpochMilli());
vcpeClosedLoopStatus.put("closedLoopEventClient", clEvent.getClosedLoopEventClient());
@@ -122,24 +125,24 @@ else {
vcpeClosedLoopStatus.put("notification", "ACTIVE");
vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
vcpeClosedLoopStatus.put("message", "");
-
+
var aaiInfo = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type");
-
+
aaiInfo.put("genericVnfVnfName", clEvent.getAai().get("generic-vnf.vnf-name"));
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(vnfName.toString(), vcpeClosedLoopStatus);
-
+
executor.logger.info("Created context information for new vCPE VNF \"" + vnfName.toString() + "\"");
}
executor.outFields.put("requestID", requestID);
- executor.outFields.put("vnfName", vnfName);
+ executor.outFields.put("vnfName", vnfName);
executor.logger.info(executor.outFields);
}
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js
deleted file mode 100644
index b397a5f7c..000000000
--- a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-executor.logger.info(executor.subject.id);
-executor.logger.info(executor.inFields);
-
-var returnValue = executor.isTrue;
-
-if( executor.inFields.get("vnfID") == null) {
- executor.logger.info("ReceiveEventPolicyRequestAAIStateTSL: vnfID is null");
- var vnfName = executor.inFields.get("vnfName");
- var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
- executor.inFields.get("vnfName"));
- executor.logger.info("CL event status: " + vcpeClosedLoopStatus.get("closedLoopEventStatus"));
- executor.subject.getTaskKey("NoAAILookupTask").copyTo(executor.selectedTask);
- } else {
- var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
- executor.inFields.get("vnfID").toString());
- var aaiInfo = vcpeClosedLoopStatus.get("AAI");
-
- executor.logger.info(aaiInfo);
-
- if (aaiInfo.get("genericVnfResourceVersion") != null
- && aaiInfo.get("genericVnfVnfName") != null
- && aaiInfo.get("genericVnfProvStatus") != null
- && aaiInfo.get("genericVnfIsClosedLoopDisabled") != null
- && aaiInfo.get("genericVnfOrchestrationStatus") != null
- && aaiInfo.get("genericVnfVnfType") != null
- && aaiInfo.get("genericVnfInMaint") != null
- && aaiInfo.get("genericVnfServiceId") != null
- && aaiInfo.get("genericVnfVnfId") != null) {
- executor.subject.getTaskKey("NoAAILookupTask").copyTo(executor.selectedTask);
- } else {
- executor.subject.getTaskKey("AAILookupRequestTask").copyTo(executor.selectedTask);
- }
-}
-executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask);