diff options
author | 2020-03-10 21:09:28 +0000 | |
---|---|---|
committer | 2020-03-11 15:41:13 +0000 | |
commit | 938108832179d5ca9b28e5cb981ce5602ca59344 (patch) | |
tree | 0bdb6b0c3d0b42b42ca8805451c190b707133bfe /examples/examples-onap-vcpe/src/main/resources/logic/definitive | |
parent | 4eb64b73443620c8588ee48b54d225326ff4550e (diff) |
Adapt vCPE example for Rhino Javascript
Minor changes to Javascript source for execution under the Rhino script
engine.
Issue-ID: POLICY-2106
Change-Id: Ib7e30ce0067a11ea1bb3ca8d197c796dba9ea091
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'examples/examples-onap-vcpe/src/main/resources/logic/definitive')
12 files changed, 77 insertions, 60 deletions
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js index fcb39052d..7d0178261 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,17 +29,18 @@ executor.logger.info("Executing A&AI Lookup"); executor.logger.info(vcpeClosedLoopStatus); var aaiInfo = vcpeClosedLoopStatus.get("AAI"); +var returnValue = true; 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; + returnValue = false; } 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; + returnValue = false; } else { var restManager = new org.onap.policy.rest.RestManager; @@ -46,7 +48,7 @@ else { // 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 aaiCqResponseType = org.onap.policy.aai.AaiCqResponse; var aaiResponse = aaiManager.getCustomQueryResponse( "http://localhost:54321/OnapVCpeSim/sim", @@ -80,6 +82,6 @@ else { executor.outFields.put("vnfID", executor.inFields.get("vnfID")); executor.logger.info(executor.outFields); - - var returnValue = executor.isTrue; } + +returnValue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js index dd69dcb1d..9ee928fca 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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========================================================= */ @@ -64,4 +65,4 @@ executor.outFields.put("APPCLCMRequestEvent", appcRequest); executor.logger.info(executor.outFields); -var returnValue = executor.isTrue; +true; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js index 75ab6a3af..ac22abbff 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js @@ -1,26 +1,27 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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. - * + * * APPC LCM Response code: 100 ACCEPTED * 200 ERROR UNEXPECTED ERROR means failure * 312 REJECTED DUPLICATE REQUEST - * 400 SUCCESS + * 400 SUCCESS * * Note: Sometimes the corelationId has a -1 at the tail, need to get rid of it when present. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -38,7 +39,7 @@ executor.logger.info("Size of RequestIDVNFIDAlbum = " + executor.getContextAlbum("RequestIDVNFIDAlbum").size()); executor.logger.info("vnfID = " + vnfID); -var returnValue = executor.isTrue; +var returnValue = true; if (vnfID != null) { var vcpeClosedLoopStatus = executor.getContextAlbum( @@ -82,7 +83,9 @@ if (vnfID != null) { } else { executor.message = "VNF ID not found in context album for request ID " + requestIDString; - returnValue = executor.isFalse; + returnValue = false } executor.logger.info(executor.outFields); + +returnValue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AbatedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AbatedTask.js index f37b6f1b5..e19b8b1f4 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AbatedTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AbatedTask.js @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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========================================================= */ @@ -21,7 +22,7 @@ executor.logger.info(executor.subject.id); executor.logger.info(executor.inFields); -var vcpeClosedLoopStatus = null; +var vcpeClosedLoopStatus = null; if( executor.inFields.get("vnfID") == null) { executor.logger.info("AbatedTask: vnfID is null"); var vnfName = executor.inFields.get("vnfName"); @@ -38,4 +39,4 @@ vcpeClosedLoopStatus.put("message", "situation has been abated"); executor.logger.info(executor.outFields); -var returnValue = executor.isTrue; +true; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js index a5a692cbc..3e2771a74 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js @@ -63,6 +63,7 @@ clNotification.getAai().put("generic-vnf.orchestration-status", aaiInfo.get(" clNotification.getAai().put("generic-vnf.vnf-type", aaiInfo.get("genericVnfVnfType")); clNotification.getAai().put("generic-vnf.in-maint", aaiInfo.get("genericVnfInMaint")); clNotification.getAai().put("generic-vnf.service-id", aaiInfo.get("genericVnfServiceId")); + if(vnfID != null) { clNotification.getAai().put("generic-vnf.vnf-id", aaiInfo.get("genericVnfVnfId")); } @@ -70,4 +71,4 @@ executor.outFields.put("VirtualControlLoopNotification", clNotification); executor.logger.info(executor.outFields); -var returnValue = executor.isTrue; +true; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js index 353c21ef6..73b989f5e 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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========================================================= */ @@ -29,4 +30,4 @@ vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis( executor.logger.info(executor.outFields); -var returnValue = executor.isTrue; +true; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js index f4f6d908d..9882a434f 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +26,9 @@ executor.logger.info(executor.subject.id); executor.logger.info(executor.inFields); -var clEventType = Java.type("org.onap.policy.controlloop.VirtualControlLoopEvent"); -var longType = Java.type("java.lang.Long"); -var uuidType = Java.type("java.util.UUID"); +var clEventType = org.onap.policy.controlloop.VirtualControlLoopEvent; +var longType = java.lang.Long; +var uuidType = java.util.UUID; var clEvent = executor.inFields.get("VirtualControlLoopEvent"); @@ -146,4 +147,4 @@ else { executor.logger.info(executor.outFields); } -returnValue = executor.isTrue; +true; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardRequestTask.js index d247f8a65..66c6213e1 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardRequestTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardRequestTask.js @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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========================================================= */ @@ -41,4 +42,4 @@ executor.getContextAlbum("ControlLoopExecutionIDAlbum").put(executor.executionId executor.logger.info(executor.outFields); -var returnValue = executor.isTrue; +true; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js index 2a9100b7f..55fee56dd 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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========================================================= */ @@ -29,17 +30,18 @@ var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum") executor.logger.info(vcpeClosedLoopStatus); var guardResult = executor.inFields.get("decision"); +var returnValue = true; -if (guardResult === "PERMIT") { +if (guardResult == "PERMIT") { vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_PERMIT"); -} else if (guardResult === "DENY") { +} else if (guardResult == "DENY") { vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_DENY"); } else { executor.message = "guard result must be either \"PERMIT\" or \"DENY\""; - returnValue = executor.FALSE; + returnValue = false; } -var uuidType = Java.type("java.util.UUID"); +var uuidType = java.util.UUID; var requestID = uuidType.fromString(vcpeClosedLoopStatus.get("requestID")); executor.outFields.put("requestID", requestID); @@ -47,4 +49,5 @@ executor.outFields.put("vnfID", vnfID); executor.logger.info(executor.outFields); -var returnValue = executor.isTrue; + +returnValue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js index ebc0e6387..7b3d5c478 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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========================================================= */ @@ -23,4 +24,4 @@ executor.logger.info(executor.inFields); executor.logger.info(executor.outFields); -var returnValue = executor.isTrue; +true; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js index c8a3bfba8..4f6c32120 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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========================================================= */ @@ -21,7 +22,7 @@ executor.logger.info(executor.subject.id); executor.logger.info(executor.inFields); -var returnValue = executor.isTrue; +var returnValue = true; var status = null; if( executor.inFields.get("vnfID") == null) { @@ -36,16 +37,16 @@ if( executor.inFields.get("vnfID") == null) { status = vcpeClosedLoopStatus.get("closedLoopEventStatus").toString(); } -var returnValue = executor.isTrue; - -if (status === "ONSET") { +if (status == "ONSET") { executor.subject.getTaskKey("GuardRequestTask").copyTo(executor.selectedTask); -} else if (status === "ABATED") { +} else if (status == "ABATED") { executor.subject.getTaskKey("AbatedTask").copyTo(executor.selectedTask); onsetFlag = executor.isFalse; } else { executor.message = "closedLoopEventStatus is \"" + status + "\", it must be either \"ONSET\" or \"ABATED\""; - returnValue = executor.isFalse; + returnValue = false; } executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask); + +returnValue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js index a1bac6546..7ab346f53 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * 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========================================================= */ @@ -26,7 +27,7 @@ var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum") var guardResult = vcpeClosedLoopStatus.get("notification"); -if (guardResult === "OPERATION: GUARD_PERMIT") { +if (guardResult == "OPERATION: GUARD_PERMIT") { executor.subject.getTaskKey("APPCRestartVNFRequestTask").copyTo(executor.selectedTask); } else { executor.subject.getTaskKey("DeniedTask").copyTo(executor.selectedTask); @@ -34,4 +35,4 @@ if (guardResult === "OPERATION: GUARD_PERMIT") { executor.logger.info("RestartAPPCRequestPolicyPermitOrDenyTSL State Selected Task:" + executor.selectedTask); -var returnValue = executor.isTrue; +true; |